6969#include "ompi/mca/bml/base/base.h"
7070#include "ompi/mca/mtl/base/base.h"
7171
72+ static int ompi_osc_rdma_shared_query (struct ompi_win_t * win , int rank , size_t * size ,
73+ ptrdiff_t * disp_unit , void * baseptr );
7274static int ompi_osc_rdma_component_register (void );
7375static int ompi_osc_rdma_component_init (bool enable_progress_threads , bool enable_mpi_threads );
7476static int ompi_osc_rdma_component_finalize (void );
@@ -113,6 +115,7 @@ ompi_osc_rdma_component_t mca_osc_rdma_component = {
113115MCA_BASE_COMPONENT_INIT (ompi , osc , rdma )
114116
115117ompi_osc_base_module_t ompi_osc_rdma_module_rdma_template = {
118+ .osc_win_shared_query = ompi_osc_rdma_shared_query ,
116119 .osc_win_attach = ompi_osc_rdma_attach ,
117120 .osc_win_detach = ompi_osc_rdma_detach ,
118121 .osc_free = ompi_osc_rdma_free ,
@@ -527,6 +530,7 @@ static int allocate_state_single (ompi_osc_rdma_module_t *module, void **base, s
527530 module -> my_peer = my_peer ;
528531 module -> free_after = module -> rank_array ;
529532 my_peer -> flags |= OMPI_OSC_RDMA_PEER_LOCAL_BASE ;
533+ my_peer -> flags |= OMPI_OSC_RDMA_PEER_CPU_ATOMICS ;
530534 my_peer -> state = (uint64_t ) (uintptr_t ) module -> state ;
531535
532536 if (use_cpu_atomics ) {
@@ -636,7 +640,6 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
636640 /* ensure proper alignment */
637641 if (MPI_WIN_FLAVOR_ALLOCATE == module -> flavor ) {
638642 data_base += OPAL_ALIGN_PAD_AMOUNT (data_base , memory_alignment );
639- size += OPAL_ALIGN_PAD_AMOUNT (size , memory_alignment );
640643 }
641644
642645 do {
@@ -836,6 +839,7 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
836839 if (MPI_WIN_FLAVOR_DYNAMIC == module -> flavor ) {
837840 if (use_cpu_atomics && peer_rank == my_rank ) {
838841 peer -> flags |= OMPI_OSC_RDMA_PEER_LOCAL_BASE ;
842+ peer -> flags |= OMPI_OSC_RDMA_PEER_CPU_ATOMICS ;
839843 }
840844 /* nothing more to do */
841845 continue ;
@@ -850,7 +854,7 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
850854 ex_peer -> size = temp [i ].size ;
851855 }
852856
853- if (use_cpu_atomics && ( MPI_WIN_FLAVOR_ALLOCATE == module -> flavor || peer_rank == my_rank ) ) {
857+ if (MPI_WIN_FLAVOR_ALLOCATE == module -> flavor || peer_rank == my_rank ) {
854858 /* base is local and cpu atomics are available */
855859 if (MPI_WIN_FLAVOR_ALLOCATE == module -> flavor ) {
856860 ex_peer -> super .base = (uintptr_t ) module -> segment_base + offset ;
@@ -859,7 +863,11 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
859863 }
860864
861865 peer -> flags |= OMPI_OSC_RDMA_PEER_LOCAL_BASE ;
866+ if (use_cpu_atomics ) {
867+ peer -> flags |= OMPI_OSC_RDMA_PEER_CPU_ATOMICS ;
868+ }
862869 offset += temp [i ].size ;
870+ offset += OPAL_ALIGN_PAD_AMOUNT (offset , memory_alignment );
863871 } else {
864872 ex_peer -> super .base = peer_region -> base ;
865873
@@ -898,7 +906,7 @@ static void ompi_osc_rdma_ensure_local_add_procs (void)
898906 /* this will cause add_proc to get called if it has not already been called */
899907 (void ) mca_bml_base_get_endpoint (proc );
900908 }
901- }
909+ }
902910
903911 free (procs );
904912}
@@ -1632,3 +1640,60 @@ ompi_osc_rdma_set_no_lock_info(opal_infosubscriber_t *obj, const char *key, cons
16321640 */
16331641 return module -> no_locks ? "true" : "false" ;
16341642}
1643+
1644+ int ompi_osc_rdma_shared_query (
1645+ struct ompi_win_t * win , int rank , size_t * size ,
1646+ ptrdiff_t * disp_unit , void * baseptr )
1647+ {
1648+ int rc = OMPI_ERR_NOT_SUPPORTED ;
1649+ ompi_osc_rdma_peer_t * peer ;
1650+ int actual_rank = rank ;
1651+ ompi_osc_rdma_module_t * module = GET_MODULE (win );
1652+
1653+ peer = ompi_osc_module_get_peer (module , actual_rank );
1654+ if (NULL == peer ) {
1655+ return OMPI_ERR_NOT_SUPPORTED ;
1656+ }
1657+
1658+ /* currently only supported for allocated windows */
1659+ if (MPI_WIN_FLAVOR_ALLOCATE != module -> flavor ) {
1660+ return OMPI_ERR_NOT_SUPPORTED ;
1661+ }
1662+
1663+ if (!ompi_osc_rdma_peer_local_base (peer )) {
1664+ return OMPI_ERR_NOT_SUPPORTED ;
1665+ }
1666+
1667+ if (MPI_PROC_NULL == rank ) {
1668+ /* iterate until we find a rank that has a non-zero size */
1669+ for (int i = 0 ; i < ompi_comm_size (module -> comm ) ; ++ i ) {
1670+ peer = ompi_osc_module_get_peer (module , i );
1671+ ompi_osc_rdma_peer_extended_t * ex_peer = (ompi_osc_rdma_peer_extended_t * ) peer ;
1672+ if (!ompi_osc_rdma_peer_local_base (peer )) {
1673+ continue ;
1674+ } else if (module -> same_size && ex_peer -> super .base ) {
1675+ break ;
1676+ } else if (ex_peer -> size > 0 ) {
1677+ break ;
1678+ }
1679+ }
1680+ }
1681+
1682+ if (module -> same_size && module -> same_disp_unit ) {
1683+ * size = module -> size ;
1684+ * disp_unit = module -> disp_unit ;
1685+ ompi_osc_rdma_peer_basic_t * ex_peer = (ompi_osc_rdma_peer_basic_t * ) peer ;
1686+ * ((void * * ) baseptr ) = (void * ) (intptr_t )ex_peer -> base ;
1687+ rc = OMPI_SUCCESS ;
1688+ } else {
1689+ ompi_osc_rdma_peer_extended_t * ex_peer = (ompi_osc_rdma_peer_extended_t * ) peer ;
1690+ if (ex_peer -> super .base != 0 ) {
1691+ /* we know the base of the peer */
1692+ * ((void * * ) baseptr ) = (void * ) (intptr_t )ex_peer -> super .base ;
1693+ * size = ex_peer -> size ;
1694+ * disp_unit = ex_peer -> disp_unit ;
1695+ rc = OMPI_SUCCESS ;
1696+ }
1697+ }
1698+ return rc ;
1699+ }
0 commit comments