Browse Source

Remove dead code

Cédric Augonnet 14 years ago
parent
commit
20e50d126a
2 changed files with 32 additions and 55 deletions
  1. 32 51
      src/datawizard/memalloc.c
  2. 0 4
      src/datawizard/memalloc.h

+ 32 - 51
src/datawizard/memalloc.c

@@ -378,44 +378,6 @@ static unsigned try_to_reuse_mem_chunk(starpu_mem_chunk_t mc, unsigned node, sta
 	return success;
 	return success;
 }
 }
 
 
-/* this function looks for a memory chunk that matches a given footprint in the
- * list of mem chunk that need to be freed. This function must be called with
- * mc_rwlock[node] taken in write mode. */
-static unsigned try_to_find_reusable_mem_chunk(unsigned node, starpu_data_handle data, uint32_t footprint)
-{
-	starpu_mem_chunk_t mc, next_mc;
-
-	/* go through all buffers in the cache */
-	mc = _starpu_memchunk_cache_lookup_locked(node, handle);
-	if (mc)
-	{
-		/* We found an entry in the cache so we can reuse it */
-		reuse_mem_chunk(node, data, mc, 0);
-		return 1;
-	}
-
-	/* now look for some non essential data in the active list */
-	for (mc = starpu_mem_chunk_list_begin(mc_list[node]);
-	     mc != starpu_mem_chunk_list_end(mc_list[node]);
-	     mc = next_mc)
-	{
-		/* there is a risk that the memory chunk is freed before next
-		 * iteration starts: so we compute the next element of the list
-		 * now */
-		next_mc = starpu_mem_chunk_list_next(mc);
-
-		if (mc->data->is_not_important && (mc->footprint == footprint))
-		{
-//			fprintf(stderr, "found a candidate ...\n");
-			if (try_to_reuse_mem_chunk(mc, node, data, 1))
-				return 1;
-		}
-	}
-
-	return 0;
-}
-#endif
-
 static int _starpu_data_interface_compare(void *interface_a, struct starpu_data_interface_ops_t *ops_a,
 static int _starpu_data_interface_compare(void *interface_a, struct starpu_data_interface_ops_t *ops_a,
 						void *interface_b, struct starpu_data_interface_ops_t *ops_b)
 						void *interface_b, struct starpu_data_interface_ops_t *ops_b)
 {
 {
@@ -428,7 +390,7 @@ static int _starpu_data_interface_compare(void *interface_a, struct starpu_data_
 }
 }
 
 
 /* This function must be called with mc_rwlock[node] taken in write mode */
 /* This function must be called with mc_rwlock[node] taken in write mode */
-starpu_mem_chunk_t _starpu_memchunk_cache_lookup_locked(uint32_t node, starpu_data_handle handle)
+static starpu_mem_chunk_t _starpu_memchunk_cache_lookup_locked(uint32_t node, starpu_data_handle handle)
 {
 {
 	uint32_t footprint = _starpu_compute_data_footprint(handle);
 	uint32_t footprint = _starpu_compute_data_footprint(handle);
 
 
@@ -456,24 +418,43 @@ starpu_mem_chunk_t _starpu_memchunk_cache_lookup_locked(uint32_t node, starpu_da
 	return NULL;
 	return NULL;
 }
 }
 
 
-starpu_mem_chunk_t _starpu_memchunk_cache_lookup(uint32_t node, starpu_data_handle handle)
+/* this function looks for a memory chunk that matches a given footprint in the
+ * list of mem chunk that need to be freed. This function must be called with
+ * mc_rwlock[node] taken in write mode. */
+static unsigned try_to_find_reusable_mem_chunk(unsigned node, starpu_data_handle data, uint32_t footprint)
 {
 {
-	starpu_mem_chunk_t mc;
+	starpu_mem_chunk_t mc, next_mc;
 
 
-	PTHREAD_RWLOCK_WRLOCK(&mc_rwlock[node]);
+	/* go through all buffers in the cache */
 	mc = _starpu_memchunk_cache_lookup_locked(node, handle);
 	mc = _starpu_memchunk_cache_lookup_locked(node, handle);
-	PTHREAD_RWLOCK_UNLOCK(&mc_rwlock[node]);
+	if (mc)
+	{
+		/* We found an entry in the cache so we can reuse it */
+		reuse_mem_chunk(node, data, mc, 0);
+		return 1;
+	}
 
 
-	return mc;
-}
+	/* now look for some non essential data in the active list */
+	for (mc = starpu_mem_chunk_list_begin(mc_list[node]);
+	     mc != starpu_mem_chunk_list_end(mc_list[node]);
+	     mc = next_mc)
+	{
+		/* there is a risk that the memory chunk is freed before next
+		 * iteration starts: so we compute the next element of the list
+		 * now */
+		next_mc = starpu_mem_chunk_list_next(mc);
 
 
-void _starpu_memchunk_cache_insert(uint32_t node, starpu_mem_chunk_t mc)
-{
-	PTHREAD_RWLOCK_WRLOCK(&mc_rwlock[node]);
-	mc->data = NULL;
-	starpu_mem_chunk_list_push_front(memchunk_cache[node], mc);
-	PTHREAD_RWLOCK_UNLOCK(&mc_rwlock[node]);
+		if (mc->data->is_not_important && (mc->footprint == footprint))
+		{
+//			fprintf(stderr, "found a candidate ...\n");
+			if (try_to_reuse_mem_chunk(mc, node, data, 1))
+				return 1;
+		}
+	}
+
+	return 0;
 }
 }
+#endif
 
 
 /*
 /*
  * Free the memory chuncks that are explicitely tagged to be freed. The
  * Free the memory chuncks that are explicitely tagged to be freed. The

+ 0 - 4
src/datawizard/memalloc.h

@@ -55,8 +55,4 @@ void _starpu_deinit_mem_chunk_lists(void);
 void _starpu_request_mem_chunk_removal(starpu_data_handle handle, unsigned node);
 void _starpu_request_mem_chunk_removal(starpu_data_handle handle, unsigned node);
 int _starpu_allocate_memory_on_node(starpu_data_handle handle, struct starpu_data_replicate_s *replicate);
 int _starpu_allocate_memory_on_node(starpu_data_handle handle, struct starpu_data_replicate_s *replicate);
 size_t _starpu_free_all_automatically_allocated_buffers(uint32_t node);
 size_t _starpu_free_all_automatically_allocated_buffers(uint32_t node);
-
-/* Memory chunk cache */
-void _starpu_memchunk_cache_insert(uint32_t node, starpu_mem_chunk_t);
-starpu_mem_chunk_t _starpu_memchunk_cache_lookup(uint32_t node, starpu_data_handle handle);
 #endif
 #endif