Pārlūkot izejas kodu

mic: generic lookup

Thibaud Lambert 12 gadi atpakaļ
vecāks
revīzija
2429a37512

+ 8 - 0
src/drivers/mic/driver_mic_sink.c

@@ -16,6 +16,7 @@
 
 
 #include <errno.h>
+#include <dlfcn.h>
 
 #include <common/COISysInfo_common.h>
 
@@ -202,3 +203,10 @@ void _starpu_mic_sink_bind_thread(const struct _starpu_mp_node *mp_node STARPU_A
 
 	pthread_setaffinity_np(((pthread_t*)mp_node->thread_table)[coreid],sizeof(cpu_set_t),&cpuset);
 }
+
+void (*_starpu_mic_sink_lookup (const struct _starpu_mp_node * node STARPU_ATTRIBUTE_UNUSED, char* func_name))(void)
+{
+	void *dl_handle = dlopen(NULL, RTLD_NOW);
+	return dlsym(dl_handle, func_name);
+}
+

+ 4 - 0
src/drivers/mic/driver_mic_sink.h

@@ -40,6 +40,10 @@ void _starpu_mic_sink_deinit(struct _starpu_mp_node *node);
 void _starpu_mic_sink_allocate(const struct _starpu_mp_node *mp_node, void *arg, int arg_size);
 void _starpu_mic_sink_free(const struct _starpu_mp_node *mp_node STARPU_ATTRIBUTE_UNUSED, void *arg, int arg_size);
 void _starpu_mic_sink_bind_thread(const struct _starpu_mp_node *mp_node STARPU_ATTRIBUTE_UNUSED, int coreid, int * core_table, int nb_core);
+
+void (*_starpu_mic_sink_lookup (const struct _starpu_mp_node * node STARPU_ATTRIBUTE_UNUSED,
+			char* func_name))(void);
+
 #endif /* STARPU_USE_MIC */
 
 

+ 4 - 0
src/drivers/mp_common/mp_common.c

