소스 검색

we now assume that _fetch_data is called with the header_lock taken so that we
avoid to release a lock to grab it immediately.

Cédric Augonnet 16 년 전
부모
커밋
97c3bc1a57
2개의 변경된 파일5개의 추가작업 그리고 12개의 파일을 삭제
  1. 3 12
      src/datawizard/coherency.c
  2. 2 0
      src/datawizard/hierarchy.c

+ 3 - 12
src/datawizard/coherency.c

@@ -114,20 +114,16 @@ static void update_data_state(data_state *state, uint32_t requesting_node,
  * 		    else (invalid,owner->shared)
  */
 
+/* we assume that the header lock is already taken */
 int _fetch_data(data_state *state, uint32_t requesting_node,
 			uint8_t read, uint8_t write)
 {
 	int ret;
 
-	while (starpu_spin_trylock(&state->header_lock)) {
-		datawizard_progress(requesting_node);
-	}
-
 	if (state->per_node[requesting_node].state != INVALID)
 	{
 		update_data_state(state, requesting_node, write);
 
-		starpu_spin_unlock(&state->header_lock);
 		msi_cache_hit(requesting_node);
 		return 0;
 	}
@@ -153,13 +149,10 @@ int _fetch_data(data_state *state, uint32_t requesting_node,
 
 	update_data_state(state, requesting_node, write);
 
-	starpu_spin_unlock(&state->header_lock);
-
 	return 0;
 
 enomem:
 	/* there was not enough local memory to fetch the data */
-	starpu_spin_unlock(&state->header_lock);
 	return -ENOMEM;
 }
 
@@ -188,18 +181,16 @@ static int fetch_data(data_state *state, starpu_access_mode mode)
 		datawizard_progress(requesting_node);
 
 	state->per_node[requesting_node].refcnt++;
-	starpu_spin_unlock(&state->header_lock);
 
 	ret = _fetch_data(state, requesting_node, read, write);
 	if (ret != 0)
 		goto enomem;
 
+	starpu_spin_unlock(&state->header_lock);
+
 	return 0;
 enomem:
 	/* we did not get the data so remove the lock anyway */
-	while (starpu_spin_trylock(&state->header_lock))
-		datawizard_progress(requesting_node);
-
 	state->per_node[requesting_node].refcnt--;
 	starpu_spin_unlock(&state->header_lock);
 

+ 2 - 0
src/datawizard/hierarchy.c

@@ -239,7 +239,9 @@ void starpu_unpartition_data(data_state *root_data, uint32_t gathering_node)
 			starpu_unpartition_data(&root_data->children[child], gathering_node);
 
 		int ret;
+		starpu_spin_lock(&root_data->children[child].header_lock);
 		ret = _fetch_data(&root_data->children[child], gathering_node, 1, 0);
+		starpu_spin_unlock(&root_data->children[child].header_lock);
 		/* for now we pretend that the RAM is almost unlimited and that gathering 
 		 * data should be possible from the node that does the unpartionning ... we
 		 * don't want to have the programming deal with memory shortage at that time,