removed need for comm& in shared_window

This commit is contained in:
mmorale3 2019-12-16 12:01:37 -08:00
parent 084eac41a7
commit eefed964f2
3 changed files with 28 additions and 23 deletions

View File

@ -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<enum error>(MPI_Comm_create(MPI_COMM_WORLD, &g, &impl_));
if(e != mpi3::error::success) throw std::system_error{e, "cannot create"};

View File

@ -20,9 +20,9 @@ namespace mpi3{
template<class T>
struct shared_window : window<T>{
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<T>(), 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<T>(), comm_{comm}
{
void* base_ptr = nullptr;
auto e = static_cast<enum error>(
@ -37,12 +37,12 @@ struct shared_window : window<T>{
shared_window(comm, 0, disp_unit)
{}
shared_window(shared_window const&) = default;
shared_window(shared_window&& other) noexcept : window<T>{std::move(other)}, comm_{other.comm_}
shared_window(shared_window&& other) noexcept : window<T>{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;

View File

@ -168,7 +168,7 @@ shm_ptr_with_raw_ptr_dispatch<T> 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<T> 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<T> destroy_n(shm_ptr_with_raw_ptr_dispatch<T> 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<T> 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<T> 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<T> 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<T> 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<T> 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<T> 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<T> 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<T> 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<T> 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<T> 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<T, 1, shm::shm_ptr_with_raw_ptr_dispatch<T>> 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<T, 1, shm::shm_ptr_with_raw_ptr_dispatch<T>> 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<T, 1, shm::shm_ptr_with_raw_ptr_dispatch<T>> 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<T, 1, shm::shm_ptr_with_raw_ptr_dispatch<T>> 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<T, 1, T*> 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);
}