Pārlūkot izejas kodu

Show an example of getting perfmodel results

Samuel Thibault 14 gadi atpakaļ
vecāks
revīzija
f402c040c1

+ 2 - 1
doc/starpu.texi

@@ -1303,7 +1303,8 @@ functions with a @code{NULL} pointer (and need to be unregistered as usual)
 and the desired data sizes. The @code{starpu_task_expected_length} and
 @code{starpu_task_expected_power} functions can then be called to get an
 estimation of the task duration on a given arch. @code{starpu_task_destroy}
-needs to be called to destroy the dummy task afterwards.
+needs to be called to destroy the dummy task afterwards. See
+@code{tests/perfmodels/regression_based.c} for an example.
 
 @node Theoretical lower bound on execution time
 @section Theoretical lower bound on execution time

+ 2 - 0
include/starpu_perfmodel.h

@@ -120,6 +120,8 @@ struct starpu_perfmodel_t {
 #endif
 };
 
+enum starpu_perf_archtype starpu_worker_get_perf_archtype(int workerid);
+
 /* This function is intended to be used by external tools that should read the
  * performance model files */
 int starpu_load_history_debug(const char *symbol, struct starpu_perfmodel_t *model);

+ 0 - 2
src/core/perfmodel/perfmodel.h

@@ -113,8 +113,6 @@ double _starpu_predict_transfer_time(unsigned src_node, unsigned dst_node, size_
 void _starpu_set_calibrate_flag(unsigned val);
 unsigned _starpu_get_calibrate_flag(void);
 
-enum starpu_perf_archtype starpu_worker_get_perf_archtype(int workerid);
-
 #if defined(STARPU_USE_CUDA)
 int *_starpu_get_cuda_affinity_vector(unsigned gpuid);
 #endif

+ 33 - 0
tests/perfmodels/regression_based.c

@@ -91,9 +91,22 @@ static void test_memset(int nelems, starpu_codelet *codelet)
         starpu_data_unregister(handle);
 }
 
+static void show_task_perfs(int size, struct starpu_task *task) {
+	unsigned workerid;
+	for (workerid = 0; workerid < starpu_worker_get_count(); workerid++) {
+		char name[16];
+		starpu_worker_get_name(workerid, name, sizeof(name));
+
+		printf("Expected time for %d on %s:\t%f\n", size, name, starpu_task_expected_length(task, starpu_worker_get_perf_archtype(workerid)));
+	}
+}
+
 int main(int argc, char **argv)
 {
 	struct starpu_conf conf;
+	starpu_data_handle handle;
+	struct starpu_task *task = starpu_task_create();
+
 	starpu_conf_init(&conf);
 
 	conf.sched_policy_name = "eager";
@@ -113,6 +126,26 @@ int main(int argc, char **argv)
 
 	starpu_task_wait_for_all();
 
+	/* Now create a dummy task just to estimate its duration according to the regression */
+
+	size = 12345;
+
+	starpu_vector_data_register(&handle, -1, (uintptr_t)NULL, size, sizeof(int));
+
+	task->cl = &memset_cl;
+	task->buffers[0].handle = handle;
+	task->buffers[0].mode = STARPU_W;
+
+	show_task_perfs(size, task);
+
+	task->cl = &nl_memset_cl;
+
+	show_task_perfs(size, task);
+
+	starpu_task_destroy(task);
+
+	starpu_data_unregister(handle);
+
 	starpu_shutdown();
 
 	return 0;