Skip to content

Commit bc64fb4

Browse files
committed
WIP: Add session info APIs and fix some bugs
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
1 parent c5490fb commit bc64fb4

File tree

10 files changed

+271
-37
lines changed

10 files changed

+271
-37
lines changed

ompi/include/mpi.h.in

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,11 @@ OMPI_DECLSPEC extern MPI_Fint *MPI_F_STATUSES_IGNORE;
11741174
#define PMPI_Aint_add(base, disp) MPI_Aint_add(base, disp)
11751175
#define PMPI_Aint_diff(addr1, addr2) MPI_Aint_diff(addr1, addr2)
11761176

1177+
/*
1178+
* Predefined info keys
1179+
*/
1180+
#define MPI_INFO_KEY_SESSION_PSET_SIZE "size"
1181+
11771182
/*
11781183
* MPI API
11791184
*/
@@ -1702,13 +1707,16 @@ OMPI_DECLSPEC int MPI_Session_finalize (MPI_Session *session);
17021707
OMPI_DECLSPEC int MPI_Session_free_keyval(int *session_keyval);
17031708
OMPI_DECLSPEC int MPI_Session_get_attr (MPI_Session datatype, int session_keyval,
17041709
void *attribute_val, int *flag);
1710+
OMPI_DECLSPEC int MPI_Session_get_info (MPI_Session session, MPI_Info *info_used);
17051711
OMPI_DECLSPEC int MPI_Session_get_num_psets (MPI_Session session, int *npset_names);
1706-
OMPI_DECLSPEC int MPI_Session_get_psetlen (MPI_Session session, int n, int *pset_name_len);
17071712
OMPI_DECLSPEC int MPI_Session_get_nth_pset (MPI_Session session, int n, int len, char *pset_name);
1713+
OMPI_DECLSPEC int MPI_Session_get_pset_info (MPI_Session session, const char *pset_name, MPI_Info *info_used);
1714+
OMPI_DECLSPEC int MPI_Session_get_psetlen (MPI_Session session, int n, int *pset_name_len);
17081715
OMPI_DECLSPEC int MPI_Session_init (MPI_Flags *flags, MPI_Info info, MPI_Errhandler errhandler,
17091716
MPI_Session *session);
17101717
OMPI_DECLSPEC MPI_Session MPI_Session_f2c (MPI_Fint session);
17111718
OMPI_DECLSPEC int MPI_Session_set_attr (MPI_Session session, int session_keyval, void *attribute_val);
1719+
OMPI_DECLSPEC int MPI_Session_set_info (MPI_Session session, MPI_Info info);
17121720
OMPI_DECLSPEC int MPI_Ssend_init(const void *buf, int count, MPI_Datatype datatype,
17131721
int dest, int tag, MPI_Comm comm,
17141722
MPI_Request *request);
@@ -2412,13 +2420,16 @@ OMPI_DECLSPEC int PMPI_Session_finalize (MPI_Session *session);
24122420
OMPI_DECLSPEC int PMPI_Session_free_keyval(int *session_keyval);
24132421
OMPI_DECLSPEC int PMPI_Session_get_attr (MPI_Session datatype, int session_keyval,
24142422
void *attribute_val, int *flag);
2423+
OMPI_DECLSPEC int PMPI_Session_get_info (MPI_Session session, MPI_Info *info_used);
24152424
OMPI_DECLSPEC int PMPI_Session_get_num_psets (MPI_Session session, int *npset_names);
24162425
OMPI_DECLSPEC int PMPI_Session_get_nth_pset (MPI_Session session, int n, int len, char *pset_name);
2426+
OMPI_DECLSPEC int PMPI_Session_get_pset_info (MPI_Session session, const char *pset_name, MPI_Info *info_used);
24172427
OMPI_DECLSPEC int PMPI_Session_get_psetlen (MPI_Session session, int n, int *pset_name_len);
24182428
OMPI_DECLSPEC int PMPI_Session_init (MPI_Flags *flags, MPI_Info info, MPI_Errhandler errhandler,
24192429
MPI_Session *session);
24202430
OMPI_DECLSPEC MPI_Session PMPI_Session_f2c (MPI_Fint session);
24212431
OMPI_DECLSPEC int PMPI_Session_set_attr (MPI_Session session, int session_keyval, void *attribute_val);
2432+
OMPI_DECLSPEC int PMPI_Session_set_info (MPI_Session session, MPI_Info info);
24222433
OMPI_DECLSPEC int PMPI_Ssend_init(const void *buf, int count, MPI_Datatype datatype,
24232434
int dest, int tag, MPI_Comm comm,
24242435
MPI_Request *request);

