소스 검색

src/datawizard: re-add field size in struct _starpu_mem_chunk however
it is only set when calling _starpu_request_mem_chunk_removal(), as it
is needed by free_memory_on_node() which is called when the handle is
no longer valid. It should not be used otherwise.

Nathalie Furmento 12 년 전
부모
커밋
93c3d6029a
2개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      src/datawizard/memalloc.c
  2. 6 0
      src/datawizard/memalloc.h

+ 4 - 1
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->ops->get_size(handle);
+		freed = mc->size;
 
 		if (handle && !data_was_deleted)
 			STARPU_ASSERT(replicate->refcnt == 0);
@@ -673,6 +673,8 @@ void _starpu_request_mem_chunk_removal(starpu_data_handle_t handle, unsigned nod
 {
 	_STARPU_PTHREAD_RWLOCK_WRLOCK(&mc_rwlock[node]);
 
+	size_t size = _starpu_data_get_size(handle);
+
 	/* iterate over the list of memory chunks and remove the entry */
 	struct _starpu_mem_chunk *mc, *next_mc;
 	for (mc = _starpu_mem_chunk_list_begin(mc_list[node]);
@@ -684,6 +686,7 @@ void _starpu_request_mem_chunk_removal(starpu_data_handle_t handle, unsigned nod
 		if (mc->data == handle)
 		{
 			/* we found the data */
+			mc->size = size;
 			mc->data_was_deleted = handle_deleted;
 
 			/* remove it from the main list */

+ 6 - 0
src/datawizard/memalloc.h

@@ -44,6 +44,12 @@ LIST_TYPE(_starpu_mem_chunk,
 	unsigned automatically_allocated;
 	unsigned data_was_deleted;
 
+	/* the size 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
+	 */
+	size_t size;
+
 	/* A buffer that is used for SCRATCH or reduction cannnot be used with
 	 * filters. */
 	unsigned relaxed_coherency;