Browse Source

_starpu_allocate_memory_on_node now manipulates a data replicate rather than a
simple (handle,node).

Cédric Augonnet 14 years ago
parent
commit
fc5da2fa67
3 changed files with 12 additions and 9 deletions
  1. 2 2
      src/datawizard/copy_driver.c
  2. 7 6
      src/datawizard/memalloc.c
  3. 3 1
      src/datawizard/memalloc.h

+ 2 - 2
src/datawizard/copy_driver.c

@@ -220,9 +220,9 @@ 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 */
-	if (!handle->per_node[dst_node].allocated)
+	if (!dst_replicate->allocated)
 	{
-		ret_alloc = _starpu_allocate_memory_on_node(handle, dst_node);
+		ret_alloc = _starpu_allocate_memory_on_node(handle, dst_replicate);
 		if (ret_alloc)
 			goto nomem;
 	}

+ 7 - 6
src/datawizard/memalloc.c

@@ -704,18 +704,19 @@ 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)
+int _starpu_allocate_memory_on_node(starpu_data_handle handle, struct starpu_data_replicate_s *replicate)
 {
 	ssize_t allocated_memory;
 
+	unsigned dst_node = replicate->memory_node;
+
 	STARPU_ASSERT(handle);
 
 	/* A buffer is already allocated on the node */
-	if (handle->per_node[dst_node].allocated)
+	if (replicate->allocated)
 		return 0;
 
-	void *interface = starpu_data_get_interface_on_node(handle, dst_node);
-	allocated_memory = _starpu_allocate_interface(handle, interface, dst_node);
+	allocated_memory = _starpu_allocate_interface(handle, replicate->interface, dst_node);
 
 	/* perhaps we could really not handle that capacity misses */
 	if (allocated_memory == -ENOMEM)
@@ -723,8 +724,8 @@ int _starpu_allocate_memory_on_node(starpu_data_handle handle, uint32_t dst_node
 
 	register_mem_chunk(handle, dst_node, allocated_memory, 1);
 
-	handle->per_node[dst_node].allocated = 1;
-	handle->per_node[dst_node].automatically_allocated = 1;
+	replicate->allocated = 1;
+	replicate->automatically_allocated = 1;
 
 	return 0;
 }

+ 3 - 1
src/datawizard/memalloc.h

@@ -25,6 +25,8 @@
 #include <datawizard/coherency.h>
 #include <datawizard/copy_driver.h>
 
+struct starpu_data_replicate_s;
+
 LIST_TYPE(starpu_mem_chunk,
 	starpu_data_handle data;
 	size_t size;
@@ -47,7 +49,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);
+int _starpu_allocate_memory_on_node(starpu_data_handle handle, struct starpu_data_replicate_s *replicate);
 size_t _starpu_free_all_automatically_allocated_buffers(uint32_t node);
 
 /* Memory chunk cache */