|
@@ -0,0 +1,110 @@
|
|
|
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
|
|
|
+ *
|
|
|
+ * Copyright (C) 2012-2017 Université de Bordeaux
|
|
|
+ * Copyright (C) 2016, 2017 Inria
|
|
|
+ * Copyright (C) 2016, 2017 CNRS
|
|
|
+ *
|
|
|
+ * StarPU is free software; you can redistribute it and/or modify
|
|
|
+ * it under the terms of the GNU Lesser General Public License as published by
|
|
|
+ * the Free Software Foundation; either version 2.1 of the License, or (at
|
|
|
+ * your option) any later version.
|
|
|
+ *
|
|
|
+ * StarPU is distributed in the hope that it will be useful, but
|
|
|
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
+ *
|
|
|
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
|
|
|
+ */
|
|
|
+
|
|
|
+#include <starpu.h>
|
|
|
+#include <common/config.h>
|
|
|
+
|
|
|
+#ifdef STARPU_SIMGRID
|
|
|
+#include <simgrid/msg.h>
|
|
|
+#include <simgrid/simix.h>
|
|
|
+#ifdef STARPU_HAVE_SIMGRID_HOST_H
|
|
|
+#include <simgrid/host.h>
|
|
|
+#endif
|
|
|
+
|
|
|
+/* thread_create function which implements inheritence of MPI privatization */
|
|
|
+/* See https://github.com/simgrid/simgrid/issues/139 */
|
|
|
+
|
|
|
+typedef struct
|
|
|
+{
|
|
|
+ void_f_pvoid_t code;
|
|
|
+ void *userparam;
|
|
|
+ void *father_data;
|
|
|
+} thread_data_t;
|
|
|
+
|
|
|
+static int _starpu_simgrid_xbt_thread_create_wrapper(int argc STARPU_ATTRIBUTE_UNUSED, char *argv[] STARPU_ATTRIBUTE_UNUSED)
|
|
|
+{
|
|
|
+ /* FIXME: Ugly work-around for bug in simgrid: the MPI context is not properly set at MSG process startup */
|
|
|
+ MSG_process_sleep(0.000001);
|
|
|
+
|
|
|
+#ifdef HAVE_SMX_ACTOR_T
|
|
|
+ smx_actor_t
|
|
|
+#else
|
|
|
+ smx_process_t
|
|
|
+#endif
|
|
|
+ self = SIMIX_process_self();
|
|
|
+#if SIMGRID_VERSION_MAJOR < 3 || (SIMGRID_VERSION_MAJOR == 3 && SIMGRID_VERSION_MINOR < 13)
|
|
|
+ thread_data_t *t = (thread_data_t *) SIMIX_process_self_get_data(self);
|
|
|
+#else
|
|
|
+ thread_data_t *t = (thread_data_t *) SIMIX_process_self_get_data();
|
|
|
+#endif
|
|
|
+ simcall_process_set_data(self, t->father_data);
|
|
|
+ t->code(t->userparam);
|
|
|
+ simcall_process_set_data(self, NULL);
|
|
|
+ free(t);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+void _starpu_simgrid_xbt_thread_create(const char *name, void_f_pvoid_t code, void *param)
|
|
|
+{
|
|
|
+#ifdef HAVE_SIMCALL_PROCESS_CREATE
|
|
|
+#ifdef HAVE_SMX_ACTOR_T
|
|
|
+ smx_actor_t process STARPU_ATTRIBUTE_UNUSED;
|
|
|
+#else
|
|
|
+ smx_process_t process STARPU_ATTRIBUTE_UNUSED;
|
|
|
+#endif
|
|
|
+ thread_data_t *res = (thread_data_t *) malloc(sizeof(thread_data_t));
|
|
|
+ res->userparam = param;
|
|
|
+ res->code = code;
|
|
|
+#if SIMGRID_VERSION_MAJOR < 3 || (SIMGRID_VERSION_MAJOR == 3 && SIMGRID_VERSION_MINOR < 13)
|
|
|
+ res->father_data = SIMIX_process_self_get_data(SIMIX_process_self());
|
|
|
+#else
|
|
|
+ res->father_data = SIMIX_process_self_get_data();
|
|
|
+#endif
|
|
|
+
|
|
|
+#if SIMGRID_VERSION_MAJOR < 3 || (SIMGRID_VERSION_MAJOR == 3 && SIMGRID_VERSION_MINOR < 12)
|
|
|
+ simcall_process_create(&process,
|
|
|
+#else
|
|
|
+ process = simcall_process_create(
|
|
|
+#endif
|
|
|
+ name,
|
|
|
+ _starpu_simgrid_xbt_thread_create_wrapper, res,
|
|
|
+#if SIMGRID_VERSION_MAJOR < 3 || (SIMGRID_VERSION_MAJOR == 3 && SIMGRID_VERSION_MINOR < 14)
|
|
|
+ SIMIX_host_self_get_name(),
|
|
|
+#else
|
|
|
+# ifdef HAVE_SG_HOST_SELF
|
|
|
+ sg_host_self(),
|
|
|
+# else
|
|
|
+ SIMIX_host_self(),
|
|
|
+# endif
|
|
|
+#endif
|
|
|
+#if SIMGRID_VERSION_MAJOR < 3 || (SIMGRID_VERSION_MAJOR == 3 && SIMGRID_VERSION_MINOR < 15)
|
|
|
+ -1.0,
|
|
|
+#endif
|
|
|
+ 0, NULL,
|
|
|
+ /*props */ NULL
|
|
|
+#if SIMGRID_VERSION_MAJOR < 3 || (SIMGRID_VERSION_MAJOR == 3 && SIMGRID_VERSION_MINOR < 15)
|
|
|
+ , 0
|
|
|
+#endif
|
|
|
+ );
|
|
|
+#else
|
|
|
+ STARPU_ABORT_MSG("Can't run StarPU-Simgrid-MPI with a Simgrid version which does not provide simcall_process_create and does not fix https://github.com/simgrid/simgrid/issues/139 , sorry.");
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
+#endif
|