소스 검색

port r13570 from 1.1: Fix mc memory leak

Samuel Thibault 10 년 전
부모
커밋
c209bb90fd
3개의 변경된 파일10개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 1
      src/datawizard/coherency.c
  2. 1 0
      src/datawizard/malloc.c
  3. 8 2
      src/datawizard/memalloc.c

+ 1 - 1
src/datawizard/coherency.c

@@ -260,7 +260,7 @@ static int link_supports_direct_transfers(starpu_data_handle_t handle, unsigned
 	if (src_node != dst_node && starpu_node_get_kind(src_node) == STARPU_CUDA_RAM && starpu_node_get_kind(dst_node) == STARPU_CUDA_RAM)
 	{
 		const struct starpu_data_copy_methods *copy_methods = handle->ops->copy_methods;
-		if (!copy_methods->cuda_to_cuda_async)
+		if (!copy_methods->cuda_to_cuda_async && !copy_methods->any_to_any)
 			return 0;
 	}
 #endif

+ 1 - 0
src/datawizard/malloc.c

@@ -404,6 +404,7 @@ _starpu_malloc_on_node(unsigned dst_node, size_t size)
 			STARPU_ASSERT(last[dst_node] >= addr);
 			STARPU_PTHREAD_MUTEX_UNLOCK(&cuda_alloc_mutex);
 #else
+			//starpu_cuda_set_device(devid); /* !!! */
 			status = cudaMalloc((void **)&addr, size);
 			if (!addr || (status != cudaSuccess))
 			{

+ 8 - 2
src/datawizard/memalloc.c

@@ -440,12 +440,15 @@ static void reuse_mem_chunk(unsigned node, struct _starpu_data_replicate *new_re
 
 	if (!old_replicate)
 	{
+		/* Free the copy that we made */
 		free(mc->chunk_interface);
 		mc->chunk_interface = NULL;
 	}
 
-	mc->data = new_replicate->handle;
-	/* mc->ops, mc->footprint and mc->interface should be
+	/* XXX: We do not actually reuse the mc at the moment, only the interface */
+
+	/* mc->data = new_replicate->handle; */
+	/* mc->footprint, mc->ops, mc->size_interface, mc->automatically_allocated should be
  	 * unchanged ! */
 
 	/* remove the mem chunk from the list of active memory chunks, register_mem_chunk will put it back later */
@@ -453,6 +456,8 @@ static void reuse_mem_chunk(unsigned node, struct _starpu_data_replicate *new_re
 	{
 		_starpu_mem_chunk_list_delete(mc);
 	}
+
+	free(mc);
 }
 
 static unsigned try_to_reuse_mem_chunk(struct _starpu_mem_chunk *mc, unsigned node, struct _starpu_data_replicate *replicate, unsigned is_already_in_mc_list)
@@ -543,6 +548,7 @@ static unsigned try_to_find_reusable_mem_chunk(unsigned node, starpu_data_handle
 	mc = _starpu_memchunk_cache_lookup_locked(node, data, footprint);
 	if (mc)
 	{
+		/* TODO: return the MC !! */
 		/* We found an entry in the cache so we can reuse it */
 		reuse_mem_chunk(node, replicate, mc, 0);
 		return 1;