* throughput). Our "error" estimate (the amount of noise that might be present in the
* frequency band we're really interested in) is the average of the adjacent bands. */
throughput_wave_component = mono_double_complex_scalar_div (hill_climbing_get_wave_component (hc->samples, sample_count, hc->wave_period), average_throughput);
- throughput_error_estimate = cabs (mono_double_complex_scalar_div (hill_climbing_get_wave_component (hc->samples, sample_count, adjacent_period_1), average_throughput));
+ throughput_error_estimate = mono_cabs (mono_double_complex_scalar_div (hill_climbing_get_wave_component (hc->samples, sample_count, adjacent_period_1), average_throughput));
if (adjacent_period_2 <= sample_count) {
- throughput_error_estimate = MAX (throughput_error_estimate, cabs (mono_double_complex_scalar_div (hill_climbing_get_wave_component (
+ throughput_error_estimate = MAX (throughput_error_estimate, mono_cabs (mono_double_complex_scalar_div (hill_climbing_get_wave_component (
hc->samples, sample_count, adjacent_period_2), average_throughput)));
}
+ ((1.0 + hc->throughput_error_smoothing_factor) * hc->average_throughput_noise);
}
- if (cabs (thread_wave_component) > 0) {
+ if (mono_cabs (thread_wave_component) > 0) {
/* Adjust the throughput wave so it's centered around the target wave,
* and then calculate the adjusted throughput/thread ratio. */
ratio = mono_double_complex_div (mono_double_complex_sub (throughput_wave_component, mono_double_complex_scalar_mul(thread_wave_component, hc->target_throughput_ratio)), thread_wave_component);
noise_for_confidence = MAX (hc->average_throughput_noise, throughput_error_estimate);
if (noise_for_confidence > 0) {
- confidence = cabs (thread_wave_component) / noise_for_confidence / hc->target_signal_to_noise_ratio;
+ confidence = mono_cabs (thread_wave_component) / noise_for_confidence / hc->target_signal_to_noise_ratio;
} else {
/* there is no noise! */
confidence = 1.0;
* backward (because this indicates that our changes are having the opposite of the intended effect).
* If they're 90 degrees out of phase, we won't move at all, because we can't tell wether we're
* having a negative or positive effect on throughput. */
- move = creal (ratio);
+ move = mono_creal (ratio);
move = CLAMP (move, -1.0, 1.0);
/* Apply our confidence multiplier. */
if (new_thread_count != current_thread_count)
hill_climbing_change_thread_count (new_thread_count, transition);
- if (creal (ratio) < 0.0 && new_thread_count == worker.limit_worker_min)
- *adjustment_interval = (gint)(0.5 + hc->current_sample_interval * (10.0 * MAX (-1.0 * creal (ratio), 1.0)));
+ if (mono_creal (ratio) < 0.0 && new_thread_count == worker.limit_worker_min)
+ *adjustment_interval = (gint)(0.5 + hc->current_sample_interval * (10.0 * MAX (-1.0 * mono_creal (ratio), 1.0)));
else
*adjustment_interval = hc->current_sample_interval;
#define _USE_MATH_DEFINES // needed by MSVC to define math constants
#include <math.h>
-#undef cabs
-#undef cimag
-#undef creal
-#define cabs mono_cabs
-#define cimag mono_cimag
-#define creal mono_creal
-
typedef struct double_complex {
double real;
double imag;
} double_complex;
-static inline double
-creal (double_complex c)
-{
- return c.real;
-}
-
-static inline double
-cimag (double_complex c)
-{
- return c.imag;
-}
+#define mono_creal(c) ((c).real)
+#define mono_cimag(c) ((c).imag)
static inline
double_complex mono_double_complex_make(gdouble re, gdouble im)
static inline
double_complex mono_double_complex_scalar_div(double_complex c, gdouble s)
{
- return mono_double_complex_make(creal(c) / s, cimag(c) / s);
+ return mono_double_complex_make (mono_creal (c) / s, mono_cimag (c) / s);
}
static inline
double_complex mono_double_complex_scalar_mul(double_complex c, gdouble s)
{
- return mono_double_complex_make(creal(c) * s, cimag(c) * s);
+ return mono_double_complex_make (mono_creal (c) * s, mono_cimag (c) * s);
}
static inline
double_complex mono_double_complex_div(double_complex left, double_complex right)
{
- double denom = creal(right) * creal(right) + cimag(right) * cimag(right);
+ double denom = mono_creal (right) * mono_creal (right) + mono_cimag (right) * mono_cimag (right);
return mono_double_complex_make(
- (creal(left) * creal(right) + cimag(left) * cimag(right)) / denom,
- (-creal(left) * cimag(right) + cimag(left) * creal(right)) / denom);
+ (mono_creal (left) * mono_creal (right) + mono_cimag (left) * mono_cimag (right)) / denom,
+ (-mono_creal (left) * mono_cimag (right) + mono_cimag (left) * mono_creal (right)) / denom);
}
static inline
double_complex mono_double_complex_sub(double_complex left, double_complex right)
{
- return mono_double_complex_make(creal(left) - creal(right), cimag(left)
- - cimag(right));
+ return mono_double_complex_make (mono_creal (left) - mono_creal (right), mono_cimag (left)
+ - mono_cimag (right));
}
#include "../../support/libm/complex.c"