From 5412784ee26744ac8832ea1cdca5d3b9b9701427 Mon Sep 17 00:00:00 2001 From: John Biddiscombe Date: Tue, 3 Mar 2026 08:49:28 +0100 Subject: [PATCH] Kokkos 5 replaces HostMirror with host_mirror_type --- .../ChargedParticles.hpp | 19 +++-- doc/examples/BasicsFFT.hpp | 2 +- src/Field/BareField.h | 4 +- src/Particle/ParticleAttrib.h | 8 +-- src/Utility/ViewUtils.h | 2 +- test/FFT/TestCos.cpp | 4 +- test/FFT/TestCos1.cpp | 4 +- test/FFT/TestFFTCC.cpp | 4 +- test/FFT/TestFFTRC.cpp | 4 +- test/FFT/TestSine.cpp | 4 +- test/kokkos/TestVectorField.cpp | 12 ++-- test/kokkos/TestVectorField2.cpp | 12 ++-- test/kokkos/TestVectorField3.cpp | 14 ++-- test/kokkos/TestVectorField4.cpp | 4 +- test/particle/PICnd.cpp | 2 +- test/particle/TestGather.cpp | 10 +-- test/particle/TestHashedScatter.cpp | 72 +++++++++++-------- test/particle/TestScatter.cpp | 5 +- test/particle/benchmarkParticleUpdate.cpp | 4 +- test/serialization/serialize01.cpp | 8 ++- unit_tests/FFT/FFT.cpp | 21 +++--- unit_tests/Particle/ParticleBC.cpp | 2 +- 22 files changed, 115 insertions(+), 106 deletions(-) diff --git a/alpine/ExamplesWithoutPicManager/ChargedParticles.hpp b/alpine/ExamplesWithoutPicManager/ChargedParticles.hpp index 44afd8749..47d0a4124 100644 --- a/alpine/ExamplesWithoutPicManager/ChargedParticles.hpp +++ b/alpine/ExamplesWithoutPicManager/ChargedParticles.hpp @@ -63,15 +63,18 @@ using FFTSolver_t = ConditionalType, Field_t>>; template -using FFTTruncatedGreenSolver_t = ConditionalType, Field_t>>; +using FFTTruncatedGreenSolver_t = + ConditionalType, Field_t>>; template using OpenSolver_t = ConditionalType, Field_t>>; template -using Solver_t = VariantFromConditionalTypes, FFTSolver_t, - FFTTruncatedGreenSolver_t, OpenSolver_t>; +using Solver_t = + VariantFromConditionalTypes, FFTSolver_t, + FFTTruncatedGreenSolver_t, OpenSolver_t>; const double pi = Kokkos::numbers::pi_v; @@ -652,13 +655,13 @@ class ChargedParticles : public ippl::ParticleBase { ippl::Comm->barrier(); } - typename VField_t::HostMirror getEMirror() const { + typename VField_t::host_mirror_type getEMirror() const { auto Eview = E_m.getHostMirror(); updateEMirror(Eview); return Eview; } - void updateEMirror(typename VField_t::HostMirror& mirror) const { + void updateEMirror(typename VField_t::host_mirror_type& mirror) const { Kokkos::deep_copy(mirror, E_m.getView()); } @@ -770,8 +773,10 @@ class ChargedParticles : public ippl::ParticleBase { } void dumpParticleData() { - typename ParticleAttrib>::HostMirror R_host = this->R.getHostMirror(); - typename ParticleAttrib>::HostMirror P_host = this->P.getHostMirror(); + typename ParticleAttrib>::host_mirror_type R_host = + this->R.getHostMirror(); + typename ParticleAttrib>::host_mirror_type P_host = + this->P.getHostMirror(); Kokkos::deep_copy(R_host, this->R.getView()); Kokkos::deep_copy(P_host, P.getView()); std::stringstream pname; diff --git a/doc/examples/BasicsFFT.hpp b/doc/examples/BasicsFFT.hpp index a866317f3..010e8a92a 100644 --- a/doc/examples/BasicsFFT.hpp +++ b/doc/examples/BasicsFFT.hpp @@ -68,7 +68,7 @@ field_type_complex fieldOutput(meshOutput, layoutOutput); // Fill Field fieldInput with random numbers typename field_type_real::view_type& view = fieldInput.getView(); -typename field_type_real::HostMirror fieldInput_host = fieldInput.getHostMirror(); +typename field_type_real::host_mirror_type fieldInput_host = fieldInput.getHostMirror(); const int nghost = fieldInput.getNghost(); std::mt19937_64 eng(42 + ippl::Comm->rank()); diff --git a/src/Field/BareField.h b/src/Field/BareField.h index 06c80aef5..33908ef53 100644 --- a/src/Field/BareField.h +++ b/src/Field/BareField.h @@ -50,7 +50,7 @@ namespace ippl { using view_type = typename detail::ViewType::view_type; typedef typename view_type::memory_space memory_space; typedef typename view_type::execution_space execution_space; - using HostMirror = typename view_type::host_mirror_type; + using host_mirror_type = typename view_type::host_mirror_type; template using policy_type = typename RangePolicy::policy_type; @@ -170,7 +170,7 @@ namespace ippl { const view_type& getView() const { return dview_m; } - HostMirror getHostMirror() const { return Kokkos::create_mirror(dview_m); } + host_mirror_type getHostMirror() const { return Kokkos::create_mirror(dview_m); } /*! * Generate the range policy for iterating over the field, diff --git a/src/Particle/ParticleAttrib.h b/src/Particle/ParticleAttrib.h index ca55ca81f..b9732fdf0 100644 --- a/src/Particle/ParticleAttrib.h +++ b/src/Particle/ParticleAttrib.h @@ -41,7 +41,7 @@ namespace ippl { using view_type = typename detail::ViewType::view_type; - using HostMirror = typename view_type::host_mirror_type; + using host_mirror_type = typename view_type::host_mirror_type; using memory_space = typename view_type::memory_space; using execution_space = typename view_type::execution_space; @@ -87,7 +87,7 @@ namespace ippl { void realloc(size_type n) { Kokkos::realloc(dview_m, n); } void print() { - HostMirror hview = Kokkos::create_mirror_view(dview_m); + host_mirror_type hview = Kokkos::create_mirror_view(dview_m); Kokkos::deep_copy(hview, dview_m); for (size_type i = 0; i < *(this->localNum_mp); ++i) { std::cout << hview(i) << std::endl; @@ -100,8 +100,8 @@ namespace ippl { const view_type& getView() const { return dview_m; } - HostMirror getHostMirror() const { return Kokkos::create_mirror(dview_m); } - + host_mirror_type getHostMirror() const { return Kokkos::create_mirror(dview_m); } + void set_name(const std::string& name_) override { size_t len = name_.size(); if (len >= detail::ATTRIB_NAME_MAX_LEN) { diff --git a/src/Utility/ViewUtils.h b/src/Utility/ViewUtils.h index 383b78128..f03ae5a21 100644 --- a/src/Utility/ViewUtils.h +++ b/src/Utility/ViewUtils.h @@ -84,7 +84,7 @@ namespace ippl { void write(const typename ViewType::view_type& view, std::ostream& out = std::cout) { using view_type = typename ViewType::view_type; - typename view_type::HostMirror hview = Kokkos::create_mirror_view(view); + typename view_type::host_mirror_type hview = Kokkos::create_mirror_view(view); Kokkos::deep_copy(hview, view); nestedViewLoop( diff --git a/test/FFT/TestCos.cpp b/test/FFT/TestCos.cpp index 66392432b..17a16f80d 100644 --- a/test/FFT/TestCos.cpp +++ b/test/FFT/TestCos.cpp @@ -51,8 +51,8 @@ int main(int argc, char* argv[]) { fft = std::make_unique(layout, fftParams); - typename field_type::view_type& view = field.getView(); - typename field_type::HostMirror field_host = field.getHostMirror(); + typename field_type::view_type& view = field.getView(); + typename field_type::host_mirror_type field_host = field.getHostMirror(); const int nghost = field.getNghost(); std::mt19937_64 eng(42 + ippl::Comm->rank()); diff --git a/test/FFT/TestCos1.cpp b/test/FFT/TestCos1.cpp index 10313301e..67ae5af5e 100644 --- a/test/FFT/TestCos1.cpp +++ b/test/FFT/TestCos1.cpp @@ -51,8 +51,8 @@ int main(int argc, char* argv[]) { fft = std::make_unique(layout, fftParams); - typename field_type::view_type& view = field.getView(); - typename field_type::HostMirror field_host = field.getHostMirror(); + typename field_type::view_type& view = field.getView(); + typename field_type::host_mirror_type field_host = field.getHostMirror(); const int nghost = field.getNghost(); std::mt19937_64 eng(42 + ippl::Comm->rank()); diff --git a/test/FFT/TestFFTCC.cpp b/test/FFT/TestFFTCC.cpp index 15c47d62e..8ed81b1a6 100644 --- a/test/FFT/TestFFTCC.cpp +++ b/test/FFT/TestFFTCC.cpp @@ -48,8 +48,8 @@ int main(int argc, char* argv[]) { fft = std::make_unique(layout, fftParams); - typename field_type::view_type& view = field.getView(); - typename field_type::HostMirror field_host = field.getHostMirror(); + typename field_type::view_type& view = field.getView(); + typename field_type::host_mirror_type field_host = field.getHostMirror(); const int nghost = field.getNghost(); std::mt19937_64 engReal(42 + ippl::Comm->rank()); diff --git a/test/FFT/TestFFTRC.cpp b/test/FFT/TestFFTRC.cpp index 8a61cec47..190a810f6 100644 --- a/test/FFT/TestFFTRC.cpp +++ b/test/FFT/TestFFTRC.cpp @@ -77,8 +77,8 @@ int main(int argc, char* argv[]) { fft = std::make_unique(layoutInput, layoutOutput, fftParams); - typename field_type_real::view_type& view = fieldInput.getView(); - typename field_type_real::HostMirror fieldInput_host = fieldInput.getHostMirror(); + typename field_type_real::view_type& view = fieldInput.getView(); + typename field_type_real::host_mirror_type fieldInput_host = fieldInput.getHostMirror(); const int nghost = fieldInput.getNghost(); std::mt19937_64 eng(42 + ippl::Comm->rank()); diff --git a/test/FFT/TestSine.cpp b/test/FFT/TestSine.cpp index f6e8f0e18..e07efcc3d 100644 --- a/test/FFT/TestSine.cpp +++ b/test/FFT/TestSine.cpp @@ -52,8 +52,8 @@ int main(int argc, char* argv[]) { fft = std::make_unique(layout, fftParams); - typename field_type::view_type& view = field.getView(); - typename field_type::HostMirror field_host = field.getHostMirror(); + typename field_type::view_type& view = field.getView(); + typename field_type::host_mirror_type field_host = field.getHostMirror(); const int nghost = field.getNghost(); std::mt19937_64 eng(42 + ippl::Comm->rank()); diff --git a/test/kokkos/TestVectorField.cpp b/test/kokkos/TestVectorField.cpp index 6113f5b1c..9a9265d05 100644 --- a/test/kokkos/TestVectorField.cpp +++ b/test/kokkos/TestVectorField.cpp @@ -197,16 +197,12 @@ int main(int argc, char* argv[]) { vector_field_type vfield("vfield", length); Kokkos::parallel_for( - "assign", length, KOKKOS_LAMBDA(const int i) { - vfield(i) = {1.0, 2.0, 3.0}; - }); + "assign", length, KOKKOS_LAMBDA(const int i) { vfield(i) = {1.0, 2.0, 3.0}; }); vector_field_type wfield("wfield", length); Kokkos::parallel_for( - "assign", length, KOKKOS_LAMBDA(const int i) { - wfield(i) = {4.0, -5.0, 6.0}; - }); + "assign", length, KOKKOS_LAMBDA(const int i) { wfield(i) = {4.0, -5.0, 6.0}; }); vector_field_type vvfield("vvfield", length); Kokkos::parallel_for( @@ -215,7 +211,7 @@ int main(int argc, char* argv[]) { Kokkos::fence(); - vector_field_type::HostMirror host_view = Kokkos::create_mirror_view(vvfield); + vector_field_type::host_mirror_type host_view = Kokkos::create_mirror_view(vvfield); Kokkos::deep_copy(host_view, vvfield); for (int i = 0; i < length; ++i) { @@ -232,7 +228,7 @@ int main(int argc, char* argv[]) { Kokkos::fence(); - scalar_field_type::HostMirror host_sview = Kokkos::create_mirror_view(sfield); + scalar_field_type::host_mirror_type host_sview = Kokkos::create_mirror_view(sfield); Kokkos::deep_copy(host_sview, sfield); for (int i = 0; i < length; ++i) { diff --git a/test/kokkos/TestVectorField2.cpp b/test/kokkos/TestVectorField2.cpp index a8210f936..4e9ce36bf 100644 --- a/test/kokkos/TestVectorField2.cpp +++ b/test/kokkos/TestVectorField2.cpp @@ -16,16 +16,12 @@ int main(int argc, char* argv[]) { vector_field_type vfield("vfield", length); Kokkos::parallel_for( - "assign", length, KOKKOS_LAMBDA(const int i) { - vfield(i) = {1.0, 2.0, 3.0}; - }); + "assign", length, KOKKOS_LAMBDA(const int i) { vfield(i) = {1.0, 2.0, 3.0}; }); vector_field_type wfield("wfield", length); Kokkos::parallel_for( - "assign", length, KOKKOS_LAMBDA(const int i) { - wfield(i) = {4.0, -5.0, 6.0}; - }); + "assign", length, KOKKOS_LAMBDA(const int i) { wfield(i) = {4.0, -5.0, 6.0}; }); vector_field_type vvfield("vvfield", length); Kokkos::parallel_for( @@ -36,7 +32,7 @@ int main(int argc, char* argv[]) { Kokkos::fence(); - vector_field_type::HostMirror host_view = Kokkos::create_mirror_view(vvfield); + vector_field_type::host_mirror_type host_view = Kokkos::create_mirror_view(vvfield); Kokkos::deep_copy(host_view, vvfield); for (int i = 0; i < length; ++i) { @@ -53,7 +49,7 @@ int main(int argc, char* argv[]) { Kokkos::fence(); - scalar_field_type::HostMirror host_sview = Kokkos::create_mirror_view(sfield); + scalar_field_type::host_mirror_type host_sview = Kokkos::create_mirror_view(sfield); Kokkos::deep_copy(host_sview, sfield); for (int i = 0; i < length; ++i) { diff --git a/test/kokkos/TestVectorField3.cpp b/test/kokkos/TestVectorField3.cpp index 166dafd8b..f47701121 100644 --- a/test/kokkos/TestVectorField3.cpp +++ b/test/kokkos/TestVectorField3.cpp @@ -18,16 +18,14 @@ int main(int argc, char* argv[]) { using mdrange_t = Kokkos::MDRangePolicy>; Kokkos::parallel_for( - "assign", mdrange_t({0, 0}, {length, length}), KOKKOS_LAMBDA(const int i, const int j) { - vfield(i, j) = {1.0, 2.0, 3.0}; - }); + "assign", mdrange_t({0, 0}, {length, length}), + KOKKOS_LAMBDA(const int i, const int j) { vfield(i, j) = {1.0, 2.0, 3.0}; }); vector_field_type wfield("wfield", length, length); Kokkos::parallel_for( - "assign", mdrange_t({0, 0}, {length, length}), KOKKOS_LAMBDA(const int i, const int j) { - wfield(i, j) = {4.0, -5.0, 6.0}; - }); + "assign", mdrange_t({0, 0}, {length, length}), + KOKKOS_LAMBDA(const int i, const int j) { wfield(i, j) = {4.0, -5.0, 6.0}; }); vector_field_type vvfield("vvfield", length, length); Kokkos::parallel_for( @@ -39,7 +37,7 @@ int main(int argc, char* argv[]) { Kokkos::fence(); - vector_field_type::HostMirror host_view = Kokkos::create_mirror_view(vvfield); + vector_field_type::host_mirror_type host_view = Kokkos::create_mirror_view(vvfield); Kokkos::deep_copy(host_view, vvfield); for (int i = 0; i < length; ++i) { @@ -60,7 +58,7 @@ int main(int argc, char* argv[]) { Kokkos::fence(); - scalar_field_type::HostMirror host_sview = Kokkos::create_mirror_view(sfield); + scalar_field_type::host_mirror_type host_sview = Kokkos::create_mirror_view(sfield); Kokkos::deep_copy(host_sview, sfield); for (int i = 0; i < length; ++i) { diff --git a/test/kokkos/TestVectorField4.cpp b/test/kokkos/TestVectorField4.cpp index 38a533c9a..33e40e495 100644 --- a/test/kokkos/TestVectorField4.cpp +++ b/test/kokkos/TestVectorField4.cpp @@ -42,7 +42,7 @@ int main(int argc, char* argv[]) { Kokkos::fence(); - vector_field_type::HostMirror host_view = Kokkos::create_mirror_view(vvfield); + vector_field_type::host_mirror_type host_view = Kokkos::create_mirror_view(vvfield); Kokkos::deep_copy(host_view, vvfield); for (int i = 0; i < length; ++i) { @@ -67,7 +67,7 @@ int main(int argc, char* argv[]) { Kokkos::fence(); - scalar_field_type::HostMirror host_sview = Kokkos::create_mirror_view(sfield); + scalar_field_type::host_mirror_type host_sview = Kokkos::create_mirror_view(sfield); Kokkos::deep_copy(host_sview, sfield); for (int i = 0; i < length; ++i) { diff --git a/test/particle/PICnd.cpp b/test/particle/PICnd.cpp index abd4db4ae..c3e6e93ed 100644 --- a/test/particle/PICnd.cpp +++ b/test/particle/PICnd.cpp @@ -297,7 +297,7 @@ class ChargedParticles : public ippl::ParticleBase { // 0 -> gridpoints void initPositions(FieldLayout_t& fl, Vector_t& hr, unsigned int nloc, int tag = 2) { Inform m("initPositions "); - typename ippl::ParticleBase::particle_position_type::HostMirror R_host = + typename ippl::ParticleBase::particle_position_type::host_mirror_type R_host = this->R.getHostMirror(); std::mt19937_64 eng[Dim]; diff --git a/test/particle/TestGather.cpp b/test/particle/TestGather.cpp index 9f13d44f0..ef29766a3 100644 --- a/test/particle/TestGather.cpp +++ b/test/particle/TestGather.cpp @@ -50,8 +50,10 @@ int main(int argc, char* argv[]) { std::mt19937_64 eng; std::uniform_real_distribution unif(0, 1); - typename bunch_type::particle_position_type::HostMirror R_host = bunch.R.getHostMirror(); - typename bunch_type::charge_container_type::HostMirror Q_host = bunch.Q.getHostMirror(); + typename bunch_type::particle_position_type::host_mirror_type R_host = + bunch.R.getHostMirror(); + typename bunch_type::charge_container_type::host_mirror_type Q_host = + bunch.Q.getHostMirror(); for (int i = 0; i < n; ++i) { ippl::Vector r = {unif(eng), unif(eng), unif(eng)}; R_host(i) = r; @@ -72,11 +74,11 @@ int main(int argc, char* argv[]) { msg << "Testing addToAttribute=false. Expected output: 1" << endl; gather(bunch.Q, field, bunch.R); - + // Should printout 1.0 for each particle bunch.Q.print(); - ippl::Comm->barrier(); // so output of 1 and 2 is separated + ippl::Comm->barrier(); // so output of 1 and 2 is separated msg << "Testing addToAttribute=true. Expected output: 2" << endl; gather(bunch.Q, field, bunch.R, true); diff --git a/test/particle/TestHashedScatter.cpp b/test/particle/TestHashedScatter.cpp index 57029ece6..407ff1244 100644 --- a/test/particle/TestHashedScatter.cpp +++ b/test/particle/TestHashedScatter.cpp @@ -68,8 +68,9 @@ int main(int argc, char* argv[]) { eng.discard(nLoc * ippl::Comm->rank()); std::uniform_real_distribution unif(hx[0] / 2, 1 - (hx[0] / 2)); - typename bunch_type::particle_position_type::HostMirror R_host = bunch.R.getHostMirror(); - double sum_coord = 0.0; + typename bunch_type::particle_position_type::host_mirror_type R_host = + bunch.R.getHostMirror(); + double sum_coord = 0.0; for (unsigned int i = 0; i < nLoc; ++i) { ippl::Vector r = {unif(eng), unif(eng), unif(eng)}; R_host(i) = r; @@ -88,22 +89,23 @@ int main(int argc, char* argv[]) { Inform msg2All("TestHashedScatter", INFORM_ALL_NODES); bunch.update(); - msg << "Updated bunch and local number of particles: " << nLoc << " --> " << bunch.getLocalNum() << endl; - nLoc = bunch.getLocalNum(); // update moves particles --> update nLoc for multi rank + msg << "Updated bunch and local number of particles: " << nLoc << " --> " + << bunch.getLocalNum() << endl; + nLoc = bunch.getLocalNum(); // update moves particles --> update nLoc for multi rank /* - First test for custom range policy: Only scatter pt/2 particles and compare to the + First test for custom range policy: Only scatter pt/2 particles and compare to the total sum of the field. - For this test, charges need to be all the same. + For this test, charges need to be all the same. */ { - bunch.Q = 1.0; - field = 0.0; + bunch.Q = 1.0; + field = 0.0; int NScatterred = nLoc / 2 + ippl::Comm->rank(); - + double Q_total = 1.0 * NScatterred; ippl::Comm->allreduce(Q_total, 1, std::plus()); - + Kokkos::RangePolicy<> policy(0, NScatterred); scatter(bunch.Q, field, bunch.R, policy); @@ -114,27 +116,30 @@ int main(int argc, char* argv[]) { msg2All << "Total charge in the field: " << Total_charge_field << endl; msg2All << "Total charge of the particles: " << Q_total << endl; - msg2All << "Error: --> " << std::fabs(Q_total - Total_charge_field) << endl; + msg2All << "Error: --> " + << std::fabs(Q_total - Total_charge_field) << endl; } ippl::Comm->barrier(); - - + /* - Second test for custom hash_type: Assign random charges, create an index array, shuffle it - and scatter the first half of the particles. Then compute the total charge in a loop and compare - it to the sum from the field. + Second test for custom hash_type: Assign random charges, create an index array, shuffle it + and scatter the first half of the particles. Then compute the total charge in a loop and + compare it to the sum from the field. */ using hash_type = typename bunch_type::charge_container_type::hash_type; { // Sample random charges uniformly (use the same eng from before) std::uniform_real_distribution unif_charge(0.5, 1.5); - typename bunch_type::charge_container_type::HostMirror Q_host = bunch.Q.getHostMirror(); - for (unsigned int i = 0; i < nLoc; ++i) { Q_host(i) = unif_charge(eng); } + typename bunch_type::charge_container_type::host_mirror_type Q_host = + bunch.Q.getHostMirror(); + for (unsigned int i = 0; i < nLoc; ++i) { + Q_host(i) = unif_charge(eng); + } Kokkos::deep_copy(bunch.Q.getView(), Q_host); - + // Reset the field unsigned int NScatterred = nLoc / 2 + ippl::Comm->rank(); - field = 0.0; + field = 0.0; // Create index array using hash_type std::vector host_indices(nLoc); @@ -142,19 +147,23 @@ int main(int argc, char* argv[]) { std::shuffle(host_indices.begin(), host_indices.end(), eng); hash_type hash("indexArray", nLoc); - auto hash_host = Kokkos::create_mirror_view(hash); // Create a host mirror of the hash array - for (unsigned int i = 0; i < nLoc; ++i) { hash_host(i) = host_indices[i]; } // Fill the host mirror with the shuffled index array - Kokkos::deep_copy(hash, hash_host); // Copy the shuffled host mirror back to the device + auto hash_host = + Kokkos::create_mirror_view(hash); // Create a host mirror of the hash array + for (unsigned int i = 0; i < nLoc; ++i) { + hash_host(i) = host_indices[i]; + } // Fill the host mirror with the shuffled index array + Kokkos::deep_copy(hash, hash_host); // Copy the shuffled host mirror back to the device // The custom range policy Kokkos::RangePolicy<> policy(0, NScatterred); // Compute total scattered charge manually double Q_total = 0.0; - auto viewQ = bunch.Q.getView(); - Kokkos::parallel_reduce("computeTotalCharge", policy, KOKKOS_LAMBDA(const size_t i, double& val) { - val += viewQ(hash(i)); - }, Kokkos::Sum(Q_total)); + auto viewQ = bunch.Q.getView(); + Kokkos::parallel_reduce( + "computeTotalCharge", policy, + KOKKOS_LAMBDA(const size_t i, double& val) { val += viewQ(hash(i)); }, + Kokkos::Sum(Q_total)); ippl::Comm->allreduce(Q_total, 1, std::plus()); /*{ @@ -178,11 +187,14 @@ int main(int argc, char* argv[]) { msg2All << "Total charge in the field: " << Total_charge_field << endl; msg2All << "Total charge of the particles: " << Q_total << endl; - msg2All << "Error: --> " << std::fabs(Q_total - Total_charge_field) << endl; + msg2All << "Error: --> " + << std::fabs(Q_total - Total_charge_field) << endl; } ippl::Comm->barrier(); - msg << endl << "Note: the values should all be the same per test case, since they are communicated over ranks!" << endl; - + msg << endl + << "Note: the values should all be the same per test case, since they are communicated " + "over ranks!" + << endl; } ippl::finalize(); diff --git a/test/particle/TestScatter.cpp b/test/particle/TestScatter.cpp index d92f6a9b1..6b3dd88b7 100644 --- a/test/particle/TestScatter.cpp +++ b/test/particle/TestScatter.cpp @@ -68,8 +68,9 @@ int main(int argc, char* argv[]) { eng.discard(nLoc * ippl::Comm->rank()); std::uniform_real_distribution unif(hx[0] / 2, 1 - (hx[0] / 2)); - typename bunch_type::particle_position_type::HostMirror R_host = bunch.R.getHostMirror(); - double sum_coord = 0.0; + typename bunch_type::particle_position_type::host_mirror_type R_host = + bunch.R.getHostMirror(); + double sum_coord = 0.0; for (unsigned int i = 0; i < nLoc; ++i) { ippl::Vector r = {unif(eng), unif(eng), unif(eng)}; R_host(i) = r; diff --git a/test/particle/benchmarkParticleUpdate.cpp b/test/particle/benchmarkParticleUpdate.cpp index cb0a98a25..857e637c1 100644 --- a/test/particle/benchmarkParticleUpdate.cpp +++ b/test/particle/benchmarkParticleUpdate.cpp @@ -180,7 +180,7 @@ int main(int argc, char* argv[]) { } std::uniform_real_distribution unif(0, 1); - typename bunch_type::particle_position_type::HostMirror R_host = P->R.getHostMirror(); + typename bunch_type::particle_position_type::host_mirror_type R_host = P->R.getHostMirror(); double sum_coord = 0.0; for (unsigned long int i = 0; i < nloc; i++) { @@ -209,7 +209,7 @@ int main(int argc, char* argv[]) { msg << "particles created and initial conditions assigned " << endl; std::uniform_real_distribution unifP(0, hr_min); - typename bunch_type::particle_position_type::HostMirror P_host = P->P.getHostMirror(); + typename bunch_type::particle_position_type::host_mirror_type P_host = P->P.getHostMirror(); // begin main timestep loop msg << "Starting iterations ..." << endl; diff --git a/test/serialization/serialize01.cpp b/test/serialization/serialize01.cpp index 484a461ab..7bd1b32a5 100644 --- a/test/serialization/serialize01.cpp +++ b/test/serialization/serialize01.cpp @@ -207,13 +207,15 @@ int main(int argc, char* argv[]) { bunch.update(); if (rank > 0) { - BunchBase::view_type::HostMirror h_id = Kokkos::create_mirror_view(bunch.id_m); + BunchBase::view_type::host_mirror_type h_id = Kokkos::create_mirror_view(bunch.id_m); Kokkos::deep_copy(h_id, bunch.id_m); - BunchBase::view_type::HostMirror h_charge = Kokkos::create_mirror_view(bunch.charge_m); + BunchBase::view_type::host_mirror_type h_charge = + Kokkos::create_mirror_view(bunch.charge_m); Kokkos::deep_copy(h_charge, bunch.charge_m); - BunchBase::view_type::HostMirror h_mass = Kokkos::create_mirror_view(bunch.mass_m); + BunchBase::view_type::host_mirror_type h_mass = + Kokkos::create_mirror_view(bunch.mass_m); Kokkos::deep_copy(h_mass, bunch.mass_m); for (size_t i = 0; i < h_id.size(); ++i) { diff --git a/unit_tests/FFT/FFT.cpp b/unit_tests/FFT/FFT.cpp index 2009b8b7b..f6777c5d1 100644 --- a/unit_tests/FFT/FFT.cpp +++ b/unit_tests/FFT/FFT.cpp @@ -84,7 +84,7 @@ class FFTTest>> : public ::testing::Test { * @param nghost number of ghost cells * @param mirror the field view's host mirror */ - void randomizeRealField(int nghost, typename field_type_real::HostMirror& mirror) { + void randomizeRealField(int nghost, typename field_type_real::host_mirror_type& mirror) { std::mt19937_64 eng(42 + ippl::Comm->rank()); std::uniform_real_distribution unif(0, 1); @@ -93,16 +93,16 @@ class FFTTest>> : public ::testing::Test { }); } - /*! + /*! * Fill a real-valued field with zero values * @param nghost number of ghost cells * @param mirror the field view's host mirror */ - - void zeroRealField(int nghost, typename field_type_real::HostMirror& mirror) { + void zeroRealField(int nghost, typename field_type_real::host_mirror_type& mirror) { nestedViewLoop(mirror, nghost, [&](const Idx... args) { - mirror(args...) = 0.0;; + mirror(args...) = 0.0; + ; }); } @@ -111,7 +111,7 @@ class FFTTest>> : public ::testing::Test { * @param nghost number of ghost cells * @param mirror the field view's host mirror */ - void randomizeComplexField(int nghost, typename field_type_complex::HostMirror& mirror) { + void randomizeComplexField(int nghost, typename field_type_complex::host_mirror_type& mirror) { std::mt19937_64 engReal(42 + ippl::Comm->rank()); std::uniform_real_distribution unifReal(0, 1); @@ -129,16 +129,13 @@ class FFTTest>> : public ::testing::Test { * @param nghost number of ghost cells * @param mirror the field view's host mirror */ - void zeroComplexField(int nghost, typename field_type_complex::HostMirror& mirror) { - + void zeroComplexField(int nghost, typename field_type_complex::host_mirror_type& mirror) { nestedViewLoop(mirror, nghost, [&](const Idx... args) { mirror(args...).real() = 0.0; mirror(args...).imag() = 0.0; }); } - - /*! * Verify the contents of a computation * @tparam MirrorA the type of the computed view @@ -206,11 +203,11 @@ using Tests = TestParams::tests<2, 3>; TYPED_TEST_SUITE(FFTTest, Tests); TYPED_TEST(FFTTest, Cos) { - //this->template testTrig(this->realField, this->layout); + // this->template testTrig(this->realField, this->layout); } TYPED_TEST(FFTTest, Sin) { - //this->template testTrig(this->realField, this->layout); + // this->template testTrig(this->realField, this->layout); } TYPED_TEST(FFTTest, RC) { diff --git a/unit_tests/Particle/ParticleBC.cpp b/unit_tests/Particle/ParticleBC.cpp index 91fe2679b..1350fa4e9 100644 --- a/unit_tests/Particle/ParticleBC.cpp +++ b/unit_tests/Particle/ParticleBC.cpp @@ -67,7 +67,7 @@ class ParticleBCTest>> : public ::testing::Te using region_type = ippl::NDRegion; region_type nr; - using mirror_type = typename bunch_type::particle_position_type::HostMirror; + using mirror_type = typename bunch_type::particle_position_type::host_mirror_type; mirror_type mirror; playout_type playout;