瀏覽代碼

examples/interface: move definition of display codelet to a separate file

Nathalie Furmento 13 年之前
父節點
當前提交
25f36c7e72
共有 4 個文件被更改,包括 50 次插入20 次删除
  1. 1 0
      examples/Makefile.am
  2. 1 20
      examples/interface/complex.c
  3. 44 0
      examples/interface/complex_codelet.h
  4. 4 0
      examples/interface/complex_interface.h

+ 1 - 0
examples/Makefile.am

@@ -136,6 +136,7 @@ noinst_HEADERS = 				\
 	filters/custom_mf/custom_interface.h    \
 	filters/custom_mf/custom_types.h	\
 	interface/complex_interface.h		\
+	interface/complex_codelet.h		\
 	pi/pi.h					\
 	pi/SobolQRNG/sobol.h			\
 	pi/SobolQRNG/sobol_gold.h		\

+ 1 - 20
examples/interface/complex.c

@@ -16,6 +16,7 @@
 
 #include <starpu.h>
 #include "complex_interface.h"
+#include "complex_codelet.h"
 #ifdef STARPU_USE_OPENCL
 #include <starpu_opencl.h>
 #endif
@@ -53,26 +54,6 @@ void compare_complex_codelet(void *descr[], __attribute__ ((unused)) void *_args
 	fprintf(stderr, "Complex numbers are%s similar\n", compare==0 ? " NOT" : "");
 }
 
-void display_complex_codelet(void *descr[], __attribute__ ((unused)) void *_args)
-{
-	int nx = STARPU_COMPLEX_GET_NX(descr[0]);
-	double *real = STARPU_COMPLEX_GET_REAL(descr[0]);
-	double *imaginary = STARPU_COMPLEX_GET_IMAGINARY(descr[0]);
-	int i;
-
-	for(i=0 ; i<nx ; i++)
-	{
-		fprintf(stderr, "Complex[%d] = %3.2f + %3.2f i\n", i, real[i], imaginary[i]);
-	}
-}
-
-struct starpu_codelet cl_display =
-{
-	.cpu_funcs = {display_complex_codelet, NULL},
-	.nbuffers = 1,
-	.modes = {STARPU_R}
-};
-
 struct starpu_codelet cl_copy =
 {
 #ifdef STARPU_USE_CUDA

+ 44 - 0
examples/interface/complex_codelet.h

@@ -0,0 +1,44 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2012  Centre National de la Recherche Scientifique
+ *
+ * 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.
+ */
+
+#include <starpu.h>
+#include "complex_interface.h"
+
+#ifndef __COMPLEX_CODELET_H
+#define __COMPLEX_CODELET_H
+
+
+void display_complex_codelet(void *descr[], __attribute__ ((unused)) void *_args)
+{
+	int nx = STARPU_COMPLEX_GET_NX(descr[0]);
+	double *real = STARPU_COMPLEX_GET_REAL(descr[0]);
+	double *imaginary = STARPU_COMPLEX_GET_IMAGINARY(descr[0]);
+	int i;
+
+	for(i=0 ; i<nx ; i++)
+	{
+		fprintf(stderr, "Complex[%d] = %3.2f + %3.2f i\n", i, real[i], imaginary[i]);
+	}
+}
+
+struct starpu_codelet cl_display =
+{
+	.cpu_funcs = {display_complex_codelet, NULL},
+	.nbuffers = 1,
+	.modes = {STARPU_R}
+};
+
+#endif /* __COMPLEX_CODELET_H */

+ 4 - 0
examples/interface/complex_interface.h

@@ -16,6 +16,9 @@
 
 #include <starpu.h>
 
+#ifndef __COMPLEX_INTERFACE_H
+#define __COMPLEX_INTERFACE_H
+
 /* interface for complex numbers */
 struct starpu_complex_interface
 {
@@ -34,3 +37,4 @@ int starpu_complex_get_nx(starpu_data_handle_t handle);
 #define STARPU_COMPLEX_GET_IMAGINARY(interface)	(((struct starpu_complex_interface *)(interface))->imaginary)
 #define STARPU_COMPLEX_GET_NX(interface)	(((struct starpu_complex_interface *)(interface))->nx)
 
+#endif /* __COMPLEX_INTERFACE_H */