Browse Source

port r 11483 from 1.1: Default to using only 90% of the available GPU memory, to avoid seeing cudaMemset run out of memory..

Samuel Thibault 11 years ago
parent
commit
b801a66994
2 changed files with 12 additions and 10 deletions
  1. 6 5
      src/drivers/cuda/driver_cuda.c
  2. 6 5
      src/drivers/opencl/driver_opencl.c

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

@@ -80,7 +80,8 @@ static void _starpu_cuda_limit_gpu_mem_if_needed(unsigned devid)
 	char name[30];
 
 #ifdef STARPU_USE_CUDA
-	global_mem[devid] = props[devid].totalGlobalMem;
+	/* Find the size of the memory on the device */
+	totalGlobalMem = props[devid].totalGlobalMem;
 #endif
 
 	limit = starpu_get_env_number("STARPU_LIMIT_CUDA_MEM");
@@ -89,17 +90,17 @@ static void _starpu_cuda_limit_gpu_mem_if_needed(unsigned devid)
 		sprintf(name, "STARPU_LIMIT_CUDA_%u_MEM", devid);
 		limit = starpu_get_env_number(name);
 	}
+#ifdef STARPU_USE_CUDA
 	if (limit == -1)
 	{
-		return;
+		/* Use 90% of the available memory by default.  */
+		limit = totalGlobalMem / (1024*1024) * 0.9;
 	}
+#endif
 
 	global_mem[devid] = limit * 1024*1024;
 
 #ifdef STARPU_USE_CUDA
-	/* Find the size of the memory on the device */
-	totalGlobalMem = props[devid].totalGlobalMem;
-
 	/* How much memory to waste ? */
 	to_waste = totalGlobalMem - global_mem[devid];
 

+ 6 - 5
src/drivers/opencl/driver_opencl.c

@@ -81,14 +81,15 @@ static void _starpu_opencl_limit_gpu_mem_if_needed(unsigned devid)
 		sprintf(name, "STARPU_LIMIT_OPENCL_%u_MEM", devid);
 		limit = starpu_get_env_number(name);
 	}
+#ifdef STARPU_USE_OPENCL
 	if (limit == -1)
 	{
-		global_mem[devid] = totalGlobalMem;
-	}
-	else
-	{
-		global_mem[devid] = limit * 1024*1024;
+		/* Use 90% of the available memory by default.  */
+		limit = totalGlobalMem / (1024*1024) * 0.9;
 	}
+#endif
+
+	global_mem[devid] = limit * 1024*1024;
 
 #ifdef STARPU_USE_OPENCL
 	/* How much memory to waste ? */