Browse Source

Revert previous commit: as the comment DID tell, there is a problem as we could
have a piece of data deleted wile the corresponding memory chunks are only
deallocated in a lazy fashion, perhaps we can get rid of that local copy if a
refcnt is kept along with the interface structure ...

Cédric Augonnet 16 years ago
parent
commit
d80fb2d49a
2 changed files with 8 additions and 4 deletions
  1. 7 4
      src/datawizard/memalloc.c
  2. 1 0
      src/datawizard/memalloc.h

+ 7 - 4
src/datawizard/memalloc.c

@@ -250,9 +250,11 @@ static void reuse_mem_chunk(unsigned node, data_state *new_data, mem_chunk_t mc,
 	new_data->per_node[node].allocated = 1;
 	new_data->per_node[node].automatically_allocated = 1;
 
+	memcpy(&new_data->interface[node], &mc->interface, sizeof(starpu_data_interface_t));
+
 	mc->data = new_data;
 	mc->data_was_deleted = 0;
-	/* mc->ops, mc->size and mc->footprint should be
+	/* mc->ops, mc->size, mc->footprint and mc->interface should be
  	 * unchanged ! */
 	
 	/* reinsert the mem chunk in the list of active memory chunks */
@@ -425,6 +427,9 @@ static void register_mem_chunk(data_state *state, uint32_t dst_node, size_t size
 	mc->data_was_deleted = 0;
 	mc->automatically_allocated = automatically_allocated;
 
+	/* the interface was already filled by ops->allocate_data_on_node */
+	memcpy(&mc->interface, &state->interface[dst_node], sizeof(starpu_data_interface_t));
+
 	res = pthread_rwlock_wrlock(&mc_rwlock[dst_node]);
 	STARPU_ASSERT(!res);
 
@@ -489,9 +494,7 @@ static size_t liberate_memory_on_node(mem_chunk_t mc, uint32_t node)
 	{
 		STARPU_ASSERT(state->per_node[node].allocated);
 
-		starpu_data_interface_t *interface =
-			starpu_data_get_interface_on_node(state, node);
-		mc->ops->liberate_data_on_node(interface, node);
+		mc->ops->liberate_data_on_node(&mc->interface, node);
 
 		if (!mc->data_was_deleted)
 		{

+ 1 - 0
src/datawizard/memalloc.h

@@ -38,6 +38,7 @@ LIST_TYPE(mem_chunk,
 	 * because when a data is deleted, the memory chunk remains.
 	 */
 	struct data_interface_ops_t *ops;
+	starpu_data_interface_t interface;
 	unsigned automatically_allocated;
 	unsigned data_was_deleted;
 )