/* StarPU --- Runtime system for heterogeneous multicore architectures. * * Copyright (C) 2019-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria * * StarPU is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or (at * your option) any later version. * * StarPU is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU Lesser General Public License in COPYING.LGPL for more details. */ #include #include #include #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0) /* global counters */ static int id_g_total_submitted; static int id_g_peak_submitted; static int id_g_peak_ready; /* per worker counters */ static int id_w_total_executed; static int id_w_cumul_execution_time; /* per_codelet counters */ static int id_c_total_submitted; static int id_c_peak_submitted; static int id_c_peak_ready; static int id_c_total_executed; static int id_c_cumul_execution_time; void g_listener_cb(struct starpu_perf_counter_listener *listener, struct starpu_perf_counter_sample *sample, void *context) { (void) listener; (void) context; int64_t g_total_submitted = starpu_perf_counter_sample_get_int64_value(sample, id_g_total_submitted); int64_t g_peak_submitted = starpu_perf_counter_sample_get_int64_value(sample, id_g_peak_submitted); int64_t g_peak_ready = starpu_perf_counter_sample_get_int64_value(sample, id_g_peak_ready); printf("global: g_total_submitted = %"PRId64", g_peak_submitted = %"PRId64", g_peak_ready = %"PRId64"\n", g_total_submitted, g_peak_submitted, g_peak_ready); } void w_listener_cb(struct starpu_perf_counter_listener *listener, struct starpu_perf_counter_sample *sample, void *context) { (void) listener; (void) context; int workerid = starpu_worker_get_id(); int64_t w_total_executed = starpu_perf_counter_sample_get_int64_value(sample, id_w_total_executed); double w_cumul_execution_time = starpu_perf_counter_sample_get_double_value(sample, id_w_cumul_execution_time); printf("worker[%d]: w_total_executed = %"PRId64", w_cumul_execution_time = %lf\n", workerid, w_total_executed, w_cumul_execution_time); } void c_listener_cb(struct starpu_perf_counter_listener *listener, struct starpu_perf_counter_sample *sample, void *context) { (void) listener; struct starpu_codelet *cl = context; int64_t c_total_submitted = starpu_perf_counter_sample_get_int64_value(sample, id_c_total_submitted); int64_t c_peak_submitted = starpu_perf_counter_sample_get_int64_value(sample, id_c_peak_submitted); int64_t c_peak_ready = starpu_perf_counter_sample_get_int64_value(sample, id_c_peak_ready); int64_t c_total_executed = starpu_perf_counter_sample_get_int64_value(sample, id_c_total_executed); double c_cumul_execution_time = starpu_perf_counter_sample_get_double_value(sample, id_c_cumul_execution_time); if (cl->name != NULL) { printf("codelet[%s]: c_total_submitted = %"PRId64", c_peak_submitted = %"PRId64", c_peak_ready = %"PRId64", c_total_executed = %"PRId64", c_cumul_execution_time = %lf\n", cl->name, c_total_submitted, c_peak_submitted, c_peak_ready, c_total_executed, c_cumul_execution_time); } else { printf("codelet[%p]: c_total_submitted = %"PRId64", c_peak_submitted = %"PRId64", c_peak_ready = %"PRId64", c_total_executed = %"PRId64", c_cumul_execution_time = %lf\n", cl, c_total_submitted, c_peak_submitted, c_peak_ready, c_total_executed, c_cumul_execution_time); } } void f(void *buffers[], void *cl_args) { int *int_vector = (int*)STARPU_VECTOR_GET_PTR(buffers[0]); int NX = (int)STARPU_VECTOR_GET_NX(buffers[0]); const int niters; starpu_codelet_unpack_args(cl_args, &niters); int i; for (i=0; i