#if COMPILATION_INSTRUCTIONS mpic++ -O3 -std=c++14 -Wall -Wextra `#-Wfatal-errors` -I$HOME/prj/alf $0 -o $0x.x && mpirun -n 4 $0x.x $@ && rm -f $0x.x; exit #endif #include "../../mpi3/shm/allocator.hpp" #include "../../mpi3/main.hpp" #include "boost/multi/array.hpp" #include namespace mpi3 = boost::mpi3; namespace multi = boost::multi; using std::cout; namespace boost{namespace mpi3{namespace shm{ namespace multi{ template using array = boost::multi::array>; } }}} int mpi3::main(int, char*[], mpi3::communicator world){ mpi3::shared_communicator node = world.split_shared(); multi::array> A({16, 16}, node); assert(A[2][2] == 0); node.barrier(); if(node.root()) A[2][2] = 3.14; node.barrier(); assert(A[2][2] == 3.14); shm::multi::array B = A; // multi::array> B = A; assert(A[2][2] == 3.14); assert(B[2][2] == 3.14); shm::multi::array C({1, 1}, node); C.reextent({30,30}); assert(C.size() == 30); // C = std::move(A); // assert(C[2][2] == 3.14); // assert(A.size()==0); node.barrier(); { std::vector> w; std::vector> v(2, shm::multi::array(shm::allocator{node})); v.reserve(3); v.emplace_back(shm::multi::array({10,10}, node)); v.emplace_back(node); v.emplace_back(shm::multi::array({20,20}, node)); v.emplace_back(shm::multi::array({15,15}, node)); if(world.rank() == 0) v[4][2][3] = 5.; world.barrier(); if(world.rank() == 1) assert(v[4][2][3] == 5.); world.barrier(); v[2].reextent({30, 30}); assert( v[2].size() == 30 ); v.pop_back(); assert( v.back().size() == 20 ); } shm::multi::array AA({0,0}, node); assert(AA.size() == 0); { boost::multi::array, 1, shm::allocator>> v(std::array{{3}}, shm::allocator>{node}); v[0].reextent({10, 10}); v[1].reextent({20, 20}); v[2].reextent({30, 30}); if(world.rank() == 1) v[1][2][3] = 5.; world.barrier(); if(world.rank() == 1) assert(v[1][2][3] == 5.); } { using inner_ma = boost::multi::array>; // using dd = inner_ma::allocator_type; using outter_vec = std::vector>; using scoped_alloc = std::scoped_allocator_adaptor, shm::allocator>; shm::allocator aaaa{node}; scoped_alloc sa(std::allocator{}, aaaa ); outter_vec v(sa); // std::vector v; v.emplace_back(shm::allocator{node}); // v.emplace_back(std::array{{10, 10}}); // v.resize(10, {node}); // boost::multi::array, 1, std::scoped_allocator_adaptor>>, shm::allocator> > v(sa); cout << "fdfsd " << std::uses_allocator>{} << std::endl; cout << "fdffddf " << std::is_constructible&>{} << std::endl; } return 0; }