@@ -63,6 +63,7 @@ _starpu_mp_common_node_create(enum _starpu_mp_node_kind node_kind,
 		node->dt_recv = _starpu_mic_common_dt_recv;
 
 		node->get_kernel_from_job =_starpu_mic_src_get_kernel_from_job;
+		node->lookup = NULL;
 		node->bind_thread = NULL;
 		node->execute = NULL;
 		node->allocate = NULL;
@@ -86,6 +87,7 @@ _starpu_mp_common_node_create(enum _starpu_mp_node_kind node_kind,
 		node->dt_recv = _starpu_mic_common_dt_recv;
 
 		node->get_kernel_from_job = NULL;
+		node->lookup = _starpu_mic_sink_lookup;
 		node->bind_thread = _starpu_mic_sink_bind_thread;
 		node->execute = _starpu_sink_common_execute;
 		node->allocate = _starpu_mic_sink_allocate;
@@ -111,6 +113,7 @@ _starpu_mp_common_node_create(enum _starpu_mp_node_kind node_kind,
 		node->dt_recv_from_device = NULL;
 
 		node->get_kernel_from_job =_starpu_scc_src_get_kernel_from_job;
+		node->lookup = NULL;
 		node->bind_thread = NULL;
 		node->execute = NULL;
 		node->allocate = NULL;
@@ -133,6 +136,7 @@ _starpu_mp_common_node_create(enum _starpu_mp_node_kind node_kind,
 		node->dt_recv_from_device = _starpu_scc_sink_recv_from_device;
 
 		node->get_kernel_from_job = NULL;
+		node->lookup = _starpu_scc_sink_lookup;
 		node->bind_thread = _starpu_scc_sink_bind_thread;
 		node->execute = _starpu_scc_sink_execute;
 		node->allocate = _starpu_sink_common_allocate;

+ 1 - 0
src/drivers/mp_common/mp_common.h

@@ -201,6 +201,7 @@ struct _starpu_mp_node
 	void (*dt_recv_from_device)(const struct _starpu_mp_node *, int, void *, int);
 
 	void (*(*get_kernel_from_job)(const struct _starpu_mp_node *,struct _starpu_job *))(void);
+	void (*(*lookup)(const struct _starpu_mp_node *, char* ))(void);
 	void (*bind_thread)(const struct _starpu_mp_node *, int,int *,int);
 	void (*execute)(struct _starpu_mp_node *, void *, int);
 	void (*allocate)(const struct _starpu_mp_node *, void *, int);

+ 2 - 5
src/drivers/mp_common/sink_common.c

@@ -15,8 +15,6 @@
  */
 
 
-#include <dlfcn.h>
-
 #include <starpu.h>
 #include <common/config.h>
 #include <common/utils.h>
@@ -68,8 +66,7 @@ static void _starpu_sink_common_lookup(const struct _starpu_mp_node *node,
 				       char *func_name)
 {
 	void (*func)(void);
-	void *dl_handle = dlopen(NULL, RTLD_NOW);
-	func = dlsym(dl_handle, func_name);
+	func = node->lookup(node,func_name);
 	
 	//_STARPU_DEBUG("Looked up %s, got %p\n", func_name, func);
 
@@ -356,7 +353,7 @@ static void _starpu_sink_common_execute_thread(struct _starpu_mp_node *node, str
 /* Search for the mp_barrier correspondind to the specified combined worker 
  * and create it if it doesn't exist
  */
-struct mp_barrier * _starpu_sink_common_get_barrier(struct _starpu_mp_node * node, int cb_workerid, int cb_workersize)
+static struct mp_barrier * _starpu_sink_common_get_barrier(struct _starpu_mp_node * node, int cb_workerid, int cb_workersize)
 {
 	struct mp_barrier * b = NULL;
 	pthread_mutex_lock(&node->barrier_mutex);

+ 14 - 16
src/drivers/mp_common/source_common.c

@@ -152,10 +152,9 @@ static void _starpu_src_common_recv_async(struct _starpu_mp_node * baseworker_no
 }
 
 
-	int
-_starpu_src_common_sink_nbcores (const struct _starpu_mp_node *node, int *buf)
+/* Send a request to the sink NODE for the number of cores on it. */
+int _starpu_src_common_sink_nbcores (const struct _starpu_mp_node *node, int *buf)
 {
-	// Send a request to the sink NODE for the number of cores on it.
 
 	enum _starpu_mp_command answer;
 	void *arg;
@@ -608,21 +607,20 @@ void _starpu_src_common_worker(struct _starpu_worker_set * worker_set,
 					j = _starpu_get_job_associated_to_task(tasks[i]);
 					_starpu_set_local_worker_key(&worker_set->workers[i]);
 					res =  _starpu_src_common_execute(j, &worker_set->workers[i], mp_node);
-					if (res)
+					switch (res)
 					{
-						switch (res)
-						{
-							case -EAGAIN:
-								_STARPU_DISP("ouch, Xeon Phi could not actually run task %p, putting it back...\n", tasks[i]);
-								_starpu_push_task_to_workers(tasks[i]);
-								STARPU_ABORT();
-								continue;
-								break;
-							default:
-								STARPU_ASSERT(0);
-						}
+						case 0:
+							/* The task task has been launched with no error */
+							break;
+						case -EAGAIN:
+							_STARPU_DISP("ouch, Xeon Phi could not actually run task %p, putting it back...\n", tasks[i]);
+							_starpu_push_task_to_workers(tasks[i]);
+							STARPU_ABORT();
+							continue;
+							break;
+						default:
+							STARPU_ASSERT(0);
 					}
-					//_STARPU_DEBUG(" exec fin\n");
 				}
 			}
 		}

+ 8 - 0
src/drivers/scc/driver_scc_sink.c

@@ -16,6 +16,7 @@
 
 
 #include <RCCE.h>
+#include <dlfcn.h>
 
 #include <datawizard/interfaces/data_interface.h>
 #include <drivers/mp_common/sink_common.h>
@@ -144,3 +145,10 @@ void _starpu_scc_sink_execute(const struct _starpu_mp_node *node, void *arg, int
 
 	_starpu_sink_common_execute(node, arg, arg_size);
 }
+
+void (*_starpu_scc_sink_lookup (const struct _starpu_mp_node * node STARPU_ATTRIBUTE_UNUSED, char* func_name))(void)
+{
+	void *dl_handle = dlopen(NULL, RTLD_NOW);
+	return dlsym(dl_handle, func_name);
+}
+

+ 2 - 0
src/drivers/scc/driver_scc_sink.h

@@ -34,6 +34,8 @@ void _starpu_scc_sink_bind_thread(const struct _starpu_mp_node *mp_node STARPU_A
 
 void _starpu_scc_sink_execute(const struct _starpu_mp_node *node, void *arg, int arg_size);
 
+void (*_starpu_scc_sink_lookup (const struct _starpu_mp_node * node STARPU_ATTRIBUTE_UNUSED, char* func_name))(void);
+
 #endif /* STARPU_USE_SCC */