浏览代码

round task lengths

Samuel Thibault 12 年之前
父节点
当前提交
e5b0426821
共有 2 个文件被更改,包括 23 次插入12 次删除
  1. 21 12
      tests/microbenchs/tasks_size_overhead.c
  2. 2 0
      tests/microbenchs/tasks_size_overhead.gp

+ 21 - 12
tests/microbenchs/tasks_size_overhead.c

@@ -30,10 +30,10 @@
 #include <starpu.h>
 #include <starpu.h>
 #include "../helper.h"
 #include "../helper.h"
 
 
-#define START 1000
-#define STOP 1000000
+#define START 4
+#define STOP 4096
 #ifdef STARPU_SLOW_MACHINE
 #ifdef STARPU_SLOW_MACHINE
-#define FACTOR 4
+#define FACTOR 8
 #else
 #else
 #define FACTOR 2
 #define FACTOR 2
 #endif
 #endif
@@ -52,10 +52,19 @@ struct starpu_task *tasks;
 
 
 static void func(void *descr[] __attribute__ ((unused)), void *arg)
 static void func(void *descr[] __attribute__ ((unused)), void *arg)
 {
 {
+	struct timeval tv1, tv2;
 	unsigned n = (uintptr_t)arg;
 	unsigned n = (uintptr_t)arg;
-	volatile unsigned i;
-	for (i = 0; i < n ; i++)
-		;
+	suseconds_t usec = 0;
+	gettimeofday(&tv1, NULL);
+	do {
+		gettimeofday(&tv2, NULL);
+		if (tv2.tv_usec < tv1.tv_usec) {
+			tv2.tv_usec += 1000000;
+			tv2.tv_sec--;
+		}
+		usec = (tv2.tv_sec-tv1.tv_sec)*1000000
+			+ (tv2.tv_usec - tv1.tv_usec);
+	} while (usec < n);
 }
 }
 
 
 static struct starpu_codelet codelet = 
 static struct starpu_codelet codelet = 
@@ -123,11 +132,11 @@ int main(int argc, char **argv)
 	/* Emit headers and compute raw tasks speed */
 	/* Emit headers and compute raw tasks speed */
 	FPRINTF(stdout, "# tasks : %u buffers : %u\n", ntasks, nbuffers);
 	FPRINTF(stdout, "# tasks : %u buffers : %u\n", ntasks, nbuffers);
 	FPRINTF(stdout, "# ncpus\t");
 	FPRINTF(stdout, "# ncpus\t");
-	for (size = START; size < STOP; size *= FACTOR)
-		FPRINTF(stdout, "%d iters(us)\ttotal(s)\t", size);
+	for (size = START; size <= STOP; size *= FACTOR)
+		FPRINTF(stdout, "%u iters(us)\ttotal(s)\t", size);
 	FPRINTF(stdout, "\n");
 	FPRINTF(stdout, "\n");
 	FPRINTF(stdout, "\"seq\"\t");
 	FPRINTF(stdout, "\"seq\"\t");
-	for (size = START; size < STOP; size *= FACTOR) {
+	for (size = START; size <= STOP; size *= FACTOR) {
 		double start,end;
 		double start,end;
 		start = starpu_timing_now();
 		start = starpu_timing_now();
 		for (i = 0; i < ntasks; i++)
 		for (i = 0; i < ntasks; i++)
@@ -140,7 +149,7 @@ int main(int argc, char **argv)
 
 
 	/* For each number of cpus, benchmark */
 	/* For each number of cpus, benchmark */
 	for (ncpus= 1; ncpus <= totcpus; ncpus++) {
 	for (ncpus= 1; ncpus <= totcpus; ncpus++) {
-		FPRINTF(stdout, "%d\t", ncpus);
+		FPRINTF(stdout, "%u\t", ncpus);
 		fflush(stdout);
 		fflush(stdout);
 
 
 		conf.ncpus = ncpus;
 		conf.ncpus = ncpus;
@@ -149,7 +158,7 @@ int main(int argc, char **argv)
 		for (buffer = 0; buffer < nbuffers; buffer++)
 		for (buffer = 0; buffer < nbuffers; buffer++)
 			starpu_vector_data_register(&data_handles[buffer], 0, (uintptr_t)buffers[buffer], 16, sizeof(float));
 			starpu_vector_data_register(&data_handles[buffer], 0, (uintptr_t)buffers[buffer], 16, sizeof(float));
 
 
-		for (size = START; size < STOP; size *= FACTOR)
+		for (size = START; size <= STOP; size *= FACTOR)
 		{
 		{
 			/* submit tasks */
 			/* submit tasks */
 			gettimeofday(&start, NULL);
 			gettimeofday(&start, NULL);
@@ -177,7 +186,7 @@ int main(int argc, char **argv)
 
 
 			timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 			timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 
 
-			FPRINTF(stdout, "%f\t%f\t", (timing*ncpus)/ntasks, timing/1000000);
+			FPRINTF(stdout, "%u\t%f\t", size, timing/1000000);
 			fflush(stdout);
 			fflush(stdout);
 
 
 			{
 			{

+ 2 - 0
tests/microbenchs/tasks_size_overhead.gp

@@ -11,6 +11,7 @@ VAL7=$(echo "$VALS" | cut -d '	' -f 15)
 VAL8=$(echo "$VALS" | cut -d '	' -f 17)
 VAL8=$(echo "$VALS" | cut -d '	' -f 17)
 VAL9=$(echo "$VALS" | cut -d '	' -f 19)
 VAL9=$(echo "$VALS" | cut -d '	' -f 19)
 VAL10=$(echo "$VALS" | cut -d '	' -f 21)
 VAL10=$(echo "$VALS" | cut -d '	' -f 21)
+VAL11=$(echo "$VALS" | cut -d '	' -f 23)
 gnuplot << EOF
 gnuplot << EOF
 set terminal eps
 set terminal eps
 set output "tasks_size_overhead.eps"
 set output "tasks_size_overhead.eps"
@@ -26,5 +27,6 @@ plot \
 	"$OUTPUT" using 1:($VAL8)/(\$17) with linespoints title columnheader(16), \
 	"$OUTPUT" using 1:($VAL8)/(\$17) with linespoints title columnheader(16), \
 	"$OUTPUT" using 1:($VAL9)/(\$19) with linespoints title columnheader(18), \
 	"$OUTPUT" using 1:($VAL9)/(\$19) with linespoints title columnheader(18), \
 	"$OUTPUT" using 1:($VAL10)/(\$21) with linespoints title columnheader(20), \
 	"$OUTPUT" using 1:($VAL10)/(\$21) with linespoints title columnheader(20), \
+	"$OUTPUT" using 1:($VAL11)/(\$23) with linespoints title columnheader(22), \
 	x title "linear"
 	x title "linear"
 EOF
 EOF