Переглянути джерело

protect worker status with the scheduler mutex

Samuel Thibault 10 роки тому
батько
коміт
7ac2c135ad

+ 1 - 2
src/drivers/cpu/driver_cpu.c

@@ -176,12 +176,11 @@ int _starpu_cpu_driver_init(struct _starpu_worker *cpu_worker)
 	snprintf(cpu_worker->name, sizeof(cpu_worker->name), "CPU %d", devid);
 	snprintf(cpu_worker->short_name, sizeof(cpu_worker->short_name), "CPU %d", devid);
 
-	cpu_worker->status = STATUS_UNKNOWN;
-
 	_STARPU_TRACE_WORKER_INIT_END(cpu_worker->workerid);
 
 	/* tell the main thread that we are ready */
 	STARPU_PTHREAD_MUTEX_LOCK(&cpu_worker->mutex);
+	cpu_worker->status = STATUS_UNKNOWN;
 	cpu_worker->worker_is_initialized = 1;
 	STARPU_PTHREAD_COND_SIGNAL(&cpu_worker->ready_cond);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&cpu_worker->mutex);

+ 1 - 2
src/drivers/cuda/driver_cuda.c

@@ -532,8 +532,6 @@ int _starpu_cuda_driver_init(struct _starpu_worker_set *worker_set)
 	/* one more time to avoid hacks from third party lib :) */
 	_starpu_bind_thread_on_cpu(worker0->config, worker0->bindid);
 
-	worker0->status = STATUS_UNKNOWN;
-
 	float size = (float) global_mem[devid] / (1<<30);
 #ifdef STARPU_SIMGRID
 	const char *devname = "Simgrid";
@@ -565,6 +563,7 @@ int _starpu_cuda_driver_init(struct _starpu_worker_set *worker_set)
 
 	/* tell the main thread that this one is ready */
 	STARPU_PTHREAD_MUTEX_LOCK(&worker0->mutex);
+	worker0->status = STATUS_UNKNOWN;
 	worker0->worker_is_initialized = 1;
 	STARPU_PTHREAD_COND_SIGNAL(&worker0->ready_cond);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&worker0->mutex);

+ 1 - 2
src/drivers/mic/driver_mic_source.c

@@ -533,8 +533,6 @@ void *_starpu_mic_src_worker(void *arg)
 		snprintf(worker->name, sizeof(worker->name), "MIC %d core %u", devid, i);
 	}
 
-	baseworker->status = STATUS_UNKNOWN;
-
 	for (i = 0; i < worker_set->nworkers; i++)
 	{
 		struct _starpu_worker *worker = &worker_set->workers[i];
@@ -543,6 +541,7 @@ void *_starpu_mic_src_worker(void *arg)
 
 	/* tell the main thread that this one is ready */
 	STARPU_PTHREAD_MUTEX_LOCK(&worker_set->mutex);
+	baseworker->status = STATUS_UNKNOWN;
 	worker_set->set_is_initialized = 1;
 	STARPU_PTHREAD_COND_SIGNAL(&worker_set->ready_cond);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&worker_set->mutex);

+ 1 - 1
src/drivers/opencl/driver_opencl.c

@@ -584,7 +584,6 @@ int _starpu_opencl_driver_init(struct _starpu_worker *worker)
 
 	_starpu_malloc_init(worker->memory_node);
 
-	worker->status = STATUS_UNKNOWN;
 	float size = (float) global_mem[devid] / (1<<30);
 
 #ifdef STARPU_SIMGRID
@@ -605,6 +604,7 @@ int _starpu_opencl_driver_init(struct _starpu_worker *worker)
 
 	/* tell the main thread that this one is ready */
 	STARPU_PTHREAD_MUTEX_LOCK(&worker->mutex);
+	worker->status = STATUS_UNKNOWN;
 	worker->worker_is_initialized = 1;
 	STARPU_PTHREAD_COND_SIGNAL(&worker->ready_cond);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&worker->mutex);

+ 1 - 2
src/drivers/scc/driver_scc_source.c

@@ -295,8 +295,6 @@ void *_starpu_scc_src_worker(void *arg)
 
 	_starpu_scc_src_init_context(subworkerid);
 
-	args->status = STATUS_UNKNOWN;
-
 	for (i = 0; i < config->topology.nmiccores[devid]; i++)
 	{
 		struct _starpu_worker *worker = &config->workers[baseworkerid+i];
@@ -307,6 +305,7 @@ void *_starpu_scc_src_worker(void *arg)
 
 	/* tell the main thread that this one is ready */
 	STARPU_PTHREAD_MUTEX_LOCK(&args->mutex);
+	args->status = STATUS_UNKNOWN;
 	args->worker_is_initialized = 1;
 	STARPU_PTHREAD_COND_SIGNAL(&args->ready_cond);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&args->mutex);