Browse Source

Add sync and async variants for data overhead

Samuel Thibault 5 years ago
parent
commit
8b764bdf64

+ 2 - 0
configure.ac

@@ -3490,6 +3490,8 @@ AC_CONFIG_COMMANDS([executable-scripts], [
   chmod +x doc/doxygen_dev/doxygen_filter.sh
   mkdir -p tests/microbenchs
   test -e tests/microbenchs/tasks_data_overhead.sh || ln -sf $ac_abs_top_srcdir/tests/microbenchs/tasks_data_overhead.sh tests/microbenchs/
+  test -e tests/microbenchs/sync_tasks_data_overhead.sh || ln -sf $ac_abs_top_srcdir/tests/microbenchs/sync_tasks_data_overhead.sh tests/microbenchs/
+  test -e tests/microbenchs/async_tasks_data_overhead.sh || ln -sf $ac_abs_top_srcdir/tests/microbenchs/async_tasks_data_overhead.sh tests/microbenchs/
   test -e tests/microbenchs/tasks_size_overhead.sh || ln -sf $ac_abs_top_srcdir/tests/microbenchs/tasks_size_overhead.sh tests/microbenchs/
   test -e tests/microbenchs/tasks_size_overhead_sched.sh || ln -sf $ac_abs_top_srcdir/tests/microbenchs/tasks_size_overhead_sched.sh tests/microbenchs/
   test -e tests/microbenchs/tasks_size_overhead_scheds.sh || ln -sf $ac_abs_top_srcdir/tests/microbenchs/tasks_size_overhead_scheds.sh tests/microbenchs/

+ 4 - 0
tests/Makefile.am

@@ -33,6 +33,8 @@ EXTRA_DIST =					\
 	regression/regression.sh.in		\
 	regression/profiles.build.only.in	\
 	microbenchs/tasks_data_overhead.sh	\
+	microbenchs/sync_tasks_data_overhead.sh	\
+	microbenchs/async_tasks_data_overhead.sh	\
 	microbenchs/tasks_size_overhead.sh	\
 	microbenchs/tasks_size_overhead_sched.sh	\
 	microbenchs/tasks_size_overhead_scheds.sh	\
@@ -393,6 +395,8 @@ examplebin_PROGRAMS = \
 	microbenchs/local_pingpong
 examplebin_SCRIPTS = \
 	microbenchs/tasks_data_overhead.sh \
+	microbenchs/sync_tasks_data_overhead.sh \
+	microbenchs/async_tasks_data_overhead.sh \
 	microbenchs/tasks_size_overhead.gp \
 	microbenchs/tasks_size_overhead.sh
 if !STARPU_SIMGRID

+ 19 - 0
tests/microbenchs/async_tasks_data_overhead.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+# StarPU --- Runtime system for heterogeneous multicore architectures.
+#
+# Copyright (C) 2020                                     Université de Bordeaux
+#
+# 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.
+#
+ROOT=${0%.sh}
+ROOT=${ROOT/tasks_data_overhead/tasks_overhead}
+exec $ROOT -b 1 "$@"

+ 47 - 25
tests/microbenchs/async_tasks_overhead.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2014,2016                           Université de Bordeaux
+ * Copyright (C) 2009-2014,2016,2020                      Université de Bordeaux
  * Copyright (C) 2010-2013,2015-2017                      CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -24,7 +24,17 @@
  * Measure the cost of submitting asynchronous tasks
  */
 
+starpu_data_handle_t data_handles[8];
+float *buffers[8];
+
+#ifdef STARPU_QUICK_CHECK
+static unsigned ntasks = 128;
+#else
 static unsigned ntasks = 65536;
+#endif
+static unsigned nbuffers = 0;
+
+#define BUFFERSIZE 16
 
 //static unsigned finished = 0;
 
@@ -45,36 +55,29 @@ static struct starpu_codelet dummy_codelet =
         .opencl_funcs = {dummy_func},
 	.cpu_funcs_name = {"dummy_func"},
 	.model = NULL,
-	.nbuffers = 0
+	.nbuffers = 0,
+	.modes = {STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW}
 };
 
-//static void inject_one_task(void)
-//{
-//	struct starpu_task *task = starpu_task_create();
-//
-//	task->cl = &dummy_codelet;
-//	task->cl_arg = NULL;
-//	task->detach = 0;
-//
-//	int ret = starpu_task_submit(task);
-//	STARPU_ASSERT(!ret);
-//}
-
 static void usage(char **argv)
 {
-	fprintf(stderr, "%s [-i ntasks] [-p sched_policy] [-h]\n", argv[0]);
-	exit(-1);
+	fprintf(stderr, "Usage: %s [-i ntasks] [-p sched_policy] [-b nbuffers] [-h]\n", argv[0]);
+	exit(EXIT_FAILURE);
 }
 
 static void parse_args(int argc, char **argv, struct starpu_conf *conf)
 {
 	int c;
-	while ((c = getopt(argc, argv, "i:p:h")) != -1)
+	while ((c = getopt(argc, argv, "i:b:p:h")) != -1)
 	switch(c)
 	{
 		case 'i':
 			ntasks = atoi(optarg);
 			break;
+		case 'b':
+			nbuffers = atoi(optarg);
+			dummy_codelet.nbuffers = nbuffers;
+			break;
 		case 'p':
 			conf->sched_policy_name = optarg;
 			break;
@@ -96,19 +99,22 @@ int main(int argc, char **argv)
 	starpu_conf_init(&conf);
 	conf.ncpus = 2;
 
-#ifdef STARPU_QUICK_CHECK
-	ntasks = 128;
-#endif
-
 	parse_args(argc, argv, &conf);
 
 	ret = starpu_initialize(&conf, &argc, &argv);
 	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
+	unsigned buffer;
+	for (buffer = 0; buffer < nbuffers; buffer++)
+	{
+		starpu_malloc((void**)&buffers[buffer], BUFFERSIZE*sizeof(float));
+		starpu_vector_data_register(&data_handles[buffer], STARPU_MAIN_RAM, (uintptr_t)buffers[buffer], BUFFERSIZE, sizeof(float));
+	}
+
 	starpu_profiling_status_set(STARPU_PROFILING_ENABLE);
 
-	fprintf(stderr, "#tasks : %u\n", ntasks);
+	fprintf(stderr, "#tasks : %u\n#buffers : %u\n", ntasks, nbuffers);
 
 	/* Create an array of tasks */
 	struct starpu_task **tasks = (struct starpu_task **) malloc(ntasks*sizeof(struct starpu_task *));
@@ -117,8 +123,14 @@ int main(int argc, char **argv)
 	{
 		struct starpu_task *task = starpu_task_create();
 		task->cl = &dummy_codelet;
-		task->cl_arg = NULL;
 		task->detach = 0;
+
+		/* we have 8 buffers at most */
+		for (buffer = 0; buffer < nbuffers; buffer++)
+		{
+			task->handles[buffer] = data_handles[buffer];
+		}
+
 		tasks[i] = task;
 	}
 
@@ -165,15 +177,25 @@ int main(int argc, char **argv)
 
                 if (output_dir && bench_id)
 		{
+                        char number[1+sizeof(nbuffers)*3+1];
+                        const char *numberp;
                         char file[1024];
                         FILE *f;
 
-                        snprintf(file, sizeof(file), "%s/async_tasks_overhead_total.dat", output_dir);
+                        if (nbuffers)
+                        {
+                                snprintf(number, sizeof(number), "_%u", nbuffers);
+                                numberp = number;
+                        }
+                        else
+                                numberp = "";
+
+                        snprintf(file, sizeof(file), "%s/async_tasks_overhead_total%s.dat", output_dir, numberp);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, timing/1000000);
                         fclose(f);
 
-                        snprintf(file, sizeof(file), "%s/async_tasks_overhead_per_task.dat", output_dir);
+                        snprintf(file, sizeof(file), "%s/async_tasks_overhead_per_task%s.dat", output_dir, numberp);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, timing/ntasks);
                         fclose(f);

+ 19 - 0
tests/microbenchs/sync_tasks_data_overhead.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+# StarPU --- Runtime system for heterogeneous multicore architectures.
+#
+# Copyright (C) 2020                                     Université de Bordeaux
+#
+# 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.
+#
+ROOT=${0%.sh}
+ROOT=${ROOT/tasks_data_overhead/tasks_overhead}
+exec $ROOT -b 1 "$@"

+ 64 - 15
tests/microbenchs/sync_tasks_overhead.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2014,2016                           Université de Bordeaux
+ * Copyright (C) 2009-2014,2016,2020                      Université de Bordeaux
  * Copyright (C) 2010-2013,2015-2017                      CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -25,7 +25,17 @@
  * Measure the cost of submitting synchronous tasks
  */
 
+starpu_data_handle_t data_handles[8];
+float *buffers[8];
+
+#ifdef STARPU_QUICK_CHECK
+static unsigned ntasks = 128;
+#else
 static unsigned ntasks = 65536;
+#endif
+static unsigned nbuffers = 0;
+
+#define BUFFERSIZE 16
 
 void dummy_func(void *descr[], void *arg)
 {
@@ -40,11 +50,11 @@ static struct starpu_codelet dummy_codelet =
         .opencl_funcs = {dummy_func},
 	.cpu_funcs_name = {"dummy_func"},
 	.model = NULL,
-	.nbuffers = 0
+	.nbuffers = 0,
+	.modes = {STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW}
 };
 
-static
-int inject_one_task(void)
+static int inject_one_task(void)
 {
 	int ret;
 	struct starpu_task *task = starpu_task_create();
@@ -59,15 +69,31 @@ int inject_one_task(void)
 
 }
 
-static void parse_args(int argc, char **argv)
+static void usage(char **argv)
+{
+	fprintf(stderr, "Usage: %s [-i ntasks] [-p sched_policy] [-b nbuffers] [-h]\n", argv[0]);
+	exit(EXIT_FAILURE);
+}
+
+static void parse_args(int argc, char **argv, struct starpu_conf *conf)
 {
 	int c;
-	while ((c = getopt(argc, argv, "i:")) != -1)
+	while ((c = getopt(argc, argv, "i:b:p:h")) != -1)
 	switch(c)
 	{
 		case 'i':
 			ntasks = atoi(optarg);
 			break;
+		case 'b':
+			nbuffers = atoi(optarg);
+			dummy_codelet.nbuffers = nbuffers;
+			break;
+		case 'p':
+			conf->sched_policy_name = optarg;
+			break;
+		case 'h':
+			usage(argv);
+			break;
 	}
 }
 
@@ -82,22 +108,35 @@ int main(int argc, char **argv)
 	starpu_conf_init(&conf);
 	conf.ncpus = 2;
 
-#ifdef STARPU_QUICK_CHECK
-	ntasks = 128;
-#endif
-
-	parse_args(argc, argv);
+	parse_args(argc, argv, &conf);
 
 	ret = starpu_initialize(&conf, &argc, &argv);
 	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
-	fprintf(stderr, "#tasks : %u\n", ntasks);
+	unsigned buffer;
+	for (buffer = 0; buffer < nbuffers; buffer++)
+	{
+		starpu_malloc((void**)&buffers[buffer], BUFFERSIZE*sizeof(float));
+		starpu_vector_data_register(&data_handles[buffer], STARPU_MAIN_RAM, (uintptr_t)buffers[buffer], BUFFERSIZE, sizeof(float));
+	}
+
+	fprintf(stderr, "#tasks : %u\n#buffers : %u\n", ntasks, nbuffers);
 
 	start = starpu_timing_now();
 	for (i = 0; i < ntasks; i++)
 	{
-		ret = inject_one_task();
+		struct starpu_task *task = starpu_task_create();
+		task->cl = &dummy_codelet;
+		task->synchronous = 1;
+
+		/* we have 8 buffers at most */
+		for (buffer = 0; buffer < nbuffers; buffer++)
+		{
+			task->handles[buffer] = data_handles[buffer];
+		}
+
+		ret = starpu_task_submit(task);
 		if (ret == -ENODEV) goto enodev;
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
@@ -114,15 +153,25 @@ int main(int argc, char **argv)
 
                 if (output_dir && bench_id)
 		{
+                        char number[1+sizeof(nbuffers)*3+1];
+                        const char *numberp;
                         char file[1024];
                         FILE *f;
 
-                        snprintf(file, sizeof(file), "%s/sync_tasks_overhead_total.dat", output_dir);
+                        if (nbuffers)
+                        {
+                                snprintf(number, sizeof(number), "_%u", nbuffers);
+                                numberp = number;
+                        }
+                        else
+                                numberp = "";
+
+                        snprintf(file, sizeof(file), "%s/sync_tasks_overhead_total%s.dat", output_dir, numberp);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, timing/1000000);
                         fclose(f);
 
-                        snprintf(file, sizeof(file), "%s/sync_tasks_overhead_per_task.dat", output_dir);
+                        snprintf(file, sizeof(file), "%s/sync_tasks_overhead_per_task%s.dat", output_dir, numberp);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, timing/ntasks);
                         fclose(f);

+ 10 - 18
tests/microbenchs/tasks_overhead.c

@@ -57,25 +57,16 @@ static struct starpu_codelet dummy_codelet =
 	.modes = {STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW, STARPU_RW}
 };
 
-static
-int inject_one_task(void)
+static void usage(char **argv)
 {
-	struct starpu_task *task = starpu_task_create();
-
-	task->cl = &dummy_codelet;
-	task->cl_arg = NULL;
-	task->callback_func = NULL;
-	task->synchronous = 1;
-
-	int ret;
-	ret = starpu_task_submit(task);
-	return ret;
+	fprintf(stderr, "Usage: %s [-i ntasks] [-p sched_policy] [-b nbuffers] [-h]\n", argv[0]);
+	exit(EXIT_FAILURE);
 }
 
-static void parse_args(int argc, char **argv)
+static void parse_args(int argc, char **argv, struct starpu_conf *conf)
 {
 	int c;
-	while ((c = getopt(argc, argv, "i:b:h")) != -1)
+	while ((c = getopt(argc, argv, "i:b:p:h")) != -1)
 	switch(c)
 	{
 		case 'i':
@@ -85,8 +76,11 @@ static void parse_args(int argc, char **argv)
 			nbuffers = atoi(optarg);
 			dummy_codelet.nbuffers = nbuffers;
 			break;
+		case 'p':
+			conf->sched_policy_name = optarg;
+			break;
 		case 'h':
-			fprintf(stderr, "Usage: %s [-i ntasks] [-b nbuffers] [-h]\n", argv[0]);
+			usage(argv);
 			break;
 	}
 }
@@ -107,7 +101,7 @@ int main(int argc, char **argv)
 	starpu_conf_init(&conf);
 	conf.ncpus = 2;
 
-	parse_args(argc, argv);
+	parse_args(argc, argv, &conf);
 
 	ret = starpu_initialize(&conf, &argc, &argv);
 	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
@@ -128,9 +122,7 @@ int main(int argc, char **argv)
 	for (i = 0; i < ntasks; i++)
 	{
 		starpu_task_init(&tasks[i]);
-		tasks[i].callback_func = NULL;
 		tasks[i].cl = &dummy_codelet;
-		tasks[i].cl_arg = NULL;
 		tasks[i].synchronous = 0;
 		tasks[i].use_tag = 1;
 		tasks[i].tag_id = (starpu_tag_t)i;