Parcourir la source

Use latest simgrid git functions to simplify code and get rid of MSG_process_create_with_arguments

Samuel Thibault il y a 5 ans
Parent
commit
20ec45574e
3 fichiers modifiés avec 26 ajouts et 18 suppressions
  1. 1 1
      configure.ac
  2. 9 8
      src/common/thread.c
  3. 16 9
      src/core/simgrid.c

+ 1 - 1
configure.ac

@@ -185,7 +185,7 @@ if test x$enable_simgrid = xyes ; then
 	AC_CHECK_TYPES([smx_actor_t], [AC_DEFINE([STARPU_HAVE_SMX_ACTOR_T], [1], [Define to 1 if you have the smx_actor_t type.])], [], [[#include <simgrid/simix.h>]])
 
 	# Latest functions
-	AC_CHECK_FUNCS([MSG_process_attach sg_actor_attach MSG_zone_get_hosts MSG_process_self_name MSG_process_userdata_init sg_actor_data])
+	AC_CHECK_FUNCS([MSG_process_attach sg_actor_attach sg_actor_init MSG_zone_get_hosts MSG_process_self_name MSG_process_userdata_init sg_actor_data])
 	AC_CHECK_FUNCS([xbt_mutex_try_acquire smpi_process_set_user_data sg_zone_get_by_name sg_link_name sg_host_route sg_host_self sg_host_speed simcall_process_create sg_config_continue_after_help])
 	AC_CHECK_FUNCS([xbt_barrier_init], [AC_DEFINE([STARPU_SIMGRID_HAVE_XBT_BARRIER_INIT], [1], [Define to 1 if you have the `xbt_barrier_init' function.])])
 	AC_CHECK_FUNCS([sg_actor_sleep_for sg_actor_self sg_actor_ref sg_host_get_properties sg_host_send_to sg_cfg_set_int sg_actor_self_execute simgrid_get_clock])

+ 9 - 8
src/common/thread.c

@@ -85,13 +85,18 @@ int starpu_pthread_create_on(char *name, starpu_pthread_t *thread, const starpu_
 #else
 		host = MSG_get_host_by_name("MAIN");
 #endif
+
 	void *tsd;
-#ifdef HAVE_SG_ACTOR_DATA
-	tsd = NULL;
-#else
 	_STARPU_CALLOC(tsd, MAX_TSD+1, sizeof(void*));
-#endif
+
+#ifdef HAVE_SG_ACTOR_INIT
+	*thread= sg_actor_init(name, host);
+	sg_actor_data_set(*thread, tsd);
+	sg_actor_start(*thread, _starpu_simgrid_thread_start, 2, _args);
+#else
 	*thread = MSG_process_create_with_arguments(name, _starpu_simgrid_thread_start, tsd, host, 2, _args);
+#endif
+
 #if SIMGRID_VERSION >= 31500 && SIMGRID_VERSION != 31559
 #  ifdef HAVE_SG_ACTOR_REF
 	sg_actor_ref(*thread);
@@ -306,10 +311,6 @@ int starpu_pthread_setspecific(starpu_pthread_key_t key, const void *pointer)
 	void **array;
 #ifdef HAVE_SG_ACTOR_DATA
 	array = sg_actor_data(sg_actor_self());
-	if (!array) {
-		_STARPU_CALLOC(array, MAX_TSD + 1, sizeof(void*));
-		sg_actor_data_set(sg_actor_self(), array);
-	}
 #else
 #if defined(HAVE_SMPI_PROCESS_SET_USER_DATA) || defined(smpi_process_get_user_data)
 #if defined(HAVE_MSG_PROCESS_SELF_NAME) || defined(MSG_process_self_name)

+ 16 - 9
src/core/simgrid.c

@@ -409,18 +409,18 @@ void _starpu_simgrid_init_early(int *argc STARPU_ATTRIBUTE_UNUSED, char ***argv
 		SIMIX_set_maestro(maestro, NULL);
 		/* Initialize simgrid */
 		_starpu_start_simgrid(argc, *argv);
+
 		/* And attach the main thread to the main simgrid process */
 		void **tsd;
-#ifdef HAVE_SG_ACTOR_DATA
-		tsd = NULL;
-#else
 		_STARPU_CALLOC(tsd, MAX_TSD+1, sizeof(void*));
-#endif
+
 #ifdef HAVE_SG_ACTOR_ATTACH
-		sg_actor_attach("main", tsd, _starpu_simgrid_get_host_by_name("MAIN"), NULL);
+		sg_actor_t actor = sg_actor_attach("main", tsd, _starpu_simgrid_get_host_by_name("MAIN"), NULL);
+		sg_actor_data_set(actor, tsd);
 #else
 		MSG_process_attach("main", tsd, _starpu_simgrid_get_host_by_name("MAIN"), NULL);
 #endif
+
 		/* We initialized through MSG_process_attach */
 		simgrid_started = 3;
 	}
@@ -442,7 +442,11 @@ void _starpu_simgrid_init_early(int *argc STARPU_ATTRIBUTE_UNUSED, char ***argv
 #endif
 		void **tsd;
 		_STARPU_CALLOC(tsd, MAX_TSD+1, sizeof(void*));
+#ifdef HAVE_SG_ACTOR_DATA
+		sg_actor_data_set(sg_actor_self(), tsd);
+#else
 		smpi_process_set_user_data(tsd);
+#endif
 	}
 	unsigned i;
 	for (i = 0; i < STARPU_MAXNODES; i++)
@@ -1106,12 +1110,15 @@ _starpu_simgrid_thread_start(int argc STARPU_ATTRIBUTE_UNUSED, char *argv[])
 starpu_pthread_t _starpu_simgrid_actor_create(const char *name, xbt_main_func_t code, starpu_sg_host_t host, int argc, char *argv[])
 {
 	void **tsd;
-#ifdef HAVE_SG_ACTOR_DATA
-	tsd = NULL;
-#else
 	_STARPU_CALLOC(tsd, MAX_TSD+1, sizeof(void*));
-#endif
+#ifdef HAVE_SG_ACTOR_INIT
+	starpu_pthread_t actor = sg_actor_init(name, host);
+	sg_actor_data_set(actor, tsd);
+	sg_actor_start(actor, code, argc, argv);
+	return actor;
+#else
 	return MSG_process_create_with_arguments(name, code, tsd, host, argc, argv);
+#endif
 }
 
 starpu_sg_host_t _starpu_simgrid_get_memnode_host(unsigned node)