浏览代码

exemples/interface/complex: Make sure CUDA cards with capabilities < 1.3 do not try to perform operations on doubles

Nathalie Furmento 12 年之前
父节点
当前提交
c989236047
共有 2 个文件被更改,包括 28 次插入3 次删除
  1. 2 0
      examples/Makefile.am
  2. 26 3
      examples/interface/complex.c

+ 2 - 0
examples/Makefile.am

@@ -746,6 +746,8 @@ interface_complex_SOURCES	=	\
 if STARPU_USE_CUDA
 interface_complex_SOURCES	+=	\
 	interface/complex_kernels.cu
+interface/complex_kernels.o: interface/complex_kernels.cu
+	$(NVCC) $< -c -o $@ $(NVCCFLAGS) -arch sm_13
 endif
 
 if STARPU_USE_OPENCL

+ 26 - 3
examples/interface/complex.c

@@ -18,6 +18,28 @@
 #include "complex_interface.h"
 #include "complex_codelet.h"
 
+static int can_execute(unsigned workerid, struct starpu_task *task, unsigned nimpl)
+{
+       if (starpu_worker_get_type(workerid) == STARPU_OPENCL_WORKER)
+               return 1;
+
+#ifdef STARPU_USE_CUDA
+       /* Cuda device */
+       const struct cudaDeviceProp *props;
+       props = starpu_cuda_get_device_properties(workerid);
+       if (props->major >= 2 || props->minor >= 3)
+       {
+               /* At least compute capability 1.3, supports doubles */
+               return 1;
+       }
+       else
+       {
+               /* Old card does not support doubles */
+               return 0;
+       }
+#endif
+}
+
 #ifdef STARPU_USE_CUDA
 extern void copy_complex_codelet_cuda(void *descr[], __attribute__ ((unused)) void *_args);
 #endif
@@ -34,10 +56,10 @@ struct starpu_codelet cl_copy =
 	.opencl_funcs = {copy_complex_codelet_opencl, NULL},
 #endif
 	.nbuffers = 2,
-	.modes = {STARPU_R, STARPU_W}
+	.modes = {STARPU_R, STARPU_W},
+	.can_execute = can_execute
 };
 
-
 #ifdef STARPU_USE_OPENCL
 struct starpu_opencl_program opencl_program;
 #endif
@@ -95,7 +117,6 @@ int main(int argc, char **argv)
 	if (ret == -ENODEV) goto enodev;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_insert_task");
 
-
 	ret = starpu_insert_task(&cl_compare,
 				 STARPU_R, handle1,
 				 STARPU_R, handle2,
@@ -103,6 +124,8 @@ int main(int argc, char **argv)
 	if (ret == -ENODEV) goto enodev;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_insert_task");
 
+#warning get the comparison result and return it as the application return code
+
 	starpu_task_wait_for_all();
 
 #ifdef STARPU_USE_OPENCL