Просмотр исходного кода

We now assume that the header lock is already taken when calling
notify_data_dependencies, this avoids to release a lock and to grab it
immediately in the critical path.

Cédric Augonnet лет назад: 15
Родитель
Сommit
e561dd511a

+ 1 - 5
src/core/dependencies/data-concurrency.c

@@ -191,10 +191,9 @@ unsigned submit_job_enforce_data_deps(job_t j)
 }
 
 
+/* The header lock must already be taken by the caller */
 void notify_data_dependencies(data_state *data)
 {
-	starpu_spin_lock(&data->header_lock);
-
 	data->refcnt--;
 
 	while (may_unlock_data_req_list_head(data))
@@ -226,7 +225,4 @@ void notify_data_dependencies(data_state *data)
 		
 		starpu_spin_lock(&data->header_lock);
 	}
-	
-	starpu_spin_unlock(&data->header_lock);
-
 }

+ 2 - 1
src/datawizard/coherency.c

@@ -309,9 +309,10 @@ void release_data_on_node(data_state *state, uint32_t default_wb_mask, uint32_t
 		datawizard_progress(local_node, 1);
 
 	state->per_node[memory_node].refcnt--;
-	starpu_spin_unlock(&state->header_lock);
 
 	notify_data_dependencies(state);
+
+	starpu_spin_unlock(&state->header_lock);
 }
 
 int prefetch_task_input_on_node(struct starpu_task *task, uint32_t node)

+ 10 - 0
src/datawizard/user_interactions.c

@@ -154,7 +154,9 @@ int starpu_notify_data_modification(data_state *state, uint32_t modifying_node)
 	}
 
 	/* remove the "lock"/reference */
+	starpu_spin_lock(&state->header_lock);
 	notify_data_dependencies(state);
+	starpu_spin_unlock(&state->header_lock);
 
 	return 0;
 }
@@ -171,7 +173,11 @@ static void _prefetch_data_on_node(void *arg)
 	pthread_mutex_unlock(&statenode->lock);
 
 	if (!statenode->async)
+	{
+		starpu_spin_lock(&statenode->state->header_lock);
 		notify_data_dependencies(statenode->state);
+		starpu_spin_unlock(&statenode->state->header_lock);
+	}
 
 }
 
@@ -198,7 +204,11 @@ int starpu_prefetch_data_on_node(data_state *state, unsigned node, unsigned asyn
 
 		/* remove the "lock"/reference */
 		if (!async)
+		{
+			starpu_spin_lock(&state->header_lock);
 			notify_data_dependencies(state);
+			starpu_spin_unlock(&state->header_lock);
+		}
 	}
 	else {
 		pthread_mutex_lock(&statenode.lock);