ompi/instance/instance.c

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ static int ompi_instance_group_pmix_pset (ompi_instance_t *instance, const char
972972
return OMPI_ERR_OUT_OF_RESOURCE;
973973
}
974974

975-
for (size_t i = 0 ; i < size ; ++i) {
975+
for (size_t i = 0 ; i < ompi_process_info.num_procs ; ++i) {
976976
opal_process_name_t name = {.vpid = i, .jobid = OMPI_PROC_MY_NAME->jobid};
977977
opal_value_t *val = NULL;
978978
int ret;
@@ -1020,17 +1020,83 @@ static int ompi_instance_group_pmix_pset (ompi_instance_t *instance, const char
10201020
return OMPI_SUCCESS;
10211021
}
10221022

1023+
static int ompi_instance_get_pmix_pset_size (ompi_instance_t *instance, const char *pset_name, size_t *size_out)
1024+
{
1025+
size_t size = 0;
1026+
1027+
for (size_t i = 0 ; i < ompi_process_info.num_procs ; ++i) {
1028+
opal_process_name_t name = {.vpid = i, .jobid = OMPI_PROC_MY_NAME->jobid};
1029+
opal_value_t *val = NULL;
1030+
int ret;
1031+
1032+
ret = opal_pmix.get (&name, OPAL_PMIX_PSET_NAME, NULL, &val);
1033+
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
1034+
return ret;
1035+
}
1036+
1037+
size += (0 == strcmp (pset_name, val->data.string));
1038+
OBJ_RELEASE(val);
1039+
1040+
++size;
1041+
}
1042+
1043+
*size_out = size;
1044+
1045+
return OMPI_SUCCESS;
1046+
}
1047+
10231048
int ompi_group_from_pset (ompi_instance_t *instance, const char *pset_name, ompi_group_t **group_out)
10241049
{
1025-
if (0 == strcmp (pset_name, "mpi://world")) {
1050+
if (0 == strncmp (pset_name, "mpi://", 6)) {
1051+
pset_name += 6;
1052+
if (0 == strcmp (pset_name, "world")) {
10261053
return ompi_instance_group_world (instance, group_out);
1054+
}
1055+
if (0 == strcmp (pset_name, "self")) {
1056+
return ompi_instance_group_self (instance, group_out);
1057+
}
1058+
if (0 == strcmp (pset_name, "shared")) {
1059+
return ompi_instance_group_shared (instance, group_out);
1060+
}
1061+
}
1062+
1063+
return ompi_instance_group_pmix_pset (instance, pset_name, group_out);
1064+
}
1065+
1066+
int ompi_instance_get_pset_info (ompi_instance_t *instance, const char *pset_name, opal_info_t **info_used)
1067+
{
1068+
ompi_info_t *info = ompi_info_allocate ();
1069+
char tmp[16];
1070+
size_t size;
1071+
int ret;
1072+
1073+
*info_used = (opal_info_t *) MPI_INFO_NULL;
1074+
1075+
if (OPAL_UNLIKELY(NULL == info)) {
1076+
return OMPI_ERR_OUT_OF_RESOURCE;
10271077
}
1028-
if (0 == strcmp (pset_name, "mpi://self")) {
1029-
return ompi_instance_group_self (instance, group_out);
1078+
1079+
if (0 == strncmp (pset_name, "mpi://", 6)) {
1080+
pset_name += 6;
1081+
if (0 == strcmp (pset_name, "world")) {
1082+
size = ompi_process_info.num_procs;
1083+
} else if (0 == strcmp (pset_name, "self")) {
1084+
size = 1;
1085+
} else if (0 == strcmp (pset_name, "shared")) {
1086+
size = ompi_process_info.num_local_peers + 1;
1087+
}
1088+
} else {
1089+
ompi_instance_get_pmix_pset_size (instance, pset_name, &size);
10301090
}
1031-
if (0 == strcmp (pset_name, "mpi://shared")) {
1032-
return ompi_instance_group_shared (instance, group_out);
1091+
1092+
snprintf (tmp, 16, "%" PRIsize_t, size);
1093+
ret = opal_info_set (&info->super, MPI_INFO_KEY_SESSION_PSET_SIZE, tmp);
1094+
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
1095+
ompi_info_free (&info);
1096+
return ret;
10331097
}
10341098

1035-
return ompi_instance_group_pmix_pset (instance, pset_name, group_out);
1099+
*info_used = &info->super;
1100+
1101+
return OMPI_SUCCESS;
10361102
}

ompi/instance/instance.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ OMPI_DECLSPEC int ompi_group_from_pset (ompi_instance_t *instance, const char *p
148148
OMPI_DECLSPEC int ompi_instance_get_num_psets (ompi_instance_t *instance, int *npset_names);
149149
OMPI_DECLSPEC int ompi_instance_get_psetlen (ompi_instance_t *instance, int n, int *pset_name_len);
150150
OMPI_DECLSPEC int ompi_instance_get_nth_pset (ompi_instance_t *instance, int n, int len, char *pset_name);
151+
OMPI_DECLSPEC int ompi_instance_get_pset_info (ompi_instance_t *instance, const char *pset_name, opal_info_t **info_used);
151152

152153
/**
153154
* @brief current number of active instances

ompi/mca/coll/lazy/coll_lazy.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ int mca_coll_lazy_barrier (struct ompi_communicator_t *comm, mca_coll_base_modul
5656

5757
typedef struct mca_coll_lazy_module_t {
5858
mca_coll_base_module_t super;
59-
60-
pthread_barrier_t pth_barrier;
61-
bool pth_barrier_init;
6259
} mca_coll_lazy_module_t;
6360

6461
OBJ_CLASS_DECLARATION(mca_coll_lazy_module_t);

ompi/mca/coll/lazy/coll_lazy_module.c

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,7 @@
4444
#include "coll_lazy.h"
4545

4646

47-
static void mca_coll_lazy_module_construct(mca_coll_lazy_module_t *module)
48-
{
49-
module->pth_barrier_init = false;
50-
}
51-
52-
static void mca_coll_lazy_module_destruct(mca_coll_lazy_module_t *module)
53-
{
54-
if (module->pth_barrier_init) {
55-
pthread_barrier_destroy (&module->pth_barrier);
56-
module->pth_barrier_init = false;
57-
}
58-
}
59-
60-
OBJ_CLASS_INSTANCE(mca_coll_lazy_module_t, mca_coll_base_module_t,
61-
mca_coll_lazy_module_construct,
62-
mca_coll_lazy_module_destruct);
47+
OBJ_CLASS_INSTANCE(mca_coll_lazy_module_t, mca_coll_base_module_t, NULL, NULL);
6348

6449

6550
/*
@@ -111,15 +96,5 @@ mca_coll_base_module_t *mca_coll_lazy_comm_query (ompi_communicator_t *comm, int
11196
*/
11297
int mca_coll_lazy_module_enable (mca_coll_base_module_t *module, ompi_communicator_t *comm)
11398
{
114-
mca_coll_lazy_module_t *lazy_module = (mca_coll_lazy_module_t *) module;
115-
int rc;
116-
117-
rc = pthread_barrier_init (&lazy_module->pth_barrier, NULL, comm->c_local_group->grp_proc_count);
118-
if (0 != rc) {
119-
return OMPI_ERR_NOT_FOUND;
120-
}
121-
122-
lazy_module->pth_barrier_init = true;
123-
12499
return OMPI_SUCCESS;
125100
}

ompi/mpi/c/Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,14 +347,17 @@ libmpi_c_mpi_la_SOURCES = \
347347
session_create_keyval.c \
348348
session_delete_attr.c \
349349
session_get_attr.c \
350+
session_get_info.c \
350351
session_get_num_psets.c \
351352
session_get_nth_pset.c \
353+
session_get_pset_info.c \
352354
session_get_psetlen.c \
353355
session_init.c \
354356
session_f2c.c \
355357
session_finalize.c \
356358
session_free_keyval.c \
357359
session_set_attr.c \
360+
session_set_info.c \
358361
ssend_init.c \
359362
ssend.c \
360363
start.c \

ompi/mpi/c/profile/Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,17 @@ nodist_libmpi_c_pmpi_la_SOURCES = \
327327
psession_create_keyval.c \
328328
psession_delete_attr.c \
329329
psession_get_attr.c \
330+
psession_get_info.c \
330331
psession_get_num_psets.c \
331332
psession_get_nth_pset.c \
333+
psession_get_pset_info.c \
332334
psession_get_psetlen.c \
333335
psession_init.c \
334336
psession_f2c.c \
335337
psession_finalize.c \
336338
psession_free_keyval.c \
337339
psession_set_attr.c \
340+
psession_set_info.c \
338341
pssend_init.c \
339342
pssend.c \
340343
pstart.c \

ompi/mpi/c/session_get_info.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
4+
* Copyright (c) 2015 Research Organization for Information Science
5+
* and Technology (RIST). All rights reserved.
6+
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
7+
* Copyright (c) 2018 Triad National Security, LLC. All rights
8+
* reserved.
9+
* $COPYRIGHT$
10+
*
11+
* Additional copyrights may follow
12+
*
13+
* $HEADER$
14+
*/
15+
16+
#include "ompi_config.h"
17+
18+
#include "ompi/mpi/c/bindings.h"
19+
#include "ompi/runtime/params.h"
20+
#include "ompi/instance/instance.h"
21+
#include "ompi/errhandler/errhandler.h"
22+
#include "ompi/info/info.h"
23+
#include <stdlib.h>
24+
#include <string.h>
25+
26+
#if OMPI_BUILD_MPI_PROFILING
27+
#if OPAL_HAVE_WEAK_SYMBOLS
28+
#pragma weak MPI_Session_get_info = PMPI_Session_get_info
29+
#endif
30+
#define MPI_Session_get_info PMPI_Session_get_info
31+
#endif
32+
33+
static const char FUNC_NAME[] = "MPI_Session_get_info";
34+
35+
36+
int MPI_Session_get_info (MPI_Session session, MPI_Info *info_used)
37+
{
38+
OPAL_CR_NOOP_PROGRESS();
39+
40+
if (MPI_PARAM_CHECK) {
41+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
42+
if (NULL == session || MPI_SESSION_NULL == session) {
43+
return MPI_ERR_ARG;
44+
}
45+
if (NULL == info_used) {
46+
return OMPI_ERRHANDLER_INVOKE (session, MPI_ERR_INFO, FUNC_NAME);
47+
}
48+
}
49+
50+
if (NULL == session->super.s_info) {
51+
/*
52+
* Setup any defaults if MPI_Win_set_info was never called
53+
*/
54+
opal_infosubscribe_change_info (&session->super, &MPI_INFO_NULL->super);
55+
}
56+
57+
58+
*info_used = ompi_info_allocate ();
59+
if (OPAL_UNLIKELY(NULL == *info_used)) {
60+
return OMPI_ERRHANDLER_INVOKE (session, MPI_ERR_NO_MEM, FUNC_NAME);
61+
}
62+
63+
opal_info_t *opal_info_used = &(*info_used)->super;
64+
65+
opal_info_dup_mpistandard (session->super.s_info, &opal_info_used);
66+
67+
return MPI_SUCCESS;
68+
}

ompi/mpi/c/session_get_pset_info.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
4+
* Copyright (c) 2015 Research Organization for Information Science
5+
* and Technology (RIST). All rights reserved.
6+
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
7+
* Copyright (c) 2018 Triad National Security, LLC. All rights
8+
* reserved.
9+
* $COPYRIGHT$
10+
*
11+
* Additional copyrights may follow
12+
*
13+
* $HEADER$
14+
*/
15+
16+
#include "ompi_config.h"
17+
18+
#include "ompi/mpi/c/bindings.h"
19+
#include "ompi/runtime/params.h"
20+
#include "ompi/instance/instance.h"
21+
#include "ompi/errhandler/errhandler.h"
22+
#include "ompi/info/info.h"
23+
#include <stdlib.h>
24+
#include <string.h>
25+
26+
#if OMPI_BUILD_MPI_PROFILING
27+
#if OPAL_HAVE_WEAK_SYMBOLS
28+
#pragma weak MPI_Session_get_pset_info = PMPI_Session_get_pset_info
29+
#endif
30+
#define MPI_Session_get_pset_info PMPI_Session_get_pset_info
31+
#endif
32+
33+
static const char FUNC_NAME[] = "MPI_Session_get_pset_info";
34+
35+
36+
int MPI_Session_get_pset_info (MPI_Session session, const char *pset_name, MPI_Info *info_used)
37+
{
38+
int ret;
39+
40+
OPAL_CR_NOOP_PROGRESS();
41+
42+
if (MPI_PARAM_CHECK) {
43+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
44+
if (NULL == session || MPI_SESSION_NULL == session) {
45+
return MPI_ERR_ARG;
46+
}
47+
if (NULL == info_used) {
48+
return OMPI_ERRHANDLER_INVOKE (session, MPI_ERR_INFO, FUNC_NAME);
49+
}
50+
}
51+
52+
ret = ompi_instance_get_pset_info (session, pset_name, (opal_info_t **) info_used);
53+
return OMPI_ERRHANDLER_INVOKE(session, ret, FUNC_NAME);
54+
}

0 commit comments

Comments
 (0)