/***************************************************************************** * This example shows how to use PAPI_add_event, PAPI_start, PAPI_read, * * PAPI_stop and PAPI_remove_event. * ******************************************************************************/ #include #include #include #include #include #include #include "../helper.h" /* * A multi-implementation benchmark with dmda scheduler * we aim to test the energy model with the different size of gamma * for large size of gamma, dmda choose the second implementation which consumes less energy * otherwise, it choose the first implementtaion which minimizes the execution time */ #define ERROR_RETURN(retval) { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); } #define STARTlin 131072 #define START 1024 #ifdef STARPU_QUICK_CHECK #define END 1048576 #else #define END 16777216 #endif int ntasks; /* First implementation */ void memset0_cpu(void *descr[], void *arg) { (void)arg; STARPU_SKIP_IF_VALGRIND; int *ptr = (int *)STARPU_VECTOR_GET_PTR(descr[0]); unsigned n = STARPU_VECTOR_GET_NX(descr[0]); unsigned i; starpu_usleep(100); for (i=0; icl = codelet; task->where = STARPU_CPU; task->handles[0] = tab_handle[loop]; int ret = starpu_task_submit(task); if (ret == -ENODEV) exit(STARPU_TEST_SKIPPED); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit"); } for (loop = 0; loop < ntasks; loop++) { starpu_data_unregister(tab_handle[loop]); } } int main(int argc, char **argv) { starpu_profiling_status_set(STARPU_PROFILING_ENABLE); struct starpu_conf conf; starpu_data_handle_t handle; int ret; int retval; int size; starpu_conf_init(&conf); conf.sched_policy_name = "eager"; ret = starpu_initialize(&conf, &argc, &argv); if (ret == -ENODEV) return STARPU_TEST_SKIPPED; STARPU_CHECK_RETURN_VALUE(ret, "starpu_init"); for (size = STARTlin; size < END; size *= 2) { starpu_vector_data_register(&handle, -1, (uintptr_t)NULL, size, sizeof(int)); struct starpu_task *task = starpu_task_create(); task->cl = &memset_cl; task->handles[0] = handle; task->synchronous = 1; task->destroy = 0; /* Start counting */ if ( (retval = starpu_energy_start()) != 0) ERROR_RETURN(retval); test_memset(size, &memset_cl); /* Stop counting and store the values into the array */ if ( (retval = starpu_energy_stop(&energy_model, task, ntasks)) != 0) ERROR_RETURN(retval); starpu_task_destroy(task); starpu_data_unregister(handle); } starpu_shutdown(); return EXIT_SUCCESS; }