@@ -115,6 +115,8 @@ ompi_osc_sm_module_t ompi_osc_sm_module_template = {
115115
116116static int component_register (void )
117117{
118+ char * description_str ;
119+
118120 if (0 == access ("/dev/shm" , W_OK )) {
119121 mca_osc_sm_component .backing_directory = "/dev/shm" ;
120122 } else {
@@ -128,6 +130,16 @@ static int component_register (void)
128130 MCA_BASE_VAR_TYPE_STRING , NULL , 0 , 0 , OPAL_INFO_LVL_3 ,
129131 MCA_BASE_VAR_SCOPE_READONLY , & mca_osc_sm_component .backing_directory );
130132
133+ mca_osc_sm_component .priority = 100 ;
134+ opal_asprintf (& description_str , "Priority of the osc/sm component (default: %d)" ,
135+ mca_osc_sm_component .priority );
136+ (void )mca_base_component_var_register (& mca_osc_sm_component .super .osc_version ,
137+ "priority" , description_str ,
138+ MCA_BASE_VAR_TYPE_UNSIGNED_INT , NULL , 0 , 0 ,
139+ OPAL_INFO_LVL_3 , MCA_BASE_VAR_SCOPE_GROUP ,
140+ & mca_osc_sm_component .priority );
141+ free (description_str );
142+
131143 return OPAL_SUCCESS ;
132144}
133145
@@ -154,36 +166,32 @@ component_finalize(void)
154166}
155167
156168
157- static int
158- check_win_ok (ompi_communicator_t * comm , int flavor )
159- {
160- if (! (MPI_WIN_FLAVOR_SHARED == flavor
161- || MPI_WIN_FLAVOR_ALLOCATE == flavor ) ) {
162- return OMPI_ERR_NOT_SUPPORTED ;
163- }
164-
165- if (ompi_group_have_remote_peers (comm -> c_local_group )) {
166- return OMPI_ERR_RMA_SHARED ;
167- }
168-
169- return OMPI_SUCCESS ;
170- }
171-
172-
173169static int
174170component_query (struct ompi_win_t * win , void * * base , size_t size , int disp_unit ,
175171 struct ompi_communicator_t * comm , struct opal_info_t * info ,
176172 int flavor )
177173{
178174 int ret ;
179- if (OMPI_SUCCESS != (ret = check_win_ok (comm , flavor ))) {
180- if (OMPI_ERR_NOT_SUPPORTED == ret ) {
175+
176+ /* component only supports shared or allocate flavors */
177+ if (! (MPI_WIN_FLAVOR_SHARED == flavor ||
178+ MPI_WIN_FLAVOR_ALLOCATE == flavor )) {
179+ return -1 ;
180+ }
181+
182+ /* If flavor is win_allocate, we can't run if there are remote
183+ * peers in the group. The same check for flavor_shared happens
184+ * in select(), so that we can return an error to the user (since
185+ * we should be able to run for all flavor_shared use cases.
186+ * There's no way to return an error from component_query to the
187+ * user, hence the delayed check. */
188+ if (MPI_WIN_FLAVOR_ALLOCATE == flavor ) {
189+ if (ompi_group_have_remote_peers (comm -> c_local_group )) {
181190 return -1 ;
182191 }
183- return ret ;
184192 }
185193
186- return 100 ;
194+ return mca_osc_sm_component . priority ;
187195}
188196
189197
@@ -198,8 +206,10 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
198206 int ret = OMPI_ERROR ;
199207 size_t memory_alignment = OPAL_ALIGN_MIN ;
200208
201- if (OMPI_SUCCESS != (ret = check_win_ok (comm , flavor ))) {
202- return ret ;
209+ assert (MPI_WIN_FLAVOR_SHARED == flavor || MPI_WIN_FLAVOR_ALLOCATE == flavor );
210+
211+ if (ompi_group_have_remote_peers (comm -> c_local_group )) {
212+ return OMPI_ERR_RMA_SHARED ;
203213 }
204214
205215 /* create module structure */
0 commit comments