Skip to content

Commit f9f4779

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 4d01bcc commit f9f4779

Some content is hidden

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

62 files changed

+765
-203
lines changed

AUTHORS

-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ Dave Goodell, Cisco
8080
8181
David Daniel, Los Alamos National Laboratory
8282
83-
David Solt, IBM
84-
8583
Denis Dimick, Los Alamos National Laboratory
8684
8785
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) 2016-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

+22-22
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
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.
21+
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
2222
* $COPYRIGHT$
2323
*
2424
* Additional copyrights may follow
@@ -704,7 +704,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
704704
if ( array_of_info != NULL && array_of_info[i] != MPI_INFO_NULL ) {
705705

706706
/* check for personality - this is a job-level key */
707-
opal_info_get (array_of_info[i], "personality", sizeof(host) - 1, host, &flag);
707+
ompi_info_get (array_of_info[i], "personality", sizeof(host) - 1, host, &flag);
708708
if ( flag ) {
709709
personality = true;
710710
info = OBJ_NEW(opal_value_t);
@@ -714,7 +714,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
714714
}
715715

716716
/* check for 'host' */
717-
opal_info_get (array_of_info[i], "host", sizeof(host) - 1, host, &flag);
717+
ompi_info_get (array_of_info[i], "host", sizeof(host) - 1, host, &flag);
718718
if ( flag ) {
719719
info = OBJ_NEW(opal_value_t);
720720
info->key = strdup(OPAL_PMIX_HOST);
@@ -723,7 +723,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
723723
}
724724

725725
/* check for 'hostfile' */
726-
opal_info_get (array_of_info[i], "hostfile", sizeof(host) - 1, host, &flag);
726+
ompi_info_get (array_of_info[i], "hostfile", sizeof(host) - 1, host, &flag);
727727
if ( flag ) {
728728
info = OBJ_NEW(opal_value_t);
729729
info->key = strdup(OPAL_PMIX_HOSTFILE);
@@ -732,7 +732,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
732732
}
733733

734734
/* check for 'add-hostfile' */
735-
opal_info_get (array_of_info[i], "add-hostfile", sizeof(host) - 1, host, &flag);
735+
ompi_info_get (array_of_info[i], "add-hostfile", sizeof(host) - 1, host, &flag);
736736
if ( flag ) {
737737
info = OBJ_NEW(opal_value_t);
738738
info->key = strdup(OPAL_PMIX_ADD_HOSTFILE);
@@ -741,7 +741,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
741741
}
742742

743743
/* check for 'add-host' */
744-
opal_info_get (array_of_info[i], "add-host", sizeof(host) - 1, host, &flag);
744+
ompi_info_get (array_of_info[i], "add-host", sizeof(host) - 1, host, &flag);
745745
if ( flag ) {
746746
info = OBJ_NEW(opal_value_t);
747747
info->key = strdup(OPAL_PMIX_ADD_HOST);
@@ -750,7 +750,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
750750
}
751751

752752
/* check for env */
753-
opal_info_get (array_of_info[i], "env", sizeof(host)-1, host, &flag);
753+
ompi_info_get (array_of_info[i], "env", sizeof(host)-1, host, &flag);
754754
if ( flag ) {
755755
envars = opal_argv_split(host, '\n');
756756
for (j=0; NULL != envars[j]; j++) {
@@ -766,7 +766,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
766766
*
767767
* This is a job-level key
768768
*/
769-
opal_info_get (array_of_info[i], "ompi_prefix", sizeof(prefix) - 1, prefix, &flag);
769+
ompi_info_get (array_of_info[i], "ompi_prefix", sizeof(prefix) - 1, prefix, &flag);
770770
if ( flag ) {
771771
info = OBJ_NEW(opal_value_t);
772772
info->key = strdup(OPAL_PMIX_PREFIX);
@@ -775,7 +775,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
775775
}
776776

777777
/* check for 'wdir' */
778-
opal_info_get (array_of_info[i], "wdir", sizeof(cwd) - 1, cwd, &flag);
778+
ompi_info_get (array_of_info[i], "wdir", sizeof(cwd) - 1, cwd, &flag);
779779
if ( flag ) {
780780
info = OBJ_NEW(opal_value_t);
781781
info->key = strdup(OPAL_PMIX_WDIR);
@@ -785,7 +785,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
785785
}
786786

787787
/* check for 'mapper' - a job-level key */
788-
opal_info_get(array_of_info[i], "mapper", sizeof(mapper) - 1, mapper, &flag);
788+
ompi_info_get(array_of_info[i], "mapper", sizeof(mapper) - 1, mapper, &flag);
789789
if ( flag ) {
790790
info = OBJ_NEW(opal_value_t);
791791
info->key = strdup(OPAL_PMIX_MAPPER);
@@ -794,7 +794,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
794794
}
795795

796796
/* check for 'display_map' - a job-level key */
797-
opal_info_get_bool(array_of_info[i], "display_map", &local_spawn, &flag);
797+
ompi_info_get_bool(array_of_info[i], "display_map", &local_spawn, &flag);
798798
if ( flag ) {
799799
info = OBJ_NEW(opal_value_t);
800800
info->key = strdup(OPAL_PMIX_DISPLAY_MAP);
@@ -803,22 +803,22 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
803803
}
804804

805805
/* check for 'npernode' and 'ppr' - job-level key */
806-
opal_info_get (array_of_info[i], "npernode", sizeof(slot_list) - 1, slot_list, &flag);
806+
ompi_info_get (array_of_info[i], "npernode", sizeof(slot_list) - 1, slot_list, &flag);
807807
if ( flag ) {
808808
info = OBJ_NEW(opal_value_t);
809809
info->key = strdup(OPAL_PMIX_PPR);
810810
info->type = OPAL_STRING;
811811
(void)asprintf(&(info->data.string), "%s:n", slot_list);
812812
opal_list_append(&job_info, &info->super);
813813
}
814-
opal_info_get (array_of_info[i], "pernode", sizeof(slot_list) - 1, slot_list, &flag);
814+
ompi_info_get (array_of_info[i], "pernode", sizeof(slot_list) - 1, slot_list, &flag);
815815
if ( flag ) {
816816
info = OBJ_NEW(opal_value_t);
817817
info->key = strdup(OPAL_PMIX_PPR);
818818
opal_value_load(info, "1:n", OPAL_STRING);
819819
opal_list_append(&job_info, &info->super);
820820
}
821-
opal_info_get (array_of_info[i], "ppr", sizeof(slot_list) - 1, slot_list, &flag);
821+
ompi_info_get (array_of_info[i], "ppr", sizeof(slot_list) - 1, slot_list, &flag);
822822
if ( flag ) {
823823
info = OBJ_NEW(opal_value_t);
824824
info->key = strdup(OPAL_PMIX_PPR);
@@ -827,7 +827,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
827827
}
828828

829829
/* check for 'map_by' - job-level key */
830-
opal_info_get(array_of_info[i], "map_by", sizeof(slot_list) - 1, slot_list, &flag);
830+
ompi_info_get(array_of_info[i], "map_by", sizeof(slot_list) - 1, slot_list, &flag);
831831
if ( flag ) {
832832
info = OBJ_NEW(opal_value_t);
833833
info->key = strdup(OPAL_PMIX_MAPBY);
@@ -836,7 +836,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
836836
}
837837

838838
/* check for 'rank_by' - job-level key */
839-
opal_info_get(array_of_info[i], "rank_by", sizeof(slot_list) - 1, slot_list, &flag);
839+
ompi_info_get(array_of_info[i], "rank_by", sizeof(slot_list) - 1, slot_list, &flag);
840840
if ( flag ) {
841841
info = OBJ_NEW(opal_value_t);
842842
info->key = strdup(OPAL_PMIX_RANKBY);
@@ -845,7 +845,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
845845
}
846846

847847
/* check for 'bind_to' - job-level key */
848-
opal_info_get(array_of_info[i], "bind_to", sizeof(slot_list) - 1, slot_list, &flag);
848+
ompi_info_get(array_of_info[i], "bind_to", sizeof(slot_list) - 1, slot_list, &flag);
849849
if ( flag ) {
850850
info = OBJ_NEW(opal_value_t);
851851
info->key = strdup(OPAL_PMIX_BINDTO);
@@ -854,7 +854,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
854854
}
855855

856856
/* check for 'preload_binary' - job-level key */
857-
opal_info_get_bool(array_of_info[i], "ompi_preload_binary", &local_spawn, &flag);
857+
ompi_info_get_bool(array_of_info[i], "ompi_preload_binary", &local_spawn, &flag);
858858
if ( flag ) {
859859
info = OBJ_NEW(opal_value_t);
860860
info->key = strdup(OPAL_PMIX_PRELOAD_BIN);
@@ -863,7 +863,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
863863
}
864864

865865
/* check for 'preload_files' - job-level key */
866-
opal_info_get (array_of_info[i], "ompi_preload_files", sizeof(cwd) - 1, cwd, &flag);
866+
ompi_info_get (array_of_info[i], "ompi_preload_files", sizeof(cwd) - 1, cwd, &flag);
867867
if ( flag ) {
868868
info = OBJ_NEW(opal_value_t);
869869
info->key = strdup(OPAL_PMIX_PRELOAD_FILES);
@@ -874,7 +874,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
874874
/* see if this is a non-mpi job - if so, then set the flag so ORTE
875875
* knows what to do - job-level key
876876
*/
877-
opal_info_get_bool(array_of_info[i], "ompi_non_mpi", &non_mpi, &flag);
877+
ompi_info_get_bool(array_of_info[i], "ompi_non_mpi", &non_mpi, &flag);
878878
if (flag && non_mpi) {
879879
info = OBJ_NEW(opal_value_t);
880880
info->key = strdup(OPAL_PMIX_NON_PMI);
@@ -883,15 +883,15 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
883883
}
884884

885885
/* 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);
886+
ompi_info_get (array_of_info[i], "ompi_param", sizeof(params) - 1, params, &flag);
887887
if ( flag ) {
888888
opal_argv_append_unique_nosize(&app->env, params, true);
889889
}
890890

891891
/* see if user specified what to do with stdin - defaults to
892892
* not forwarding stdin to child processes - job-level key
893893
*/
894-
opal_info_get (array_of_info[i], "ompi_stdin_target", sizeof(stdin_target) - 1, stdin_target, &flag);
894+
ompi_info_get (array_of_info[i], "ompi_stdin_target", sizeof(stdin_target) - 1, stdin_target, &flag);
895895
if ( flag ) {
896896
if (0 == strcmp(stdin_target, "all")) {
897897
ui32 = ORTE_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 &&

0 commit comments

Comments
 (0)