Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
intercept getpid call in SMPI, to provide internal PID instead of same of for all...
authorAugustin Degomme <adegomme@users.noreply.github.com>
Tue, 9 Aug 2022 14:00:13 +0000 (16:00 +0200)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Tue, 9 Aug 2022 14:29:43 +0000 (16:29 +0200)
include/smpi/smpi_helpers.h
include/smpi/smpi_helpers_internal.h
src/smpi/internals/smpi_bench.cpp

index 5317dee..d5a0100 100644 (file)
@@ -41,4 +41,5 @@
 
 #define exit(x) smpi_exit(x)
 
+#define getpid smpi_getpid
 #endif
index c089449..26f2148 100644 (file)
@@ -12,6 +12,7 @@
 #include <unistd.h>
 
 #include <sys/time.h>
+#include <sys/types.h>
 #if _POSIX_TIMERS
 #include <time.h>
 #endif
@@ -44,6 +45,8 @@ void* smpi_shared_malloc_intercept(size_t size, const char* file, int line);
 void* smpi_shared_calloc_intercept(size_t num_elm, size_t elem_size, const char* file, int line);
 void* smpi_shared_realloc_intercept(void* data, size_t size, const char* file, int line);
 void smpi_shared_free(void* data);
+
+pid_t smpi_getpid();
 #ifdef __cplusplus
 [[noreturn]] // c++11
 #else
index f4687af..e398719 100644 (file)
@@ -483,3 +483,7 @@ int smpi_getopt (int argc,  char *const *argv,  const char *options)
     smpi_process()->set_optind(optind);
   return ret;
 }
+
+pid_t smpi_getpid(){
+  return static_cast<pid_t>(simgrid::s4u::this_actor::get_pid());
+}