Skip to content

Commit faade64

Browse files
authored
Merge pull request #9246 from devreal/info_dup_mpi4
Make MPI_[Comm|File|Win]_get_info MPI 4.0 compliant
2 parents 050713d + 1e4b849 commit faade64

File tree

8 files changed

+24
-272
lines changed

8 files changed

+24
-272
lines changed

ompi/info/info.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,6 @@ int ompi_mpiinfo_init(void)
213213
int ompi_info_dup (ompi_info_t *info, ompi_info_t **newinfo) {
214214
return opal_info_dup (&(info->super), (opal_info_t **)newinfo);
215215
}
216-
int ompi_info_dup_mpistandard (ompi_info_t *info, ompi_info_t **newinfo) {
217-
return opal_info_dup_mpistandard (&(info->super), (opal_info_t **)newinfo);
218-
}
219216
int ompi_info_set (ompi_info_t *info, const char *key, const char *value) {
220217
return opal_info_set (&(info->super), key, value);
221218
}

ompi/mpi/c/comm_get_info.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ int MPI_Comm_get_info(MPI_Comm comm, MPI_Info *info_used)
4646
}
4747

4848
if (NULL == comm->super.s_info) {
49-
/*
50-
* Setup any defaults if MPI_Win_set_info was never called
51-
*/
49+
/*
50+
* Setup any defaults if MPI_Win_set_info was never called
51+
*/
5252
opal_infosubscribe_change_info(&comm->super, &MPI_INFO_NULL->super);
5353
}
5454

@@ -60,7 +60,7 @@ int MPI_Comm_get_info(MPI_Comm comm, MPI_Info *info_used)
6060
}
6161
opal_info_t *opal_info_used = &(*info_used)->super;
6262

63-
opal_info_dup_mpistandard(comm->super.s_info, &opal_info_used);
63+
opal_info_dup(comm->super.s_info, &opal_info_used);
6464

6565
return MPI_SUCCESS;
6666
}

ompi/mpi/c/file_get_info.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ int MPI_File_get_info(MPI_File fh, MPI_Info *info_used)
7070
}
7171

7272
if (NULL == fh->super.s_info) {
73-
/*
74-
* Setup any defaults if MPI_Win_set_info was never called
75-
*/
73+
/*
74+
* Setup any defaults if MPI_Win_set_info was never called
75+
*/
7676
opal_infosubscribe_change_info(&fh->super, &MPI_INFO_NULL->super);
7777
}
7878

@@ -83,7 +83,7 @@ int MPI_File_get_info(MPI_File fh, MPI_Info *info_used)
8383
}
8484
opal_info_t *opal_info_used = &(*info_used)->super;
8585

86-
opal_info_dup_mpistandard(fh->super.s_info, &opal_info_used);
86+
opal_info_dup(fh->super.s_info, &opal_info_used);
8787

8888
return OMPI_SUCCESS;
8989
}

ompi/mpi/c/info_set.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,6 @@ int MPI_Info_set(MPI_Info info, const char *key, const char *value)
9999
}
100100
}
101101

102-
// An extra warning condition is a key that uses our reserved prefix "__IN_".
103-
// That one is used internally to deal with the dynamic nature the key/val
104-
// pairs where we have callbacks that modify the val, and the MPI standard
105-
// wants the get_info call to give back the original setting rather than
106-
// the callback-modified setting. So if a user directly used a key __IN_foo
107-
// it would confuse our accounting slightly.
108-
if (0 == strncmp(key, OPAL_INFO_SAVE_PREFIX, strlen(OPAL_INFO_SAVE_PREFIX))) {
109-
opal_show_help("help-mpi-api.txt", "info-set-with-reserved-prefix", true,
110-
key, OPAL_INFO_SAVE_PREFIX);
111-
}
112-
113102
/*
114103
* If all is right with the arguments, then call the back-end
115104
* allocator.

ompi/mpi/c/win_get_info.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ int MPI_Win_get_info(MPI_Win win, MPI_Info *info_used)
4848
}
4949

5050
if (NULL == win->super.s_info) {
51-
/*
52-
* Setup any defaults if MPI_Win_set_info was never called
53-
*/
54-
opal_infosubscribe_change_info(&win->super, &MPI_INFO_NULL->super);
51+
/*
52+
* Setup any defaults if MPI_Win_set_info was never called
53+
*/
54+
opal_infosubscribe_change_info(&win->super, &MPI_INFO_NULL->super);
5555
}
5656

