瀏覽代碼

Don't try to allocate a piece of data that is already allocated.

Cédric Augonnet 14 年之前
父節點
當前提交
f57828e9d1
共有 3 個文件被更改,包括 8 次插入8 次删除
  1. 6 3
      src/datawizard/copy_driver.c
  2. 1 4
      src/datawizard/memalloc.c
  3. 1 1
      src/datawizard/memalloc.h

+ 6 - 3
src/datawizard/copy_driver.c

@@ -220,9 +220,12 @@ int __attribute__((warn_unused_result)) _starpu_driver_copy_data_1_to_1(starpu_d
 	unsigned dst_node = dst_replicate->memory_node;
 
 	/* first make sure the destination has an allocated buffer */
-	ret_alloc = _starpu_allocate_memory_on_node(handle, dst_node, may_alloc);
-	if (ret_alloc)
-		goto nomem;
+	if (!handle->per_node[dst_node].allocated)
+	{
+		ret_alloc = _starpu_allocate_memory_on_node(handle, dst_node);
+		if (ret_alloc)
+			goto nomem;
+	}
 
 	STARPU_ASSERT(dst_replicate->allocated);
 	STARPU_ASSERT(dst_replicate->refcnt);

+ 1 - 4
src/datawizard/memalloc.c

@@ -704,7 +704,7 @@ ssize_t _starpu_allocate_interface(starpu_data_handle handle, void *interface, u
 	return allocated_memory;
 }
 
-int _starpu_allocate_memory_on_node(starpu_data_handle handle, uint32_t dst_node, unsigned may_alloc)
+int _starpu_allocate_memory_on_node(starpu_data_handle handle, uint32_t dst_node)
 {
 	ssize_t allocated_memory;
 
@@ -714,9 +714,6 @@ int _starpu_allocate_memory_on_node(starpu_data_handle handle, uint32_t dst_node
 	if (handle->per_node[dst_node].allocated)
 		return 0;
 
-	if (!may_alloc)
-		return -ENOMEM;
-
 	void *interface = starpu_data_get_interface_on_node(handle, dst_node);
 	allocated_memory = _starpu_allocate_interface(handle, interface, dst_node);
 

+ 1 - 1
src/datawizard/memalloc.h

@@ -47,7 +47,7 @@ void _starpu_init_mem_chunk_lists(void);
 void _starpu_deinit_mem_chunk_lists(void);
 void _starpu_request_mem_chunk_removal(starpu_data_handle handle, unsigned node);
 ssize_t _starpu_allocate_interface(starpu_data_handle handle, void *interface, uint32_t dst_node);
-int _starpu_allocate_memory_on_node(starpu_data_handle handle, uint32_t dst_node, unsigned may_alloc);
+int _starpu_allocate_memory_on_node(starpu_data_handle handle, uint32_t dst_node);
 size_t _starpu_free_all_automatically_allocated_buffers(uint32_t node);
 
 /* Memory chunk cache */