Samuel Thibault лет назад: 8
Родитель
Сommit
f3a4fb9302
1 измененных файлов с 6 добавлено и 2 удалено
  1. 6 2
      src/datawizard/memalloc.c

+ 6 - 2
src/datawizard/memalloc.c

@@ -647,8 +647,12 @@ static unsigned try_to_reuse_mem_chunk(struct _starpu_mem_chunk *mc, unsigned no
 					/* mc is still associated with the old
 					 * handle, now replace the previous data
 					 */
-					reuse_mem_chunk(node, replicate, mc, is_already_in_mc_list);
-					success = 1;
+					if (old_data->per_node[node].refcnt == 0)
+					{
+						/* And still nobody on it, now the actual buffer may be reused */
+						reuse_mem_chunk(node, replicate, mc, is_already_in_mc_list);
+						success = 1;
+					}
 				}
 			}
 		}