ソースを参照

Warn about maxcudadev being too small instead of crashing

Samuel Thibault 10 年 前
コミット
2413cbf4ef
共有1 個のファイルを変更した3 個の追加2 個の削除を含む
  1. 3 2
      src/drivers/cuda/driver_cuda.c

+ 3 - 2
src/drivers/cuda/driver_cuda.c

@@ -386,8 +386,9 @@ static size_t _starpu_cuda_get_global_mem_size(unsigned devid)
 
 unsigned _starpu_get_cuda_device_count(void)
 {
+	int cnt;
 #ifdef STARPU_SIMGRID
-	return _starpu_simgrid_get_nbhosts("CUDA");
+	cnt = _starpu_simgrid_get_nbhosts("CUDA");
 #else
 	int cnt;
 
@@ -395,6 +396,7 @@ unsigned _starpu_get_cuda_device_count(void)
 	cures = cudaGetDeviceCount(&cnt);
 	if (STARPU_UNLIKELY(cures))
 		 return 0;
+#endif
 
 	if (cnt > STARPU_MAXCUDADEVS)
 	{
@@ -402,7 +404,6 @@ unsigned _starpu_get_cuda_device_count(void)
 		cnt = STARPU_MAXCUDADEVS;
 	}
 	return (unsigned)cnt;
-#endif
 }
 
 void _starpu_init_cuda(void)