Forráskód Böngészése

fix some over-optimist rdlocks into wrlocks

Olivier Aumage 8 éve
szülő
commit
b542d1e3eb
2 módosított fájl, 8 hozzáadás és 8 törlés
  1. 5 5
      src/core/sched_ctx.c
  2. 3 3
      src/core/sched_policy.c

+ 5 - 5
src/core/sched_ctx.c

@@ -1572,7 +1572,7 @@ unsigned _starpu_increment_nready_tasks_of_sched_ctx(unsigned sched_ctx_id, doub
 	if(!sched_ctx->is_initial_sched)
 	{
 		starpu_pthread_rwlock_t *ctx_mutex = _starpu_sched_ctx_get_mutex(sched_ctx->id);
-		STARPU_PTHREAD_RWLOCK_RDLOCK(ctx_mutex);
+		STARPU_PTHREAD_RWLOCK_WRLOCK(ctx_mutex);
 	}
 
 	_starpu_barrier_counter_increment(&sched_ctx->ready_tasks_barrier, ready_flops);
@@ -1599,7 +1599,7 @@ void _starpu_decrement_nready_tasks_of_sched_ctx(unsigned sched_ctx_id, double r
 	if(!sched_ctx->is_initial_sched)
 	{
 		starpu_pthread_rwlock_t *ctx_mutex = _starpu_sched_ctx_get_mutex(sched_ctx->id);
-		STARPU_PTHREAD_RWLOCK_RDLOCK(ctx_mutex);
+		STARPU_PTHREAD_RWLOCK_WRLOCK(ctx_mutex);
 	}
 
 	_starpu_barrier_counter_decrement_until_empty_counter(&sched_ctx->ready_tasks_barrier, ready_flops);
@@ -2288,7 +2288,7 @@ void starpu_sched_ctx_list_task_counters_increment_all(struct starpu_task *task,
 
 		workers->init_iterator_for_parallel_tasks(workers, &it, task);
 		starpu_pthread_rwlock_t *ctx_mutex = _starpu_sched_ctx_get_mutex(sched_ctx->id);
-		STARPU_PTHREAD_RWLOCK_RDLOCK(ctx_mutex);
+		STARPU_PTHREAD_RWLOCK_WRLOCK(ctx_mutex);
 		while(workers->has_next(workers, &it))
 		{
 			int worker = workers->get_next(workers, &it);
@@ -2315,7 +2315,7 @@ void starpu_sched_ctx_list_task_counters_decrement_all(struct starpu_task *task,
 		struct starpu_sched_ctx_iterator it;
 		workers->init_iterator_for_parallel_tasks(workers, &it, task);
 		starpu_pthread_rwlock_t *ctx_mutex = _starpu_sched_ctx_get_mutex(sched_ctx->id);
-		STARPU_PTHREAD_RWLOCK_RDLOCK(ctx_mutex);
+		STARPU_PTHREAD_RWLOCK_WRLOCK(ctx_mutex);
 		while(workers->has_next(workers, &it))
 		{
 			int worker = workers->get_next(workers, &it);
@@ -2352,7 +2352,7 @@ void starpu_sched_ctx_list_task_counters_reset_all(struct starpu_task *task, uns
 		struct starpu_sched_ctx_iterator it;
 		workers->init_iterator_for_parallel_tasks(workers, &it, task);
 		starpu_pthread_rwlock_t *ctx_mutex = _starpu_sched_ctx_get_mutex(sched_ctx->id);
-		STARPU_PTHREAD_RWLOCK_RDLOCK(ctx_mutex);
+		STARPU_PTHREAD_RWLOCK_WRLOCK(ctx_mutex);
 		while(workers->has_next(workers, &it))
 		{
 			int worker = workers->get_next(workers, &it);

+ 3 - 3
src/core/sched_policy.c

@@ -432,7 +432,7 @@ int _starpu_repush_task(struct _starpu_job *j)
 		if(nworkers == 0)
 		{
 			starpu_pthread_rwlock_t *ctx_mutex = _starpu_sched_ctx_get_mutex(sched_ctx->id);
-			STARPU_PTHREAD_RWLOCK_RDLOCK(ctx_mutex);
+			STARPU_PTHREAD_RWLOCK_WRLOCK(ctx_mutex);
 			starpu_task_list_push_front(&sched_ctx->empty_ctx_tasks, task);
 			STARPU_PTHREAD_RWLOCK_UNLOCK(ctx_mutex);
 #ifdef STARPU_USE_SC_HYPERVISOR
@@ -499,7 +499,7 @@ int _starpu_push_task_to_workers(struct starpu_task *task)
 		if (nworkers == 0)
 		{
 			starpu_pthread_rwlock_t *ctx_mutex = _starpu_sched_ctx_get_mutex(sched_ctx->id);
-			STARPU_PTHREAD_RWLOCK_RDLOCK(ctx_mutex);
+			STARPU_PTHREAD_RWLOCK_WRLOCK(ctx_mutex);
 			starpu_task_list_push_back(&sched_ctx->empty_ctx_tasks, task);
 			STARPU_PTHREAD_RWLOCK_UNLOCK(ctx_mutex);
 #ifdef STARPU_USE_SC_HYPERVISOR
@@ -592,7 +592,7 @@ int _starpu_push_task_to_workers(struct starpu_task *task)
 			STARPU_ASSERT(sched_ctx->sched_policy->push_task);
 			/* check out if there are any workers in the context */
 			starpu_pthread_rwlock_t *ctx_mutex = _starpu_sched_ctx_get_mutex(sched_ctx->id);
-			STARPU_PTHREAD_RWLOCK_RDLOCK(ctx_mutex);
+			STARPU_PTHREAD_RWLOCK_WRLOCK(ctx_mutex);
 			nworkers = starpu_sched_ctx_get_nworkers(sched_ctx->id);
 			if (nworkers == 0)
 				ret = -1;