Selaa lähdekoodia

Store the identifier of the device associated to a memory node (when
applicable).

Cédric Augonnet 14 vuotta sitten
vanhempi
commit
44990565b1
3 muutettua tiedostoa jossa 16 lisäystä ja 5 poistoa
  1. 3 3
      src/core/topology.c
  2. 8 1
      src/datawizard/memory_nodes.c
  3. 5 1
      src/datawizard/memory_nodes.h

+ 3 - 3
src/core/topology.c

@@ -645,7 +645,7 @@ static void _starpu_init_workers_binding(struct starpu_machine_config_s *config)
 
 	/* note that even if the CPU cpu are not used, we always have a RAM node */
 	/* TODO : support NUMA  ;) */
-	ram_memory_node = _starpu_register_memory_node(STARPU_CPU_RAM);
+	ram_memory_node = _starpu_register_memory_node(STARPU_CPU_RAM, -1);
 
 	/* We will store all the busid of the different (src, dst) combinations
 	 * in a matrix which we initialize here. */
@@ -684,7 +684,7 @@ static void _starpu_init_workers_binding(struct starpu_machine_config_s *config)
 					npreferred = config->topology.nhwcpus;
 				}
 				is_a_set_of_accelerators = 0;
-				memory_node = _starpu_register_memory_node(STARPU_CUDA_RAM);
+				memory_node = _starpu_register_memory_node(STARPU_CUDA_RAM, workerarg->devid);
 
 				_starpu_register_bus(0, memory_node);
 				_starpu_register_bus(memory_node, 0);
@@ -700,7 +700,7 @@ static void _starpu_init_workers_binding(struct starpu_machine_config_s *config)
 					npreferred = config->topology.nhwcpus;
 				}
 				is_a_set_of_accelerators = 0;
-				memory_node = _starpu_register_memory_node(STARPU_OPENCL_RAM);
+				memory_node = _starpu_register_memory_node(STARPU_OPENCL_RAM, workerarg->devid);
 				_starpu_register_bus(0, memory_node);
 				_starpu_register_bus(memory_node, 0);
 				break;

+ 8 - 1
src/datawizard/memory_nodes.c

@@ -81,12 +81,17 @@ inline starpu_node_kind _starpu_get_node_kind(uint32_t node)
 	return descr.nodes[node];
 }
 
+int starpu_memory_node_to_devid(unsigned node)
+{
+	return descr.devid[node];
+}
+
 unsigned _starpu_get_memory_nodes_count(void)
 {
 	return descr.nnodes;
 }
 
-unsigned _starpu_register_memory_node(starpu_node_kind kind)
+unsigned _starpu_register_memory_node(starpu_node_kind kind, int devid)
 {
 	unsigned nnodes;
 	/* ATOMIC_ADD returns the new value ... */
@@ -95,6 +100,8 @@ unsigned _starpu_register_memory_node(starpu_node_kind kind)
 	descr.nodes[nnodes-1] = kind;
 	STARPU_TRACE_NEW_MEM_NODE(nnodes-1);
 
+	descr.devid[nnodes-1] = devid;
+
 	/* for now, there is no condition associated to that newly created node */
 	descr.condition_count[nnodes-1] = 0;
 

+ 5 - 1
src/datawizard/memory_nodes.h

@@ -46,6 +46,9 @@ typedef struct {
 	unsigned nnodes;
 	starpu_node_kind nodes[STARPU_MAXNODES];
 
+	/* Get the device id associated to this node, or -1 if not applicable */
+	int devid[STARPU_MAXNODES];
+
 	// TODO move this 2 lists outside starpu_mem_node_descr
 	/* Every worker is associated to a condition variable on which the
 	 * worker waits when there is task available. It is possible that
@@ -65,11 +68,12 @@ void _starpu_init_memory_nodes(void);
 void _starpu_deinit_memory_nodes(void);
 void _starpu_set_local_memory_node_key(unsigned *node);
 unsigned _starpu_get_local_memory_node(void);
-unsigned _starpu_register_memory_node(starpu_node_kind kind);
+unsigned _starpu_register_memory_node(starpu_node_kind kind, int devid);
 //void _starpu_memory_node_attach_queue(struct starpu_jobq_s *q, unsigned nodeid);
 void _starpu_memory_node_register_condition(pthread_cond_t *cond, pthread_mutex_t *mutex, unsigned memory_node);
 
 starpu_node_kind _starpu_get_node_kind(uint32_t node);
+int starpu_memory_node_to_devid(unsigned node);
 unsigned _starpu_get_memory_nodes_count(void);
 
 starpu_mem_node_descr *_starpu_get_memory_node_description(void);