Kaynağa Gözat

Add a get_memory_nodes_count function which returns the number of memory nodes:
this permits to avoid updating the status of a piece of data on unused memory
nodes.

Cédric Augonnet 15 yıl önce
ebeveyn
işleme
15fa9b57cd

+ 9 - 4
src/datawizard/coherency.c

@@ -48,10 +48,13 @@ uint32_t select_src_node(starpu_data_handle handle)
 	unsigned src_node = 0;
 	unsigned i;
 
+	unsigned nnodes = get_memory_nodes_count();
+
 	/* first find a valid copy, either a OWNER or a SHARED */
 	uint32_t node;
+
 	uint32_t src_node_mask = 0;
-	for (node = 0; node < MAXNODES; node++)
+	for (node = 0; node < nnodes; node++)
 	{
 		if (handle->per_node[node].state != INVALID) {
 			/* we found a copy ! */
@@ -63,7 +66,7 @@ uint32_t select_src_node(starpu_data_handle handle)
 	STARPU_ASSERT(src_node_mask != 0);
 
 	/* find the node that will be the actual source */
-	for (i = 0; i < MAXNODES; i++)
+	for (i = 0; i < nnodes; i++)
 	{
 		if (src_node_mask & (1<<i))
 		{
@@ -86,13 +89,15 @@ uint32_t select_src_node(starpu_data_handle handle)
 /* this may be called once the data is fetched with header and STARPU_RW-lock hold */
 void update_data_state(starpu_data_handle handle, uint32_t requesting_node, uint8_t write)
 {
+	unsigned nnodes = get_memory_nodes_count();
+
 	/* the data is present now */
 	handle->per_node[requesting_node].requested = 0;
 
 	if (write) {
 		/* the requesting node now has the only valid copy */
 		uint32_t node;
-		for (node = 0; node < MAXNODES; node++)
+		for (node = 0; node < nnodes; node++)
 			handle->per_node[node].state = INVALID;
 
 		handle->per_node[requesting_node].state = OWNER;
@@ -102,7 +107,7 @@ void update_data_state(starpu_data_handle handle, uint32_t requesting_node, uint
 		{
 			/* there was at least another copy of the data */
 			uint32_t node;
-			for (node = 0; node < MAXNODES; node++)
+			for (node = 0; node < nnodes; node++)
 			{
 				if (handle->per_node[node].state != INVALID)
 					handle->per_node[node].state = SHARED;

+ 1 - 2
src/datawizard/copy-driver.c

@@ -52,7 +52,6 @@ void wake_all_blocked_workers(void)
 	struct sched_policy_s *sched = get_sched_policy();
 	pthread_cond_t *sched_cond = &sched->sched_activity_cond;
 	pthread_mutex_t *sched_mutex = &sched->sched_activity_mutex;
-	mem_node_descr * const descr = get_memory_node_description();
 
 	pthread_mutex_lock(sched_mutex);
 	pthread_cond_broadcast(sched_cond);
@@ -60,7 +59,7 @@ void wake_all_blocked_workers(void)
 
 	/* workers may be blocked on the various queues' conditions */
 	unsigned node;
-	unsigned nnodes =  descr->nnodes;
+	unsigned nnodes = get_memory_nodes_count();
 	for (node = 0; node < nnodes; node++)
 	{
 		wake_all_blocked_workers_on_node(node);

+ 4 - 0
src/datawizard/memory_nodes.c

@@ -79,6 +79,10 @@ inline node_kind get_node_kind(uint32_t node)
 	return descr.nodes[node];
 }
 
+unsigned get_memory_nodes_count(void)
+{
+	return descr.nnodes;
+}
 
 unsigned register_memory_node(node_kind kind)
 {

+ 1 - 0
src/datawizard/memory_nodes.h

@@ -54,6 +54,7 @@ unsigned register_memory_node(node_kind kind);
 void memory_node_attach_queue(struct jobq_s *q, unsigned nodeid);
 
 node_kind get_node_kind(uint32_t node);
+unsigned get_memory_nodes_count(void);
 
 inline mem_node_descr *get_memory_node_description(void);