5757
(*info_used) = OBJ_NEW(ompi_info_t);
5858
if (NULL == (*info_used)) {
59-
return OMPI_ERRHANDLER_INVOKE(win, MPI_ERR_NO_MEM, FUNC_NAME);
59+
return OMPI_ERRHANDLER_INVOKE(win, MPI_ERR_NO_MEM, FUNC_NAME);
6060
}
6161
opal_info_t *opal_info_used = &(*info_used)->super;
6262

63-
ret = opal_info_dup_mpistandard(win->super.s_info, &opal_info_used);
63+
ret = opal_info_dup(win->super.s_info, &opal_info_used);
6464

6565
OMPI_ERRHANDLER_RETURN(ret, win, ret, FUNC_NAME);
6666
}

opal/util/info.c

Lines changed: 1 addition & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2007 The University of Tennessee and The University
6+
* Copyright (c) 2004-2021 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -171,124 +171,6 @@ static int opal_info_set_nolock(opal_info_t *info, const char *key, const char *
171171
return OPAL_SUCCESS;
172172
}
173173

174-
/*
175-
* An object's info can be set, but those settings can be modified by
176-
* system callbacks. When those callbacks happen, we save a "__IN_<key>"/"val"
177-
* copy of changed or erased values.
178-
*
179-
* extra options for how to dup:
180-
* include_system_extras (default 1)
181-
* omit_ignored (default 1)
182-
* show_modifications (default 0)
183-
*/
184-
static int opal_info_dup_mode(opal_info_t *info, opal_info_t **newinfo,
185-
int include_system_extras, // (k/v with no corresponding __IN_k)
186-
int omit_ignored, // (__IN_k with no k/v)
187-
int show_modifications) // (pick v from k/v or __IN_k/v)
188-
{
189-
int err, flag;
190-
opal_info_entry_t *iterator;
191-
192-
const char *pkey;
193-
int is_IN_key;
194-
int exists_IN_key, exists_reg_key;
195-
196-
OPAL_THREAD_LOCK(info->i_lock);
197-
OPAL_LIST_FOREACH (iterator, &info->super, opal_info_entry_t) {
198-
// If we see an __IN_<key> key but no <key>, decide what to do based on mode.
199-
// If we see an __IN_<key> and a <key>, skip since it'll be handled when
200-
// we process <key>.
201-
is_IN_key = 0;
202-
exists_IN_key = 0;
203-
exists_reg_key = 0;
204-
pkey = iterator->ie_key->string;
205-
opal_cstring_t *savedval = NULL;
206-
opal_cstring_t *valstr = NULL;
207-
if (0
208-
== strncmp(iterator->ie_key->string, OPAL_INFO_SAVE_PREFIX,
209-
strlen(OPAL_INFO_SAVE_PREFIX))) {
210-
pkey += strlen(OPAL_INFO_SAVE_PREFIX);
211-
212-
is_IN_key = 1;
213-
exists_IN_key = 1;
214-
opal_info_get_nolock(info, pkey, NULL, &flag);
215-
if (flag) {
216-
exists_reg_key = 1;
217-
}
218-
} else {
219-
is_IN_key = 0;
220-
exists_reg_key = 1;
221-
222-
// see if there is an __IN_<key> for the current <key>
223-
if (strlen(OPAL_INFO_SAVE_PREFIX) + strlen(pkey) < OPAL_MAX_INFO_KEY) {
224-
char savedkey[OPAL_MAX_INFO_KEY + 1]; // iterator->ie_key has this as its size
225-
snprintf(savedkey, OPAL_MAX_INFO_KEY + 1, OPAL_INFO_SAVE_PREFIX "%s", pkey);
226-
// (the prefix macro is a string, so the unreadable part above is a string
227-
// concatenation)
228-
opal_info_get_nolock(info, savedkey, &savedval, &flag);
229-
// release savedval, it remains valid as long we're holding the lock
230-
OBJ_RELEASE(savedval);
231-
exists_IN_key = 1;
232-
} else {
233-
flag = 0;
234-
}
235-
}
236-
237-
if (is_IN_key) {
238-
if (exists_reg_key) {
239-
// we're processing __IN_<key> and there exists a <key> so we'll handle it then
240-
continue;
241-
} else {
242-
// we're processing __IN_<key> and no <key> exists
243-
// this would mean <key> was set by the user but ignored by the system
244-
// so base our behavior on the omit_ignored
245-
if (!omit_ignored) {
246-
err = opal_info_set_cstring_nolock(*newinfo, pkey, iterator->ie_value);
247-
if (OPAL_SUCCESS != err) {
248-
OPAL_THREAD_UNLOCK(info->i_lock);
249-
return err;
250-
}
251-
}
252-
}
253-
} else {
254-
if (!exists_IN_key) {
255-
// we're processing <key> and no __IN_<key> <key> exists
256-
// this would mean it's a system setting, not something that came from the user
257-
if (include_system_extras) {
258-
valstr = iterator->ie_value;
259-
}
260-
} else {
261-
// we're processing <key> and __IN_<key> also exists
262-
// pick which value to use
263-
if (!show_modifications) {
264-
valstr = savedval;
265-
} else {
266-
valstr = iterator->ie_value;
267-
}
268-
}
269-
if (NULL != valstr) {
270-
err = opal_info_set_cstring_nolock(*newinfo, pkey, valstr);
271-
/* NOTE: we have not retained valstr so don't release here after using it */
272-
if (OPAL_SUCCESS != err) {
273-
OPAL_THREAD_UNLOCK(info->i_lock);
274-
return err;
275-
}
276-
}
277-
}
278-
}
279-
OPAL_THREAD_UNLOCK(info->i_lock);
280-
return OPAL_SUCCESS;
281-
}
282-
283-
/*
284-
* Implement opal_info_dup_mpistandard by using whatever mode
285-
* settings represent our interpretation of the standard
286-
*/
287-
int opal_info_dup_mpistandard(opal_info_t *info, opal_info_t **newinfo)
288-
{
289-
return opal_info_dup_mode(info, newinfo, 1, 1, 0);
290-
}
291-
292174
/*
293175
* Set a value on the info
294176
*/

