From 62b4fe2b67d42001d52f77c28dc77ec8e090b3e3 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 25 Jul 2024 21:17:12 +0000 Subject: [PATCH] session --- xprof/sync_daemon_mpi.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/xprof/sync_daemon_mpi.c b/xprof/sync_daemon_mpi.c index 601ad2f4..214ba8f8 100644 --- a/xprof/sync_daemon_mpi.c +++ b/xprof/sync_daemon_mpi.c @@ -21,23 +21,24 @@ } \ } while (0) -int MPIX_Init_Session(MPI_Session *lib_shandle, MPI_Comm *lib_comm) { +int MPIX_Init_Session(MPI_Comm *lib_comm) { /* * Create session */ int ret = 0; const char mt_key[] = "thread_level"; const char mt_value[] = "MPI_THREAD_SINGLE"; + MPI_Session lib_shandle = MPI_SESSION_NULL; MPI_Group wgroup = MPI_GROUP_NULL; MPI_Info sinfo = MPI_INFO_NULL; MPI_Info tinfo = MPI_INFO_NULL; MPI_Info_create(&sinfo); MPI_Info_set(sinfo, mt_key, mt_value); - CHECK_MPI(MPI_Session_init(sinfo, MPI_ERRORS_RETURN, lib_shandle)); + CHECK_MPI(MPI_Session_init(sinfo, MPI_ERRORS_RETURN, &lib_shandle)); /* * check we got thread support level foo library needs */ - CHECK_MPI(MPI_Session_get_info(*lib_shandle, &tinfo)); + CHECK_MPI(MPI_Session_get_info(lib_shandle, &tinfo)); { char out_value[100] = {0}; int valuelen = sizeof(out_value); @@ -54,7 +55,7 @@ int MPIX_Init_Session(MPI_Session *lib_shandle, MPI_Comm *lib_comm) { */ { const char pset_name[] = "mpi://WORLD"; - CHECK_MPI(MPI_Group_from_session_pset(*lib_shandle, pset_name, &wgroup)); + CHECK_MPI(MPI_Group_from_session_pset(lib_shandle, pset_name, &wgroup)); } /* * get a communicator @@ -71,8 +72,9 @@ int MPIX_Init_Session(MPI_Session *lib_shandle, MPI_Comm *lib_comm) { MPI_Info_free(&sinfo); if (tinfo != MPI_INFO_NULL) MPI_Info_free(&tinfo); - if (ret != 0) - MPI_Session_finalize(lib_shandle); + if (lib_shandle != MPI_SESSION_NULL) { + MPI_Session_finalize(&lib_shandle); + } return ret; } @@ -131,11 +133,10 @@ int main(int argc, char **argv) { int ret = 0; int parent_pid = 0; // World Session and Communicator - MPI_Session lib_shandle = MPI_SESSION_NULL; MPI_Comm MPI_COMM_WORLD_THAPI = MPI_COMM_NULL; MPI_Comm MPI_COMM_NODE = MPI_COMM_NULL; - CHECK_MPI(MPIX_Init_Session(&lib_shandle, &MPI_COMM_WORLD_THAPI)); + CHECK_MPI(MPIX_Init_Session(&MPI_COMM_WORLD_THAPI)); CHECK_MPI(MPI_Comm_split_type(MPI_COMM_WORLD_THAPI, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &MPI_COMM_NODE)); @@ -147,8 +148,6 @@ int main(int argc, char **argv) { MPI_Comm_free(&MPI_COMM_NODE); if (MPI_COMM_WORLD_THAPI != MPI_COMM_NULL) MPI_Comm_free(&MPI_COMM_WORLD_THAPI); - if (lib_shandle != MPI_SESSION_NULL) - MPI_Session_finalize(&lib_shandle); if (parent_pid != 0) kill(parent_pid, RT_SIGNAL_READY); return ret;