Просмотр исходного кода

Keep the status of each worker so that we can detect whether a blocking call is
made within a codelet or a callback.

Cédric Augonnet лет назад: 16
Родитель
Сommit
a9394e1af3

+ 2 - 0
src/Makefile.am

@@ -49,6 +49,7 @@ noinst_HEADERS = 						\
 	core/workers.h						\
 	core/topology.h						\
 	core/debug.h						\
+	core/errorcheck.h					\
 	datawizard/footprint.h					\
 	datawizard/datawizard.h					\
 	datawizard/data_request.h				\
@@ -96,6 +97,7 @@ libstarpu_la_SOURCES = 						\
 	core/workers.c						\
 	core/topology.c						\
 	core/debug.c						\
+	core/errorcheck.c					\
 	core/dependencies/tags.c				\
 	core/dependencies/htable.c				\
 	core/dependencies/data-concurrency.c			\

+ 6 - 0
src/core/jobs.c

@@ -90,9 +90,15 @@ void handle_job_termination(job_t j)
  	 * of the task itself */
 	if (task->callback_func)
 	{
+		/* so that we can check whether we are doing blocking calls
+		 * within the callback */
+		set_local_worker_status(STATUS_CALLBACK);
+
 		TRACE_START_CALLBACK(j);
 		task->callback_func(task->callback_arg);
 		TRACE_END_CALLBACK(j);
+
+		set_local_worker_status(STATUS_UNKNOWN);
 	}
 
 	if (!task->detach)

+ 1 - 7
src/core/jobs.h

@@ -30,12 +30,10 @@
 #include <common/timing.h>
 #include <common/list.h>
 #include <common/fxt.h>
-
 #include <core/dependencies/tags.h>
-
 #include <datawizard/datawizard.h>
-
 #include <core/perfmodel/perfmodel.h>
+#include <core/errorcheck.h>
 
 #ifdef USE_CUDA
 #include <cuda.h>
@@ -81,10 +79,6 @@ unsigned enforce_deps_and_schedule(job_t j);
 void handle_job_termination(job_t j);
 size_t job_get_data_size(job_t j);
 
-//int submit_job(job_t j);
-//int submit_prio_job(job_t j);
-//int submit_job_sync(job_t j);
-
 job_t pop_local_task(struct worker_s *worker);
 int push_local_task(struct worker_s *worker, job_t j);
 

+ 3 - 1
src/core/workers.c

@@ -85,6 +85,8 @@ static void init_workers(struct machine_config_s *config)
 		workerarg->local_jobs = job_list_new();
 		pthread_mutex_init(&workerarg->local_jobs_mutex, NULL);
 	
+		workerarg->status = STATUS_INITIALIZING;
+
 		switch (workerarg->arch) {
 #ifdef USE_CPUS
 			case STARPU_CORE_WORKER:
@@ -167,7 +169,7 @@ void set_local_worker_key(struct worker_s *worker)
 	pthread_setspecific(worker_key, worker);
 }
 
-static inline struct worker_s *get_local_worker_key(void)
+struct worker_s *get_local_worker_key(void)
 {
 	return pthread_getspecific(worker_key);
 }

+ 3 - 0
src/core/workers.h

@@ -30,6 +30,7 @@
 #include <core/perfmodel/perfmodel.h>
 #include <core/policies/sched_policy.h>
 #include <core/topology.h>
+#include <core/errorcheck.h>
 
 #include <starpu.h>
 
@@ -78,6 +79,7 @@ struct worker_s {
 	struct job_list_s *terminated_jobs; /* list of pending jobs which were executed */
 	unsigned worker_is_running;
 	unsigned worker_is_initialized;
+	worker_status status; /* what is the worker doing now ? (eg. CALLBACK) */
 	char name[32];
 };
 
@@ -145,6 +147,7 @@ inline void unlock_all_queues_attached_to_node(unsigned node);
 inline void broadcast_all_queues_attached_to_node(unsigned node);
 
 void set_local_worker_key(struct worker_s *worker);
+struct worker_s *get_local_worker_key(void);
 
 struct worker_s *get_worker_struct(unsigned id);
 

+ 4 - 0
src/drivers/core/driver_core.c

@@ -54,6 +54,7 @@ static int execute_job_on_core(job_t j, struct worker_s *core_args)
 	if (calibrate_model || BENCHMARK_COMM)
 		GET_TICK(codelet_start);
 
+	core_args->status = STATUS_EXECUTING;
 	cl_func func = task->cl->core_func;
 	func(task->interface, task->cl_arg);
 
@@ -63,6 +64,7 @@ static int execute_job_on_core(job_t j, struct worker_s *core_args)
 		GET_TICK(codelet_end);
 
 	TRACE_END_CODELET_BODY(j);
+	core_args->status = STATUS_UNKNOWN;
 
 	push_task_output(task, 0);
 
@@ -122,6 +124,8 @@ void *core_worker(void *arg)
 	core_arg->jobq->total_communication_time = 0.0;
 	core_arg->jobq->total_computation_time_error = 0.0;
 	core_arg->jobq->total_job_performed = 0;
+
+	core_arg->status = STATUS_UNKNOWN;
 	
 	TRACE_WORKER_INIT_END
 

+ 5 - 0
src/drivers/cuda/driver_cuda.c

@@ -111,6 +111,7 @@ static int execute_job_on_cuda(job_t j, struct worker_s *args)
 
 	TRACE_START_CODELET_BODY(j);
 
+	args->status = STATUS_EXECUTING;
 	cl_func func = cl->cuda_func;
 	STARPU_ASSERT(func);
 	GET_TICK(codelet_start);
@@ -120,6 +121,8 @@ static int execute_job_on_cuda(job_t j, struct worker_s *args)
 
 	GET_TICK(codelet_end);
 
+	args->status = STATUS_UNKNOWN;
+
 	TRACE_END_CODELET_BODY(j);	
 
 //#ifdef MODEL_DEBUG
@@ -179,6 +182,8 @@ void *cuda_worker(void *arg)
 
 	init_context(devid);
 
+	args->status = STATUS_UNKNOWN;
+
 	/* get the device's name */
 	char devname[128];
 	struct cudaDeviceProp prop;