- xbt_assert0(samples, "You did something very inconsistent, didn't you?");
- data = xbt_dict_get_or_null(samples, loc);
- if (!data) {
- xbt_assert0(data, "Please, do thing in order");
- }
- if (!data->started) {
- if (data->count < data->max) {
- data->started = 1;
- data->count++;
- } else {
- DEBUG1("Perform some wait of %f", data->time / (double)data->count);
- smpi_execute(data->time / (double)data->count);
+ xbt_assert(samples, "You did something very inconsistent, didn't you?");
+ data = xbt_dict_get_or_null(samples, loc);
+ if (!data) {
+ xbt_assert(data, "Please, do thing in order");
+ }
+ if (!data->started) {
+ if ((data->iters > 0 && data->count >= data->iters)
+ || (data->count > 1 && data->threshold > 0.0 && data->relstderr <= data->threshold)) {
+ XBT_DEBUG("Perform some wait of %f", data->mean);
+ smpi_execute(data->mean);
+ } else {
+ data->started = 1;
+ data->count++;
+ }
+ } else {
+ data->started = 0;
+ }
+ free(loc);
+ smpi_bench_begin();
+ smpi_process_simulated_start();
+ return data->started;
+}
+
+void smpi_sample_3(int global, const char *file, int line)
+{
+ char *loc = sample_location(global, file, line);
+ local_data_t *data;
+ double sample, n;
+
+ xbt_assert(samples, "You did something very inconsistent, didn't you?");
+ data = xbt_dict_get_or_null(samples, loc);
+ smpi_bench_end();
+ if(data && data->started && data->count < data->iters) {
+ sample = smpi_process_simulated_elapsed();
+ data->sum += sample;
+ data->sum_pow2 += sample * sample;
+ n = (double)data->count;
+ data->mean = data->sum / n;
+ data->relstderr = sqrt((data->sum_pow2 / n - data->mean * data->mean) / n) / data->mean;
+ XBT_DEBUG("Average mean after %d steps is %f, relative standard error is %f (sample was %f)", data->count,
+ data->mean, data->relstderr, sample);
+ }
+ free(loc);
+}
+
+void smpi_sample_flops(double flops)
+{
+ smpi_execute_flops(flops);
+}
+
+void *smpi_shared_malloc(size_t size, const char *file, int line)
+{
+ char *loc = bprintf("%zu_%s_%d", (size_t)getpid(), file, line);
+ size_t len = strlen(loc);
+ size_t i;
+ int fd;
+ void* mem;
+ shared_data_t *data;
+
+ for(i = 0; i < len; i++) {
+ /* Make the 'loc' ID be a flat filename */
+ if(loc[i] == '/') {
+ loc[i] = '_';
+ }
+ }
+ if (!allocs) {
+ allocs = xbt_dict_new_homogeneous(free);
+ }
+ data = xbt_dict_get_or_null(allocs, loc);
+ if(!data) {
+ fd = shm_open(loc, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if(fd < 0) {
+ switch(errno) {
+ case EEXIST:
+ xbt_die("Please cleanup /dev/shm/%s", loc);
+ default:
+ xbt_die("An unhandled error occured while opening %s: %s", loc, strerror(errno));