From eefed964f28f7c2d40bdf13e10037a24893d7a45 Mon Sep 17 00:00:00 2001 From: mmorale3 Date: Mon, 16 Dec 2019 12:01:37 -0800 Subject: [PATCH] removed need for comm& in shared_window --- .../mpi_wrapper/mpi3/communicator.hpp | 5 +++ .../mpi_wrapper/mpi3/shared_window.hpp | 10 +++--- .../shm_ptr_with_raw_ptr_dispatch.hpp | 36 +++++++++---------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/external_codes/mpi_wrapper/mpi3/communicator.hpp b/external_codes/mpi_wrapper/mpi3/communicator.hpp index 150e806c4..a2feb29d7 100644 --- a/external_codes/mpi_wrapper/mpi3/communicator.hpp +++ b/external_codes/mpi_wrapper/mpi3/communicator.hpp @@ -200,6 +200,7 @@ protected: } public: communicator(communicator const& o, group const& g); + communicator(group const& g, int tag); communicator(group const& g); explicit operator group() const; @@ -2935,6 +2936,10 @@ friend communicator& operator<<(communicator& comm, T const& t){ inline void barrier(communicator const& self){self.barrier();} +inline communicator::communicator(group const& g, int tag){ + MPI3_CALL(MPI_Comm_create_group)(MPI_COMM_WORLD, &g, tag, &impl_); +} + inline communicator::communicator(group const& g){ auto e = static_cast(MPI_Comm_create(MPI_COMM_WORLD, &g, &impl_)); if(e != mpi3::error::success) throw std::system_error{e, "cannot create"}; diff --git a/external_codes/mpi_wrapper/mpi3/shared_window.hpp b/external_codes/mpi_wrapper/mpi3/shared_window.hpp index 60e4af39e..f1a9cdb73 100644 --- a/external_codes/mpi_wrapper/mpi3/shared_window.hpp +++ b/external_codes/mpi_wrapper/mpi3/shared_window.hpp @@ -20,9 +20,9 @@ namespace mpi3{ template struct shared_window : window{ - shared_communicator& comm_; - shared_window(shared_communicator& comm, mpi3::size_t n, int disp_unit = alignof(T)) : //sizeof(T)) : // here we assume that disp_unit is used for align - window(), comm_{comm} +// shared_communicator& comm_; + shared_window(shared_communicator& comm, mpi3::size_t n, int disp_unit = alignof(T)) //sizeof(T)) : // here we assume that disp_unit is used for align + //window(), comm_{comm} { void* base_ptr = nullptr; auto e = static_cast( @@ -37,12 +37,12 @@ struct shared_window : window{ shared_window(comm, 0, disp_unit) {} shared_window(shared_window const&) = default; - shared_window(shared_window&& other) noexcept : window{std::move(other)}, comm_{other.comm_} + shared_window(shared_window&& other) noexcept : window{std::move(other)} //, comm_{other.comm_} {} group get_group() const{ group r; MPI3_CALL(MPI_Win_get_group)(this->impl_, &(&r)); return r; } - shared_communicator& get_communicator() const{return comm_;} +// shared_communicator& get_communicator() const{return comm_;} struct query_t{ mpi3::size_t size; int disp_unit; diff --git a/src/AFQMC/Memory/SharedMemory/shm_ptr_with_raw_ptr_dispatch.hpp b/src/AFQMC/Memory/SharedMemory/shm_ptr_with_raw_ptr_dispatch.hpp index a7f063571..5babb6bca 100644 --- a/src/AFQMC/Memory/SharedMemory/shm_ptr_with_raw_ptr_dispatch.hpp +++ b/src/AFQMC/Memory/SharedMemory/shm_ptr_with_raw_ptr_dispatch.hpp @@ -168,7 +168,7 @@ shm_ptr_with_raw_ptr_dispatch uninitialized_fill_n(shm_ptr_with_raw_ptr_dispa if(first.wSP_->get_group().root()) std::uninitialized_fill_n(to_address(first), n, val); // change to to_pointer first.wSP_->fence(); first.wSP_->fence(); - first.wSP_->comm_.barrier(); + mpi3::communicator(first.wSP_->get_group(),0).barrier(); return first + n; } @@ -178,7 +178,7 @@ shm_ptr_with_raw_ptr_dispatch uninitialized_fill_n(Alloc &a, shm_ptr_with_raw if(first.wSP_->get_group().root()) std::uninitialized_fill_n(to_address(first), n, val); // change to to_pointer first.wSP_->fence(); first.wSP_->fence(); - first.wSP_->comm_.barrier(); + mpi3::communicator(first.wSP_->get_group(),0).barrier(); return first + n; } @@ -191,7 +191,7 @@ shm_ptr_with_raw_ptr_dispatch destroy_n(shm_ptr_with_raw_ptr_dispatch firs } first.wSP_->fence(); first.wSP_->fence(); - first.wSP_->comm_.barrier(); + mpi3::communicator(first.wSP_->get_group(),0).barrier(); return first + n; } @@ -204,7 +204,7 @@ shm_ptr_with_raw_ptr_dispatch destroy_n(Alloc &a, shm_ptr_with_raw_ptr_dispat } first.wSP_->fence(); first.wSP_->fence(); - first.wSP_->comm_.barrier(); + mpi3::communicator(first.wSP_->get_group(),0).barrier(); return first + n; } @@ -214,7 +214,7 @@ shm_ptr_with_raw_ptr_dispatch copy_n(It1 first, Size n, shm_ptr_with_raw_ptr_ using std::copy_n; if(d_first.wSP_->get_group().root()) copy_n(first, n, to_address(d_first)); d_first.wSP_->fence(); - d_first.wSP_->comm_.barrier(); + mpi3::communicator(d_first.wSP_->get_group(),0).barrier(); return d_first + n; } @@ -224,7 +224,7 @@ shm_ptr_with_raw_ptr_dispatch copy(It1 first, It1 last, shm_ptr_with_raw_ptr_ using std::copy; if(d_first.wSP_->get_group().root()) copy(first, last, to_address(d_first)); first.wSP_->fence(); - d_first.wSP_->comm_.barrier(); + mpi3::communicator(d_first.wSP_->get_group(),0).barrier(); using std::distance; return d_first + distance(first, last); } @@ -235,7 +235,7 @@ shm_ptr_with_raw_ptr_dispatch uninitialized_copy_n(It1 f, Size n, shm_ptr_wit using std::uninitialized_copy_n; if(d.wSP_->get_group().root()) uninitialized_copy_n(f, n, to_address(d)); f.wSP_->fence(); - d.wSP_->comm_.barrier(); + mpi3::communicator(d.wSP_->get_group(),0).barrier(); return d + n; } @@ -245,7 +245,7 @@ shm_ptr_with_raw_ptr_dispatch uninitialized_copy_n(Alloc &a, It1 f, Size n, s using std::uninitialized_copy_n; if(d.wSP_->get_group().root()) uninitialized_copy_n(f, n, to_address(d)); f.wSP_->fence(); - d.wSP_->comm_.barrier(); + mpi3::communicator(d.wSP_->get_group(),0).barrier(); return d + n; } @@ -256,7 +256,7 @@ shm_ptr_with_raw_ptr_dispatch uninitialized_copy(It1 f, It1 l, shm_ptr_with_r using std::uninitialized_copy; if(d.wSP_->get_group().root()) uninitialized_copy(f, l, to_address(d)); d.wSP_->fence(); - d.wSP_->comm_.barrier(); + mpi3::communicator(d.wSP_->get_group(),0).barrier(); using std::distance; return d + distance(f, l); } @@ -271,7 +271,7 @@ shm_ptr_with_raw_ptr_dispatch uninitialized_default_construct_n(shm_ptr_with_ }catch(...) {throw;} // leak! } f.wSP_->fence(); - f.wSP_->comm_.barrier(); + mpi3::communicator(f.wSP_->get_group(),0).barrier(); return f + n; } @@ -285,7 +285,7 @@ shm_ptr_with_raw_ptr_dispatch uninitialized_value_construct_n(shm_ptr_with_ra }catch(...){throw;} // leak !! } f.wSP_->fence(); - f.wSP_->comm_.barrier(); + mpi3::communicator(f.wSP_->get_group(),0).barrier(); return f + n; } @@ -300,7 +300,7 @@ shm_ptr_with_raw_ptr_dispatch uninitialized_default_construct_n(Alloc &a, shm }catch(...) {throw;} // leak! } f.wSP_->fence(); - f.wSP_->comm_.barrier(); + mpi3::communicator(f.wSP_->get_group(),0).barrier(); return f + n; } @@ -315,7 +315,7 @@ shm_ptr_with_raw_ptr_dispatch uninitialized_value_construct_n(Alloc &a, shm_p }catch(...){throw;} // leak !! } f.wSP_->fence(); - f.wSP_->comm_.barrier(); + mpi3::communicator(f.wSP_->get_group(),0).barrier(); return f + n; } @@ -340,7 +340,7 @@ multi::array_iterator> uninitialized } base(first).wSP_->fence(); base(first).wSP_->fence(); - base(first).wSP_->comm_.barrier(); + mpi3::communicator(base(first).wSP_->get_group(),0).barrier(); return first + n; } @@ -371,7 +371,7 @@ multi::array_iterator> copy_n( } base(dest).wSP_->fence(); base(dest).wSP_->fence(); - base(dest).wSP_->comm_.barrier(); + mpi3::communicator(base(dest).wSP_->get_group(),0).barrier(); return dest + n; } @@ -390,7 +390,7 @@ multi::array_iterator> copy_n( } base(dest).wSP_->fence(); base(dest).wSP_->fence(); - base(dest).wSP_->comm_.barrier(); + mpi3::communicator(base(dest).wSP_->get_group(),0).barrier(); return dest + n; } @@ -463,7 +463,7 @@ multi::array_iterator> uninitialized } base(dest).wSP_->fence(); base(dest).wSP_->fence(); - base(dest).wSP_->comm_.barrier(); + mpi3::communicator(base(dest).wSP_->get_group(),0).barrier(); return dest + n; } @@ -495,7 +495,7 @@ multi::array_iterator uninitialized_copy( a.construct(addressof(*d), *first); }catch(...){throw;} } - base(first).wSP_->comm_.barrier(); + mpi3::communicator(base(first).wSP_->get_group(),0).barrier(); return dest + std::distance(first,last); }