소스 검색

Fix wt_mask against node number beyond 32

Samuel Thibault 4 년 전
부모
커밋
5c810ff1b7
3개의 변경된 파일10개의 추가작업 그리고 5개의 파일을 삭제
  1. 7 2
      src/datawizard/coherency.c
  2. 2 2
      src/datawizard/memalloc.c
  3. 1 1
      tools/gdbinit

+ 7 - 2
src/datawizard/coherency.c

@@ -864,8 +864,13 @@ uint32_t _starpu_data_get_footprint(starpu_data_handle_t handle)
 void _starpu_release_data_on_node(starpu_data_handle_t handle, uint32_t default_wt_mask, enum starpu_data_access_mode down_to_mode, struct _starpu_data_replicate *replicate)
 {
 	uint32_t wt_mask;
+	const size_t max_wt_mask = sizeof(wt_mask) * 8;
+	unsigned wt_count = starpu_memory_nodes_get_count();
+	if (wt_count > max_wt_mask)
+		wt_count = max_wt_mask;
+
 	wt_mask = default_wt_mask | handle->wt_mask;
-	wt_mask &= (1<<starpu_memory_nodes_get_count())-1;
+	wt_mask &= (1ULL<<max_wt_mask)-1;
 
 	/* Note that it is possible that there is no valid copy of the data (if
 	 * starpu_data_invalidate was called for instance). In that case, we do
@@ -874,7 +879,7 @@ void _starpu_release_data_on_node(starpu_data_handle_t handle, uint32_t default_
 	unsigned memory_node = replicate->memory_node;
 
 	if (replicate->state != STARPU_INVALID && handle->current_mode & STARPU_W)
-	if (wt_mask & ~(1<<memory_node))
+	if (wt_mask && (memory_node >= max_wt_mask || wt_mask & ~(1<<memory_node)))
 		_starpu_write_through_data(handle, memory_node, wt_mask);
 
 	int cpt = 0;

+ 2 - 2
src/datawizard/memalloc.c

@@ -553,7 +553,7 @@ static void reuse_mem_chunk(unsigned node, struct _starpu_data_replicate *new_re
 int starpu_data_can_evict(starpu_data_handle_t handle, unsigned node, enum starpu_is_prefetch is_prefetch)
 {
 	/* This data should be written through to this node, avoid dropping it! */
-	if (handle->wt_mask & (1<<node))
+	if (node < sizeof(handle->wt_mask) * 8 && handle->wt_mask & (1<<node))
 		return 0;
 
 	/* This data was registered from this node, we will not be able to drop it anyway */
@@ -1179,7 +1179,7 @@ void starpu_memchunk_tidy(unsigned node)
 			if (
 				/* This data should be written through to this node, avoid
 				 * dropping it! */
-				handle->wt_mask & (1<<node)
+				(node < sizeof(handle->wt_mask) * 8 && handle->wt_mask & (1<<node))
 				/* This is partitioned, don't care about the
 				 * whole data, we'll work on the subdatas.  */
 			     || handle->nchildren

+ 1 - 1
tools/gdbinit

@@ -812,7 +812,7 @@ define starpu-memusage
         printf "\rinspected %d data...", $total
       end
       set $total_b = $total_b + $size
-      if $handle->wt_mask & (1 << $node)
+      if $node < sizeof($handle->wt_mask) * 8 && $handle->wt_mask & (1 << $node)
         set $wt = $wt + 1
 	set $wt_b = $wt_b + $size
       end