Browse Source

bandwidth: add interleave test

Samuel Thibault 4 years ago
parent
commit
0a046a3504
2 changed files with 43 additions and 13 deletions
  1. 37 12
      tests/microbenchs/bandwidth.c
  2. 6 1
      tests/microbenchs/bandwidth_scheds.sh

+ 37 - 12
tests/microbenchs/bandwidth.c

@@ -36,7 +36,7 @@ static unsigned cpustep = 1;
 
 static unsigned noalone = 0;
 static unsigned iter = 30;
-static unsigned ncpus;
+static unsigned total_ncpus;
 static starpu_pthread_barrier_t barrier;
 static float *result;
 
@@ -108,7 +108,15 @@ static void parse_args(int argc, char **argv)
 	}
 }
 
-static float bench(int *argc, char ***argv, unsigned nbusy, unsigned nidle)
+static unsigned interleave(unsigned i)
+{
+	if (total_ncpus > 1)
+		return (i % (total_ncpus/2))*2 + i / (total_ncpus/2);
+	else
+		return 0;
+}
+
+static float bench(int *argc, char ***argv, unsigned nbusy, unsigned ncpus, int intl)
 {
 	int ret;
 	unsigned i;
@@ -120,7 +128,14 @@ static float bench(int *argc, char ***argv, unsigned nbusy, unsigned nidle)
 	conf.nopencl = 0;
 	conf.nmic = 0;
 	conf.nmpi_ms = 0;
-	conf.ncpus = nbusy + nidle;
+	conf.ncpus = ncpus;
+
+	if (intl && nbusy == ncpus)
+	{
+		conf.use_explicit_workers_bindid = 1;
+		for (i = 0; i < ncpus; i++)
+			conf.workers_bindid[i] = interleave(i);
+	}
 
 	ret = starpu_initialize(&conf, argc, argv);
 	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
@@ -133,7 +148,10 @@ static float bench(int *argc, char ***argv, unsigned nbusy, unsigned nidle)
 		struct starpu_task *task = starpu_task_create();
 		task->cl = &bw_codelet;
 		task->execute_on_a_specific_worker = 1;
-		task->workerid = i;
+		if (intl && nbusy != ncpus)
+			task->workerid = interleave(i);
+		else
+			task->workerid = i;
 		ret = starpu_task_submit(task);
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
@@ -153,7 +171,7 @@ int main(int argc, char **argv)
 	int ret;
 	unsigned n;
 	struct starpu_conf conf;
-	float alone, idle;
+	float alone, alone_int, idle, idle_int;
 
 	parse_args(argc, argv);
 
@@ -166,20 +184,27 @@ int main(int argc, char **argv)
 	ret = starpu_initialize(&conf, &argc, &argv);
 	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
-	ncpus = starpu_cpu_worker_get_count();
+	total_ncpus = starpu_cpu_worker_get_count();
 	starpu_shutdown();
 
-	result = malloc(ncpus * sizeof(result[0]));
+	result = malloc(total_ncpus * sizeof(result[0]));
 
-	printf("# nw\talone\t\t+idle\t\tidle efficiency\n");
-	for (n = 1; n <= ncpus; n += cpustep)
+	printf("# nw\talone\t\t+idle\t\tefficiency\talone int.l\t+idle int.l\tefficiency\n");
+	for (n = 1; n <= total_ncpus; n += cpustep)
 	{
 		if (noalone)
+		{
 			alone = 0.;
+			alone_int = 0.;
+		}
 		else
-			alone = bench(&argc, &argv, n, 0);
-		idle = bench(&argc, &argv, n, ncpus-n);
-		printf("%d\t%f\t%f\t%f\n", n, alone/1000, idle/1000, idle*100/alone);
+		{
+			alone = bench(&argc, &argv, n, n, 0);
+			alone_int = bench(&argc, &argv, n, n, 1);
+		}
+		idle = bench(&argc, &argv, n, total_ncpus, 0);
+		idle_int = bench(&argc, &argv, n, total_ncpus, 1);
+		printf("%d\t%f\t%f\t%f\t%f\t%f\t%f\n", n, alone/1000, idle/1000, idle*100/alone, alone_int/1000, idle_int/1000, idle_int*100/alone_int);
 	}
 
 	free(result);

+ 6 - 1
tests/microbenchs/bandwidth_scheds.sh

@@ -40,13 +40,16 @@ fi
 
 cat >> bandwidth.gp << EOF
 set key outside
+set size 2,1
 set ylabel "GB/s"
 set xlabel "ncores"
 
 plot \\
 	"bandwidth-$DEFAULT.dat" using 1:2 with lines title "alone", \\
+	"bandwidth-$DEFAULT.dat" using 1:5 with lines title "alone interleave", \\
 EOF
 
+type=1
 for sched in $SCHEDS
 do
 	if [ "$sched" != eager -a "$sched" != "$SCHEDS" ]; then
@@ -56,7 +59,9 @@ do
 	fi
 
 	STARPU_BACKOFF_MIN=0 STARPU_BACKOFF_MAX=0 STARPU_SCHED=$sched $STARPU_LAUNCH $(dirname $0)/bandwidth $extra | tee bandwidth-$sched.dat
-	echo "\"bandwidth-$sched.dat\" using 1:3 with linespoints title \"$sched\", \\" >> bandwidth.gp
+	echo "\"bandwidth-$sched.dat\" using 1:3 with linespoints lt $type pt $type title \"$sched\", \\" >> bandwidth.gp
+	echo "\"bandwidth-$sched.dat\" using 1:6 with linespoints lt $type pt $type notitle, \\" >> bandwidth.gp
+	type=$((type+1))
 done
 
 if gnuplot bandwidth.gp ; then