Quellcode durchsuchen

In order to facilitate some microbenchmarking, we add a src/debug directory
which should contain code dedicated to microbenchmarks.

Cédric Augonnet vor 15 Jahren
Ursprung
Commit
c4a9cdc768
3 geänderte Dateien mit 36 neuen und 14 gelöschten Zeilen
  1. 2 1
      src/Makefile.am
  2. 31 0
      src/debug/latency.c
  3. 3 13
      tests/microbenchs/local_pingpong.c

+ 2 - 1
src/Makefile.am

@@ -141,7 +141,8 @@ libstarpu_la_SOURCES = 						\
 	util/execute_on_all.c					\
 	util/starpu_create_sync_task.c				\
 	util/starpu_cublas.c					\
-	util/file.c
+	util/file.c						\
+	debug/latency.c
 
 if STARPU_USE_CPU
 libstarpu_la_SOURCES += drivers/cpu/driver_cpu.c

+ 31 - 0
src/debug/latency.c

@@ -0,0 +1,31 @@
+/*
+ * StarPU
+ * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
+
+#include <starpu.h>
+#include <common/config.h>
+#include <datawizard/coherency.h>
+
+void _starpu_benchmark_ping_pong(starpu_data_handle handle,
+			unsigned node0, unsigned node1, unsigned niter)
+{
+	/* We assume that no one is using that handle !! */
+	unsigned iter;
+	for (iter = 0; iter < niter; iter++)
+	{
+		_starpu_fetch_data_on_node(handle, node0, 1, 1, 0);
+		_starpu_fetch_data_on_node(handle, node1, 1, 1, 0);
+	}
+}

+ 3 - 13
tests/microbenchs/local_pingpong.c

@@ -22,7 +22,7 @@
 
 static size_t vector_size = 1;
 
-static niter = 10000;
+static niter = 1000;
 static unsigned cnt;
 
 static unsigned finished = 0;
@@ -81,21 +81,11 @@ int main(int argc, char **argv)
 
 	/* warm up */
 	unsigned nwarmupiter = 128;
-	for (iter = 0; iter < nwarmupiter; iter++)
-	{
-		 _starpu_prefetch_data_on_node_with_mode(v_handle, memory_node_0, 0, STARPU_RW);
-		 _starpu_prefetch_data_on_node_with_mode(v_handle, memory_node_1, 0, STARPU_RW);
-	}
+	_starpu_benchmark_ping_pong(v_handle, memory_node_0, memory_node_1, 128);
 
 	gettimeofday(&start, NULL);
 
-	for (iter = 0; iter < niter; iter++)
-	{
-		starpu_trace_user_event(0x42);
-		 _starpu_prefetch_data_on_node_with_mode(v_handle, memory_node_0, 0, STARPU_RW);
-		starpu_trace_user_event(0x43);
-		 _starpu_prefetch_data_on_node_with_mode(v_handle, memory_node_1, 0, STARPU_RW);
-	}
+	_starpu_benchmark_ping_pong(v_handle, memory_node_0, memory_node_1, niter);
 
 	gettimeofday(&end, NULL);