@@ -19,6 +19,10 @@ template <> const MaterialPointSlice meshFieldIndexToMPSlice < MeshF_OnSurfVeloI
1919
2020class MPMesh {
2121
22+ private:
23+
24+ Kokkos::View<double **, Kokkos::HostSpace>fieldHostBuffer;
25+
2226 public:
2327
2428 Mesh* p_mesh;
@@ -34,7 +38,7 @@ class MPMesh{
3438 std::vector<std::vector<int >> ownerHaloLocalIDs;
3539
3640 void startCommunication ();
37-
41+
3842 void communicate_and_take_halo_contributions (const Kokkos::View<double **>& meshField, int nEntities, int numEntries, int mode, int op);
3943 // Now Kokkos views are made 1D
4044 template <typename ViewType>
@@ -50,40 +54,18 @@ class MPMesh{
5054 MPI_Comm_rank (comm, &self);
5155
5256 Kokkos::Timer timer;
53- auto reconVals_host = Kokkos::create_mirror_view_and_copy (Kokkos::HostSpace (), meshField);
57+ // auto reconVals_host_old = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), meshField);
58+ // Replace alocation + copy with just copy
59+ if (fieldHostBuffer.extent (0 ) < nEntities || fieldHostBuffer.extent (1 )< numEntries){
60+ printf (" Buffer extent before %d %d \n " , fieldHostBuffer.extent (0 ), fieldHostBuffer.extent (1 ));
61+ fieldHostBuffer= Kokkos::View<double **, Kokkos::HostSpace>(" host buffer fields" , nEntities, numEntries);
62+ printf (" Buffer extent after %d %d \n " , fieldHostBuffer.extent (0 ), fieldHostBuffer.extent (1 ));
63+ }
64+ auto reconVals_host=Kokkos::subview (fieldHostBuffer, std::make_pair (0 , nEntities), std::make_pair (0 , numEntries));
65+ Kokkos::deep_copy (reconVals_host, meshField);
5466 Kokkos::fence ();
5567 pumipic::RecordTime (" SD: GPU-CPU copy-" + std::to_string (self), timer.seconds ());
56-
57- /*
58- timer.reset();
59- std::vector<double> fieldData1(nEntities*numEntries);
60- pumipic::RecordTime("SD: STL alloc-" + std::to_string(self), timer.seconds());
61- timer.reset();
62-
63- for (int i=0;i<nEntities;i++)
64- for (int j=0;j<numEntries;j++)
65- fieldData1[i*numEntries+j]=reconVals_host(i,j);
66-
67- std::memcpy(fieldData1.data(), reconVals_host.data(), nEntities*numEntries*sizeof(double));
68- pumipic::RecordTime("SD: STL alloc_copy-" + std::to_string(self), timer.seconds());
69- */
70- /*
71- for (int i=0; i<nEntities; i++) {
72- for (int j=0; j<numEntries; j++) {
73- if (fieldData1[i*numEntries+j] != reconVals_host(i,j)) {
74- std::cout
75- << "Mismatch at "
76- << i << " " << j
77- << " : "
78- << fieldData1[i*numEntries+j]
79- << " "
80- << reconVals_host(i,j)
81- << std::endl;
82- break;
83- }
84- }
85- }
86- */
68+
8769 timer.reset ();
8870 std::vector<std::vector<int >> recvIDVec;
8971 std::vector<std::vector<double >> recvDataVec;
0 commit comments