Parcourir la source

src/datawizard/memalloc: store interface size of the memchunk as the handle may no longer be valid when reusing the memchunk (thanks to Cyril Bordage for reporting the bug)

Nathalie Furmento il y a 12 ans
Parent
commit
402e568b27
2 fichiers modifiés avec 4 ajouts et 2 suppressions
  1. 2 1
      src/datawizard/memalloc.c
  2. 2 1
      src/datawizard/memalloc.h

+ 2 - 1
src/datawizard/memalloc.c

@@ -427,7 +427,7 @@ static void reuse_mem_chunk(unsigned node, struct _starpu_data_replicate *new_re
 
 	STARPU_ASSERT(new_replicate->data_interface);
 	STARPU_ASSERT(mc->chunk_interface);
-	memcpy(new_replicate->data_interface, mc->chunk_interface, old_replicate->handle->ops->interface_size);
+	memcpy(new_replicate->data_interface, mc->chunk_interface, mc->size_interface);
 
 	mc->data = new_replicate->handle;
 	/* mc->ops, mc->footprint and mc->interface should be
@@ -721,6 +721,7 @@ static struct _starpu_mem_chunk *_starpu_memchunk_init(struct _starpu_data_repli
 
 	/* Save a copy of the interface */
 	mc->chunk_interface = malloc(interface_size);
+	mc->size_interface = interface_size;
 	STARPU_ASSERT(mc->chunk_interface);
 	memcpy(mc->chunk_interface, replicate->data_interface, interface_size);
 

+ 2 - 1
src/datawizard/memalloc.h

@@ -41,9 +41,10 @@ LIST_TYPE(_starpu_mem_chunk,
 	 */
 	struct starpu_data_interface_ops *ops;
 	void *chunk_interface;
+	size_t size_interface;
 	unsigned automatically_allocated;
 
-	/* the size is only set when calling _starpu_request_mem_chunk_removal(),
+	/* the size of the data is only set when calling _starpu_request_mem_chunk_removal(),
          * it is needed by free_memory_on_node() which is called when
          * the handle is no longer valid. It should not be used otherwise.
 	 */