|
|
@@ -33,202 +33,197 @@
|
|
|
#define END 16777216
|
|
|
#endif
|
|
|
|
|
|
-int ret;
|
|
|
-
|
|
|
-//1er implémentation avec un delai initial (100 us)
|
|
|
+// first implementation with an initial delay (100 us)
|
|
|
void memset0_cpu(void *descr[], void *arg)
|
|
|
{
|
|
|
- (void)arg;
|
|
|
- STARPU_SKIP_IF_VALGRIND;
|
|
|
+ (void)arg;
|
|
|
+ STARPU_SKIP_IF_VALGRIND;
|
|
|
|
|
|
- int *ptr = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
|
|
|
- unsigned n = STARPU_VECTOR_GET_NX(descr[0]);
|
|
|
- int i;
|
|
|
+ int *ptr = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
|
|
|
+ unsigned n = STARPU_VECTOR_GET_NX(descr[0]);
|
|
|
+ unsigned i;
|
|
|
|
|
|
- //usleep(100);
|
|
|
+ usleep(100);
|
|
|
|
|
|
- for (i=0; i<n ; i++)
|
|
|
- {
|
|
|
- ptr[0] += i;
|
|
|
- }
|
|
|
+ for (i=0; i<n ; i++)
|
|
|
+ {
|
|
|
+ ptr[0] += i;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-//deuxième implémentation sans delai initial usleep() et fait 2.5 plus de tours de boucles
|
|
|
+// second implementation without initial delay but 2.5 more loops
|
|
|
void memset_cpu(void *descr[], void *arg)
|
|
|
{
|
|
|
- (void)arg;
|
|
|
- STARPU_SKIP_IF_VALGRIND;
|
|
|
+ (void)arg;
|
|
|
+ STARPU_SKIP_IF_VALGRIND;
|
|
|
|
|
|
- int *ptr = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
|
|
|
- unsigned n = STARPU_VECTOR_GET_NX(descr[0]);
|
|
|
- int i;
|
|
|
+ int *ptr = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
|
|
|
+ unsigned n = STARPU_VECTOR_GET_NX(descr[0]);
|
|
|
+ int i;
|
|
|
|
|
|
- for (i=0; i<6.5*n ; i++)
|
|
|
- {
|
|
|
- ptr[0] += i;
|
|
|
- }
|
|
|
+ for (i=0; i<6.5*n ; i++)
|
|
|
+ {
|
|
|
+ ptr[0] += i;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//fonction pour mesurer l'energie
|
|
|
double energy_function(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl)
|
|
|
|
|
|
{
|
|
|
- double energy;
|
|
|
- int factor;
|
|
|
- if (nimpl == 0)
|
|
|
- factor = 10;
|
|
|
- else
|
|
|
- factor = 1;
|
|
|
+ double energy;
|
|
|
+ int factor;
|
|
|
+ if (nimpl == 0)
|
|
|
+ factor = 10;
|
|
|
+ else
|
|
|
+ factor = 1;
|
|
|
|
|
|
- energy=starpu_task_expected_length(task, arch, nimpl)*factor;
|
|
|
+ energy=starpu_task_expected_length(task, arch, nimpl)*factor;
|
|
|
|
|
|
- return energy;
|
|
|
+ return energy;
|
|
|
}
|
|
|
|
|
|
static struct starpu_perfmodel model =
|
|
|
{
|
|
|
- .type = STARPU_REGRESSION_BASED,
|
|
|
- .symbol = "memset_regression_based"
|
|
|
+ .type = STARPU_REGRESSION_BASED,
|
|
|
+ .symbol = "memset_regression_based"
|
|
|
};
|
|
|
|
|
|
static struct starpu_perfmodel nl_model =
|
|
|
{
|
|
|
- .type = STARPU_NL_REGRESSION_BASED,
|
|
|
- .symbol = "non_linear_memset_regression_based"
|
|
|
+ .type = STARPU_NL_REGRESSION_BASED,
|
|
|
+ .symbol = "non_linear_memset_regression_based"
|
|
|
};
|
|
|
|
|
|
static struct starpu_perfmodel nl_energy_model=
|
|
|
{
|
|
|
- .type = STARPU_PER_ARCH,
|
|
|
- .symbol = "non_linear_energy_model",
|
|
|
- .arch_cost_function={energy_function},
|
|
|
+ .type = STARPU_PER_ARCH,
|
|
|
+ .symbol = "non_linear_energy_model",
|
|
|
+ .arch_cost_function=energy_function,
|
|
|
};
|
|
|
|
|
|
static struct starpu_codelet memset_cl =
|
|
|
{
|
|
|
- .cpu_funcs = {memset0_cpu, memset_cpu},
|
|
|
- .cpu_funcs_name = {"memset0_cpu", "memset_cpu"},
|
|
|
- .model = &model,
|
|
|
- .nbuffers = 1,
|
|
|
- .modes = {STARPU_W}
|
|
|
+ .cpu_funcs = {memset0_cpu, memset_cpu},
|
|
|
+ .cpu_funcs_name = {"memset0_cpu", "memset_cpu"},
|
|
|
+ .model = &model,
|
|
|
+ .nbuffers = 1,
|
|
|
+ .modes = {STARPU_W}
|
|
|
};
|
|
|
|
|
|
static struct starpu_codelet nl_memset_cl =
|
|
|
{
|
|
|
- .cpu_funcs = {memset0_cpu, memset_cpu},
|
|
|
- .cpu_funcs_name = {"memset0_cpu", "memset_cpu"},
|
|
|
- .model = &nl_model,
|
|
|
- .energy_model = &nl_energy_model,
|
|
|
- .nbuffers = 1,
|
|
|
- .modes = {STARPU_W}
|
|
|
+ .cpu_funcs = {memset0_cpu, memset_cpu},
|
|
|
+ .cpu_funcs_name = {"memset0_cpu", "memset_cpu"},
|
|
|
+ .model = &nl_model,
|
|
|
+ .energy_model = &nl_energy_model,
|
|
|
+ .nbuffers = 1,
|
|
|
+ .modes = {STARPU_W}
|
|
|
};
|
|
|
|
|
|
static void test_memset(int nelems, struct starpu_codelet *codelet)
|
|
|
{
|
|
|
- int nloops = 100;
|
|
|
- int loop;
|
|
|
- starpu_data_handle_t handle;
|
|
|
+ int nloops = 100;
|
|
|
+ int loop;
|
|
|
+ starpu_data_handle_t handle;
|
|
|
|
|
|
- starpu_vector_data_register(&handle, -1, (uintptr_t)NULL, nelems, sizeof(int));
|
|
|
- for (loop = 0; loop < nloops; loop++)
|
|
|
- {
|
|
|
- struct starpu_task *task = starpu_task_create();
|
|
|
+ starpu_vector_data_register(&handle, -1, (uintptr_t)NULL, nelems, sizeof(int));
|
|
|
+ for (loop = 0; loop < nloops; loop++)
|
|
|
+ {
|
|
|
+ struct starpu_task *task = starpu_task_create();
|
|
|
|
|
|
- task->cl = codelet;
|
|
|
- task->handles[0] = handle;
|
|
|
+ task->cl = codelet;
|
|
|
+ task->handles[0] = handle;
|
|
|
|
|
|
- int ret = starpu_task_submit(task);
|
|
|
- if (ret == -ENODEV)
|
|
|
- exit(STARPU_TEST_SKIPPED);
|
|
|
- STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
|
|
|
- }
|
|
|
+ int ret = starpu_task_submit(task);
|
|
|
+ if (ret == -ENODEV)
|
|
|
+ exit(STARPU_TEST_SKIPPED);
|
|
|
+ STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
|
|
|
+ }
|
|
|
|
|
|
- starpu_data_unregister(handle);
|
|
|
+ starpu_data_unregister(handle);
|
|
|
}
|
|
|
|
|
|
-static void compare_performance(int size, struct starpu_codelet *codelet, struct starpu_task *task)
|
|
|
+static void compare_performance(int size, struct starpu_codelet *codelet, struct starpu_task *compar_task)
|
|
|
{
|
|
|
- unsigned i;
|
|
|
- int niter = 100;
|
|
|
- starpu_data_handle_t handle;
|
|
|
-
|
|
|
- starpu_vector_data_register(&handle, -1, (uintptr_t)NULL, size, sizeof(int));
|
|
|
+ unsigned i;
|
|
|
+ unsigned niter = 100;
|
|
|
+ starpu_data_handle_t handle;
|
|
|
|
|
|
- struct starpu_task **tasks = (struct starpu_task **) malloc(niter*sizeof(struct starpu_task *));
|
|
|
- assert(tasks);
|
|
|
+ starpu_vector_data_register(&handle, -1, (uintptr_t)NULL, size, sizeof(int));
|
|
|
|
|
|
- for (i = 0; i < niter; i++)
|
|
|
- {
|
|
|
- //fabriquer la tache
|
|
|
- struct starpu_task *task = starpu_task_create();
|
|
|
+ struct starpu_task **tasks = (struct starpu_task **) malloc(niter*sizeof(struct starpu_task *));
|
|
|
+ assert(tasks);
|
|
|
|
|
|
- task->cl = codelet;
|
|
|
- task->handles[0] = handle;
|
|
|
+ for (i = 0; i < niter; i++)
|
|
|
+ {
|
|
|
+ struct starpu_task *task = starpu_task_create();
|
|
|
|
|
|
- task->synchronous = 1;
|
|
|
+ task->cl = codelet;
|
|
|
+ task->handles[0] = handle;
|
|
|
|
|
|
- /* We will destroy the task structure by hand so that we can
|
|
|
- * query the profiling info before the task is destroyed. */
|
|
|
- task->destroy = 0;
|
|
|
+ task->synchronous = 1;
|
|
|
|
|
|
- tasks[i] = task;
|
|
|
+ /* We will destroy the task structure by hand so that we can
|
|
|
+ * query the profiling info before the task is destroyed. */
|
|
|
+ task->destroy = 0;
|
|
|
|
|
|
- //soumettre la tache
|
|
|
- ret = starpu_task_submit(task);
|
|
|
+ tasks[i] = task;
|
|
|
|
|
|
- if (STARPU_UNLIKELY(ret == -ENODEV))
|
|
|
- {
|
|
|
- FPRINTF(stderr, "No worker may execute this task\n");
|
|
|
- exit(0);
|
|
|
- }
|
|
|
- }
|
|
|
+ int ret = starpu_task_submit(task);
|
|
|
|
|
|
- starpu_data_unregister(handle);
|
|
|
+ if (STARPU_UNLIKELY(ret == -ENODEV))
|
|
|
+ {
|
|
|
+ FPRINTF(stderr, "No worker may execute this task\n");
|
|
|
+ exit(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- starpu_task_wait_for_all();
|
|
|
+ starpu_data_unregister(handle);
|
|
|
|
|
|
- double length_sum = 0.0;
|
|
|
+ starpu_task_wait_for_all();
|
|
|
|
|
|
- for (i = 0; i < niter; i++)
|
|
|
- {
|
|
|
- struct starpu_task *task = tasks[i];
|
|
|
+ double length_sum = 0.0;
|
|
|
|
|
|
- struct starpu_profiling_task_info *info = task->profiling_info;
|
|
|
+ for (i = 0; i < niter; i++)
|
|
|
+ {
|
|
|
+ struct starpu_task *task = tasks[i];
|
|
|
+ struct starpu_profiling_task_info *info = task->profiling_info;
|
|
|
|
|
|
|
|
|
- /* How long was the task execution ? */
|
|
|
- length_sum += starpu_timing_timespec_delay_us(&info->start_time, &info->end_time);
|
|
|
+ /* How long was the task execution ? */
|
|
|
+ length_sum += starpu_timing_timespec_delay_us(&info->start_time, &info->end_time);
|
|
|
|
|
|
- /* We don't need the task structure anymore */
|
|
|
- starpu_task_destroy(task);
|
|
|
- }
|
|
|
+ /* We don't need the task structure anymore */
|
|
|
+ starpu_task_destroy(task);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- /* Display the occupancy of all workers during the test */
|
|
|
- unsigned worker;
|
|
|
- for (worker = 0; worker < starpu_worker_get_count(); worker++)
|
|
|
- {
|
|
|
- struct starpu_profiling_worker_info worker_info;
|
|
|
- ret = starpu_profiling_worker_get_info(worker, &worker_info);
|
|
|
- STARPU_ASSERT(!ret);
|
|
|
+ /* Display the occupancy of all workers during the test */
|
|
|
+ unsigned worker;
|
|
|
+ for (worker = 0; worker < starpu_worker_get_count(); worker++)
|
|
|
+ {
|
|
|
+ struct starpu_profiling_worker_info worker_info;
|
|
|
+ int ret = starpu_profiling_worker_get_info(worker, &worker_info);
|
|
|
+ STARPU_ASSERT(!ret);
|
|
|
|
|
|
- char workername[128];
|
|
|
- starpu_worker_get_name(worker, workername, sizeof(workername));
|
|
|
- unsigned nimpl;
|
|
|
+ char workername[128];
|
|
|
+ starpu_worker_get_name(worker, workername, sizeof(workername));
|
|
|
+ unsigned nimpl;
|
|
|
|
|
|
- if (starpu_worker_get_type(worker)==STARPU_CPU_WORKER)
|
|
|
- {
|
|
|
- FPRINTF(stdout, "\n Worker :%s ::::::::::\n\n", workername);
|
|
|
+ if (starpu_worker_get_type(worker)==STARPU_CPU_WORKER)
|
|
|
+ {
|
|
|
+ FPRINTF(stdout, "\n Worker :%s ::::::::::\n\n", workername);
|
|
|
|
|
|
- for (nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
|
|
|
- {
|
|
|
+ for (nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
|
|
|
+ {
|
|
|
|
|
|
- FPRINTF(stdout, "Expected time for %d on %s (impl %u): %f, Measured time: %f, Expected energy: %f\n",
|
|
|
- size, workername, nimpl,starpu_task_expected_length(task, starpu_worker_get_perf_archtype(worker, task->sched_ctx), nimpl), ((length_sum)/niter),
|
|
|
- starpu_task_expected_energy(task, starpu_worker_get_perf_archtype(worker, task->sched_ctx), nimpl));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ FPRINTF(stdout, "Expected time for %d on %s (impl %u): %f, Measured time: %f, Expected energy: %f\n",
|
|
|
+ size, workername, nimpl,starpu_task_expected_length(compar_task, starpu_worker_get_perf_archtype(worker, compar_task->sched_ctx), nimpl), ((length_sum)/niter),
|
|
|
+ starpu_task_expected_energy(compar_task, starpu_worker_get_perf_archtype(worker, compar_task->sched_ctx), nimpl));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|
|
|
@@ -236,74 +231,75 @@ static void compare_performance(int size, struct starpu_codelet *codelet, struct
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
{
|
|
|
+ /* Enable profiling */
|
|
|
+ starpu_profiling_status_set(STARPU_PROFILING_ENABLE);
|
|
|
|
|
|
- /* Enable profiling */
|
|
|
- starpu_profiling_status_set(1);
|
|
|
+ struct starpu_conf conf;
|
|
|
+ starpu_data_handle_t handle;
|
|
|
+ int ret;
|
|
|
|
|
|
- struct starpu_conf conf;
|
|
|
- starpu_data_handle_t handle;
|
|
|
- int ret;
|
|
|
+ starpu_conf_init(&conf);
|
|
|
|
|
|
- starpu_conf_init(&conf);
|
|
|
+ conf.sched_policy_name = "dmda";
|
|
|
+ conf.calibrate = 2;
|
|
|
|
|
|
- conf.sched_policy_name = "dmda";
|
|
|
- conf.calibrate = 2;
|
|
|
+ ret = starpu_initialize(&conf, &argc, &argv);
|
|
|
+ if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
|
|
|
+ STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
|
|
|
|
|
|
- ret = starpu_initialize(&conf, &argc, &argv);
|
|
|
- if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
|
|
|
- STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
|
|
|
-
|
|
|
- int size;
|
|
|
- /*for (size = STARTlin; size < END; size *= 2)
|
|
|
- {
|
|
|
- /* Use a linear regression */
|
|
|
- //test_memset(size, &memset_cl);
|
|
|
- //}
|
|
|
+ int size;
|
|
|
+#if 0
|
|
|
+ for (size = STARTlin; size < END; size *= 2)
|
|
|
+ {
|
|
|
+ /* Use a linear regression */
|
|
|
+ test_memset(size, &memset_cl);
|
|
|
+ }
|
|
|
+#endif
|
|
|
|
|
|
- for (size = START; size < END; size *= 2)
|
|
|
- {
|
|
|
- /* Use a non-linear regression */
|
|
|
- test_memset(size, &nl_memset_cl);
|
|
|
- }
|
|
|
+ for (size = START; size < END; size *= 2)
|
|
|
+ {
|
|
|
+ /* Use a non-linear regression */
|
|
|
+ test_memset(size, &nl_memset_cl);
|
|
|
+ }
|
|
|
|
|
|
- ret = starpu_task_wait_for_all();
|
|
|
- STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
|
|
|
+ ret = starpu_task_wait_for_all();
|
|
|
+ STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
|
|
|
|
|
|
- starpu_shutdown();
|
|
|
+ starpu_shutdown();
|
|
|
|
|
|
|
|
|
- /* Test Phase */
|
|
|
- starpu_conf_init(&conf);
|
|
|
+ /* Test Phase */
|
|
|
+ starpu_conf_init(&conf);
|
|
|
|
|
|
- conf.sched_policy_name = "dmda";
|
|
|
- conf.calibrate = 0;
|
|
|
+ conf.sched_policy_name = "dmda";
|
|
|
+ conf.calibrate = 0;
|
|
|
|
|
|
- ret = starpu_initialize(&conf, &argc, &argv);
|
|
|
- if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
|
|
|
- STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
|
|
|
+ ret = starpu_initialize(&conf, &argc, &argv);
|
|
|
+ if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
|
|
|
+ STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
|
|
|
|
|
|
- /* Now create a dummy task just to estimate its duration according to the regression */
|
|
|
+ /* Now create a dummy task just to estimate its duration according to the regression */
|
|
|
|
|
|
- size = 1234567;
|
|
|
+ size = 1234567;
|
|
|
|
|
|
- starpu_vector_data_register(&handle, -1, (uintptr_t)NULL, size, sizeof(int));
|
|
|
+ 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->destroy = 0;
|
|
|
+ struct starpu_task *task = starpu_task_create();
|
|
|
+ task->cl = &memset_cl;
|
|
|
+ task->handles[0] = handle;
|
|
|
+ task->destroy = 0;
|
|
|
|
|
|
- task->cl = &nl_memset_cl;
|
|
|
+ task->cl = &nl_memset_cl;
|
|
|
|
|
|
- FPRINTF(stdout, "\n ////non linear regression results////\n");
|
|
|
+ FPRINTF(stdout, "\n ////non linear regression results////\n");
|
|
|
|
|
|
- compare_performance(size, &nl_memset_cl,task);
|
|
|
+ compare_performance(size, &nl_memset_cl, task);
|
|
|
|
|
|
- starpu_task_destroy(task);
|
|
|
+ starpu_task_destroy(task);
|
|
|
|
|
|
- starpu_data_unregister(handle);
|
|
|
+ starpu_data_unregister(handle);
|
|
|
|
|
|
- starpu_shutdown();
|
|
|
+ starpu_shutdown();
|
|
|
|
|
|
- return EXIT_SUCCESS;
|
|
|
+ return EXIT_SUCCESS;
|
|
|
}
|