Quellcode durchsuchen

move busy state flag back in worker

Olivier Aumage vor 8 Jahren
Ursprung
Commit
e7834f1722
4 geänderte Dateien mit 7 neuen und 8 gelöschten Zeilen
  1. 2 3
      src/core/sched_ctx.c
  2. 0 1
      src/core/sched_ctx.h
  3. 1 0
      src/core/workers.h
  4. 4 4
      src/drivers/driver_common/driver_common.c

+ 2 - 3
src/core/sched_ctx.c

@@ -586,7 +586,6 @@ struct _starpu_sched_ctx* _starpu_create_sched_ctx(struct starpu_sched_policy *p
 
 		STARPU_PTHREAD_COND_INIT(&sched_ctx->parallel_sect_cond[w], NULL);
 		STARPU_PTHREAD_COND_INIT(&sched_ctx->parallel_sect_cond_busy[w], NULL);
-		sched_ctx->busy[w] = 0;
 
 		sched_ctx->parallel_sect[w] = 0;
 		sched_ctx->sleeping[w] = 0;
@@ -1157,9 +1156,9 @@ void starpu_sched_ctx_delete(unsigned sched_ctx_id)
 		int w;
 		for(w = 0; w < nworkers_ctx; w++)
 		{
-			while (sched_ctx->busy[w])
+			struct _starpu_worker *worker = _starpu_get_worker_struct(backup_workerids[w]);
+			while (worker->state_busy_in_parallel)
 			{
-				struct _starpu_worker *worker = _starpu_get_worker_struct(backup_workerids[w]);
 				STARPU_PTHREAD_COND_WAIT(&sched_ctx->parallel_sect_cond_busy[w], &worker->sched_mutex);
 			}
 		}

+ 0 - 1
src/core/sched_ctx.h

@@ -130,7 +130,6 @@ struct _starpu_sched_ctx
 	/* conditions variables used when parallel sections are executed in contexts */
 	starpu_pthread_cond_t parallel_sect_cond[STARPU_NMAXWORKERS];
 	starpu_pthread_cond_t parallel_sect_cond_busy[STARPU_NMAXWORKERS];
-	int busy[STARPU_NMAXWORKERS];
 
 	/* boolean indicating that workers should block in order to allow
 	   parallel sections to be executed on their allocated resources */

+ 1 - 0
src/core/workers.h

@@ -84,6 +84,7 @@ LIST_TYPE(_starpu_worker,
         starpu_pthread_mutex_t sched_mutex; /* mutex protecting sched_cond */
 	int state_sched_op_pending:1; /* a task pop is ongoing even though sched_mutex may temporarily be unlocked */
 	int state_changing_ctx_waiting:1; /* a thread is waiting for transient operations such as pop to complete before acquiring sched_mutex and modifying the worker ctx*/
+	int state_busy_in_parallel:1;
 	struct starpu_task_list local_tasks; /* this queue contains tasks that have been explicitely submitted to that queue */
 	struct starpu_task **local_ordered_tasks; /* this queue contains tasks that have been explicitely submitted to that queue with an explicit order */
 	unsigned local_ordered_tasks_size; /* this records the size of local_ordered_tasks */

+ 4 - 4
src/drivers/driver_common/driver_common.c

@@ -368,9 +368,9 @@ struct starpu_task *_starpu_get_worker_task(struct _starpu_worker *worker, int w
 					   that can change in another thread */
 					needed = 0;
 					_starpu_sched_ctx_signal_worker_blocked(sched_ctx->id, workerid);
-					sched_ctx->busy[workerid] = 1;
+					worker->state_busy_in_parallel = 1;
 					STARPU_PTHREAD_COND_WAIT(&sched_ctx->parallel_sect_cond[workerid], &worker->sched_mutex);
-					sched_ctx->busy[workerid] = 0;
+					worker->state_busy_in_parallel = 0;
 					STARPU_PTHREAD_COND_SIGNAL(&sched_ctx->parallel_sect_cond_busy[workerid]);
 					_starpu_sched_ctx_signal_worker_woke_up(sched_ctx->id, workerid);
 					sched_ctx->parallel_sect[workerid] = 0;
@@ -387,9 +387,9 @@ struct starpu_task *_starpu_get_worker_task(struct _starpu_worker *worker, int w
 			{
 //				needed = 0;
 				_starpu_sched_ctx_signal_worker_blocked(sched_ctx->id, workerid);
-				sched_ctx->busy[workerid] = 1;
+				worker->state_busy_in_parallel = 1;
 				STARPU_PTHREAD_COND_WAIT(&sched_ctx->parallel_sect_cond[workerid], &worker->sched_mutex);
-				sched_ctx->busy[workerid] = 0;
+				worker->state_busy_in_parallel = 0;
 				STARPU_PTHREAD_COND_SIGNAL(&sched_ctx->parallel_sect_cond_busy[workerid]);
 				_starpu_sched_ctx_signal_worker_woke_up(sched_ctx->id, workerid);
 				sched_ctx->parallel_sect[workerid] = 0;