Explorar el Código

fix protecting post_sync_tasks_cnt with sequential_consistency_mutex. But no need to take the mutex when it is known to be 0, just tell hellgrind to be fine with it

Samuel Thibault hace 12 años
padre
commit
41dee18d0c
Se han modificado 2 ficheros con 10 adiciones y 1 borrados
  1. 9 1
      src/core/dependencies/implicit_data_deps.c
  2. 1 0
      src/datawizard/coherency.h

+ 9 - 1
src/core/dependencies/implicit_data_deps.c

@@ -481,8 +481,15 @@ void _starpu_unlock_post_sync_tasks(starpu_data_handle_t handle)
 	struct _starpu_task_wrapper_list *post_sync_tasks = NULL;
 	unsigned do_submit_tasks = 0;
 
-	if (handle->post_sync_tasks_cnt > 0)
+	VALGRIND_HG_MUTEX_LOCK_PRE(&handle->sequential_consistency_mutex, 0);
+	VALGRIND_HG_MUTEX_LOCK_POST(&handle->sequential_consistency_mutex);
+	unsigned count = handle->post_sync_tasks_cnt;
+	VALGRIND_HG_MUTEX_UNLOCK_PRE(&handle->sequential_consistency_mutex);
+	VALGRIND_HG_MUTEX_UNLOCK_POST(&handle->sequential_consistency_mutex);
+
+	if (count)
 	{
+		STARPU_PTHREAD_MUTEX_LOCK(&handle->sequential_consistency_mutex);
 		if (--handle->post_sync_tasks_cnt == 0)
 		{
 			/* unlock all tasks : we need not hold the lock while unlocking all these tasks */
@@ -490,6 +497,7 @@ void _starpu_unlock_post_sync_tasks(starpu_data_handle_t handle)
 			post_sync_tasks = handle->post_sync_tasks;
 			handle->post_sync_tasks = NULL;
 		}
+		STARPU_PTHREAD_MUTEX_UNLOCK(&handle->sequential_consistency_mutex);
 	}
 
 	if (do_submit_tasks)

+ 1 - 0
src/datawizard/coherency.h

@@ -178,6 +178,7 @@ struct _starpu_data_state
 	unsigned long last_submitted_ghost_sync_id;
 	struct _starpu_jobid_list *last_submitted_ghost_accessors_id;
 
+	/* protected by sequential_consistency_mutex */
 	struct _starpu_task_wrapper_list *post_sync_tasks;
 	unsigned post_sync_tasks_cnt;