opal/util/info.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -105,38 +105,6 @@ int opal_mpiinfo_init(void *);
105105
*/
106106
int opal_info_dup(opal_info_t *info, opal_info_t **newinfo);
107107

108-
// Comments might still say __IN_<key>, but the code should be using the
109-
// below macro instead.
110-
#define OPAL_INFO_SAVE_PREFIX "_OMPI_IN_"
111-
112-
/**
113-
* opal_info_dup_mpistandard - Duplicate an 'MPI_Info' object
114-
*
115-
* @param info source info object (handle)
116-
* @param newinfo pointer to the new info object (handle)
117-
*
118-
* @retval OPAL_SUCCESS upon success
119-
* @retval OPAL_ERR_OUT_OF_RESOURCE if out of memory
120-
*
121-
* The user sets an info object with key/value pairs and once processed,
122-
* we keep key/val pairs that might have been modified vs what the user
123-
* provided, and some user inputs might have been ignored too. The original
124-
* user inpust are kept as __IN_<key>/<val>.
125-
*
126-
* This routine then outputs key/value pairs as:
127-
*
128-
* if <key> and __IN_<key> both exist:
129-
* This means the user set a k/v pair and it was used.
130-
* output: <key> / value(__IN_<key>), the original user input
131-
* if <key> exists but __IN_<key> doesn't:
132-
* This is a system-provided setting.
133-
* output: <key>/value(<key>)
134-
* if __IN_<key> exists but <key> doesn't:
135-
* The user provided a setting that was rejected (ignored) by the system
136-
* output: nothing for this key
137-
*/
138-
int opal_info_dup_mpistandard(opal_info_t *info, opal_info_t **newinfo);
139-
140108
/**
141109
* Set a new key,value pair on info.
142110
*

0 commit comments

Comments
 (0)