Skip to content

Commit 482d84b

Browse files
committed
fixes for Dave's get/set info code
The expected sequence of events for processing info during object creation is that if there's an incoming info arg, it is opal_info_dup()ed into the obj at obj->s_info first. Then interested components register callbacks for keys they want to know about using opal_infosubscribe_infosubscribe(). Inside info_subscribe_subscribe() the specified callback() is called with whatever matching k/v is in the object's info, or with the default. The return string from the callback goes into the new k/v stored in info, and the input k/v is saved as __IN_<key>/<val>. It's saved the same way whether the input came from info or whether it was a default. A null return from the callback indicates an ignored key/val, and no k/v is stored for it, but an __IN_<key>/<val> is still kept so we still have access to the original. At MPI_*_set_info() time, opal_infosubscribe_change_info() is used. That function calls the registered callbacks for each item in the provided info. If the callback returns non-null, the info is updated with that k/v, or if the callback returns null, that key is deleted from info. An __IN_<key>/<val> is saved either way, and overwrites any previously saved value. When MPI_*_get_info() is called, opal_info_dup_mpistandard() is used, which allows relatively easy changes in interpretation of the standard, by looking at both the <key>/<val> and __IN_<key>/<val> in info. Right now it does 1. includes system extras, eg k/v defaults not expliclty set by the user 2. omits ignored keys 3. shows input values, not callback modifications, eg not the internal values Currently the callbacks are doing things like return some_condition ? "true" : "false" that is, returning static strings that are not to be freed. If the return strings start becoming more dynamic in the future I don't see how unallocated strings could support that, so I'd propose a change for the future that the callback()s registered with info_subscribe_subscribe() do a strdup on their return, and we change the callers of callback() to free the strings it returns (there are only two callers). Rough outline of the smaller changes spread over the less central files: comm.c initialize comm->super.s_info to NULL copy into comm->super.s_info in comm creation calls that provide info OBJ_RELEASE comm->super.s_info at free time comm_init.c initialize comm->super.s_info to NULL file.c copy into file->super.s_info if file creation provides info OBJ_RELEASE file->super.s_info at free time win.c copy into win->super.s_info if win creation provides info OBJ_RELEASE win->super.s_info at free time comm_get_info.c file_get_info.c win_get_info.c change_info() if there's no info attached (shouldn't happen if callbacks are registered) copy the info for the user The other category of change is generally addressing compiler warnings where ompi_info_t and opal_info_t were being used a little too interchangably. An ompi_info_t* contains an opal_info_t*, at &(ompi_info->super) Also this commit updates the copyrights. Signed-off-by: Mark Allen <[email protected]>
1 parent 50aa143 commit 482d84b

File tree

110 files changed

+800
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+800
-258
lines changed

AUTHORS

-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ Dave Goodell, Cisco
8484
8585
David Daniel, Los Alamos National Laboratory
8686
87-
David Solt, IBM
88-
8987
Denis Dimick, Los Alamos National Laboratory
9088
9189
Devendar Bureddy, Mellanox

ompi/communicator/comm.c

+27-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* and Technology (RIST). All rights reserved.
2323
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
2424
* Copyright (c) 2015 Mellanox Technologies. All rights reserved.
25-
* Copyright (c) 2016 IBM Corp. All rights reserved.
25+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
2626
* $COPYRIGHT$
2727
*
2828
* Additional copyrights may follow
@@ -158,6 +158,7 @@ int ompi_comm_set_nb ( ompi_communicator_t **ncomm,
158158

159159
/* ompi_comm_allocate */
160160
newcomm = OBJ_NEW(ompi_communicator_t);
161+
newcomm->super.s_info = NULL;
161162
/* fill in the inscribing hyper-cube dimensions */
162163
newcomm->c_cube_dim = opal_cube_dim(local_size);
163164
newcomm->c_id_available = MPI_UNDEFINED;
@@ -918,6 +919,12 @@ int ompi_comm_split_type (ompi_communicator_t *comm, int split_type, int key,
918919
break;
919920
}
920921

922+
// Copy info if there is one.
923+
newcomp->super.s_info = OBJ_NEW(opal_info_t);
924+
if (info) {
925+
opal_info_dup(info, &(newcomp->super.s_info));
926+
}
927+
921928
/* Activate the communicator and init coll-component */
922929
rc = ompi_comm_activate (&newcomp, comm, NULL, NULL, NULL, false, mode);
923930
if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) {
@@ -1015,6 +1022,12 @@ int ompi_comm_dup_with_info ( ompi_communicator_t * comm, opal_info_t *info, omp
10151022
snprintf(newcomp->c_name, MPI_MAX_OBJECT_NAME, "MPI COMMUNICATOR %d DUP FROM %d",
10161023
newcomp->c_contextid, comm->c_contextid );
10171024

1025+
// Copy info if there is one.
1026+
newcomp->super.s_info = OBJ_NEW(opal_info_t);
1027+
if (info) {
1028+
opal_info_dup(info, &(newcomp->super.s_info));
1029+
}
1030+
10181031
/* activate communicator and init coll-module */
10191032
rc = ompi_comm_activate (&newcomp, comm, NULL, NULL, NULL, false, mode);
10201033
if ( OMPI_SUCCESS != rc ) {
@@ -1095,6 +1108,15 @@ static int ompi_comm_idup_internal (ompi_communicator_t *comm, ompi_group_t *gro
10951108
return rc;
10961109
}
10971110

1111+
// Copy info if there is one.
1112+
{
1113+
ompi_communicator_t *newcomp = context->newcomp;
1114+
newcomp->super.s_info = OBJ_NEW(opal_info_t);
1115+
if (info) {
1116+
opal_info_dup(info, &(newcomp->super.s_info));
1117+
}
1118+
}
1119+
10981120
ompi_comm_request_schedule_append (request, ompi_comm_idup_getcid, subreq, subreq[0] ? 1 : 0);
10991121

11001122
/* assign the newcomm now */
@@ -1472,6 +1494,10 @@ int ompi_comm_free( ompi_communicator_t **comm )
14721494
ompi_mpi_comm_parent = &ompi_mpi_comm_null.comm;
14731495
}
14741496

1497+
if (NULL != ((*comm)->super.s_info)) {
1498+
OBJ_RELEASE((*comm)->super.s_info);
1499+
}
1500+
14751501
/* Release the communicator */
14761502
if ( OMPI_COMM_IS_DYNAMIC (*comm) ) {
14771503
ompi_comm_num_dyncomm --;

ompi/communicator/comm_init.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Copyright (c) 2015 Research Organization for Information Science
2222
* and Technology (RIST). All rights reserved.
2323
* Copyright (c) 2015 Intel, Inc. All rights reserved.
24-
* Copyright (c) 2016 IBM Corp. All rights reserved.
24+
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
2525
* $COPYRIGHT$
2626
*
2727
* Additional copyrights may follow
@@ -221,6 +221,7 @@ ompi_communicator_t *ompi_comm_allocate ( int local_size, int remote_size )
221221

222222
/* create new communicator element */
223223
new_comm = OBJ_NEW(ompi_communicator_t);
224+
new_comm->super.s_info = NULL;
224225
new_comm->c_local_group = ompi_group_allocate ( local_size );
225226
if ( 0 < remote_size ) {
226227
new_comm->c_remote_group = ompi_group_allocate (remote_size);

ompi/communicator/communicator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
2121
* Copyright (c) 2015 Research Organization for Information Science
2222
* and Technology (RIST). All rights reserved.
23-
* Copyright (c) 2017 IBM Corporation. All rights reserved.
23+
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
2424
* $COPYRIGHT$
2525
*
2626
* Additional copyrights may follow

ompi/debuggers/predefined_gap_test.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* of Tennessee Research Foundation. All rights
66
* reserved.
77
* Copyright (c) 2012-2013 Inria. All rights reserved.
8-
* Copyright (c) 2016 IBM Corp. All rights reserved.
8+
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
99
* $COPYRIGHT$
1010
*
1111
* Additional copyrights may follow

ompi/dpm/dpm.c

+21-22
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
* Copyright (c) 2013-2016 Intel, Inc. All rights reserved.
1919
* Copyright (c) 2014-2017 Research Organization for Information Science
2020
* and Technology (RIST). All rights reserved.
21-
* Copyright (c) 2016 IBM Corp. All rights reserved.
2221
* $COPYRIGHT$
2322
*
2423
* Additional copyrights may follow
@@ -704,7 +703,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
704703
if ( array_of_info != NULL && array_of_info[i] != MPI_INFO_NULL ) {
705704

706705
/* check for personality - this is a job-level key */
707-
opal_info_get (array_of_info[i], "personality", sizeof(host) - 1, host, &flag);
706+
ompi_info_get (array_of_info[i], "personality", sizeof(host) - 1, host, &flag);
708707
if ( flag ) {
709708
personality = true;
710709
info = OBJ_NEW(opal_value_t);
@@ -714,7 +713,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
714713
}
715714

716715
/* check for 'host' */
717-
opal_info_get (array_of_info[i], "host", sizeof(host) - 1, host, &flag);
716+
ompi_info_get (array_of_info[i], "host", sizeof(host) - 1, host, &flag);
718717
if ( flag ) {
719718
info = OBJ_NEW(opal_value_t);
720719
info->key = strdup(OPAL_PMIX_HOST);
@@ -723,7 +722,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
723722
}
724723

725724
/* check for 'hostfile' */
726-
opal_info_get (array_of_info[i], "hostfile", sizeof(host) - 1, host, &flag);
725+
ompi_info_get (array_of_info[i], "hostfile", sizeof(host) - 1, host, &flag);
727726
if ( flag ) {
728727
info = OBJ_NEW(opal_value_t);
729728
info->key = strdup(OPAL_PMIX_HOSTFILE);
@@ -732,7 +731,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
732731
}
733732

734733
/* check for 'add-hostfile' */
735-
opal_info_get (array_of_info[i], "add-hostfile", sizeof(host) - 1, host, &flag);
734+
ompi_info_get (array_of_info[i], "add-hostfile", sizeof(host) - 1, host, &flag);
736735
if ( flag ) {
737736
info = OBJ_NEW(opal_value_t);
738737
info->key = strdup(OPAL_PMIX_ADD_HOSTFILE);
@@ -741,7 +740,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
741740
}
742741

743742
/* check for 'add-host' */
744-
opal_info_get (array_of_info[i], "add-host", sizeof(host) - 1, host, &flag);
743+
ompi_info_get (array_of_info[i], "add-host", sizeof(host) - 1, host, &flag);
745744
if ( flag ) {
746745
info = OBJ_NEW(opal_value_t);
747746
info->key = strdup(OPAL_PMIX_ADD_HOST);
@@ -750,7 +749,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
750749
}
751750

752751
/* check for env */
753-
opal_info_get (array_of_info[i], "env", sizeof(host)-1, host, &flag);
752+
ompi_info_get (array_of_info[i], "env", sizeof(host)-1, host, &flag);
754753
if ( flag ) {
755754
envars = opal_argv_split(host, '\n');
756755
for (j=0; NULL != envars[j]; j++) {
@@ -766,7 +765,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
766765
*
767766
* This is a job-level key
768767
*/
769-
opal_info_get (array_of_info[i], "ompi_prefix", sizeof(prefix) - 1, prefix, &flag);
768+
ompi_info_get (array_of_info[i], "ompi_prefix", sizeof(prefix) - 1, prefix, &flag);
770769
if ( flag ) {
771770
info = OBJ_NEW(opal_value_t);
772771
info->key = strdup(OPAL_PMIX_PREFIX);
@@ -775,7 +774,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
775774
}
776775

777776
/* check for 'wdir' */
778-
opal_info_get (array_of_info[i], "wdir", sizeof(cwd) - 1, cwd, &flag);
777+
ompi_info_get (array_of_info[i], "wdir", sizeof(cwd) - 1, cwd, &flag);
779778
if ( flag ) {
780779
info = OBJ_NEW(opal_value_t);
781780
info->key = strdup(OPAL_PMIX_WDIR);
@@ -785,7 +784,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
785784
}
786785

787786
/* check for 'mapper' - a job-level key */
788-
opal_info_get(array_of_info[i], "mapper", sizeof(mapper) - 1, mapper, &flag);
787+
ompi_info_get(array_of_info[i], "mapper", sizeof(mapper) - 1, mapper, &flag);
789788
if ( flag ) {
790789
info = OBJ_NEW(opal_value_t);
791790
info->key = strdup(OPAL_PMIX_MAPPER);
@@ -794,7 +793,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
794793
}
795794

796795
/* check for 'display_map' - a job-level key */
797-
opal_info_get_bool(array_of_info[i], "display_map", &local_spawn, &flag);
796+
ompi_info_get_bool(array_of_info[i], "display_map", &local_spawn, &flag);
798797
if ( flag ) {
799798
info = OBJ_NEW(opal_value_t);
800799
info->key = strdup(OPAL_PMIX_DISPLAY_MAP);
@@ -803,22 +802,22 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
803802
}
804803

805804
/* check for 'npernode' and 'ppr' - job-level key */
806-
opal_info_get (array_of_info[i], "npernode", sizeof(slot_list) - 1, slot_list, &flag);
805+
ompi_info_get (array_of_info[i], "npernode", sizeof(slot_list) - 1, slot_list, &flag);
807806
if ( flag ) {
808807
info = OBJ_NEW(opal_value_t);
809808
info->key = strdup(OPAL_PMIX_PPR);
810809
info->type = OPAL_STRING;
811810
(void)asprintf(&(info->data.string), "%s:n", slot_list);
812811
opal_list_append(&job_info, &info->super);
813812
}
814-
opal_info_get (array_of_info[i], "pernode", sizeof(slot_list) - 1, slot_list, &flag);
813+
ompi_info_get (array_of_info[i], "pernode", sizeof(slot_list) - 1, slot_list, &flag);
815814
if ( flag ) {
816815
info = OBJ_NEW(opal_value_t);
817816
info->key = strdup(OPAL_PMIX_PPR);
818817
opal_value_load(info, "1:n", OPAL_STRING);
819818
opal_list_append(&job_info, &info->super);
820819
}
821-
opal_info_get (array_of_info[i], "ppr", sizeof(slot_list) - 1, slot_list, &flag);
820+
ompi_info_get (array_of_info[i], "ppr", sizeof(slot_list) - 1, slot_list, &flag);
822821
if ( flag ) {
823822
info = OBJ_NEW(opal_value_t);
824823
info->key = strdup(OPAL_PMIX_PPR);
@@ -827,7 +826,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
827826
}
828827

829828
/* check for 'map_by' - job-level key */
830-
opal_info_get(array_of_info[i], "map_by", sizeof(slot_list) - 1, slot_list, &flag);
829+
ompi_info_get(array_of_info[i], "map_by", sizeof(slot_list) - 1, slot_list, &flag);
831830
if ( flag ) {
832831
info = OBJ_NEW(opal_value_t);
833832
info->key = strdup(OPAL_PMIX_MAPBY);
@@ -836,7 +835,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
836835
}
837836

838837
/* check for 'rank_by' - job-level key */
839-
opal_info_get(array_of_info[i], "rank_by", sizeof(slot_list) - 1, slot_list, &flag);
838+
ompi_info_get(array_of_info[i], "rank_by", sizeof(slot_list) - 1, slot_list, &flag);
840839
if ( flag ) {
841840
info = OBJ_NEW(opal_value_t);
842841
info->key = strdup(OPAL_PMIX_RANKBY);
@@ -845,7 +844,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
845844
}
846845

847846
/* check for 'bind_to' - job-level key */
848-
opal_info_get(array_of_info[i], "bind_to", sizeof(slot_list) - 1, slot_list, &flag);
847+
ompi_info_get(array_of_info[i], "bind_to", sizeof(slot_list) - 1, slot_list, &flag);
849848
if ( flag ) {
850849
info = OBJ_NEW(opal_value_t);
851850
info->key = strdup(OPAL_PMIX_BINDTO);
@@ -854,7 +853,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
854853
}
855854

856855
/* check for 'preload_binary' - job-level key */
857-
opal_info_get_bool(array_of_info[i], "ompi_preload_binary", &local_spawn, &flag);
856+
ompi_info_get_bool(array_of_info[i], "ompi_preload_binary", &local_spawn, &flag);
858857
if ( flag ) {
859858
info = OBJ_NEW(opal_value_t);
860859
info->key = strdup(OPAL_PMIX_PRELOAD_BIN);
@@ -863,7 +862,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
863862
}
864863

865864
/* check for 'preload_files' - job-level key */
866-
opal_info_get (array_of_info[i], "ompi_preload_files", sizeof(cwd) - 1, cwd, &flag);
865+
ompi_info_get (array_of_info[i], "ompi_preload_files", sizeof(cwd) - 1, cwd, &flag);
867866
if ( flag ) {
868867
info = OBJ_NEW(opal_value_t);
869868
info->key = strdup(OPAL_PMIX_PRELOAD_FILES);
@@ -874,7 +873,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
874873
/* see if this is a non-mpi job - if so, then set the flag so ORTE
875874
* knows what to do - job-level key
876875
*/
877-
opal_info_get_bool(array_of_info[i], "ompi_non_mpi", &non_mpi, &flag);
876+
ompi_info_get_bool(array_of_info[i], "ompi_non_mpi", &non_mpi, &flag);
878877
if (flag && non_mpi) {
879878
info = OBJ_NEW(opal_value_t);
880879
info->key = strdup(OPAL_PMIX_NON_PMI);
@@ -883,15 +882,15 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
883882
}
884883

885884
/* see if this is an MCA param that the user wants applied to the child job */
886-
opal_info_get (array_of_info[i], "ompi_param", sizeof(params) - 1, params, &flag);
885+
ompi_info_get (array_of_info[i], "ompi_param", sizeof(params) - 1, params, &flag);
887886
if ( flag ) {
888887
opal_argv_append_unique_nosize(&app->env, params, true);
889888
}
890889

891890
/* see if user specified what to do with stdin - defaults to
892891
* not forwarding stdin to child processes - job-level key
893892
*/
894-
opal_info_get (array_of_info[i], "ompi_stdin_target", sizeof(stdin_target) - 1, stdin_target, &flag);
893+
ompi_info_get (array_of_info[i], "ompi_stdin_target", sizeof(stdin_target) - 1, stdin_target, &flag);
895894
if ( flag ) {
896895
if (0 == strcmp(stdin_target, "all")) {
897896
ui32 = OPAL_VPID_WILDCARD;

ompi/file/file.c

+12-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Copyright (c) 2015 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* Copyright (c) 2016 University of Houston. All rights reserved.
18-
* Copyright (c) 2016 IBM Corp. All rights reserved.
18+
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
1919
* $COPYRIGHT$
2020
*
2121
* Additional copyrights may follow
@@ -114,11 +114,10 @@ int ompi_file_open(struct ompi_communicator_t *comm, const char *filename,
114114
file->f_comm = comm;
115115
OBJ_RETAIN(comm);
116116

117-
/* Present the info to the info layer */
118-
119-
if (OPAL_SUCCESS != opal_infosubscribe_change_info(&file->super, info)) {
120-
OBJ_RELEASE(file);
121-
return ret;
117+
/* Copy the info for the info layer */
118+
file->super.s_info = OBJ_NEW(opal_info_t);
119+
if (info) {
120+
opal_info_dup(info, &(file->super.s_info));
122121
}
123122

124123
file->f_amode = amode;
@@ -310,6 +309,13 @@ static void file_destructor(ompi_file_t *file)
310309
#endif
311310
}
312311

312+
if (NULL != file->super.s_info) {
313+
OBJ_RELEASE(file->super.s_info);
314+
#if OPAL_ENABLE_DEBUG
315+
file->super.s_info = NULL;
316+
#endif
317+
}
318+
313319
/* Reset the f_to_c table entry */
314320

315321
if (MPI_UNDEFINED != file->f_f_to_c_index &&

ompi/file/file.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Copyright (c) 2015 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* Copyright (c) 2016 University of Houston. All rights reserved.
18-
* Copyright (c) 2016 IBM Corp. All rights reserved.
18+
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
1919
* $COPYRIGHT$
2020
*
2121
* Additional copyrights may follow

0 commit comments

Comments
 (0)