Browse Source

Introduce new variables STARPU_LIMIT_CUDA_devid_MEM and
STARPU_LIMIT_OPENCL_devid_MEM to limit memory per specific device.

Nathalie Furmento 12 years ago
parent
commit
e327177d94

+ 2 - 0
ChangeLog

@@ -90,6 +90,8 @@ New features:
     before doing an allocation on the device.
     before doing an allocation on the device.
   * Discard environment variable STARPU_LIMIT_GPU_MEM and define
   * Discard environment variable STARPU_LIMIT_GPU_MEM and define
     instead STARPU_LIMIT_CUDA_MEM and STARPU_LIMIT_OPENCL_MEM
     instead STARPU_LIMIT_CUDA_MEM and STARPU_LIMIT_OPENCL_MEM
+  * Introduce new variables STARPU_LIMIT_CUDA_devid_MEM and
+    STARPU_LIMIT_OPENCL_devid_MEM to limit memory per specific device
 
 
 Changes:
 Changes:
   * Fix the block filter functions.
   * Fix the block filter functions.

+ 18 - 0
doc/chapters/configuration.texi

@@ -583,6 +583,15 @@ This variable specifies in which file the debugging output should be saved to.
 This variable specifies in which directory to save the trace generated if FxT is enabled. It needs to have a trailing '/' character.
 This variable specifies in which directory to save the trace generated if FxT is enabled. It needs to have a trailing '/' character.
 @end defvr
 @end defvr
 
 
+@defvr {Environment variable} STARPU_LIMIT_CUDA_devid_MEM
+This variable specifies the maximum number of megabytes that should be
+available to the application on the CUDA device with the identifier
+@code{devid}. This variable is intended to be used for experimental
+purposes as it emulates devices that have a limited amount of memory.
+When defined, the variable overwrites the value of the variable
+@code{STARPU_LIMIT_CUDA_MEM}.
+@end defvr
+
 @defvr {Environment variable} STARPU_LIMIT_CUDA_MEM
 @defvr {Environment variable} STARPU_LIMIT_CUDA_MEM
 This variable specifies the maximum number of megabytes that should be
 This variable specifies the maximum number of megabytes that should be
 available to the application on each CUDA devices. This variable is
 available to the application on each CUDA devices. This variable is
@@ -590,6 +599,15 @@ intended to be used for experimental purposes as it emulates devices
 that have a limited amount of memory.
 that have a limited amount of memory.
 @end defvr
 @end defvr
 
 
+@defvr {Environment variable} STARPU_LIMIT_OPENCL_devid_MEM
+This variable specifies the maximum number of megabytes that should be
+available to the application on the OpenCL device with the identifier
+@code{devid}. This variable is intended to be used for experimental
+purposes as it emulates devices that have a limited amount of memory.
+When defined, the variable overwrites the value of the variable
+@code{STARPU_LIMIT_OPENCL_MEM}.
+@end defvr
+
 @defvr {Environment variable} STARPU_LIMIT_OPENCL_MEM
 @defvr {Environment variable} STARPU_LIMIT_OPENCL_MEM
 This variable specifies the maximum number of megabytes that should be
 This variable specifies the maximum number of megabytes that should be
 available to the application on each OpenCL devices. This variable is
 available to the application on each OpenCL devices. This variable is

+ 8 - 1
src/drivers/cuda/driver_cuda.c

@@ -74,8 +74,15 @@ _starpu_cuda_discover_devices (struct _starpu_machine_config *config)
  */
  */
 static void _starpu_cuda_limit_gpu_mem_if_needed(unsigned devid)
 static void _starpu_cuda_limit_gpu_mem_if_needed(unsigned devid)
 {
 {
-	int limit = starpu_get_env_number("STARPU_LIMIT_CUDA_MEM");
+	int limit;
+	char name[30];
 
 
+	limit = starpu_get_env_number("STARPU_LIMIT_CUDA_MEM");
+	if (limit == -1)
+	{
+		sprintf(name, "STARPU_LIMIT_CUDA_%u_MEM", devid);
+		limit = starpu_get_env_number(name);
+	}
 	if (limit == -1)
 	if (limit == -1)
 	{
 	{
 		return;
 		return;

+ 8 - 1
src/drivers/opencl/driver_opencl.c

@@ -67,8 +67,15 @@ static cl_mem wasted_memory[STARPU_MAXOPENCLDEVS];
 static void limit_gpu_mem_if_needed(int devid)
 static void limit_gpu_mem_if_needed(int devid)
 {
 {
 	cl_int err;
 	cl_int err;
+	int limit;
+	char name[30];
 
 
-	int limit = starpu_get_env_number("STARPU_LIMIT_OPENCL_MEM");
+	limit = starpu_get_env_number("STARPU_LIMIT_OPENCL_MEM");
+	if (limit == -1)
+	{
+	     sprintf(name, "STARPU_LIMIT_OPENCL_%u_MEM", devid);
+	     limit = starpu_get_env_number(name);
+	}
 	if (limit == -1)
 	if (limit == -1)
 	{
 	{
 		wasted_memory[devid] = NULL;
 		wasted_memory[devid] = NULL;