Переглянути джерело

Make sure the number of requested devices is not less than -1

Samuel Thibault 6 роки тому
батько
коміт
a07072991a
1 змінених файлів з 6 додано та 0 видалено
  1. 6 0
      src/core/topology.c

+ 6 - 0
src/core/topology.c

@@ -1220,6 +1220,7 @@ _starpu_init_mic_config (struct _starpu_machine_config *config,
 	int nmiccores;
 	nmiccores = starpu_get_env_number("STARPU_NMICTHREADS");
 
+	STARPU_ASSERT_MSG(nmiccores >= -1, "nmiccores can not be negative and different from -1");
 	if (nmiccores == -1)
 	{
 		/* Nothing was specified, so let's use the number of
@@ -1360,6 +1361,7 @@ _starpu_init_mp_config (struct _starpu_machine_config *config,
 			 * detected mic devices. ! */
 			reqmicdevices = nhwmicdevices;
 
+		STARPU_ASSERT_MSG(reqmicdevices >= -1, "nmic can not be negative and different from -1");
 		if (reqmicdevices != -1)
 		{
 			if ((unsigned) reqmicdevices > nhwmicdevices)
@@ -1555,6 +1557,7 @@ _starpu_init_machine_config(struct _starpu_machine_config *config, int no_mp_con
 		_starpu_init_cuda();
 		int nb_devices = _starpu_get_cuda_device_count();
 
+		STARPU_ASSERT_MSG(ncuda >= -1, "ncuda can not be negative and different from -1");
 		if (ncuda == -1)
 		{
 			/* Nothing was specified, so let's choose ! */
@@ -1692,6 +1695,7 @@ _starpu_init_machine_config(struct _starpu_machine_config *config, int no_mp_con
 		int nb_devices;
 		nb_devices = _starpu_opencl_get_device_count();
 
+		STARPU_ASSERT_MSG(nopencl >= -1, "nopencl can not be negative and different from -1");
 		if (nopencl == -1)
 		{
 			/* Nothing was specified, so let's choose ! */
@@ -1763,6 +1767,7 @@ _starpu_init_machine_config(struct _starpu_machine_config *config, int no_mp_con
 		 * the number of devices */
 		int nb_devices = nb_scc_nodes;
 
+		STARPU_ASSERT_MSG(nscc >= -1, "nscc can not be negative and different from -1");
 		if (nscc == -1)
 		{
 			/* Nothing was specified, so let's choose ! */
@@ -1831,6 +1836,7 @@ _starpu_init_machine_config(struct _starpu_machine_config *config, int no_mp_con
 
 	if (ncpu != 0)
 	{
+		STARPU_ASSERT_MSG(ncpu >= -1, "ncpus can not be negative and different from -1");
 		if (ncpu == -1)
 		{
 			unsigned mic_busy_cpus = 0;