瀏覽代碼

Since we are going to need the "null" gordon kernel often, let's create a small
wrapper that dynamically loads it onto the SPUs and returns its identifier so
that we do not redo the same work every time.

Cédric Augonnet 16 年之前
父節點
當前提交
63ec9fa7cf
共有 4 個文件被更改,包括 73 次插入5 次删除
  1. 9 2
      examples/Makefile.am
  2. 32 0
      examples/gordon/null.h
  3. 22 0
      examples/gordon/null_kernel_gordon.c
  4. 10 3
      examples/tag_example/tag_example.c

+ 9 - 2
examples/Makefile.am

@@ -25,11 +25,14 @@ BUILT_SOURCES =
 
 EXTRA_DIST = 					\
 	cuda/incrementer_cuda.cu		\
-	cuda/spmv_cuda.cu
+	cuda/spmv_cuda.cu			\
+	gordon/null_kernel_gordon.c
 
 CLEANFILES = 					\
 	cuda/incrementer_cuda.cubin		\
-	cuda/spmv_cuda.cubin			
+	cuda/spmv_cuda.cubin			\
+	gordon/null_kernel_gordon.spuelf
+	
 
 CLEANFILES += *.gcno *.gcda *.linkinfo
 
@@ -66,6 +69,9 @@ SPULIBS = -lblas #-lc -lgloss -lc
 .spuo.spuelf:
 	$(SPU_LD) $(SPULDFLAGS) $< -o $@ $(SPULIBS)
 
+BUILT_SOURCES +=				\
+	gordon/null_kernel_gordon.spuelf
+
 endif
 
 examplebindir = $(libdir)/starpu/examples/
@@ -83,6 +89,7 @@ noinst_HEADERS = 				\
 	common/blas.h				\
 	mult/dw_mult.h				\
 	cuda/incrementer_cuda.h			\
+	gordon/null.h				\
 	fortran/bindings/StarPU-fortran.h	\
 	ppm-downscaler/ppm-downscaler.h		\
 	strassen/strassen.h			\

+ 32 - 0
examples/gordon/null.h

@@ -0,0 +1,32 @@
+/*
+ * 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>
+
+#ifdef USE_GORDON
+static inline unsigned load_gordon_null_kernel(void)
+{
+	unsigned elf_id =
+		gordon_register_elf_plugin("./gordon/null_kernel_gordon.spuelf");
+	gordon_load_plugin_on_all_spu(elf_id);
+
+	unsigned gordon_null_kernel =
+		gordon_register_kernel(elf_id, "empty_kernel");
+	gordon_load_kernel_on_all_spu(gordon_null_kernel);
+
+	return gordon_null_kernel;
+}
+#endif

+ 22 - 0
examples/gordon/null_kernel_gordon.c

@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+void empty_kernel (__attribute__ ((unused)) void **alloc,
+                __attribute__ ((unused)) void **in,
+                __attribute__ ((unused)) void **inout,
+                __attribute__ ((unused)) void **out)
+{
+}

+ 10 - 3
examples/tag_example/tag_example.c

@@ -23,6 +23,10 @@
 
 #include <starpu.h>
 
+#ifdef USE_GORDON
+#include <gordon/null.h>
+#endif
+
 #define TAG(i, j, iter)	((starpu_tag_t) ( ((uint64_t)(iter)<<48) |  ((uint64_t)(j)<<24) | (i)) )
 
 sem_t sem;
@@ -185,6 +189,11 @@ int main(int argc __attribute__((unused)) , char **argv __attribute__((unused)))
 {
 	starpu_init(NULL);
 
+#ifdef USE_GORDON
+	/* load an empty kernel and get its identifier */
+	unsigned gordon_null_kernel = load_gordon_null_kernel();
+#endif
+
 	parse_args(argc, argv);
 
 	fprintf(stderr, "ITER: %d\n", nk);
@@ -193,9 +202,7 @@ int main(int argc __attribute__((unused)) , char **argv __attribute__((unused)))
 	cl.core_func = core_codelet;
 	cl.cublas_func = core_codelet;
 #ifdef USE_GORDON
-#ifdef SPU_FUNC_NULL
-	cl.gordon_func = SPU_FUNC_NULL;
-#endif
+	cl.gordon_func = gordon_null_kernel;
 #endif
 	cl.nbuffers = 0;