Forráskód Böngészése

ex check if cuda exits

Andra Hugo 12 éve
szülő
commit
25a6af763e
1 módosított fájl, 8 hozzáadás és 4 törlés
  1. 8 4
      examples/sched_ctx/sched_ctx.c

+ 8 - 4
examples/sched_ctx/sched_ctx.c

@@ -16,7 +16,6 @@
  */
 
 #include<starpu.h>
-#include<starpu_sched_ctx.h>
 #include<pthread.h>
 
 #define NTASKS 1000
@@ -56,15 +55,20 @@ int main(int argc, char **argv)
 #endif
 
 	pthread_mutex_init(&mut, NULL);
-
-	unsigned ncpus =  starpu_cpu_worker_get_count();
-	unsigned ncuda = starpu_cuda_worker_get_count();
+	unsigned ncuda = 0;
+	unsigned ncpus = 1;
+#ifdef STARPU_USE_CPU
+	ncpus =  starpu_cpu_worker_get_count();
 
     int cpus[ncpus];
     starpu_worker_get_ids_by_type(STARPU_CPU_WORKER, cpus, ncpus);
 
+#endif
+#ifdef STARPU_USE_CUDA
+	ncuda = starpu_cuda_worker_get_count();
     int cudadevs[ncuda];
     starpu_worker_get_ids_by_type(STARPU_CUDA_WORKER, cudadevs, ncuda);
+#endif
 
 
 	int nprocs1 = ncpus;