Browse Source

Fix simgrid-mpi with simgrid 3.22.x: the main thread should be using the smpi tsd instead of the MSG tsd

Samuel Thibault 6 years ago
parent
commit
728265bead
2 changed files with 10 additions and 4 deletions
  1. 3 3
      src/common/thread.c
  2. 7 1
      src/core/simgrid.c

+ 3 - 3
src/common/thread.c

@@ -2,7 +2,7 @@
  *
  *
  * Copyright (C) 2013,2015,2017                           Inria
  * Copyright (C) 2013,2015,2017                           Inria
  * Copyright (C) 2010-2017                                CNRS
  * Copyright (C) 2010-2017                                CNRS
- * Copyright (C) 2010,2012-2018                           Université de Bordeaux
+ * Copyright (C) 2010,2012-2019                           Université de Bordeaux
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * 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
  * it under the terms of the GNU Lesser General Public License as published by
@@ -259,7 +259,7 @@ int starpu_pthread_setspecific(starpu_pthread_key_t key, const void *pointer)
 	char *end;
 	char *end;
 	/* Test whether it is an MPI rank */
 	/* Test whether it is an MPI rank */
 	strtol(process_name, &end, 10);
 	strtol(process_name, &end, 10);
-	if (!*end || !strcmp(process_name, "wait for mpi transfer"))
+	if (!*end || !strcmp(process_name, "wait for mpi transfer") || !strcmp(process_name, "main"))
 		/* Special-case the SMPI process */
 		/* Special-case the SMPI process */
 		array = smpi_process_get_user_data();
 		array = smpi_process_get_user_data();
 	else
 	else
@@ -281,7 +281,7 @@ void* starpu_pthread_getspecific(starpu_pthread_key_t key)
 	char *end;
 	char *end;
 	/* Test whether it is an MPI rank */
 	/* Test whether it is an MPI rank */
 	strtol(process_name, &end, 10);
 	strtol(process_name, &end, 10);
-	if (!*end || !strcmp(process_name, "wait for mpi transfer"))
+	if (!*end || !strcmp(process_name, "wait for mpi transfer") || !strcmp(process_name, "main"))
 		/* Special-case the SMPI processes */
 		/* Special-case the SMPI processes */
 		array = smpi_process_get_user_data();
 		array = smpi_process_get_user_data();
 	else
 	else

+ 7 - 1
src/core/simgrid.c

@@ -38,6 +38,7 @@
 #ifdef STARPU_HAVE_SIMGRID_HOST_H
 #ifdef STARPU_HAVE_SIMGRID_HOST_H
 #include <simgrid/host.h>
 #include <simgrid/host.h>
 #endif
 #endif
+#include <smpi/smpi.h>
 
 
 #pragma weak starpu_main
 #pragma weak starpu_main
 extern int starpu_main(int argc, char *argv[]);
 extern int starpu_main(int argc, char *argv[]);
@@ -48,6 +49,11 @@ extern int smpi_main(int (*realmain) (int argc, char *argv[]), int argc, char *a
 #pragma weak _starpu_mpi_simgrid_init
 #pragma weak _starpu_mpi_simgrid_init
 extern int _starpu_mpi_simgrid_init(int argc, char *argv[]);
 extern int _starpu_mpi_simgrid_init(int argc, char *argv[]);
 
 
+#pragma weak smpi_process_set_user_data
+#if !HAVE_DECL_SMPI_PROCESS_SET_USER_DATA && !defined(smpi_process_set_user_data)
+extern void smpi_process_set_user_data(void *);
+#endif
+
 /* 1 when MSG_init was done, 2 when initialized through redirected main, 3 when
 /* 1 when MSG_init was done, 2 when initialized through redirected main, 3 when
  * initialized through MSG_process_attach */
  * initialized through MSG_process_attach */
 static int simgrid_started;
 static int simgrid_started;
@@ -396,7 +402,7 @@ void _starpu_simgrid_init_early(int *argc STARPU_ATTRIBUTE_UNUSED, char ***argv
 #endif
 #endif
 		void **tsd;
 		void **tsd;
 		_STARPU_CALLOC(tsd, MAX_TSD+1, sizeof(void*));
 		_STARPU_CALLOC(tsd, MAX_TSD+1, sizeof(void*));
-		MSG_process_set_data(MSG_process_self(), tsd);
+		smpi_process_set_user_data(tsd);
 	}
 	}
 	unsigned i;
 	unsigned i;
 	for (i = 0; i < STARPU_MAXNODES; i++)
 	for (i = 0; i < STARPU_MAXNODES; i++)