ソースを参照

data interface: no longer store data size in the handle as some interface may have variable size

Nathalie Furmento 12 年 前
コミット
8f5264b152

+ 1 - 1
src/datawizard/coherency.c

@@ -524,7 +524,7 @@ uint32_t _starpu_get_data_refcnt(starpu_data_handle_t handle, uint32_t node)
 
 size_t _starpu_data_get_size(starpu_data_handle_t handle)
 {
-	return handle->data_size;
+	return handle->ops->get_size(handle);
 }
 
 uint32_t _starpu_data_get_footprint(starpu_data_handle_t handle)

+ 0 - 3
src/datawizard/coherency.h

@@ -135,9 +135,6 @@ struct _starpu_data_state
 
 	struct starpu_data_interface_ops *ops;
 
-	/* To avoid recomputing data size all the time, we store it directly. */
-	size_t data_size;
-
 	/* Footprint which identifies data layout */
 	uint32_t footprint;
 

+ 0 - 1
src/datawizard/filters.c

@@ -245,7 +245,6 @@ void starpu_data_partition(starpu_data_handle_t initial_handle, struct starpu_da
 
 		/* We compute the size and the footprint of the child once and
 		 * store it in the handle */
-		child->data_size = child->ops->get_size(child);
 		child->footprint = _starpu_compute_data_footprint(child);
 
 		void *ptr;

+ 0 - 2
src/datawizard/interfaces/data_interface.c

@@ -160,8 +160,6 @@ static void _starpu_register_new_data(starpu_data_handle_t handle,
 
 	/* Store some values directly in the handle not to recompute them all
 	 * the time. */
-	STARPU_ASSERT(handle->ops->get_size);
-	handle->data_size = handle->ops->get_size(handle);
 	handle->footprint = _starpu_compute_data_footprint(handle);
 
 	handle->home_node = home_node;

+ 9 - 9
src/datawizard/memalloc.c

@@ -263,7 +263,7 @@ static size_t free_memory_on_node(struct _starpu_mem_chunk *mc, uint32_t node)
 			replicate->automatically_allocated = 0;
 		}
 
-		freed = mc->size;
+		freed = mc->ops->get_size(handle);
 
 		if (handle && !data_was_deleted)
 			STARPU_ASSERT(replicate->refcnt == 0);
@@ -399,7 +399,7 @@ static void reuse_mem_chunk(unsigned node, struct _starpu_data_replicate *new_re
 
 	mc->data = new_replicate->handle;
 	mc->data_was_deleted = 0;
-	/* mc->ops, mc->size, mc->footprint and mc->interface should be
+	/* mc->ops, mc->footprint and mc->interface should be
  	 * unchanged ! */
 
 	/* reinsert the mem chunk in the list of active memory chunks */
@@ -619,7 +619,7 @@ size_t _starpu_free_all_automatically_allocated_buffers(uint32_t node)
 	return reclaim_memory_generic(node, 1, 0);
 }
 
-static struct _starpu_mem_chunk *_starpu_memchunk_init(struct _starpu_data_replicate *replicate, size_t size, size_t interface_size, unsigned automatically_allocated)
+static struct _starpu_mem_chunk *_starpu_memchunk_init(struct _starpu_data_replicate *replicate, size_t interface_size, unsigned automatically_allocated)
 {
 	struct _starpu_mem_chunk *mc = _starpu_mem_chunk_new();
 	starpu_data_handle_t handle = replicate->handle;
@@ -628,7 +628,6 @@ static struct _starpu_mem_chunk *_starpu_memchunk_init(struct _starpu_data_repli
 	STARPU_ASSERT(handle->ops);
 
 	mc->data = handle;
-	mc->size = size;
 	mc->footprint = _starpu_compute_data_footprint(handle);
 	mc->ops = handle->ops;
 	mc->data_was_deleted = 0;
@@ -645,7 +644,7 @@ static struct _starpu_mem_chunk *_starpu_memchunk_init(struct _starpu_data_repli
 	return mc;
 }
 
-static void register_mem_chunk(struct _starpu_data_replicate *replicate, size_t size, unsigned automatically_allocated)
+static void register_mem_chunk(struct _starpu_data_replicate *replicate, unsigned automatically_allocated)
 {
 	unsigned dst_node = replicate->memory_node;
 
@@ -655,7 +654,7 @@ static void register_mem_chunk(struct _starpu_data_replicate *replicate, size_t
 	size_t interface_size = replicate->handle->ops->interface_size;
 
 	/* Put this memchunk in the list of memchunk in use */
-	mc = _starpu_memchunk_init(replicate, size, interface_size, automatically_allocated);
+	mc = _starpu_memchunk_init(replicate, interface_size, automatically_allocated);
 
 	_STARPU_PTHREAD_RWLOCK_WRLOCK(&mc_rwlock[dst_node]);
 
@@ -937,8 +936,9 @@ static ssize_t _starpu_allocate_interface(starpu_data_handle_t handle, struct _s
 		if (allocated_memory == -ENOMEM)
 		{
 			size_t reclaim = 0.25*_starpu_get_global_mem_size(dst_node);
-			if (starpu_memstrategy_data_size_coefficient*handle->data_size > reclaim)
-				reclaim = starpu_memstrategy_data_size_coefficient*handle->data_size;
+			size_t handle_size = handle->ops->get_size(handle);
+			if (starpu_memstrategy_data_size_coefficient*handle_size > reclaim)
+				reclaim = starpu_memstrategy_data_size_coefficient*handle_size;
 
 			/* Take temporary reference on the replicate */
 			replicate->refcnt++;
@@ -989,7 +989,7 @@ int _starpu_allocate_memory_on_node(starpu_data_handle_t handle, struct _starpu_
 	if (allocated_memory == -ENOMEM)
 		return -ENOMEM;
 
-	register_mem_chunk(replicate, allocated_memory, 1);
+	register_mem_chunk(replicate, 1);
 
 	replicate->allocated = 1;
 	replicate->automatically_allocated = 1;

+ 0 - 1
src/datawizard/memalloc.h

@@ -30,7 +30,6 @@ struct _starpu_data_replicate;
 
 LIST_TYPE(_starpu_mem_chunk,
 	starpu_data_handle_t data;
-	size_t size;
 
 	uint32_t footprint;
 

+ 1 - 1
src/datawizard/memstats.c

@@ -53,7 +53,7 @@ void _starpu_memory_display_handle_stats(starpu_data_handle_t handle)
 
 	fprintf(stderr, "#-----\n");
 	fprintf(stderr, "Data : %p\n", handle);
-	fprintf(stderr, "Size : %d\n", (int)handle->data_size);
+	fprintf(stderr, "Size : %d\n", (int)handle->ops->get_size(handle));
 	fprintf(stderr, "\n");
 
 	fprintf(stderr, "#--\n");