Browse Source

Bug fix: _starpu_fetch_data_on_node does not increase the refcnt on the
requesting node in case the transfer is marked as "prefetch". Until we properly
whether the request is asynchronous and/or detached (no one is going to wait
for it) we have to increase the refcnt prior to submitting a transfer request.

Cédric Augonnet 15 years ago
parent
commit
7555d37392
3 changed files with 9 additions and 3 deletions
  1. 2 0
      src/datawizard/coherency.c
  2. 1 1
      src/datawizard/coherency.h
  3. 6 2
      src/datawizard/user_interactions.c

+ 2 - 0
src/datawizard/coherency.c

@@ -322,6 +322,8 @@ void _starpu_release_data_on_node(starpu_data_handle handle, uint32_t default_wb
 
 	handle->per_node[memory_node].refcnt--;
 
+	STARPU_ASSERT(handle->per_node[memory_node].refcnt >= 0);
+
 	_starpu_notify_data_dependencies(handle);
 
 	_starpu_spin_unlock(&handle->header_lock);

+ 1 - 1
src/datawizard/coherency.h

@@ -41,7 +41,7 @@ typedef struct starpu_local_data_state_t {
 	/* describes the state of the local data in term of coherency */
 	starpu_cache_state	state; 
 
-	uint32_t refcnt;
+	int refcnt;
 
 	/* is the data locally allocated ? */
 	uint8_t allocated; 

+ 6 - 2
src/datawizard/user_interactions.c

@@ -81,10 +81,9 @@ static void _starpu_sync_data_with_mem_continuation_non_blocking(void *arg)
 
 	STARPU_ASSERT(handle);
 
-	ret = _starpu_fetch_data_on_node(handle, 0, statenode->mode, 0,
+	ret = _starpu_fetch_data_on_node(handle, 0, statenode->mode, 1,
 			_starpu_sync_data_with_mem_fetch_data_callback, statenode);
 	STARPU_ASSERT(!ret);
-
 }
 
 void starpu_data_sync_with_mem_non_blocking_pre_sync_callback(void *arg)
@@ -119,6 +118,11 @@ int starpu_data_sync_with_mem_non_blocking(starpu_data_handle handle,
 	PTHREAD_MUTEX_INIT(&statenode->lock, NULL);
 	statenode->finished = 0;
 
+#warning TODO instead of having the is_prefetch argument, _starpu_fetch_data shoud consider two flags: async and detached
+	_starpu_spin_lock(&handle->header_lock);
+	handle->per_node[0].refcnt++;
+	_starpu_spin_unlock(&handle->header_lock);
+
 	PTHREAD_MUTEX_LOCK(&handle->sequential_consistency_mutex);
 	int sequential_consistency = handle->sequential_consistency;
 	if (sequential_consistency)