瀏覽代碼

get rid of the useless allocate_per_node_buffer function

Cédric Augonnet 16 年之前
父節點
當前提交
326d62a34f
共有 4 個文件被更改,包括 6 次插入21 次删除
  1. 1 1
      src/datawizard/coherency.c
  2. 1 18
      src/datawizard/copy-driver.c
  3. 0 2
      src/datawizard/copy-driver.h
  4. 4 0
      src/datawizard/memalloc.c

+ 1 - 1
src/datawizard/coherency.c

@@ -328,7 +328,7 @@ int request_data_allocation(data_state *state, uint32_t node)
 	starpu_spin_lock(&state->header_lock);
 
 	int ret;
-	ret = allocate_per_node_buffer(state, node);
+	ret = allocate_memory_on_node(state, node);
 	STARPU_ASSERT(ret == 0);
 
 	/* XXX quick and dirty hack */

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

@@ -67,23 +67,6 @@ void wake_all_blocked_workers(void)
 	}
 }
 
-int allocate_per_node_buffer(data_state *state, uint32_t node)
-{
-	int ret;
-
-	if (!state->per_node[node].allocated) {
-		/* there is no room available for the data yet */
-		ret = allocate_memory_on_node(state, node);
-		if (STARPU_UNLIKELY(ret == -ENOMEM))
-			goto nomem;
-	}
-
-	return 0;
-nomem:
-	/* there was not enough memory to allocate the buffer */
-	return -ENOMEM;
-}
-
 #ifdef USE_FXT
 /* we need to identify each communication so that we can match the beginning
  * and the end of a communication in the trace, so we use a unique identifier
@@ -180,7 +163,7 @@ int __attribute__((warn_unused_result)) driver_copy_data_1_to_1(data_state *stat
 	unsigned __attribute__((unused)) com_id = 0;
 
 	/* first make sure the destination has an allocated buffer */
-	ret_alloc = allocate_per_node_buffer(state, dst_node);
+	ret_alloc = allocate_memory_on_node(state, dst_node);
 	if (ret_alloc)
 		goto nomem;
 

+ 0 - 2
src/datawizard/copy-driver.h

@@ -52,6 +52,4 @@ __attribute__((warn_unused_result))
 int driver_copy_data_1_to_1(struct starpu_data_state_t *state, uint32_t node, 
 				uint32_t requesting_node, unsigned donotread);
 
-int allocate_per_node_buffer(struct starpu_data_state_t *state, uint32_t node);
-
 #endif // __COPY_DRIVER_H__

+ 4 - 0
src/datawizard/memalloc.c

@@ -495,6 +495,10 @@ int allocate_memory_on_node(data_state *state, uint32_t dst_node)
 
 	STARPU_ASSERT(state);
 
+	/* A buffer is already allocated on the node */
+	if (state->per_node[dst_node].allocated) 
+		return 0;
+
 	data_allocation_inc_stats(dst_node);
 
 #ifdef USE_ALLOCATION_CACHE