xbt_os_timer_t smpi_process_timer(void);
void smpi_process_simulated_start(void);
double smpi_process_simulated_elapsed(void);
+void smpi_process_set_sampling(int s);
+int smpi_process_get_sampling(void);
void print_request(const char *message, MPI_Request request);
// utilities
extern double smpi_cpu_threshold;
extern double smpi_running_power;
-extern int smpi_sample_is_running;
void smpi_bench_destroy(void);
void smpi_bench_begin(void);
void smpi_bench_end(void);
int benching; /* 1: we are benchmarking; 0: we have enough data, no bench anymore */
} local_data_t;
-int smpi_sample_is_running = 0;
-
static char *sample_location(int global, const char *file, int line) {
if (global) {
return bprintf("%s:%d", file, line);
local_data_t *data;
smpi_bench_end(); /* Take time from previous, unrelated computation into account */
- smpi_sample_is_running++;
+ smpi_process_set_sampling(1);
if (!samples)
samples = xbt_dict_new_homogeneous(free);
{
char *loc = sample_location(global, file, line);
local_data_t *data;
+ int res;
xbt_assert(samples, "Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
data = xbt_dict_get(samples, loc);
// we need to run a new bench
XBT_DEBUG("benchmarking: count:%d iter:%d stderr:%f thres:%f; mean:%f",
data->count, data->iters, data->relstderr, data->threshold, data->mean);
- smpi_bench_begin();
- return 1;
+ res = 1;
} else {
// Enough data, no more bench (either we got enough data from previous visits to this benched nest, or we just ran one bench and need to bail out now that our job is done).
// Just sleep instead
XBT_DEBUG("No benchmark (either no need, or just ran one): count >= iter (%d >= %d) or stderr<thres (%f<=%f). apply the %fs delay instead",
data->count, data->iters, data->relstderr, data->threshold, data->mean);
smpi_execute(data->mean);
-
- smpi_sample_is_running--;
- smpi_bench_begin(); // prepare to capture future, unrelated computations
- return 0;
+ smpi_process_set_sampling(0);
+ res = 0; // prepare to capture future, unrelated computations
}
+ smpi_bench_begin();
+ return res;
}
void *data; /* user data */
int index;
int initialized;
+ int sampling; /* inside an SMPI_SAMPLE_ block? */
} s_smpi_process_data_t;
static smpi_process_data_t *process_data = NULL;
return data->comm_self;
}
+void smpi_process_set_sampling(int s)
+{
+ smpi_process_data_t data = smpi_process_data();
+ data->sampling = s;
+}
+
+int smpi_process_get_sampling(void)
+{
+ smpi_process_data_t data = smpi_process_data();
+ return data->sampling;
+}
+
void print_request(const char *message, MPI_Request request)
{
XBT_DEBUG
group = smpi_group_new(1);
process_data[i]->comm_self = smpi_comm_new(group);
process_data[i]->initialized = 0;
+ process_data[i]->sampling = 0;
smpi_group_set_mapping(group, i, 0);
}