Pārlūkot izejas kodu

cuda: Do not fail to allocate very large buffers

Refusing to allocate when there is only two times more room than needed
is excessive. We can reuse the same 90% rule of thumb as the total
memory estimation.
Samuel Thibault 4 gadi atpakaļ
vecāks
revīzija
6b49e1e763
1 mainītis faili ar 5 papildinājumiem un 3 dzēšanām
  1. 5 3
      src/drivers/cuda/driver_cuda.c

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

@@ -59,6 +59,9 @@
 #endif
 #endif
 
+/* Consider a rough 10% overhead cost */
+#define FREE_MARGIN 0.9
+
 /* the number of CUDA devices */
 static int ncudagpus = -1;
 
@@ -174,8 +177,7 @@ static void _starpu_cuda_limit_gpu_mem_if_needed(unsigned devid)
 #if defined(STARPU_USE_CUDA) || defined(STARPU_SIMGRID)
 	if (limit == -1)
 	{
-		/* Use 90% of the available memory by default.  */
-		limit = totalGlobalMem / (1024*1024) * 0.9;
+		limit = totalGlobalMem / (1024*1024) * FREE_MARGIN;
 	}
 #endif
 
@@ -1749,7 +1751,7 @@ uintptr_t _starpu_cuda_malloc_on_node(unsigned dst_node, size_t size, int flags)
 	size_t cuda_mem_free, cuda_mem_total;
 	cudaError_t status;
 	status = cudaMemGetInfo(&cuda_mem_free, &cuda_mem_total);
-	if (status == cudaSuccess && cuda_mem_free < (size*2))
+	if (status == cudaSuccess && cuda_mem_free * FREE_MARGIN < size)
 	{
 		addr = 0;
 	}