Skip to content

Commit

Permalink
session
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Applencourt committed Jul 25, 2024
1 parent 27d7a2d commit 62b4fe2
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions xprof/sync_daemon_mpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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));

Expand All @@ -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;
Expand Down

0 comments on commit 62b4fe2

Please sign in to comment.