Skip to content

Commit 6db30f4

Browse files
authored
Merge pull request #7 from hppritcha/topic/remove_mpi_flags
drop use of MPI_Flag
2 parents 5f83a2b + 706e163 commit 6db30f4

File tree

6 files changed

+28
-32
lines changed

6 files changed

+28
-32
lines changed

ompi/communicator/comm.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,11 @@ int ompi_comm_create_from_group (ompi_group_t *group, const char *tag, opal_info
12811281
snprintf(newcomp->c_name, MPI_MAX_OBJECT_NAME, "MPI COMM %s FROM GROUP",
12821282
ompi_comm_print_cid (newcomp));
12831283

1284+
newcomp->super.s_info = OBJ_NEW(opal_info_t);
1285+
if (NULL == newcomp->super.s_info) {
1286+
return OMPI_ERR_OUT_OF_RESOURCE;
1287+
}
1288+
12841289
/* NTH: HACK IN SLEEPY STUFF */
12851290
{
12861291
opal_info_entry_t *info_entry;

ompi/include/mpi.h.in

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,6 @@ typedef int (MPI_Grequest_query_function)(void *, MPI_Status *);
399399
typedef int (MPI_Grequest_free_function)(void *);
400400
typedef int (MPI_Grequest_cancel_function)(void *, int);
401401

402-
typedef unsigned long MPI_Flags;
403-
404402
/*
405403
* Deprecated typedefs. Usage is discouraged, as these may be deleted
406404
* in future versions of the MPI Standard.
@@ -1712,7 +1710,7 @@ OMPI_DECLSPEC int MPI_Session_get_num_psets (MPI_Session session, int *npset_na
17121710
OMPI_DECLSPEC int MPI_Session_get_nth_pset (MPI_Session session, int n, int len, char *pset_name);
17131711
OMPI_DECLSPEC int MPI_Session_get_pset_info (MPI_Session session, const char *pset_name, MPI_Info *info_used);
17141712
OMPI_DECLSPEC int MPI_Session_get_psetlen (MPI_Session session, int n, int *pset_name_len);
1715-
OMPI_DECLSPEC int MPI_Session_init (MPI_Flags *flags, MPI_Info info, MPI_Errhandler errhandler,
1713+
OMPI_DECLSPEC int MPI_Session_init (MPI_Info info, MPI_Errhandler errhandler,
17161714
MPI_Session *session);
17171715
OMPI_DECLSPEC MPI_Session MPI_Session_f2c (MPI_Fint session);
17181716
OMPI_DECLSPEC int MPI_Session_set_attr (MPI_Session session, int session_keyval, void *attribute_val);
@@ -2425,7 +2423,7 @@ OMPI_DECLSPEC int PMPI_Session_get_num_psets (MPI_Session session, int *npset_n
24252423
OMPI_DECLSPEC int PMPI_Session_get_nth_pset (MPI_Session session, int n, int len, char *pset_name);
24262424
OMPI_DECLSPEC int PMPI_Session_get_pset_info (MPI_Session session, const char *pset_name, MPI_Info *info_used);
24272425
OMPI_DECLSPEC int PMPI_Session_get_psetlen (MPI_Session session, int n, int *pset_name_len);
2428-
OMPI_DECLSPEC int PMPI_Session_init (MPI_Flags *flags, MPI_Info info, MPI_Errhandler errhandler,
2426+
OMPI_DECLSPEC int PMPI_Session_init (MPI_Info info, MPI_Errhandler errhandler,
24292427
MPI_Session *session);
24302428
OMPI_DECLSPEC MPI_Session PMPI_Session_f2c (MPI_Fint session);
24312429
OMPI_DECLSPEC int PMPI_Session_set_attr (MPI_Session session, int session_keyval, void *attribute_val);

ompi/instance/instance.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ static int ompi_mpi_instance_init_common (void)
589589
return OMPI_SUCCESS;
590590
}
591591

592-
int ompi_mpi_instance_init (MPI_Flags *flags, opal_info_t *info, ompi_errhandler_t *errhandler, ompi_instance_t **instance)
592+
int ompi_mpi_instance_init (int ts_level, opal_info_t *info, ompi_errhandler_t *errhandler, ompi_instance_t **instance)
593593
{
594594
ompi_instance_t *new_instance;
595595
int ret;
@@ -598,7 +598,7 @@ int ompi_mpi_instance_init (MPI_Flags *flags, opal_info_t *info, ompi_errhandler
598598

599599
/* If thread support was enabled, then setup OPAL to allow for them by deault. This must be done
600600
* early to prevent a race condition that can occur with orte_init(). */
601-
if (*flags & MPI_FLAG_THREAD_CONCURRENT) {
601+
if (ts_level == MPI_THREAD_MULTIPLE) {
602602
opal_set_using_threads(true);
603603
}
604604

ompi/instance/instance.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ void ompi_mpi_instance_release (void);
118118
/**
119119
* @brief Create a new MPI instance
120120
*
121-
* @param[inout] flags instance flags (see mpi.h)
121+
* @param[in] ts_level thread support level (see mpi.h)
122122
* @param[in] info info object
123123
* @param[in] errhander errhandler to set on the instance
124124
*/
125-
OMPI_DECLSPEC int ompi_mpi_instance_init (MPI_Flags *flags, opal_info_t *info, ompi_errhandler_t *errhandler, ompi_instance_t **instance);
125+
OMPI_DECLSPEC int ompi_mpi_instance_init (int ts_level, opal_info_t *info, ompi_errhandler_t *errhandler, ompi_instance_t **instance);
126126

127127
/**
128128
* @brief Destroy an MPI instance and set it to MPI_SESSION_NULL

ompi/mpi/c/session_init.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@
2525
static const char FUNC_NAME[] = "MPI_Session_init";
2626

2727

28-
int MPI_Session_init (MPI_Flags *flags, MPI_Info info, MPI_Errhandler errhandler, MPI_Session *session)
28+
int MPI_Session_init (MPI_Info info, MPI_Errhandler errhandler, MPI_Session *session)
2929
{
30-
int rc;
30+
int rc, flag;
31+
int ts_level = MPI_THREAD_SINGLE; /* for now we default to thread single for OMPI sessions */
32+
char info_value[MPI_MAX_INFO_VAL + 1];
33+
const char ts_level_multi[] = "MPI_THREAD_MULTIPLE";
3134

3235
if ( MPI_PARAM_CHECK ) {
33-
if (NULL == errhandler || NULL == flags || NULL == session) {
36+
if (NULL == errhandler || NULL == session) {
3437
return MPI_ERR_ARG;
3538
}
3639

@@ -39,7 +42,16 @@ int MPI_Session_init (MPI_Flags *flags, MPI_Info info, MPI_Errhandler errhandler
3942
}
4043
}
4144

42-
rc = ompi_mpi_instance_init (flags, &info->super, errhandler, session);
45+
if (MPI_INFO_NULL != info) {
46+
(void) ompi_info_get (info, "thread_support_level", MPI_MAX_INFO_VAL, info_value, &flag);
47+
if (flag) {
48+
if(strncmp(info_value, ts_level_multi, strlen(ts_level_multi)) == 0) {
49+
ts_level = MPI_THREAD_MULTIPLE;
50+
}
51+
}
52+
}
53+
54+
rc = ompi_mpi_instance_init (ts_level, &info->super, errhandler, session);
4355
/* if an error occured raise it on the null session */
4456
OMPI_ERRHANDLER_RETURN (rc, MPI_SESSION_NULL, rc, FUNC_NAME);
4557
}

ompi/runtime/ompi_mpi_init.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -339,28 +339,9 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided,
339339
}
340340
}
341341

342-
/* Figure out the final MPI thread levels. If we were not
343-
compiled for support for MPI threads, then don't allow
344-
MPI_THREAD_MULTIPLE. Set this stuff up here early in the
345-
process so that other components can make decisions based on
346-
this value. */
347-
348342
ompi_mpi_thread_level(requested, provided);
349343

350-
MPI_Flags flags;
351-
switch (*provided) {
352-
case MPI_THREAD_SINGLE:
353-
case MPI_THREAD_FUNNELED:
354-
case MPI_THREAD_SERIALIZED:
355-
flags = MPI_FLAG_THREAD_NONCONCURRENT_SINGLE;
356-
break;
357-
case MPI_THREAD_MULTIPLE:
358-
flags = MPI_FLAG_THREAD_CONCURRENT;
359-
break;
360-
}
361-
362-
363-
ret = ompi_mpi_instance_init (&flags, &ompi_mpi_info_null.info.super, MPI_ERRORS_ARE_FATAL, &ompi_mpi_instance_default);
344+
ret = ompi_mpi_instance_init (*provided, &ompi_mpi_info_null.info.super, MPI_ERRORS_ARE_FATAL, &ompi_mpi_instance_default);
364345
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
365346
error = "ompi_mpi_init: ompi_mpi_instance_init failed";
366347
goto error;

0 commit comments

Comments
 (0)