Browse Source

Drop arch list from topology structure

Samuel Thibault 4 years ago
parent
commit
1b65950bd9

+ 18 - 3
configure.ac

@@ -1737,9 +1737,6 @@ AC_ARG_ENABLE(maxmicthreads, [AS_HELP_STRING([--enable-maxmicthreads=<number>],
 			nmaxmicthreads=$enableval, nmaxmicthreads=120)
 			nmaxmicthreads=$enableval, nmaxmicthreads=120)
 AC_MSG_RESULT($nmaxmicthread)
 AC_MSG_RESULT($nmaxmicthread)
 
 
-AC_DEFINE_UNQUOTED(STARPU_MAXMICCORES, [$nmaxmicthreads],
-	[maximum number of MIC cores])
-
 AC_ARG_WITH(coi-dir,
 AC_ARG_WITH(coi-dir,
 	[AS_HELP_STRING([--with-coi-dir=<path>],
 	[AS_HELP_STRING([--with-coi-dir=<path>],
 	[specify the MIC's COI installation directory])],
 	[specify the MIC's COI installation directory])],
@@ -2367,6 +2364,24 @@ nmaxworkers=`expr 16 \* \( \( \( $nmaxmpidev \* $maxcpus \) + $nmaxcudadev + $nm
 AC_MSG_CHECKING(Maximum number of workers)
 AC_MSG_CHECKING(Maximum number of workers)
 AC_MSG_RESULT($nmaxworkers)
 AC_MSG_RESULT($nmaxworkers)
 AC_DEFINE_UNQUOTED(STARPU_NMAXWORKERS, [$nmaxworkers], [Maximum number of workers])
 AC_DEFINE_UNQUOTED(STARPU_NMAXWORKERS, [$nmaxworkers], [Maximum number of workers])
+nmaxdevs=0
+# XXX for now
+if test $nmaxdevs -lt $maxcpus; then
+	nmaxdevs=$maxcpus
+fi
+if test $nmaxdevs -lt $nmaxcudadev; then
+	nmaxdevs=$nmaxcudadev
+fi
+if test $nmaxdevs -lt $nmaxopencldev; then
+	nmaxdevs=$nmaxopencldev
+fi
+if test $nmaxdevs -lt $nmaxmicdev; then
+	nmaxdevs=$nmaxmicdev
+fi
+if test $nmaxdevs -lt $nmaxmpidev; then
+	nmaxdevs=$nmaxmpidev
+fi
+AC_DEFINE_UNQUOTED(STARPU_NMAXDEVS, [$nmaxdevs], [Maximum number of device per device arch])
 
 
 # Computes the maximun number of combined worker
 # Computes the maximun number of combined worker
 nmaxcombinedworkers=`expr $maxcpus + $nmaxmicthreads`
 nmaxcombinedworkers=`expr $maxcpus + $nmaxmicthreads`

+ 1 - 1
src/core/detect_combined_workers.c

@@ -252,7 +252,7 @@ static void find_and_assign_combinations_without_hwloc(int *workerids, int nwork
 	int cpu_workers[STARPU_NMAXWORKERS];
 	int cpu_workers[STARPU_NMAXWORKERS];
 	unsigned ncpus = 0;
 	unsigned ncpus = 0;
 #ifdef STARPU_USE_MIC
 #ifdef STARPU_USE_MIC
-	unsigned nb_mics = _starpu_get_machine_config()->topology.nmicdevices;
+	unsigned nb_mics = _starpu_get_machine_config()->topology.ndevices[STARPU_MIC_WORKER];
 	unsigned * nmics_table;
 	unsigned * nmics_table;
 	int * mic_id;
 	int * mic_id;
 	int ** mic_workers;
 	int ** mic_workers;

+ 1 - 1
src/core/perfmodel/perfmodel_bus.c

@@ -3045,7 +3045,7 @@ double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size
 	int busid = starpu_bus_get_id(src_node, dst_node);
 	int busid = starpu_bus_get_id(src_node, dst_node);
 	int direct = starpu_bus_get_direct(busid);
 	int direct = starpu_bus_get_direct(busid);
 #endif
 #endif
-	float ngpus = topology->ncudagpus+topology->nopenclgpus;
+	float ngpus = topology->ndevices[STARPU_CUDA_WORKER]+topology->ndevices[STARPU_OPENCL_WORKER];
 #ifdef STARPU_DEVEL
 #ifdef STARPU_DEVEL
 #warning FIXME: ngpus should not be used e.g. for slow disk transfers...
 #warning FIXME: ngpus should not be used e.g. for slow disk transfers...
 #endif
 #endif

+ 7 - 7
src/core/perfmodel/perfmodel_history.c

@@ -1217,22 +1217,22 @@ void _starpu_initialize_registered_performance_models(void)
 	starpu_perfmodel_initialize();
 	starpu_perfmodel_initialize();
 
 
 	struct _starpu_machine_config *conf = _starpu_get_machine_config();
 	struct _starpu_machine_config *conf = _starpu_get_machine_config();
-	unsigned ncores = conf->topology.nhwcpus;
-	unsigned ncuda =  conf->topology.nhwcudagpus;
-	unsigned nopencl = conf->topology.nhwopenclgpus;
+	unsigned ncores = conf->topology.nhwdevices[STARPU_CPU_WORKER];
+	unsigned ncuda =  conf->topology.nhwdevices[STARPU_CUDA_WORKER];
+	unsigned nopencl = conf->topology.nhwdevices[STARPU_OPENCL_WORKER];
 	unsigned nmic = 0;
 	unsigned nmic = 0;
 	enum starpu_worker_archtype archtype;
 	enum starpu_worker_archtype archtype;
 #if STARPU_MAXMICDEVS > 0 || STARPU_MAXMPIDEVS > 0
 #if STARPU_MAXMICDEVS > 0 || STARPU_MAXMPIDEVS > 0
 	unsigned i;
 	unsigned i;
 #endif
 #endif
 #if STARPU_MAXMICDEVS > 0
 #if STARPU_MAXMICDEVS > 0
-	for(i = 0; i < conf->topology.nhwmicdevices; i++)
-		nmic += conf->topology.nhwmiccores[i];
+	for(i = 0; i < conf->topology.nhwdevices[STARPU_MIC_WORKER]; i++)
+		nmic += conf->topology.nhwworker[STARPU_MIC_WORKER][i];
 #endif
 #endif
 	unsigned nmpi = 0;
 	unsigned nmpi = 0;
 #if STARPU_MAXMPIDEVS > 0
 #if STARPU_MAXMPIDEVS > 0
-	for(i = 0; i < conf->topology.nhwmpidevices; i++)
-		nmpi += conf->topology.nhwmpicores[i];
+	for(i = 0; i < conf->topology.nhwdevices[STARPU_MPI_MS_WORKER]; i++)
+		nmpi += conf->topology.nhwworker[STARPU_MPI_MS_WORKER][i];
 #endif
 #endif
 
 
 	// We used to allocate 2**(ncores + ncuda + nopencl + nmic + nmpi), this is too big
 	// We used to allocate 2**(ncores + ncuda + nopencl + nmic + nmpi), this is too big

+ 86 - 81
src/core/topology.c

@@ -559,13 +559,13 @@ static void _starpu_initialize_workers_cuda_gpuid(struct _starpu_machine_config
 					    &(config->current_cuda_gpuid),
 					    &(config->current_cuda_gpuid),
 					    (int *)topology->workers_cuda_gpuid,
 					    (int *)topology->workers_cuda_gpuid,
 					    "STARPU_WORKERS_CUDAID",
 					    "STARPU_WORKERS_CUDAID",
-					    topology->nhwcudagpus,
+					    topology->nhwdevices[STARPU_CUDA_WORKER],
 					    STARPU_CUDA_WORKER);
 					    STARPU_CUDA_WORKER);
 }
 }
 
 
 static inline int _starpu_get_next_cuda_gpuid(struct _starpu_machine_config *config)
 static inline int _starpu_get_next_cuda_gpuid(struct _starpu_machine_config *config)
 {
 {
-	unsigned i = ((config->current_cuda_gpuid++) % config->topology.ncudagpus);
+	unsigned i = ((config->current_cuda_gpuid++) % config->topology.ndevices[STARPU_CUDA_WORKER]);
 
 
 	return (int)config->topology.workers_cuda_gpuid[i];
 	return (int)config->topology.workers_cuda_gpuid[i];
 }
 }
@@ -583,7 +583,7 @@ static void _starpu_initialize_workers_opencl_gpuid(struct _starpu_machine_confi
 					    &(config->current_opencl_gpuid),
 					    &(config->current_opencl_gpuid),
 					    (int *)topology->workers_opencl_gpuid,
 					    (int *)topology->workers_opencl_gpuid,
 					    "STARPU_WORKERS_OPENCLID",
 					    "STARPU_WORKERS_OPENCLID",
-					    topology->nhwopenclgpus,
+					    topology->nhwdevices[STARPU_OPENCL_WORKER],
 					    STARPU_OPENCL_WORKER);
 					    STARPU_OPENCL_WORKER);
 
 
 #if defined(STARPU_USE_CUDA) || defined(STARPU_SIMGRID)
 #if defined(STARPU_USE_CUDA) || defined(STARPU_SIMGRID)
@@ -646,7 +646,7 @@ static void _starpu_initialize_workers_opencl_gpuid(struct _starpu_machine_confi
 
 
 static inline int _starpu_get_next_opencl_gpuid(struct _starpu_machine_config *config)
 static inline int _starpu_get_next_opencl_gpuid(struct _starpu_machine_config *config)
 {
 {
-	unsigned i = ((config->current_opencl_gpuid++) % config->topology.nopenclgpus);
+	unsigned i = ((config->current_opencl_gpuid++) % config->topology.ndevices[STARPU_OPENCL_WORKER]);
 
 
 	return (int)config->topology.workers_opencl_gpuid[i];
 	return (int)config->topology.workers_opencl_gpuid[i];
 }
 }
@@ -665,7 +665,7 @@ static void _starpu_initialize_workers_mic_deviceid(struct _starpu_machine_confi
 					    &(config->current_mic_deviceid),
 					    &(config->current_mic_deviceid),
 					    (int *)topology->workers_mic_deviceid,
 					    (int *)topology->workers_mic_deviceid,
 					    "STARPU_WORKERS_MICID",
 					    "STARPU_WORKERS_MICID",
-					    topology->nhwmiccores,
+					    topology->nhwdevices[STARPU_MIC_WORKER],
 					    STARPU_MIC_WORKER);
 					    STARPU_MIC_WORKER);
 }
 }
 #endif
 #endif
@@ -675,7 +675,7 @@ static void _starpu_initialize_workers_mic_deviceid(struct _starpu_machine_confi
 #ifdef STARPU_USE_MIC
 #ifdef STARPU_USE_MIC
 static inline int _starpu_get_next_mic_deviceid(struct _starpu_machine_config *config)
 static inline int _starpu_get_next_mic_deviceid(struct _starpu_machine_config *config)
 {
 {
-	unsigned i = ((config->current_mic_deviceid++) % config->topology.nmicdevices);
+	unsigned i = ((config->current_mic_deviceid++) % config->topology.ndevices[STARPU_MIC_WORKER]);
 
 
 	return (int)config->topology.workers_mic_deviceid[i];
 	return (int)config->topology.workers_mic_deviceid[i];
 }
 }
@@ -685,7 +685,7 @@ static inline int _starpu_get_next_mic_deviceid(struct _starpu_machine_config *c
 #ifdef STARPU_USE_MPI_MASTER_SLAVE
 #ifdef STARPU_USE_MPI_MASTER_SLAVE
 static inline int _starpu_get_next_mpi_deviceid(struct _starpu_machine_config *config)
 static inline int _starpu_get_next_mpi_deviceid(struct _starpu_machine_config *config)
 {
 {
-	unsigned i = ((config->current_mpi_deviceid++) % config->topology.nmpidevices);
+	unsigned i = ((config->current_mpi_deviceid++) % config->topology.ndevices[STARPU_MPI_MS_WORKER]);
 
 
 	return (int)config->topology.workers_mpi_ms_deviceid[i];
 	return (int)config->topology.workers_mpi_ms_deviceid[i];
 }
 }
@@ -694,14 +694,14 @@ static void _starpu_init_mpi_topology(struct _starpu_machine_config *config, lon
 {
 {
 	/* Discover the topology of the mpi node identifier by MPI_IDX. That
 	/* Discover the topology of the mpi node identifier by MPI_IDX. That
 	 * means, make this StarPU instance aware of the number of cores available
 	 * means, make this StarPU instance aware of the number of cores available
-	 * on this MPI device. Update the `nhwmpicores' topology field
+	 * on this MPI device. Update the `nhwworker[STARPU_MPI_MS_WORKER]' topology field
 	 * accordingly. */
 	 * accordingly. */
 
 
 	struct _starpu_machine_topology *topology = &config->topology;
 	struct _starpu_machine_topology *topology = &config->topology;
 
 
 	int nbcores;
 	int nbcores;
 	_starpu_src_common_sink_nbcores(_starpu_mpi_ms_nodes[mpi_idx], &nbcores);
 	_starpu_src_common_sink_nbcores(_starpu_mpi_ms_nodes[mpi_idx], &nbcores);
-	topology->nhwmpicores[mpi_idx] = nbcores;
+	topology->nhwworker[STARPU_MPI_MS_WORKER][mpi_idx] = nbcores;
 }
 }
 
 
 #endif /* STARPU_USE_MPI_MASTER_SLAVE */
 #endif /* STARPU_USE_MPI_MASTER_SLAVE */
@@ -711,14 +711,14 @@ static void _starpu_init_mic_topology(struct _starpu_machine_config *config, lon
 {
 {
 	/* Discover the topology of the mic node identifier by MIC_IDX. That
 	/* Discover the topology of the mic node identifier by MIC_IDX. That
 	 * means, make this StarPU instance aware of the number of cores available
 	 * means, make this StarPU instance aware of the number of cores available
-	 * on this MIC device. Update the `nhwmiccores' topology field
+	 * on this MIC device. Update the `nhwworker[STARPU_MIC_WORKER]' topology field
 	 * accordingly. */
 	 * accordingly. */
 
 
 	struct _starpu_machine_topology *topology = &config->topology;
 	struct _starpu_machine_topology *topology = &config->topology;
 
 
 	int nbcores;
 	int nbcores;
 	_starpu_src_common_sink_nbcores(_starpu_mic_nodes[mic_idx], &nbcores);
 	_starpu_src_common_sink_nbcores(_starpu_mic_nodes[mic_idx], &nbcores);
-	topology->nhwmiccores[mic_idx] = nbcores;
+	topology->nhwworker[STARPU_MIC_WORKER][mic_idx] = nbcores;
 }
 }
 
 
 static int _starpu_init_mic_node(struct _starpu_machine_config *config, int mic_idx,
 static int _starpu_init_mic_node(struct _starpu_machine_config *config, int mic_idx,
@@ -837,7 +837,7 @@ static void _starpu_init_topology(struct _starpu_machine_config *config)
 
 
 	nobind = starpu_get_env_number("STARPU_WORKERS_NOBIND");
 	nobind = starpu_get_env_number("STARPU_WORKERS_NOBIND");
 
 
-	topology->nhwcpus = 0;
+	topology->nhwdevices[STARPU_CPU_WORKER] = 0;
 	topology->nhwpus = 0;
 	topology->nhwpus = 0;
 
 
 #ifndef STARPU_SIMGRID
 #ifndef STARPU_SIMGRID
@@ -881,7 +881,7 @@ static void _starpu_init_topology(struct _starpu_machine_config *config)
 #endif
 #endif
 
 
 #ifdef STARPU_SIMGRID
 #ifdef STARPU_SIMGRID
-	config->topology.nhwcpus = config->topology.nhwpus = _starpu_simgrid_get_nbhosts("CPU");
+	config->topology.nhwdevices[STARPU_CPU_WORKER] = config->topology.nhwpus = _starpu_simgrid_get_nbhosts("CPU");
 #elif defined(STARPU_HAVE_HWLOC)
 #elif defined(STARPU_HAVE_HWLOC)
 	/* Discover the CPUs relying on the hwloc interface and fills CONFIG
 	/* Discover the CPUs relying on the hwloc interface and fills CONFIG
 	 * accordingly. */
 	 * accordingly. */
@@ -901,24 +901,24 @@ static void _starpu_init_topology(struct _starpu_machine_config *config)
 							 HWLOC_OBJ_PU);
 							 HWLOC_OBJ_PU);
 	}
 	}
 
 
-	topology->nhwcpus = hwloc_get_nbobjs_by_depth(topology->hwtopology, config->cpu_depth);
+	topology->nhwdevices[STARPU_CPU_WORKER] = hwloc_get_nbobjs_by_depth(topology->hwtopology, config->cpu_depth);
 	topology->nhwpus = hwloc_get_nbobjs_by_depth(topology->hwtopology, config->pu_depth);
 	topology->nhwpus = hwloc_get_nbobjs_by_depth(topology->hwtopology, config->pu_depth);
 
 
 #elif defined(HAVE_SYSCONF)
 #elif defined(HAVE_SYSCONF)
 	/* Discover the CPUs relying on the sysconf(3) function and fills
 	/* Discover the CPUs relying on the sysconf(3) function and fills
 	 * CONFIG accordingly. */
 	 * CONFIG accordingly. */
 
 
-	config->topology.nhwcpus = config->topology.nhwpus = sysconf(_SC_NPROCESSORS_ONLN);
+	config->topology.nhwdevices[STARPU_CPU_WORKER] = config->topology.nhwpus = sysconf(_SC_NPROCESSORS_ONLN);
 
 
 #elif defined(_WIN32)
 #elif defined(_WIN32)
 	/* Discover the CPUs on Cygwin and MinGW systems. */
 	/* Discover the CPUs on Cygwin and MinGW systems. */
 
 
 	SYSTEM_INFO sysinfo;
 	SYSTEM_INFO sysinfo;
 	GetSystemInfo(&sysinfo);
 	GetSystemInfo(&sysinfo);
-	config->topology.nhwcpus = config->topology.nhwpus = sysinfo.dwNumberOfProcessors;
+	config->topology.nhwdevices[STARPU_CPU_WORKER] = config->topology.nhwpus = sysinfo.dwNumberOfProcessors;
 #else
 #else
 #warning no way to know number of cores, assuming 1
 #warning no way to know number of cores, assuming 1
-	config->topology.nhwcpus = config->topology.nhwpus = 1;
+	config->topology.nhwdevices[STARPU_CPU_WORKER] = config->topology.nhwpus = 1;
 #endif
 #endif
 
 
 	if (config->conf.ncuda != 0)
 	if (config->conf.ncuda != 0)
@@ -926,7 +926,7 @@ static void _starpu_init_topology(struct _starpu_machine_config *config)
 	if (config->conf.nopencl != 0)
 	if (config->conf.nopencl != 0)
 		_starpu_opencl_discover_devices(config);
 		_starpu_opencl_discover_devices(config);
 #ifdef STARPU_USE_MPI_MASTER_SLAVE
 #ifdef STARPU_USE_MPI_MASTER_SLAVE
-        config->topology.nhwmpi = _starpu_mpi_src_get_device_count();
+        config->topology.nhwdevices[STARPU_MPI_MS_WORKER] = _starpu_mpi_src_get_device_count();
 #endif
 #endif
 
 
 	topology_is_initialized = 1;
 	topology_is_initialized = 1;
@@ -941,7 +941,7 @@ static void _starpu_initialize_workers_bindid(struct _starpu_machine_config *con
 	unsigned i;
 	unsigned i;
 
 
 	struct _starpu_machine_topology *topology = &config->topology;
 	struct _starpu_machine_topology *topology = &config->topology;
-	int nhyperthreads = topology->nhwpus / topology->nhwcpus;
+	int nhyperthreads = topology->nhwpus / topology->nhwdevices[STARPU_CPU_WORKER];
 	unsigned bind_on_core = 0;
 	unsigned bind_on_core = 0;
 	int scale = 1;
 	int scale = 1;
 
 
@@ -1005,7 +1005,7 @@ static void _starpu_initialize_workers_bindid(struct _starpu_machine_config *con
 						}
 						}
 						else
 						else
 						{
 						{
-							endval = (bind_on_core ? topology->nhwcpus : topology->nhwpus) - 1;
+							endval = (bind_on_core ? topology->nhwdevices[STARPU_CPU_WORKER] : topology->nhwpus) - 1;
 							if (*strval)
 							if (*strval)
 								strval++;
 								strval++;
 						}
 						}
@@ -1109,7 +1109,7 @@ static inline unsigned _starpu_get_next_bindid(struct _starpu_machine_config *co
 	STARPU_ASSERT_MSG(topology_is_initialized, "The StarPU core is not initialized yet, have you called starpu_init?");
 	STARPU_ASSERT_MSG(topology_is_initialized, "The StarPU core is not initialized yet, have you called starpu_init?");
 
 
 	unsigned current_preferred;
 	unsigned current_preferred;
-	unsigned nhyperthreads = topology->nhwpus / topology->nhwcpus;
+	unsigned nhyperthreads = topology->nhwpus / topology->nhwdevices[STARPU_CPU_WORKER];
 	unsigned ncores = topology->nhwpus / nhyperthreads;
 	unsigned ncores = topology->nhwpus / nhyperthreads;
 	unsigned i;
 	unsigned i;
 
 
@@ -1192,7 +1192,7 @@ unsigned _starpu_topology_get_nhwcpu(struct _starpu_machine_config *config)
 #endif
 #endif
 	_starpu_init_topology(config);
 	_starpu_init_topology(config);
 
 
-	return config->topology.nhwcpus;
+	return config->topology.nhwdevices[STARPU_CPU_WORKER];
 }
 }
 
 
 unsigned _starpu_topology_get_nhwpu(struct _starpu_machine_config *config)
 unsigned _starpu_topology_get_nhwpu(struct _starpu_machine_config *config)
@@ -1272,7 +1272,7 @@ static void _starpu_init_mic_config(struct _starpu_machine_config *config,
 
 
 	struct _starpu_machine_topology *topology = &config->topology;
 	struct _starpu_machine_topology *topology = &config->topology;
 
 
-	topology->nhwmiccores[mic_idx] = 0;
+	topology->nhwworker[STARPU_MIC_WORKER][mic_idx] = 0;
 
 
 	_starpu_init_mic_topology(config, mic_idx);
 	_starpu_init_mic_topology(config, mic_idx);
 
 
@@ -1284,29 +1284,29 @@ static void _starpu_init_mic_config(struct _starpu_machine_config *config,
 	{
 	{
 		/* Nothing was specified, so let's use the number of
 		/* Nothing was specified, so let's use the number of
 		 * detected mic cores. ! */
 		 * detected mic cores. ! */
-		nmiccores = topology->nhwmiccores[mic_idx];
+		nmiccores = topology->nhwworker[STARPU_MIC_WORKER][mic_idx];
 	}
 	}
 	else
 	else
 	{
 	{
-		if ((unsigned) nmiccores > topology->nhwmiccores[mic_idx])
+		if ((unsigned) nmiccores > topology->nhwworker[STARPU_MIC_WORKER][mic_idx])
 		{
 		{
 			/* The user requires more MIC cores than there is available */
 			/* The user requires more MIC cores than there is available */
-			_STARPU_MSG("# Warning: %d MIC cores requested. Only %u available.\n", nmiccores, topology->nhwmiccores[mic_idx]);
-			nmiccores = topology->nhwmiccores[mic_idx];
+			_STARPU_MSG("# Warning: %d MIC cores requested. Only %u available.\n", nmiccores, topology->nhwworker[STARPU_MIC_WORKER][mic_idx]);
+			nmiccores = topology->nhwworker[STARPU_MIC_WORKER][mic_idx];
 		}
 		}
 	}
 	}
 
 
-	topology->nmiccores[mic_idx] = nmiccores;
-	STARPU_ASSERT_MSG(topology->nmiccores[mic_idx] + topology->nworkers <= STARPU_NMAXWORKERS,
-			  "topology->nmiccores[mic_idx(%u)] (%u) + topology->nworkers (%u) <= STARPU_NMAXWORKERS (%d)",
-			  mic_idx, topology->nmiccores[mic_idx], topology->nworkers, STARPU_NMAXWORKERS);
+	topology->nworker[STARPU_MIC_WORKER][mic_idx] = nmiccores;
+	STARPU_ASSERT_MSG(topology->nworker[STARPU_MIC_WORKER][mic_idx] + topology->nworkers <= STARPU_NMAXWORKERS,
+			  "topology->nworker[STARPU_MIC_WORKER][mic_idx(%u)] (%u) + topology->nworkers (%u) <= STARPU_NMAXWORKERS (%d)",
+			  mic_idx, topology->nworker[STARPU_MIC_WORKER][mic_idx], topology->nworkers, STARPU_NMAXWORKERS);
 
 
 	/* _starpu_initialize_workers_mic_deviceid (config); */
 	/* _starpu_initialize_workers_mic_deviceid (config); */
 
 
 	mic_worker_set[mic_idx].workers = &config->workers[topology->nworkers];
 	mic_worker_set[mic_idx].workers = &config->workers[topology->nworkers];
-	mic_worker_set[mic_idx].nworkers = topology->nmiccores[mic_idx];
+	mic_worker_set[mic_idx].nworkers = topology->nworker[STARPU_MIC_WORKER][mic_idx];
 	unsigned miccore_id;
 	unsigned miccore_id;
-	for (miccore_id = 0; miccore_id < topology->nmiccores[mic_idx]; miccore_id++)
+	for (miccore_id = 0; miccore_id < topology->nworker[STARPU_MIC_WORKER][mic_idx]; miccore_id++)
 	{
 	{
 		int worker_idx = topology->nworkers + miccore_id;
 		int worker_idx = topology->nworkers + miccore_id;
 		config->workers[worker_idx].set = &mic_worker_set[mic_idx];
 		config->workers[worker_idx].set = &mic_worker_set[mic_idx];
@@ -1323,7 +1323,7 @@ static void _starpu_init_mic_config(struct _starpu_machine_config *config,
 	}
 	}
 	_starpu_mic_nodes[mic_idx]->baseworkerid = topology->nworkers;
 	_starpu_mic_nodes[mic_idx]->baseworkerid = topology->nworkers;
 
 
-	topology->nworkers += topology->nmiccores[mic_idx];
+	topology->nworkers += topology->nworker[STARPU_MIC_WORKER][mic_idx];
 }
 }
 
 
 static COIENGINE mic_handles[STARPU_MAXMICDEVS];
 static COIENGINE mic_handles[STARPU_MAXMICDEVS];
@@ -1337,7 +1337,7 @@ static void _starpu_init_mpi_config(struct _starpu_machine_config *config,
 {
 {
         struct _starpu_machine_topology *topology = &config->topology;
         struct _starpu_machine_topology *topology = &config->topology;
 
 
-        topology->nhwmpicores[mpi_idx] = 0;
+        topology->nhwworker[STARPU_MPI_MS_WORKER][mpi_idx] = 0;
 
 
         _starpu_init_mpi_topology(config, mpi_idx);
         _starpu_init_mpi_topology(config, mpi_idx);
 
 
@@ -1348,28 +1348,28 @@ static void _starpu_init_mpi_config(struct _starpu_machine_config *config,
         {
         {
                 /* Nothing was specified, so let's use the number of
                 /* Nothing was specified, so let's use the number of
                  * detected mpi cores. ! */
                  * detected mpi cores. ! */
-                nmpicores = topology->nhwmpicores[mpi_idx];
+                nmpicores = topology->nhwworker[STARPU_MPI_MS_WORKER][mpi_idx];
         }
         }
         else
         else
         {
         {
-                if ((unsigned) nmpicores > topology->nhwmpicores[mpi_idx])
+                if ((unsigned) nmpicores > topology->nhwworker[STARPU_MPI_MS_WORKER][mpi_idx])
                 {
                 {
                         /* The user requires more MPI cores than there is available */
                         /* The user requires more MPI cores than there is available */
                         _STARPU_MSG("# Warning: %d MPI cores requested. Only %u available.\n",
                         _STARPU_MSG("# Warning: %d MPI cores requested. Only %u available.\n",
-				    nmpicores, topology->nhwmpicores[mpi_idx]);
-                        nmpicores = topology->nhwmpicores[mpi_idx];
+				    nmpicores, topology->nhwworker[STARPU_MPI_MS_WORKER][mpi_idx]);
+                        nmpicores = topology->nhwworker[STARPU_MPI_MS_WORKER][mpi_idx];
                 }
                 }
         }
         }
 
 
-        topology->nmpicores[mpi_idx] = nmpicores;
-        STARPU_ASSERT_MSG(topology->nmpicores[mpi_idx] + topology->nworkers <= STARPU_NMAXWORKERS,
-                        "topology->nmpicores[mpi_idx(%u)] (%u) + topology->nworkers (%u) <= STARPU_NMAXWORKERS (%d)",
-                        mpi_idx, topology->nmpicores[mpi_idx], topology->nworkers, STARPU_NMAXWORKERS);
+        topology->nworker[STARPU_MPI_MS_WORKER][mpi_idx] = nmpicores;
+        STARPU_ASSERT_MSG(topology->nworker[STARPU_MPI_MS_WORKER][mpi_idx] + topology->nworkers <= STARPU_NMAXWORKERS,
+                        "topology->nworker[STARPU_MPI_MS_WORKER][mpi_idx(%u)] (%u) + topology->nworkers (%u) <= STARPU_NMAXWORKERS (%d)",
+                        mpi_idx, topology->nworker[STARPU_MPI_MS_WORKER][mpi_idx], topology->nworkers, STARPU_NMAXWORKERS);
 
 
         mpi_worker_set[mpi_idx].workers = &config->workers[topology->nworkers];
         mpi_worker_set[mpi_idx].workers = &config->workers[topology->nworkers];
-        mpi_worker_set[mpi_idx].nworkers = topology->nmpicores[mpi_idx];
+        mpi_worker_set[mpi_idx].nworkers = topology->nworker[STARPU_MPI_MS_WORKER][mpi_idx];
         unsigned mpicore_id;
         unsigned mpicore_id;
-        for (mpicore_id = 0; mpicore_id < topology->nmpicores[mpi_idx]; mpicore_id++)
+        for (mpicore_id = 0; mpicore_id < topology->nworker[STARPU_MPI_MS_WORKER][mpi_idx]; mpicore_id++)
         {
         {
                 int worker_idx = topology->nworkers + mpicore_id;
                 int worker_idx = topology->nworkers + mpicore_id;
                 config->workers[worker_idx].set = &mpi_worker_set[mpi_idx];
                 config->workers[worker_idx].set = &mpi_worker_set[mpi_idx];
@@ -1386,7 +1386,7 @@ static void _starpu_init_mpi_config(struct _starpu_machine_config *config,
         }
         }
 	_starpu_mpi_ms_nodes[mpi_idx]->baseworkerid = topology->nworkers;
 	_starpu_mpi_ms_nodes[mpi_idx]->baseworkerid = topology->nworkers;
 
 
-        topology->nworkers += topology->nmpicores[mpi_idx];
+        topology->nworkers += topology->nworker[STARPU_MPI_MS_WORKER][mpi_idx];
 }
 }
 #endif
 #endif
 
 
@@ -1429,13 +1429,13 @@ static void _starpu_init_mp_config(struct _starpu_machine_config *config,
 			}
 			}
 		}
 		}
 
 
-		topology->nmicdevices = 0;
+		topology->ndevices[STARPU_MIC_WORKER] = 0;
 		unsigned i;
 		unsigned i;
 		for (i = 0; i < (unsigned) reqmicdevices; i++)
 		for (i = 0; i < (unsigned) reqmicdevices; i++)
 			if (0 == _starpu_init_mic_node(config, i, &mic_handles[i], &_starpu_mic_process[i]))
 			if (0 == _starpu_init_mic_node(config, i, &mic_handles[i], &_starpu_mic_process[i]))
-				topology->nmicdevices++;
+				topology->ndevices[STARPU_MIC_WORKER]++;
 
 
-		for (i = 0; i < topology->nmicdevices; i++)
+		for (i = 0; i < topology->ndevices[STARPU_MIC_WORKER]; i++)
 			_starpu_init_mic_config(config, user_conf, i);
 			_starpu_init_mic_config(config, user_conf, i);
 	}
 	}
 #endif
 #endif
@@ -1466,10 +1466,10 @@ static void _starpu_init_mp_config(struct _starpu_machine_config *config,
 			}
 			}
 		}
 		}
 
 
-		topology->nmpidevices = reqmpidevices;
+		topology->ndevices[STARPU_MPI_MS_WORKER] = reqmpidevices;
 
 
 		/* if user don't want to use MPI slaves, we close the slave processes */
 		/* if user don't want to use MPI slaves, we close the slave processes */
-		if (no_mp_config && topology->nmpidevices == 0)
+		if (no_mp_config && topology->ndevices[STARPU_MPI_MS_WORKER] == 0)
 		{
 		{
 			_starpu_mpi_common_mp_deinit();
 			_starpu_mpi_common_mp_deinit();
 			exit(0);
 			exit(0);
@@ -1478,10 +1478,10 @@ static void _starpu_init_mp_config(struct _starpu_machine_config *config,
 		if (!no_mp_config)
 		if (!no_mp_config)
 		{
 		{
 			unsigned i;
 			unsigned i;
-			for (i = 0; i < topology->nmpidevices; i++)
+			for (i = 0; i < topology->ndevices[STARPU_MPI_MS_WORKER]; i++)
 				_starpu_mpi_ms_nodes[i] = _starpu_mp_common_node_create(STARPU_NODE_MPI_SOURCE, i);
 				_starpu_mpi_ms_nodes[i] = _starpu_mp_common_node_create(STARPU_NODE_MPI_SOURCE, i);
 
 
-			for (i = 0; i < topology->nmpidevices; i++)
+			for (i = 0; i < topology->ndevices[STARPU_MPI_MS_WORKER]; i++)
 				_starpu_init_mpi_config(config, user_conf, i);
 				_starpu_init_mpi_config(config, user_conf, i);
 		}
 		}
 	}
 	}
@@ -1517,12 +1517,12 @@ static void _starpu_deinit_mp_config(struct _starpu_machine_config *config)
 	unsigned i;
 	unsigned i;
 
 
 #ifdef STARPU_USE_MIC
 #ifdef STARPU_USE_MIC
-	for (i = 0; i < topology->nmicdevices; i++)
+	for (i = 0; i < topology->ndevices[STARPU_MIC_WORKER]; i++)
 		_starpu_deinit_mic_node(i);
 		_starpu_deinit_mic_node(i);
 	_starpu_mic_clear_kernels();
 	_starpu_mic_clear_kernels();
 #endif
 #endif
 #ifdef STARPU_USE_MPI_MASTER_SLAVE
 #ifdef STARPU_USE_MPI_MASTER_SLAVE
-	for (i = 0; i < topology->nmpidevices; i++)
+	for (i = 0; i < topology->ndevices[STARPU_MPI_MS_WORKER]; i++)
 		_starpu_deinit_mpi_node(i);
 		_starpu_deinit_mpi_node(i);
 #endif
 #endif
 }
 }
@@ -1632,9 +1632,10 @@ static int _starpu_init_machine_config(struct _starpu_machine_config *config, in
 	}
 	}
 
 
 	/* Now we know how many CUDA devices will be used */
 	/* Now we know how many CUDA devices will be used */
-	topology->ncudagpus = ncuda;
-	topology->nworkerpercuda = nworker_per_cuda;
-	STARPU_ASSERT(topology->ncudagpus <= STARPU_MAXCUDADEVS);
+	topology->ndevices[STARPU_CUDA_WORKER] = ncuda;
+	for (i = 0; i < ncuda; i++)
+		topology->nworker[STARPU_CUDA_WORKER][i] = nworker_per_cuda;
+	STARPU_ASSERT(topology->ndevices[STARPU_CUDA_WORKER] <= STARPU_MAXCUDADEVS);
 
 
 	_starpu_initialize_workers_cuda_gpuid(config);
 	_starpu_initialize_workers_cuda_gpuid(config);
 
 
@@ -1661,11 +1662,11 @@ static int _starpu_init_machine_config(struct _starpu_machine_config *config, in
 	if (!topology->cuda_th_per_dev)
 	if (!topology->cuda_th_per_dev)
 	{
 	{
 		cuda_worker_set[0].workers = &config->workers[topology->nworkers];
 		cuda_worker_set[0].workers = &config->workers[topology->nworkers];
-		cuda_worker_set[0].nworkers = topology->ncudagpus * nworker_per_cuda;
+		cuda_worker_set[0].nworkers = topology->ndevices[STARPU_CUDA_WORKER] * nworker_per_cuda;
 	}
 	}
 
 
 	unsigned cudagpu;
 	unsigned cudagpu;
-	for (cudagpu = 0; cudagpu < topology->ncudagpus; cudagpu++)
+	for (cudagpu = 0; cudagpu < topology->ndevices[STARPU_CUDA_WORKER]; cudagpu++)
 	{
 	{
 		int devid = _starpu_get_next_cuda_gpuid(config);
 		int devid = _starpu_get_next_cuda_gpuid(config);
 		int worker_idx0 = topology->nworkers + cudagpu * nworker_per_cuda;
 		int worker_idx0 = topology->nworkers + cudagpu * nworker_per_cuda;
@@ -1737,7 +1738,7 @@ static int _starpu_init_machine_config(struct _starpu_machine_config *config, in
 #endif
 #endif
         }
         }
 
 
-	topology->nworkers += topology->ncudagpus * nworker_per_cuda;
+	topology->nworkers += topology->ndevices[STARPU_CUDA_WORKER] * nworker_per_cuda;
 #endif
 #endif
 
 
 #if defined(STARPU_USE_OPENCL) || defined(STARPU_SIMGRID)
 #if defined(STARPU_USE_OPENCL) || defined(STARPU_SIMGRID)
@@ -1781,20 +1782,22 @@ static int _starpu_init_machine_config(struct _starpu_machine_config *config, in
 		}
 		}
 	}
 	}
 
 
-	topology->nopenclgpus = nopencl;
-	STARPU_ASSERT(topology->nopenclgpus + topology->nworkers <= STARPU_NMAXWORKERS);
+	topology->ndevices[STARPU_OPENCL_WORKER] = nopencl;
+	for (i = 0; i < nopencl; i++)
+		topology->nworker[STARPU_CUDA_WORKER][i] = 1;
+	STARPU_ASSERT(topology->ndevices[STARPU_OPENCL_WORKER] + topology->nworkers <= STARPU_NMAXWORKERS);
 
 
 	_starpu_initialize_workers_opencl_gpuid(config);
 	_starpu_initialize_workers_opencl_gpuid(config);
 
 
 	unsigned openclgpu;
 	unsigned openclgpu;
-	for (openclgpu = 0; openclgpu < topology->nopenclgpus; openclgpu++)
+	for (openclgpu = 0; openclgpu < topology->ndevices[STARPU_OPENCL_WORKER]; openclgpu++)
 	{
 	{
 		int worker_idx = topology->nworkers + openclgpu;
 		int worker_idx = topology->nworkers + openclgpu;
 		int devid = _starpu_get_next_opencl_gpuid(config);
 		int devid = _starpu_get_next_opencl_gpuid(config);
 		if (devid == -1)
 		if (devid == -1)
 		{
 		{
 			// There is no more devices left
 			// There is no more devices left
-			topology->nopenclgpus = openclgpu;
+			topology->ndevices[STARPU_OPENCL_WORKER] = openclgpu;
 			break;
 			break;
 		}
 		}
 		config->workers[worker_idx].arch = STARPU_OPENCL_WORKER;
 		config->workers[worker_idx].arch = STARPU_OPENCL_WORKER;
@@ -1809,7 +1812,7 @@ static int _starpu_init_machine_config(struct _starpu_machine_config *config, in
 		config->worker_mask |= STARPU_OPENCL;
 		config->worker_mask |= STARPU_OPENCL;
 	}
 	}
 
 
-	topology->nworkers += topology->nopenclgpus;
+	topology->nworkers += topology->ndevices[STARPU_OPENCL_WORKER];
 #endif
 #endif
 
 
 #if defined(STARPU_USE_MIC) || defined(STARPU_USE_MPI_MASTER_SLAVE)
 #if defined(STARPU_USE_MIC) || defined(STARPU_USE_MPI_MASTER_SLAVE)
@@ -1829,13 +1832,13 @@ static int _starpu_init_machine_config(struct _starpu_machine_config *config, in
 			unsigned mic_busy_cpus = 0;
 			unsigned mic_busy_cpus = 0;
 			int j = 0;
 			int j = 0;
 			for (j = 0; j < STARPU_MAXMICDEVS; j++)
 			for (j = 0; j < STARPU_MAXMICDEVS; j++)
-				mic_busy_cpus += (topology->nmiccores[j] ? 1 : 0);
+				mic_busy_cpus += (topology->nworker[STARPU_MIC_WORKER][j] ? 1 : 0);
 
 
 			unsigned mpi_ms_busy_cpus = 0;
 			unsigned mpi_ms_busy_cpus = 0;
 #ifdef STARPU_USE_MPI_MASTER_SLAVE
 #ifdef STARPU_USE_MPI_MASTER_SLAVE
 #ifdef STARPU_MPI_MASTER_SLAVE_MULTIPLE_THREAD
 #ifdef STARPU_MPI_MASTER_SLAVE_MULTIPLE_THREAD
 			for (j = 0; j < STARPU_MAXMPIDEVS; j++)
 			for (j = 0; j < STARPU_MAXMPIDEVS; j++)
-				mpi_ms_busy_cpus += (topology->nmpicores[j] ? 1 : 0);
+				mpi_ms_busy_cpus += (topology->nworker[STARPU_MPI_MS_WORKER][j] ? 1 : 0);
 #else
 #else
 			mpi_ms_busy_cpus = 1; /* we launch one thread to control all slaves */
 			mpi_ms_busy_cpus = 1; /* we launch one thread to control all slaves */
 #endif
 #endif
@@ -1843,14 +1846,14 @@ static int _starpu_init_machine_config(struct _starpu_machine_config *config, in
 			unsigned cuda_busy_cpus = 0;
 			unsigned cuda_busy_cpus = 0;
 #if defined(STARPU_USE_CUDA) || defined(STARPU_SIMGRID)
 #if defined(STARPU_USE_CUDA) || defined(STARPU_SIMGRID)
 			cuda_busy_cpus =
 			cuda_busy_cpus =
-				topology->cuda_th_per_dev == 0 && topology->cuda_th_per_stream == 0 ? (topology->ncudagpus ? 1 : 0) :
-				topology->cuda_th_per_stream ? (nworker_per_cuda * topology->ncudagpus) : topology->ncudagpus;
+				topology->cuda_th_per_dev == 0 && topology->cuda_th_per_stream == 0 ? (topology->ndevices[STARPU_CUDA_WORKER] ? 1 : 0) :
+				topology->cuda_th_per_stream ? (nworker_per_cuda * topology->ndevices[STARPU_CUDA_WORKER]) : topology->ndevices[STARPU_CUDA_WORKER];
 #endif
 #endif
 			unsigned already_busy_cpus = mpi_ms_busy_cpus + mic_busy_cpus
 			unsigned already_busy_cpus = mpi_ms_busy_cpus + mic_busy_cpus
 				+ cuda_busy_cpus
 				+ cuda_busy_cpus
-				+ topology->nopenclgpus;
+				+ topology->ndevices[STARPU_OPENCL_WORKER];
 
 
-			long avail_cpus = (long) topology->nhwcpus - (long) already_busy_cpus;
+			long avail_cpus = (long) topology->nhwdevices[STARPU_CPU_WORKER] - (long) already_busy_cpus;
 			if (avail_cpus < 0)
 			if (avail_cpus < 0)
 				avail_cpus = 0;
 				avail_cpus = 0;
 			int nth_per_core = starpu_get_env_number_default("STARPU_NTHREADS_PER_CORE", 1);
 			int nth_per_core = starpu_get_env_number_default("STARPU_NTHREADS_PER_CORE", 1);
@@ -1880,12 +1883,14 @@ static int _starpu_init_machine_config(struct _starpu_machine_config *config, in
 
 
 	}
 	}
 
 
-	topology->ncpus = ncpu;
-	STARPU_ASSERT(topology->ncpus + topology->nworkers <= STARPU_NMAXWORKERS);
+	topology->ndevices[STARPU_CPU_WORKER] = ncpu;
+	for (i = 0; i < ncpu; i++)
+		topology->nworker[STARPU_CPU_WORKER][i] = 1;
+	STARPU_ASSERT(topology->ndevices[STARPU_CPU_WORKER] + topology->nworkers <= STARPU_NMAXWORKERS);
 
 
 	unsigned cpu;
 	unsigned cpu;
 	unsigned homogeneous = starpu_get_env_number_default("STARPU_PERF_MODEL_HOMOGENEOUS_CPU", 1);
 	unsigned homogeneous = starpu_get_env_number_default("STARPU_PERF_MODEL_HOMOGENEOUS_CPU", 1);
-	for (cpu = 0; cpu < topology->ncpus; cpu++)
+	for (cpu = 0; cpu < topology->ndevices[STARPU_CPU_WORKER]; cpu++)
 	{
 	{
 		int worker_idx = topology->nworkers + cpu;
 		int worker_idx = topology->nworkers + cpu;
 		config->workers[worker_idx].arch = STARPU_CPU_WORKER;
 		config->workers[worker_idx].arch = STARPU_CPU_WORKER;
@@ -1900,7 +1905,7 @@ static int _starpu_init_machine_config(struct _starpu_machine_config *config, in
 		config->worker_mask |= STARPU_CPU;
 		config->worker_mask |= STARPU_CPU;
 	}
 	}
 
 
-	topology->nworkers += topology->ncpus;
+	topology->nworkers += topology->ndevices[STARPU_CPU_WORKER];
 #endif
 #endif
 
 
 	if (topology->nworkers == 0)
 	if (topology->nworkers == 0)
@@ -2033,7 +2038,7 @@ int _starpu_bind_thread_on_cpu(int cpuid STARPU_ATTRIBUTE_UNUSED, int workerid S
 
 
 			if (workerid >= 0)
 			if (workerid >= 0)
 				/* This shouldn't happen for workers */
 				/* This shouldn't happen for workers */
-				_STARPU_DISP("[%s] Maybe check starpu_machine_display's output to determine what wrong binding happened. Hwloc reported %d cores and %d threads, perhaps there is misdetection between hwloc, the kernel and the BIOS, or an administrative allocation issue from e.g. the job scheduler?\n", hostname, config->topology.nhwcpus, config->topology.nhwpus);
+				_STARPU_DISP("[%s] Maybe check starpu_machine_display's output to determine what wrong binding happened. Hwloc reported %d cores and %d threads, perhaps there is misdetection between hwloc, the kernel and the BIOS, or an administrative allocation issue from e.g. the job scheduler?\n", hostname, config->topology.nhwdevices[STARPU_CPU_WORKER], config->topology.nhwpus);
 			ret = -1;
 			ret = -1;
 		}
 		}
 		else
 		else
@@ -2323,7 +2328,7 @@ static void _starpu_init_numa_node(struct _starpu_machine_config *config)
 #endif
 #endif
 
 
 #if defined(STARPU_USE_CUDA) && defined(STARPU_HAVE_HWLOC)
 #if defined(STARPU_USE_CUDA) && defined(STARPU_HAVE_HWLOC)
-		for (i = 0; i < config->topology.ncudagpus; i++)
+		for (i = 0; i < config->topology.ndevices[STARPU_CUDA_WORKER]; i++)
 		{
 		{
 			hwloc_obj_t obj = hwloc_cuda_get_device_osdev_by_index(config->topology.hwtopology, i);
 			hwloc_obj_t obj = hwloc_cuda_get_device_osdev_by_index(config->topology.hwtopology, i);
 			if (obj)
 			if (obj)
@@ -2358,7 +2363,7 @@ static void _starpu_init_numa_node(struct _starpu_machine_config *config)
 		}
 		}
 #endif
 #endif
 #if defined(STARPU_USE_OPENCL) && defined(STARPU_HAVE_HWLOC)
 #if defined(STARPU_USE_OPENCL) && defined(STARPU_HAVE_HWLOC)
-		if (config->topology.nopenclgpus > 0)
+		if (config->topology.ndevices[STARPU_OPENCL_WORKER] > 0)
 		{
 		{
 			cl_int err;
 			cl_int err;
 			cl_platform_id platform_id[_STARPU_OPENCL_PLATFORM_MAX];
 			cl_platform_id platform_id[_STARPU_OPENCL_PLATFORM_MAX];
@@ -3021,7 +3026,7 @@ void starpu_topology_print(FILE *output)
 	unsigned worker;
 	unsigned worker;
 	unsigned nworkers = starpu_worker_get_count();
 	unsigned nworkers = starpu_worker_get_count();
 	unsigned ncombinedworkers = topology->ncombinedworkers;
 	unsigned ncombinedworkers = topology->ncombinedworkers;
-	unsigned nthreads_per_core = topology->nhwpus / topology->nhwcpus;
+	unsigned nthreads_per_core = topology->nhwpus / topology->nhwdevices[STARPU_CPU_WORKER];
 
 
 #ifdef STARPU_HAVE_HWLOC
 #ifdef STARPU_HAVE_HWLOC
 	hwloc_topology_t topo = topology->hwtopology;
 	hwloc_topology_t topo = topology->hwtopology;
@@ -3110,5 +3115,5 @@ unsigned _starpu_get_nhyperthreads()
 {
 {
 	struct _starpu_machine_config *config = _starpu_get_machine_config();
 	struct _starpu_machine_config *config = _starpu_get_machine_config();
 
 
-	return config->topology.nhwpus / config->topology.nhwcpus;
+	return config->topology.nhwpus / config->topology.nhwdevices[STARPU_CPU_WORKER];
 }
 }

+ 21 - 35
src/core/workers.c

@@ -1006,7 +1006,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
 	}
 	}
 
 
 #if defined(STARPU_USE_MPI_MASTER_SLAVE) && !defined(STARPU_MPI_MASTER_SLAVE_MULTIPLE_THREAD)
 #if defined(STARPU_USE_MPI_MASTER_SLAVE) && !defined(STARPU_MPI_MASTER_SLAVE_MULTIPLE_THREAD)
-        if (pconfig->topology.nmpidevices > 0)
+        if (pconfig->topology.ndevices[STARPU_MPI_MS_WORKER] > 0)
         {
         {
                 struct _starpu_worker_set * worker_set_zero = &mpi_worker_set[0];
                 struct _starpu_worker_set * worker_set_zero = &mpi_worker_set[0];
                 struct _starpu_worker * worker_zero = &worker_set_zero->workers[0];
                 struct _starpu_worker * worker_zero = &worker_set_zero->workers[0];
@@ -2106,32 +2106,22 @@ unsigned starpu_worker_is_slave_somewhere(int workerid)
 
 
 int starpu_worker_get_count_by_type(enum starpu_worker_archtype type)
 int starpu_worker_get_count_by_type(enum starpu_worker_archtype type)
 {
 {
-	switch (type)
-	{
-		case STARPU_CPU_WORKER:
-			return _starpu_config.topology.ncpus;
-
-		case STARPU_CUDA_WORKER:
-			return _starpu_config.topology.ncudagpus * _starpu_config.topology.nworkerpercuda;
-
-		case STARPU_OPENCL_WORKER:
-			return _starpu_config.topology.nopenclgpus;
-
-		case STARPU_MIC_WORKER:
-			return _starpu_config.topology.nmicdevices;
-
-                case STARPU_MPI_MS_WORKER:
-                        return _starpu_config.topology.nmpidevices;
+	unsigned n = 0;
 
 
-                case STARPU_ANY_WORKER:
-                        return _starpu_config.topology.ncpus+
-				_starpu_config.topology.ncudagpus * _starpu_config.topology.nworkerpercuda+
-                                _starpu_config.topology.nopenclgpus+
-                                _starpu_config.topology.nmicdevices+
-                                _starpu_config.topology.nmpidevices;
-		default:
+	if (type != STARPU_ANY_WORKER)
+	{
+		if (type >= STARPU_NARCH)
 			return -EINVAL;
 			return -EINVAL;
+
+		unsigned i;
+		for (i = 0; i < _starpu_config.topology.ndevices[type]; i++)
+			n += _starpu_config.topology.nworker[type][i];
+		return n;
 	}
 	}
+
+	for (type = 0; type < STARPU_NARCH; type++)
+		n += starpu_worker_get_count_by_type(type);
+	return n;
 }
 }
 
 
 unsigned starpu_combined_worker_get_count(void)
 unsigned starpu_combined_worker_get_count(void)
@@ -2141,17 +2131,17 @@ unsigned starpu_combined_worker_get_count(void)
 
 
 unsigned starpu_cpu_worker_get_count(void)
 unsigned starpu_cpu_worker_get_count(void)
 {
 {
-	return _starpu_config.topology.ncpus;
+	return starpu_worker_get_count_by_type(STARPU_CPU_WORKER);
 }
 }
 
 
 unsigned starpu_cuda_worker_get_count(void)
 unsigned starpu_cuda_worker_get_count(void)
 {
 {
-	return _starpu_config.topology.ncudagpus * _starpu_config.topology.nworkerpercuda;
+	return starpu_worker_get_count_by_type(STARPU_CUDA_WORKER);
 }
 }
 
 
 unsigned starpu_opencl_worker_get_count(void)
 unsigned starpu_opencl_worker_get_count(void)
 {
 {
-	return _starpu_config.topology.nopenclgpus;
+	return starpu_worker_get_count_by_type(STARPU_OPENCL_WORKER);
 }
 }
 
 
 int starpu_asynchronous_copy_disabled(void)
 int starpu_asynchronous_copy_disabled(void)
@@ -2181,17 +2171,12 @@ int starpu_asynchronous_mpi_ms_copy_disabled(void)
 
 
 unsigned starpu_mic_worker_get_count(void)
 unsigned starpu_mic_worker_get_count(void)
 {
 {
-	int i = 0, count = 0;
-
-	for (i = 0; i < STARPU_MAXMICDEVS; i++)
-		count += _starpu_config.topology.nmiccores[i];
-
-	return count;
+	return starpu_worker_get_count_by_type(STARPU_MIC_WORKER);
 }
 }
 
 
 unsigned starpu_mpi_ms_worker_get_count(void)
 unsigned starpu_mpi_ms_worker_get_count(void)
 {
 {
-        return _starpu_config.topology.nmpidevices;
+	return starpu_worker_get_count_by_type(STARPU_MPI_MS_WORKER);
 }
 }
 
 
 /* When analyzing performance, it is useful to see what is the processing unit
 /* When analyzing performance, it is useful to see what is the processing unit
@@ -2607,7 +2592,8 @@ const char *starpu_worker_get_type_as_string(enum starpu_worker_archtype type)
 const char *starpu_worker_get_type_as_env_var(enum starpu_worker_archtype type)
 const char *starpu_worker_get_type_as_env_var(enum starpu_worker_archtype type)
 {
 {
 	const char *ret = starpu_driver_info[type].name_var;
 	const char *ret = starpu_driver_info[type].name_var;
-	STARPU_ASSERT(ret);
+	if (!ret)
+		ret = "UNKNOWN";
 	return ret;
 	return ret;
 }
 }
 
 

+ 11 - 39
src/core/workers.h

@@ -269,58 +269,30 @@ struct _starpu_machine_topology
 	/** custom hwloc tree*/
 	/** custom hwloc tree*/
 	struct starpu_tree *tree;
 	struct starpu_tree *tree;
 
 
-	/** Total number of CPU cores, as detected by the topology code. May
-	 * be different from the actual number of CPU workers.
-	 */
-	unsigned nhwcpus;
-
 	/** Total number of PUs (i.e. threads), as detected by the topology code. May
 	/** Total number of PUs (i.e. threads), as detected by the topology code. May
-	 * be different from the actual number of PU workers.
+	 * be different from the actual number of CPU workers.
 	 */
 	 */
 	unsigned nhwpus;
 	unsigned nhwpus;
 
 
-	/** Total number of CUDA devices, as detected. May be different
-	 * from the actual number of CUDA workers.
+	/** Total number of devices, as detected. May be different from the
+	 * actual number of workers run by StarPU.
 	 */
 	 */
-	unsigned nhwcudagpus;
+	unsigned nhwdevices[STARPU_NARCH];
+	unsigned nhwworker[STARPU_NARCH][STARPU_NMAXDEVS];
 
 
-	/** Total number of OpenCL devices, as detected. May be
-	 * different from the actual number of OpenCL workers.
+	/** Actual number of devices used by StarPU.
 	 */
 	 */
-	unsigned nhwopenclgpus;
+	unsigned ndevices[STARPU_NARCH];
 
 
-	/** Total number of MPI nodes, as detected. May be different
-	 * from the actual number of node workers.
+	/** Number of worker per device
 	 */
 	 */
-	unsigned nhwmpi;
-
-	/** Actual number of CPU workers used by StarPU. */
-	unsigned ncpus;
+	unsigned nworker[STARPU_NARCH][STARPU_NMAXDEVS];
 
 
-	/** Actual number of CUDA GPUs used by StarPU. */
-	unsigned ncudagpus;
-	unsigned nworkerpercuda;
+	/** Whether we should have one thread per stream */
 	int cuda_th_per_stream;
 	int cuda_th_per_stream;
+	/** Whether we should have one thread per device */
 	int cuda_th_per_dev;
 	int cuda_th_per_dev;
 
 
-	/** Actual number of OpenCL workers used by StarPU. */
-	unsigned nopenclgpus;
-
-	/** Actual number of MPI workers used by StarPU. */
-	unsigned nmpidevices;
-        unsigned nhwmpidevices;
-
-	unsigned nhwmpicores[STARPU_MAXMPIDEVS]; /**< Each MPI node has its set of cores. */
-	unsigned nmpicores[STARPU_MAXMPIDEVS];
-
-	/** Topology of MP nodes (MIC) as well as necessary
-	 * objects to communicate with them. */
-	unsigned nhwmicdevices;
-	unsigned nmicdevices;
-
-	unsigned nhwmiccores[STARPU_MAXMICDEVS]; /**< Each MIC node has its set of cores. */
-	unsigned nmiccores[STARPU_MAXMICDEVS];
-
 	/** Indicates the successive logical PU identifier that should be used
 	/** Indicates the successive logical PU identifier that should be used
 	 * to bind the workers. It is either filled according to the
 	 * to bind the workers. It is either filled according to the
 	 * user's explicit parameters (from starpu_conf) or according
 	 * user's explicit parameters (from starpu_conf) or according

+ 4 - 4
src/drivers/cuda/driver_cuda.c

@@ -110,7 +110,7 @@ _starpu_cuda_discover_devices (struct _starpu_machine_config *config)
 	/* Discover the number of CUDA devices. Fill the result in CONFIG. */
 	/* Discover the number of CUDA devices. Fill the result in CONFIG. */
 
 
 #ifdef STARPU_SIMGRID
 #ifdef STARPU_SIMGRID
-	config->topology.nhwcudagpus = _starpu_simgrid_get_nbhosts("CUDA");
+	config->topology.nhwdevices[STARPU_CUDA_WORKER] = _starpu_simgrid_get_nbhosts("CUDA");
 #else
 #else
 	int cnt;
 	int cnt;
 	cudaError_t cures;
 	cudaError_t cures;
@@ -118,7 +118,7 @@ _starpu_cuda_discover_devices (struct _starpu_machine_config *config)
 	cures = cudaGetDeviceCount (&cnt);
 	cures = cudaGetDeviceCount (&cnt);
 	if (STARPU_UNLIKELY(cures != cudaSuccess))
 	if (STARPU_UNLIKELY(cures != cudaSuccess))
 		cnt = 0;
 		cnt = 0;
-	config->topology.nhwcudagpus = cnt;
+	config->topology.nhwdevices[STARPU_CUDA_WORKER] = cnt;
 #ifdef HAVE_LIBNVIDIA_ML
 #ifdef HAVE_LIBNVIDIA_ML
 	nvmlInit();
 	nvmlInit();
 #endif
 #endif
@@ -710,7 +710,7 @@ int _starpu_cuda_driver_init(struct _starpu_worker_set *worker_set)
 		init_device_context(devid, memnode);
 		init_device_context(devid, memnode);
 
 
 #ifndef STARPU_SIMGRID
 #ifndef STARPU_SIMGRID
-		if (worker->config->topology.nworkerpercuda > 1 && props[devid].concurrentKernels == 0)
+		if (worker->config->topology.nworker[STARPU_CUDA_WORKER][devid] > 1 && props[devid].concurrentKernels == 0)
 			_STARPU_DISP("Warning: STARPU_NWORKER_PER_CUDA is %u, but CUDA device %u does not support concurrent kernel execution!\n", worker_set->nworkers, devid);
 			_STARPU_DISP("Warning: STARPU_NWORKER_PER_CUDA is %u, but CUDA device %u does not support concurrent kernel execution!\n", worker_set->nworkers, devid);
 #endif /* !STARPU_SIMGRID */
 #endif /* !STARPU_SIMGRID */
 	}
 	}
@@ -723,7 +723,7 @@ int _starpu_cuda_driver_init(struct _starpu_worker_set *worker_set)
 		struct _starpu_worker *worker = &worker_set->workers[i];
 		struct _starpu_worker *worker = &worker_set->workers[i];
 		unsigned devid = worker->devid;
 		unsigned devid = worker->devid;
 		unsigned workerid = worker->workerid;
 		unsigned workerid = worker->workerid;
-		unsigned subdev = i % _starpu_get_machine_config()->topology.nworkerpercuda;
+		unsigned subdev = i % _starpu_get_machine_config()->topology.nworker[STARPU_CUDA_WORKER][devid];
 
 
 		float size = (float) global_mem[devid] / (1<<30);
 		float size = (float) global_mem[devid] / (1<<30);
 #ifdef STARPU_SIMGRID
 #ifdef STARPU_SIMGRID

+ 3 - 1
src/drivers/cuda/starpu_cublas.c

@@ -100,9 +100,11 @@ void starpu_cublas_shutdown(void)
 void starpu_cublas_set_stream(void)
 void starpu_cublas_set_stream(void)
 {
 {
 #ifdef STARPU_USE_CUDA
 #ifdef STARPU_USE_CUDA
+	unsigned workerid = starpu_worker_get_id_check();
+	int devid = starpu_worker_get_devid(workerid);
 	if (!_starpu_get_machine_config()->topology.cuda_th_per_dev ||
 	if (!_starpu_get_machine_config()->topology.cuda_th_per_dev ||
 		(!_starpu_get_machine_config()->topology.cuda_th_per_stream &&
 		(!_starpu_get_machine_config()->topology.cuda_th_per_stream &&
-		 _starpu_get_machine_config()->topology.nworkerpercuda > 1))
+		 _starpu_get_machine_config()->topology.nworker[STARPU_CUDA_WORKER][devid] > 1))
 		cublasSetKernelStream(starpu_cuda_get_local_stream());
 		cublasSetKernelStream(starpu_cuda_get_local_stream());
 #endif
 #endif
 }
 }

+ 2 - 2
src/drivers/mic/driver_mic_source.c

@@ -241,7 +241,7 @@ unsigned starpu_mic_device_get_count(void)
     struct _starpu_machine_config *config = _starpu_get_machine_config ();
     struct _starpu_machine_config *config = _starpu_get_machine_config ();
     struct _starpu_machine_topology *topology = &config->topology;
     struct _starpu_machine_topology *topology = &config->topology;
 
 
-    return topology->nmicdevices;
+    return topology->ndevices[STARPU_MIC_WORKER];
 }
 }
 
 
 starpu_mic_kernel_t _starpu_mic_src_get_kernel_from_codelet(struct starpu_codelet *cl, unsigned nimpl)
 starpu_mic_kernel_t _starpu_mic_src_get_kernel_from_codelet(struct starpu_codelet *cl, unsigned nimpl)
@@ -530,7 +530,7 @@ void *_starpu_mic_src_worker(void *arg)
 	// Current task for a thread managing a worker set has no sense.
 	// Current task for a thread managing a worker set has no sense.
 	_starpu_set_current_task(NULL);
 	_starpu_set_current_task(NULL);
 
 
-	for (i = 0; i < config->topology.nmiccores[devid]; i++)
+	for (i = 0; i < config->topology.nworker[STARPU_MIC_WORKER][devid]; i++)
 	{
 	{
 		struct _starpu_worker *worker = &config->workers[baseworkerid+i];
 		struct _starpu_worker *worker = &config->workers[baseworkerid+i];
 		snprintf(worker->name, sizeof(worker->name), "MIC %u core %u", devid, i);
 		snprintf(worker->name, sizeof(worker->name), "MIC %u core %u", devid, i);

+ 1 - 1
src/drivers/mpi/driver_mpi_common.c

@@ -127,7 +127,7 @@ void _starpu_mpi_common_mp_initialize_src_sink(struct _starpu_mp_node *node)
 {
 {
         struct _starpu_machine_topology *topology = &_starpu_get_machine_config()->topology;
         struct _starpu_machine_topology *topology = &_starpu_get_machine_config()->topology;
 
 
-        node->nb_cores = topology->nhwcpus;
+        node->nb_cores = topology->nhwdevices[STARPU_CPU_WORKER];
 }
 }
 
 
 int _starpu_mpi_common_recv_is_ready(const struct _starpu_mp_node *mp_node)
 int _starpu_mpi_common_recv_is_ready(const struct _starpu_mp_node *mp_node)

+ 1 - 1
src/drivers/mpi/driver_mpi_source.c

@@ -320,7 +320,7 @@ void *_starpu_mpi_src_worker(void *arg)
                 // Current task for a thread managing a worker set has no sense.
                 // Current task for a thread managing a worker set has no sense.
                 _starpu_set_current_task(NULL);
                 _starpu_set_current_task(NULL);
 
 
-                for (i = 0; i < config->topology.nmpicores[devid]; i++)
+                for (i = 0; i < config->topology.nworker[STARPU_MPI_MS_WORKER][devid]; i++)
                 {
                 {
                         struct _starpu_worker *worker = &config->workers[baseworkerid+i];
                         struct _starpu_worker *worker = &config->workers[baseworkerid+i];
                         snprintf(worker->name, sizeof(worker->name), "MPI_MS %u core %u", devid, i);
                         snprintf(worker->name, sizeof(worker->name), "MPI_MS %u core %u", devid, i);

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

@@ -71,7 +71,7 @@ _starpu_opencl_discover_devices(struct _starpu_machine_config *config)
 	/* As OpenCL must have been initialized before calling this function,
 	/* As OpenCL must have been initialized before calling this function,
 	 * `nb_device' is ensured to be correctly set. */
 	 * `nb_device' is ensured to be correctly set. */
 	STARPU_ASSERT(init_done == 1);
 	STARPU_ASSERT(init_done == 1);
-	config->topology.nhwopenclgpus = nb_devices;
+	config->topology.nhwdevices[STARPU_OPENCL_WORKER] = nb_devices;
 }
 }
 
 
 static void _starpu_opencl_limit_gpu_mem_if_needed(unsigned devid)
 static void _starpu_opencl_limit_gpu_mem_if_needed(unsigned devid)

+ 8 - 5
src/profiling/bound.c

@@ -231,11 +231,14 @@ static double** initialize_arch_duration(int maxdevid, unsigned* maxncore_table)
 static void initialize_duration(struct bound_task *task)
 static void initialize_duration(struct bound_task *task)
 {
 {
 	struct _starpu_machine_config *conf = _starpu_get_machine_config();
 	struct _starpu_machine_config *conf = _starpu_get_machine_config();
-	task->duration[STARPU_CPU_WORKER] = initialize_arch_duration(1,&conf->topology.nhwcpus);
-	task->duration[STARPU_CUDA_WORKER] = initialize_arch_duration(conf->topology.nhwcudagpus,NULL);
-	task->duration[STARPU_OPENCL_WORKER] = initialize_arch_duration(conf->topology.nhwopenclgpus,NULL);
-	task->duration[STARPU_MIC_WORKER] = initialize_arch_duration(conf->topology.nhwmicdevices,conf->topology.nmiccores);
-	task->duration[STARPU_MPI_MS_WORKER] = initialize_arch_duration(conf->topology.nhwmpidevices,conf->topology.nmpicores);
+	enum starpu_worker_archtype type;
+	for (type = 0; type < STARPU_NARCH; type++)
+	{
+		if (type == STARPU_CPU_WORKER)
+			task->duration[type] = initialize_arch_duration(1,&conf->topology.nhwdevices[type]);
+		else
+			task->duration[type] = initialize_arch_duration(conf->topology.nhwdevices[type], conf->topology.nworker[type]);
+	}
 }
 }
 
 
 static struct starpu_perfmodel_device device =
 static struct starpu_perfmodel_device device =

+ 1 - 1
src/profiling/profiling.c

@@ -577,7 +577,7 @@ int starpu_bus_get_ngpus(int busid)
 	int ngpus = bus_ngpus[busid];
 	int ngpus = bus_ngpus[busid];
 	if (!ngpus)
 	if (!ngpus)
 		/* Unknown number of GPUs, assume it's shared by all GPUs */
 		/* Unknown number of GPUs, assume it's shared by all GPUs */
-		ngpus = topology->ncudagpus+topology->nopenclgpus;
+		ngpus = topology->ndevices[STARPU_CUDA_WORKER]+topology->ndevices[STARPU_OPENCL_WORKER];
 	return ngpus;
 	return ngpus;
 }
 }
 
 

+ 1 - 1
src/util/openmp_runtime_support_omp_api.c

@@ -65,7 +65,7 @@ int starpu_omp_get_max_threads()
 
 
 int starpu_omp_get_num_procs (void)
 int starpu_omp_get_num_procs (void)
 {
 {
-	/* starpu_cpu_worker_get_count defined as topology.ncpus */
+	/* starpu_cpu_worker_get_count defined as topology.ndevices[STARPU_CPU_WORKER] */
 	return starpu_cpu_worker_get_count();
 	return starpu_cpu_worker_get_count();
 }
 }