Преглед на файлове

skip sched_ctx recently becomed empty

Olivier Aumage преди 7 години
родител
ревизия
9007118353
променени са 1 файла, в които са добавени 23 реда и са изтрити 19 реда
  1. 23 19
      src/core/sched_ctx.c

+ 23 - 19
src/core/sched_ctx.c

@@ -2089,28 +2089,32 @@ unsigned _starpu_sched_ctx_last_worker_awake(struct _starpu_worker *worker)
 
 		unsigned last_worker_awake = 1;
 		struct starpu_worker_collection *workers = sched_ctx->workers;
-		struct starpu_sched_ctx_iterator it;
-
-		workers->init_iterator(workers, &it);
-		while(workers->has_next(workers, &it))
+		/* workers can be NULL in some corner cases, since we do not lock sched_ctx here */
+		if (workers != NULL)
 		{
-			int workerid = workers->get_next(workers, &it);
-			if(workerid != worker->workerid)
+			struct starpu_sched_ctx_iterator it;
+
+			workers->init_iterator(workers, &it);
+			while(workers->has_next(workers, &it))
 			{
-				/* The worker status is intendedly checked
-				 * without taking locks. If multiple workers
-				 * are concurrently assessing whether they are
-				 * the last worker awake, they will follow the
-				 * pessimistic path and assume that they are
-				 * the last worker awake */
-				STARPU_HG_DISABLE_CHECKING(_starpu_config.workers[workerid].status);
-				const int cond = _starpu_config.workers[workerid].status != STATUS_SLEEPING;
-				STARPU_HG_ENABLE_CHECKING(_starpu_config.workers[workerid].status);
-
-				if (cond)
+				int workerid = workers->get_next(workers, &it);
+				if(workerid != worker->workerid)
 				{
-					last_worker_awake = 0;
-					break;
+					/* The worker status is intendedly checked
+					 * without taking locks. If multiple workers
+					 * are concurrently assessing whether they are
+					 * the last worker awake, they will follow the
+					 * pessimistic path and assume that they are
+					 * the last worker awake */
+					STARPU_HG_DISABLE_CHECKING(_starpu_config.workers[workerid].status);
+					const int cond = _starpu_config.workers[workerid].status != STATUS_SLEEPING;
+					STARPU_HG_ENABLE_CHECKING(_starpu_config.workers[workerid].status);
+
+					if (cond)
+					{
+						last_worker_awake = 0;
+						break;
+					}
 				}
 			}
 		}