diff --git a/src/binning_cabana_impl.h b/src/binning_cabana_impl.h index e814dfb..6b44c43 100644 --- a/src/binning_cabana_impl.h +++ b/src/binning_cabana_impl.h @@ -101,9 +101,9 @@ void Binning::create_binning( T_X_FLOAT dx_in, T_X_FLOAT dy_in, system->slice_x(); auto x = system->x; - using device_type = typename t_System::device_type; - Cabana::LinkedCellList cell_list( x, begin, end, delta, - min, max ); + using memory_space = typename t_System::memory_space; + Cabana::LinkedCellList cell_list( x, begin, end, delta, + min, max ); if ( sort ) { diff --git a/src/cabanamd_impl.h b/src/cabanamd_impl.h index b49b951..214f438 100644 --- a/src/cabanamd_impl.h +++ b/src/cabanamd_impl.h @@ -135,39 +135,33 @@ void CbnMD::init( InputCL commandline ) "for the neural network potential." ); else { - using t_device = typename t_System::device_type; + using device_type = typename t_System::device_type; #if ( CabanaMD_LAYOUT_NNP == 1 ) if ( serial_neigh ) - force = - new ForceNNP, t_Neighbor, - Cabana::SerialOpTag, Cabana::SerialOpTag>( - system ); + force = new ForceNNP, + t_Neighbor, Cabana::SerialOpTag, + Cabana::SerialOpTag>( system ); if ( team_neigh ) - force = - new ForceNNP, t_Neighbor, - Cabana::TeamOpTag, Cabana::TeamOpTag>( - system ); + force = new ForceNNP, + t_Neighbor, Cabana::TeamOpTag, + Cabana::TeamOpTag>( system ); if ( vector_angle ) - force = - new ForceNNP, t_Neighbor, - Cabana::TeamOpTag, Cabana::TeamVectorOpTag>( - system ); + force = new ForceNNP, + t_Neighbor, Cabana::TeamOpTag, + Cabana::TeamVectorOpTag>( system ); #elif ( CabanaMD_LAYOUT_NNP == 3 ) if ( serial_neigh ) - force = - new ForceNNP, t_Neighbor, - Cabana::SerialOpTag, Cabana::SerialOpTag>( - system ); + force = new ForceNNP, + t_Neighbor, Cabana::SerialOpTag, + Cabana::SerialOpTag>( system ); if ( team_neigh ) - force = - new ForceNNP, t_Neighbor, - Cabana::TeamOpTag, Cabana::TeamOpTag>( - system ); + force = new ForceNNP, + t_Neighbor, Cabana::TeamOpTag, + Cabana::TeamOpTag>( system ); if ( vector_angle ) - force = - new ForceNNP, t_Neighbor, - Cabana::TeamOpTag, Cabana::TeamVectorOpTag>( - system ); + force = new ForceNNP, + t_Neighbor, Cabana::TeamOpTag, + Cabana::TeamVectorOpTag>( system ); #endif } } diff --git a/src/comm_mpi.h b/src/comm_mpi.h index 00db288..0cd8825 100644 --- a/src/comm_mpi.h +++ b/src/comm_mpi.h @@ -62,7 +62,7 @@ class Comm { // Variables Comm doesn't own but requires for computations - typedef typename t_System::device_type device_type; + using memory_space = typename t_System::memory_space; T_INT N_local; T_INT N_ghost; @@ -85,20 +85,20 @@ class Comm int proc_size; // Number of processes int max_local; - Kokkos::View> pack_count; - Kokkos::View pack_indicies_all; - Kokkos::View pack_indicies; - Kokkos::View pack_ranks_all; - Kokkos::View pack_ranks; - Kokkos::View + Kokkos::View pack_indicies_all; + Kokkos::View pack_indicies; + Kokkos::View pack_ranks_all; + Kokkos::View pack_ranks; + Kokkos::View pack_ranks_migrate_all; - Kokkos::View pack_ranks_migrate; + Kokkos::View pack_ranks_migrate; std::vector> neighbors_halo, neighbors_dist; - std::vector>> halo_all; + std::vector>> halo_all; using exe_space = typename t_System::execution_space; diff --git a/src/comm_mpi_impl.h b/src/comm_mpi_impl.h index 163ea6b..2d563a1 100644 --- a/src/comm_mpi_impl.h +++ b/src/comm_mpi_impl.h @@ -61,12 +61,12 @@ Comm::Comm( t_System *s, T_X_FLOAT comm_depth_ ) MPI_Comm_size( MPI_COMM_WORLD, &proc_size ); MPI_Comm_rank( MPI_COMM_WORLD, &proc_rank ); - pack_count = Kokkos::View( + pack_count = Kokkos::View( "CommMPI::pack_count" ); pack_indicies_all = - Kokkos::View( + Kokkos::View( "CommMPI::pack_indicies_all", 6, 200 ); - pack_ranks_all = Kokkos::View( + pack_ranks_all = Kokkos::View( "CommMPI::pack_ranks_all", 6, 200 ); } @@ -201,10 +201,10 @@ T_INT Comm::exchange() max_local = x.size() * 1.1; - std::shared_ptr> distributor; + std::shared_ptr> distributor; pack_ranks_migrate_all = - Kokkos::View( + Kokkos::View( "pack_ranks_migrate", max_local ); Kokkos::parallel_for( "CommMPI::exchange_self", @@ -246,7 +246,7 @@ T_INT Comm::exchange() Kokkos::deep_copy( count, pack_count ); proc_num_send[phase] = count; - distributor = std::make_shared>( + distributor = std::make_shared>( MPI_COMM_WORLD, pack_ranks_migrate, neighbors_dist[phase] ); system->migrate( distributor ); system->resize( @@ -332,7 +332,7 @@ void Comm::exchange_halo() pack_ranks = Kokkos::subview( pack_ranks, std::pair( 0, proc_num_send[phase] ) ); - halo_all[phase] = std::make_shared>( + halo_all[phase] = std::make_shared>( MPI_COMM_WORLD, N_local + N_ghost, pack_indicies, pack_ranks, neighbors_halo[phase] ); system->resize( halo_all[phase]->numLocal() + diff --git a/src/neighbor_types/neighbor_tree.h b/src/neighbor_types/neighbor_tree.h index 183575f..db053e9 100644 --- a/src/neighbor_types/neighbor_tree.h +++ b/src/neighbor_types/neighbor_tree.h @@ -25,7 +25,6 @@ template class NeighborTree : public Neighbor { - using device_type = typename t_System::device_type; using memory_space = typename t_System::memory_space; public: @@ -73,7 +72,6 @@ template class NeighborTree : public Neighbor { - using device_type = typename t_System::device_type; using memory_space = typename t_System::memory_space; public: diff --git a/src/system.h b/src/system.h index 9a81285..a35b9df 100644 --- a/src/system.h +++ b/src/system.h @@ -62,11 +62,11 @@ #include #include -template +template class SystemCommon { public: - using device_type = t_device; + using device_type = DeviceType; using memory_space = typename device_type::memory_space; using execution_space = typename device_type::execution_space; @@ -79,9 +79,8 @@ class SystemCommon std::string atom_style; // Per Type Property - // typedef typename t_device::array_layout layout; - typedef Kokkos::View t_mass; - typedef Kokkos::View t_mass_const; + typedef Kokkos::View t_mass; + typedef Kokkos::View t_mass_const; typedef typename t_mass::HostMirror h_t_mass; t_mass mass; @@ -241,10 +240,10 @@ class SystemCommon virtual void init() = 0; virtual void resize( T_INT N_new ) = 0; - virtual void permute( Cabana::LinkedCellList cell_list ) = 0; - virtual void - migrate( std::shared_ptr> distributor ) = 0; - virtual void gather( std::shared_ptr> halo ) = 0; + virtual void permute( Cabana::LinkedCellList cell_list ) = 0; + virtual void migrate( + std::shared_ptr> distributor ) = 0; + virtual void gather( std::shared_ptr> halo ) = 0; virtual const char *name() { return "SystemNone"; } private: @@ -252,7 +251,7 @@ class SystemCommon void update_mesh_info() { auto local_mesh = - Cabana::Grid::createLocalMesh( *local_grid ); + Cabana::Grid::createLocalMesh( *local_grid ); local_mesh_lo_x = local_mesh.lowCorner( Cabana::Grid::Own(), 0 ); local_mesh_lo_y = local_mesh.lowCorner( Cabana::Grid::Own(), 1 ); @@ -272,11 +271,11 @@ class SystemCommon } }; -template -class System : public SystemCommon +template +class System : public SystemCommon { public: - using SystemCommon::SystemCommon; + using SystemCommon::SystemCommon; }; #include diff --git a/src/system_types/system_1aosoa.h b/src/system_types/system_1aosoa.h index 5195a3d..e398c10 100644 --- a/src/system_types/system_1aosoa.h +++ b/src/system_types/system_1aosoa.h @@ -16,33 +16,37 @@ #include -template -class System : public SystemCommon +template +class System : public SystemCommon { + public: + using memory_space = typename DeviceType::memory_space; + using execution_space = typename DeviceType::execution_space; + using SystemCommon::SystemCommon; + + protected: using t_tuple = Cabana::MemberTypes; using AoSoA_1 = - typename Cabana::AoSoA; + typename Cabana::AoSoA; AoSoA_1 aosoa_0; - using SystemCommon::N_max; + using SystemCommon::N_max; public: - using SystemCommon::SystemCommon; - // Per Particle Property using t_x = - typename System::AoSoA_1::template member_slice_type<0>; + typename System::AoSoA_1::template member_slice_type<0>; using t_v = - typename System::AoSoA_1::template member_slice_type<1>; + typename System::AoSoA_1::template member_slice_type<1>; using t_f = - typename System::AoSoA_1::template member_slice_type<2>; + typename System::AoSoA_1::template member_slice_type<2>; using t_type = - typename System::AoSoA_1::template member_slice_type<3>; + typename System::AoSoA_1::template member_slice_type<3>; using t_id = - typename System::AoSoA_1::template member_slice_type<4>; + typename System::AoSoA_1::template member_slice_type<4>; using t_q = - typename System::AoSoA_1::template member_slice_type<5>; + typename System::AoSoA_1::template member_slice_type<5>; t_x x; t_v v; t_f f; @@ -75,18 +79,18 @@ class System : public SystemCommon void slice_id() override { id = Cabana::slice<4>( aosoa_0 ); } void slice_q() override { q = Cabana::slice<5>( aosoa_0 ); } - void permute( Cabana::LinkedCellList cell_list ) override + void permute( Cabana::LinkedCellList cell_list ) override { Cabana::permute( cell_list, aosoa_0 ); } - void migrate( - std::shared_ptr> distributor ) override + void migrate( std::shared_ptr> + distributor ) override { Cabana::migrate( *distributor, aosoa_0 ); } - void gather( std::shared_ptr> halo ) override + void gather( std::shared_ptr> halo ) override { Cabana::gather( *halo, aosoa_0 ); } diff --git a/src/system_types/system_2aosoa.h b/src/system_types/system_2aosoa.h index 70ba423..913c20d 100644 --- a/src/system_types/system_2aosoa.h +++ b/src/system_types/system_2aosoa.h @@ -16,40 +16,42 @@ #include -template -class System : public SystemCommon +template +class System : public SystemCommon { + public: + using SystemCommon::SystemCommon; + + using memory_space = typename DeviceType::memory_space; + using execution_space = typename DeviceType::execution_space; + + protected: using t_tuple_0 = Cabana::MemberTypes; using t_tuple_1 = Cabana::MemberTypes; - using AoSoA_2_0 = - typename Cabana::AoSoA; - using AoSoA_2_1 = - typename Cabana::AoSoA; + using AoSoA_2_0 = typename Cabana::AoSoA; + using AoSoA_2_1 = typename Cabana::AoSoA; AoSoA_2_0 aosoa_0; AoSoA_2_1 aosoa_1; - using SystemCommon::N_max; - // using SystemCommon::mass; + using SystemCommon::N_max; + // using SystemCommon::mass; public: - using SystemCommon::SystemCommon; - - using memory_space = typename t_device::memory_space; - using execution_space = typename t_device::execution_space; - // Per Particle Property - using t_x = - typename System::AoSoA_2_0::template member_slice_type<0>; - using t_v = - typename System::AoSoA_2_1::template member_slice_type<0>; - using t_f = - typename System::AoSoA_2_0::template member_slice_type<1>; - using t_type = - typename System::AoSoA_2_0::template member_slice_type<2>; - using t_id = - typename System::AoSoA_2_1::template member_slice_type<1>; - using t_q = - typename System::AoSoA_2_1::template member_slice_type<2>; + using t_x = typename System::AoSoA_2_0::template member_slice_type<0>; + using t_v = typename System::AoSoA_2_1::template member_slice_type<0>; + using t_f = typename System::AoSoA_2_0::template member_slice_type<1>; + using t_type = typename System::AoSoA_2_0::template member_slice_type<2>; + using t_id = typename System::AoSoA_2_1::template member_slice_type<1>; + using t_q = typename System::AoSoA_2_1::template member_slice_type<2>; t_x x; t_v v; t_f f; @@ -88,20 +90,20 @@ class System : public SystemCommon void slice_id() override { id = Cabana::slice<1>( aosoa_1 ); } void slice_q() override { q = Cabana::slice<2>( aosoa_1 ); } - void permute( Cabana::LinkedCellList linkedcell ) override + void permute( Cabana::LinkedCellList linkedcell ) override { Cabana::permute( linkedcell, aosoa_0 ); Cabana::permute( linkedcell, aosoa_1 ); } - void migrate( - std::shared_ptr> distributor ) override + void migrate( std::shared_ptr> + distributor ) override { Cabana::migrate( *distributor, aosoa_0 ); Cabana::migrate( *distributor, aosoa_1 ); } - void gather( std::shared_ptr> halo ) override + void gather( std::shared_ptr> halo ) override { Cabana::gather( *halo, aosoa_0 ); Cabana::gather( *halo, aosoa_1 ); diff --git a/src/system_types/system_6aosoa.h b/src/system_types/system_6aosoa.h index 2f7197d..c4c3eab 100644 --- a/src/system_types/system_6aosoa.h +++ b/src/system_types/system_6aosoa.h @@ -16,24 +16,31 @@ #include -template -class System : public SystemCommon +template +class System : public SystemCommon { + public: + using SystemCommon::SystemCommon; + + using memory_space = typename DeviceType::memory_space; + using execution_space = typename DeviceType::execution_space; + + protected: using t_tuple_x = Cabana::MemberTypes; using t_tuple_int = Cabana::MemberTypes; using t_tuple_fl = Cabana::MemberTypes; - using AoSoA_x = - typename Cabana::AoSoA; - using AoSoA_v = - typename Cabana::AoSoA; - using AoSoA_f = - typename Cabana::AoSoA; - using AoSoA_id = - typename Cabana::AoSoA; - using AoSoA_type = - typename Cabana::AoSoA; - using AoSoA_q = - typename Cabana::AoSoA; + using AoSoA_x = typename Cabana::AoSoA; + using AoSoA_v = typename Cabana::AoSoA; + using AoSoA_f = typename Cabana::AoSoA; + using AoSoA_id = typename Cabana::AoSoA; + using AoSoA_type = typename Cabana::AoSoA; + using AoSoA_q = typename Cabana::AoSoA; AoSoA_x aosoa_x; AoSoA_v aosoa_v; AoSoA_f aosoa_f; @@ -41,28 +48,24 @@ class System : public SystemCommon AoSoA_type aosoa_type; AoSoA_q aosoa_q; - using SystemCommon::N_max; - // using SystemCommon::mass; + using SystemCommon::N_max; + // using SystemCommon::mass; public: - using SystemCommon::SystemCommon; - - using memory_space = typename t_device::memory_space; - using execution_space = typename t_device::execution_space; - // Per Particle Property using t_x = - typename System::AoSoA_x::template member_slice_type<0>; + typename System::AoSoA_x::template member_slice_type<0>; using t_v = - typename System::AoSoA_v::template member_slice_type<0>; + typename System::AoSoA_v::template member_slice_type<0>; using t_f = - typename System::AoSoA_f::template member_slice_type<0>; + typename System::AoSoA_f::template member_slice_type<0>; using t_type = - typename System::AoSoA_type::template member_slice_type<0>; + typename System::AoSoA_type::template member_slice_type<0>; using t_id = - typename System::AoSoA_id::template member_slice_type<0>; + typename System::AoSoA_id::template member_slice_type<0>; using t_q = - typename System::AoSoA_q::template member_slice_type<0>; + typename System::AoSoA_q::template member_slice_type<0>; t_x x; t_v v; @@ -114,7 +117,7 @@ class System : public SystemCommon void slice_id() override { id = Cabana::slice<0>( aosoa_id ); } void slice_q() override { q = Cabana::slice<0>( aosoa_q ); } - void permute( Cabana::LinkedCellList cell_list ) override + void permute( Cabana::LinkedCellList cell_list ) override { Cabana::permute( cell_list, aosoa_x ); Cabana::permute( cell_list, aosoa_v ); @@ -124,8 +127,8 @@ class System : public SystemCommon Cabana::permute( cell_list, aosoa_q ); } - void migrate( - std::shared_ptr> distributor ) override + void migrate( std::shared_ptr> + distributor ) override { Cabana::migrate( *distributor, aosoa_x ); Cabana::migrate( *distributor, aosoa_v ); @@ -135,7 +138,7 @@ class System : public SystemCommon Cabana::migrate( *distributor, aosoa_q ); } - void gather( std::shared_ptr> halo ) override + void gather( std::shared_ptr> halo ) override { Cabana::gather( *halo, aosoa_x ); Cabana::gather( *halo, aosoa_v ); diff --git a/src/system_types/system_nnp.h b/src/system_types/system_nnp.h index 882168d..edebb26 100644 --- a/src/system_types/system_nnp.h +++ b/src/system_types/system_nnp.h @@ -16,7 +16,7 @@ #include -template +template class System_NNP { }; diff --git a/src/system_types/system_nnp_1aosoa.h b/src/system_types/system_nnp_1aosoa.h index 06df9ba..8cfe65e 100644 --- a/src/system_types/system_nnp_1aosoa.h +++ b/src/system_types/system_nnp_1aosoa.h @@ -16,32 +16,36 @@ #include -template -class System_NNP +template +class System_NNP { + public: + using memory_space = typename DeviceType::memory_space; + + protected: using t_tuple_NNP = Cabana::MemberTypes; - using AoSoA_NNP_1 = typename Cabana::AoSoA; AoSoA_NNP_1 aosoa_0; public: using t_G = - typename System_NNP::AoSoA_NNP_1::template member_slice_type<0>; using t_dEdG = - typename System_NNP::AoSoA_NNP_1::template member_slice_type<1>; using t_E = - typename System_NNP::AoSoA_NNP_1::template member_slice_type<2>; t_G G; t_dEdG dEdG; t_E E; - System_NNP() { AoSoA_NNP_1 aosoa_0( "All", 0 ); } - ~System_NNP() {} + System_NNP() { AoSoA_NNP_1 aosoa_0( "All", 0 ); } + ~System_NNP() {} void resize( T_INT N_new ) { aosoa_0.resize( N_new ); } diff --git a/src/system_types/system_nnp_3aosoa.h b/src/system_types/system_nnp_3aosoa.h index 796d5e7..a61f005 100644 --- a/src/system_types/system_nnp_3aosoa.h +++ b/src/system_types/system_nnp_3aosoa.h @@ -16,17 +16,21 @@ #include -template -class System_NNP +template +class System_NNP { + public: + using memory_space = typename DeviceType::memory_space; + + protected: using t_tuple_NNP_SF = Cabana::MemberTypes; using t_tuple_NNP_fl = Cabana::MemberTypes; - using AoSoA_NNP_G = typename Cabana::AoSoA; - using AoSoA_NNP_dEdG = typename Cabana::AoSoA; - using AoSoA_NNP_E = typename Cabana::AoSoA; AoSoA_NNP_G aosoa_G; AoSoA_NNP_dEdG aosoa_dEdG; @@ -34,25 +38,25 @@ class System_NNP public: using t_G = - typename System_NNP::AoSoA_NNP_G::template member_slice_type<0>; using t_dEdG = - typename System_NNP::AoSoA_NNP_dEdG::template member_slice_type<0>; using t_E = - typename System_NNP::AoSoA_NNP_E::template member_slice_type<0>; t_G G; t_dEdG dEdG; t_E E; - System_NNP() + System_NNP() { AoSoA_NNP_G aosoa_G( "G", 0 ); AoSoA_NNP_dEdG aosoa_dEdG( "dEdG", 0 ); AoSoA_NNP_E aosoa_E( "E", 0 ); } - ~System_NNP() {} + ~System_NNP() {} void resize( T_INT N_new ) {