Browse Source

examples/codelet: move compare codelet to complex_codelet.h

Nathalie Furmento 13 years ago
parent
commit
a153f903fa
2 changed files with 32 additions and 32 deletions
  1. 0 32
      examples/interface/complex.c
  2. 32 0
      examples/interface/complex_codelet.h

+ 0 - 32
examples/interface/complex.c

@@ -28,32 +28,6 @@ extern void copy_complex_codelet_cuda(void *descr[], __attribute__ ((unused)) vo
 extern void copy_complex_codelet_opencl(void *buffers[], void *args);
 #endif
 
-void compare_complex_codelet(void *descr[], __attribute__ ((unused)) void *_args)
-{
-	int nx1 = STARPU_COMPLEX_GET_NX(descr[0]);
-	double *real1 = STARPU_COMPLEX_GET_REAL(descr[0]);
-	double *imaginary1 = STARPU_COMPLEX_GET_IMAGINARY(descr[0]);
-
-	int nx2 = STARPU_COMPLEX_GET_NX(descr[1]);
-	double *real2 = STARPU_COMPLEX_GET_REAL(descr[1]);
-	double *imaginary2 = STARPU_COMPLEX_GET_IMAGINARY(descr[1]);
-
-	int compare = (nx1 == nx2);
-	if (nx1 == nx2)
-	{
-		int i;
-		for(i=0 ; i<nx1 ; i++)
-		{
-			if (real1[i] != real2[i] || imaginary1[i] != imaginary2[i])
-			{
-				compare = 0;
-				break;
-			}
-		}
-	}
-	fprintf(stderr, "Complex numbers are%s similar\n", compare==0 ? " NOT" : "");
-}
-
 struct starpu_codelet cl_copy =
 {
 #ifdef STARPU_USE_CUDA
@@ -66,12 +40,6 @@ struct starpu_codelet cl_copy =
 	.modes = {STARPU_R, STARPU_W}
 };
 
-struct starpu_codelet cl_compare =
-{
-	.cpu_funcs = {compare_complex_codelet, NULL},
-	.nbuffers = 2,
-	.modes = {STARPU_R, STARPU_R}
-};
 
 #ifdef STARPU_USE_OPENCL
 struct starpu_opencl_program opencl_program;

+ 32 - 0
examples/interface/complex_codelet.h

@@ -20,6 +20,38 @@
 #ifndef __COMPLEX_CODELET_H
 #define __COMPLEX_CODELET_H
 
+void compare_complex_codelet(void *descr[], __attribute__ ((unused)) void *_args)
+{
+	int nx1 = STARPU_COMPLEX_GET_NX(descr[0]);
+	double *real1 = STARPU_COMPLEX_GET_REAL(descr[0]);
+	double *imaginary1 = STARPU_COMPLEX_GET_IMAGINARY(descr[0]);
+
+	int nx2 = STARPU_COMPLEX_GET_NX(descr[1]);
+	double *real2 = STARPU_COMPLEX_GET_REAL(descr[1]);
+	double *imaginary2 = STARPU_COMPLEX_GET_IMAGINARY(descr[1]);
+
+	int compare = (nx1 == nx2);
+	if (nx1 == nx2)
+	{
+		int i;
+		for(i=0 ; i<nx1 ; i++)
+		{
+			if (real1[i] != real2[i] || imaginary1[i] != imaginary2[i])
+			{
+				compare = 0;
+				break;
+			}
+		}
+	}
+	fprintf(stderr, "Complex numbers are%s similar\n", compare==0 ? " NOT" : "");
+}
+
+struct starpu_codelet cl_compare =
+{
+	.cpu_funcs = {compare_complex_codelet, NULL},
+	.nbuffers = 2,
+	.modes = {STARPU_R, STARPU_R}
+};
 
 void display_complex_codelet(void *descr[], __attribute__ ((unused)) void *_args)
 {