瀏覽代碼

STARPU_MINIMUM_AVAILABLE_MEM being 0 should not prevent tidy from cleaning buffers

Samuel Thibault 7 年之前
父節點
當前提交
5af9c89e79
共有 1 個文件被更改,包括 12 次插入9 次删除
  1. 12 9
      src/datawizard/memalloc.c

+ 12 - 9
src/datawizard/memalloc.c

@@ -998,17 +998,10 @@ size_t _starpu_free_all_automatically_allocated_buffers(unsigned node)
 /* Periodic tidy of available memory  */
 void starpu_memchunk_tidy(unsigned node)
 {
-	starpu_ssize_t total = starpu_memory_get_total(node);
-	starpu_ssize_t available = starpu_memory_get_available(node);
+	starpu_ssize_t total;
+	starpu_ssize_t available;
 	size_t target, amount;
 
-	/* Count cached allocation as being available */
-	available += mc_cache_size[node];
-
-	if (total > 0 && available >= (starpu_ssize_t) (total * minimum_p) / 100)
-		/* Enough available space, do not trigger reclaiming */
-		return;
-
 	if (mc_clean_nb[node] < (mc_nb[node] * minimum_clean_p) / 100)
 	{
 		struct _starpu_mem_chunk *mc, *orig_next_mc, *next_mc;
@@ -1143,9 +1136,19 @@ void starpu_memchunk_tidy(unsigned node)
 		_STARPU_TRACE_END_WRITEBACK_ASYNC(node);
 	}
 
+	total = starpu_memory_get_total(node);
+
 	if (total <= 0)
 		return;
 
+	available = starpu_memory_get_available(node);
+	/* Count cached allocation as being available */
+	available += mc_cache_size[node];
+
+	if (available >= (starpu_ssize_t) (total * minimum_p) / 100)
+		/* Enough available space, do not trigger reclaiming */
+		return;
+
 	/* Not enough available space, reclaim until we reach the target.  */
 	target = (total * target_p) / 100;
 	amount = target - available;