Pārlūkot izejas kodu

Fix confusion between STARPU_NMIC STARPU_NMICDEVS, the number of devices and the number of cores. STARPU_NMIC will be the number of devices, as people seem to expect, and STARPU_NMICCORES will be the number of cores per device

Samuel Thibault 9 gadi atpakaļ
vecāks
revīzija
d2d1e42b4e
2 mainītis faili ar 26 papildinājumiem un 30 dzēšanām
  1. 9 8
      doc/doxygen/chapters/40environment_variables.doxy
  2. 17 22
      src/core/topology.c

+ 9 - 8
doc/doxygen/chapters/40environment_variables.doxy

@@ -80,13 +80,6 @@ otherwise bring spurious synchronizations. The default is 2. Setting the value t
 execution of all tasks.
 </dd>
 
-<dt>STARPU_NMICDEVS</dt>
-<dd>
-\anchor STARPU_NMICDEVS
-\addindex __env__STARPU_NMICDEVS
-MIC equivalent of the environment variable \ref STARPU_NCUDA.
-</dd>
-
 <dt>STARPU_OPENCL_ON_CPUS</dt>
 <dd>
 \anchor STARPU_OPENCL_ON_CPUS
@@ -111,7 +104,15 @@ CPU devices.
 <dd>
 \anchor STARPU_NMIC
 \addindex __env__STARPU_NMIC
-MIC equivalent of the environment variable \ref STARPU_NCUDA.
+MIC equivalent of the environment variable \ref STARPU_NCUDA, i.e. the number of
+MIC devices to use.
+</dd>
+
+<dt>STARPU_NMICCORES</dt>
+<dd>
+\anchor STARPU_NMICCORES
+\addindex __env__STARPU_NMICCORES
+Number of cores to use on the MIC devices.
 </dd>
 
 <dt>STARPU_NSCC</dt>

+ 17 - 22
src/core/topology.c

@@ -745,30 +745,23 @@ _starpu_init_mic_config (struct _starpu_machine_config *config,
 	_starpu_init_mic_topology (config, mic_idx);
 
 	int nmiccores;
-	nmiccores = starpu_get_env_number("STARPU_NMIC");
+	nmiccores = starpu_get_env_number("STARPU_NMICCORES");
 
-	/* STARPU_NMIC is not set. Did the user specify anything ? */
-	if (nmiccores == -1 && user_conf)
-		nmiccores = user_conf->nmic;
-
-	if (nmiccores != 0)
+	if (nmiccores == -1)
+	{
+		/* Nothing was specified, so let's use the number of
+		 * detected mic cores. ! */
+		nmiccores = topology->nhwmiccores[mic_idx];
+	}
+	else
 	{
-		if (nmiccores == -1)
+		if ((unsigned) nmiccores > topology->nhwmiccores[mic_idx])
 		{
-			/* Nothing was specified, so let's use the number of
-			 * detected mic cores. ! */
+			/* The user requires more MIC devices than there is available */
+			fprintf(stderr,
+				"# Warning: %d MIC cores requested. Only %d available.\n",
+				nmiccores, topology->nhwmiccores[mic_idx]);
 			nmiccores = topology->nhwmiccores[mic_idx];
-		    }
-		else
-		{
-			if ((unsigned) nmiccores > topology->nhwmiccores[mic_idx])
-			{
-				/* The user requires more MIC devices than there is available */
-				fprintf(stderr,
-					"# Warning: %d MIC devices requested. Only %d available.\n",
-					nmiccores, topology->nhwmiccores[mic_idx]);
-				nmiccores = topology->nhwmiccores[mic_idx];
-			}
 		}
 	}
 
@@ -825,8 +818,10 @@ _starpu_init_mp_config (struct _starpu_machine_config *config,
 	 * infrastructure. */
 	unsigned nhwmicdevices = _starpu_mic_src_get_device_count();
 
-	int reqmicdevices = starpu_get_env_number("STARPU_NMICDEVS");
-	if (-1 == reqmicdevices)
+	int reqmicdevices = starpu_get_env_number("STARPU_NMIC");
+	if (reqmicdevices == -1 && user_conf)
+		reqmicdevices = user_conf->nmic;
+	if (reqmicdevices == -1)
 		reqmicdevices = nhwmicdevices;
 
 	topology->nmicdevices = 0;