From 27b6bc1ce4db8e62b806839aa5e4dedeed1f5576 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Wed, 18 Dec 2024 13:54:25 -0500 Subject: [PATCH 01/31] set MP position --- src/pmpo_c.cpp | 66 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index d5d0650..35046ce 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -230,36 +230,68 @@ void polympo_setMPLatLonRotatedFlag_f(MPMesh_ptr p_mpmesh, const int isRotateFla } -void polympo_setMPPositions_f(MPMesh_ptr p_mpmesh, - const int nComps, - const int numMPs, - const double* mpPositionsIn){ +template +void setMPData(MPMesh_ptr p_mpmesh, + const int nComps, + const int numMPs, + const double* mpDataIn){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; - PMT_ALWAYS_ASSERT(nComps == vec3d_nEntries); + PMT_ALWAYS_ASSERT(nComps == polyMPO::mpSliceToNumEntries()); PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getCount()); PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getMaxAppID()); - kkViewHostU mpPositionsIn_h(mpPositionsIn,nComps,numMPs); + + kkViewHostU mpDataIn_h(mpDataIn,nComps,numMPs); - if (p_MPs->rebuildOngoing()) { - p_MPs->setRebuildMPSlice(mpPositionsIn_h); + if (mpSlice == polyMPO::MPF_Cur_Pos_XYZ && p_MPs->rebuildOngoing()) { + p_MPs->setRebuildMPSlice(mpDataIn_h); return; } - auto mpPositions = p_MPs->getData(); + auto mpData = p_MPs->getData(); auto mpAppID = p_MPs->getData(); - Kokkos::View mpPositionsIn_d("mpPositionsDevice",vec3d_nEntries,numMPs); - Kokkos::deep_copy(mpPositionsIn_d, mpPositionsIn_h); - auto setPos = PS_LAMBDA(const int&, const int& mp, const int& mask){ + Kokkos::View mpData_d("mpData_d",vec3d_nEntries,numMPs); + Kokkos::deep_copy(mpData_d, mpDataIn_h); + + auto setData = PS_LAMBDA(const int&, const int& mp, const int& mask){ if(mask){ - mpPositions(mp,0) = mpPositionsIn_d(0, mpAppID(mp)); - mpPositions(mp,1) = mpPositionsIn_d(1, mpAppID(mp)); - mpPositions(mp,2) = mpPositionsIn_d(2, mpAppID(mp)); + for (int i=0; iparallel_for(setPos, "setMPPositions"); - pumipic::RecordTime("PolyMPO_setMPPositions", timer.seconds()); + p_MPs->parallel_for(setData, "setMPData"); + pumipic::RecordTime("PolyMPO_setMPData", timer.seconds()); +} + +using setMPFunc = void (*)(MPMesh_ptr, const int, const int, const double*); +std::map setMPMap = { + {polyMPO::MPF_Cur_Pos_Rot_Lat_Lon, setMPData}, + {polyMPO::MPF_Tgt_Pos_Rot_Lat_Lon, setMPData}, + {polyMPO::MPF_Cur_Pos_XYZ, setMPData}, + {polyMPO::MPF_Tgt_Pos_XYZ, setMPData}, + {polyMPO::MPF_Mass, setMPData}, + {polyMPO::MPF_Vel, setMPData}, + {polyMPO::MPF_Rot_Lat_Lon_Incr, setMPData}, + {polyMPO::MPF_Strain_Rate, setMPData}, + {polyMPO::MPF_Stress, setMPData}, + {polyMPO::MPF_Stress_Div, setMPData} +}; + +void polympo_setMPData_f(MPMesh_ptr p_mpmesh, + const int nComps, + const int numMPs, + const double* mpDataIn, + const int mpDataType){ + polyMPO::MaterialPointSlice type = static_cast(mpDataType); + (*setMPMap[type])(p_mpmesh, nComps, numMPs, mpDataIn); +} + +void polympo_setMPPositions_f(MPMesh_ptr p_mpmesh, + const int nComps, + const int numMPs, + const double* mpPositionsIn){ + setMPData(p_mpmesh, nComps, numMPs, mpPositionsIn); } void polympo_getMPPositions_f(MPMesh_ptr p_mpmesh, From da8158295c80e119c4fa5835461c88c92bdcec5e Mon Sep 17 00:00:00 2001 From: Angelyr Date: Wed, 18 Dec 2024 14:13:57 -0500 Subject: [PATCH 02/31] changed all set mp data --- src/pmpo_c.cpp | 97 ++++---------------------------------------------- 1 file changed, 7 insertions(+), 90 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index 35046ce..fb74e92 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -251,7 +251,7 @@ void setMPData(MPMesh_ptr p_mpmesh, auto mpData = p_MPs->getData(); auto mpAppID = p_MPs->getData(); - Kokkos::View mpData_d("mpData_d",vec3d_nEntries,numMPs); + Kokkos::View mpData_d("mpData_d",nComps,numMPs); Kokkos::deep_copy(mpData_d, mpDataIn_h); auto setData = PS_LAMBDA(const int&, const int& mp, const int& mask){ @@ -274,8 +274,7 @@ std::map setMPMap = { {polyMPO::MPF_Vel, setMPData}, {polyMPO::MPF_Rot_Lat_Lon_Incr, setMPData}, {polyMPO::MPF_Strain_Rate, setMPData}, - {polyMPO::MPF_Stress, setMPData}, - {polyMPO::MPF_Stress_Div, setMPData} + {polyMPO::MPF_Stress, setMPData} }; void polympo_setMPData_f(MPMesh_ptr p_mpmesh, @@ -325,24 +324,7 @@ void polympo_setMPRotLatLon_f(MPMesh_ptr p_mpmesh, const double* mpRotLatLonIn){ static int callCount = 0; PMT_ALWAYS_ASSERT(callCount == 0); - checkMPMeshValid(p_mpmesh); - auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; - PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getCount()); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getMaxAppID()); - - auto mpRotLatLon = p_MPs->getData(); - auto mpAppID = p_MPs->getData(); - kkViewHostU mpRotLatLonIn_h(mpRotLatLonIn,nComps,numMPs); - Kokkos::View mpRotLatLonIn_d("mpRotLatLonDevice",vec2d_nEntries,numMPs); - Kokkos::deep_copy(mpRotLatLonIn_d, mpRotLatLonIn_h); - auto setPos = PS_LAMBDA(const int& elm, const int& mp, const int& mask){ - if(mask){ - mpRotLatLon(mp,0) = mpRotLatLonIn_d(0, mpAppID(mp)); - mpRotLatLon(mp,1) = mpRotLatLonIn_d(1, mpAppID(mp)); - } - }; - p_MPs->parallel_for(setPos, "setMPRotLatLon"); + setMPData(p_mpmesh, nComps, numMPs, mpRotLatLonIn); callCount++; } @@ -371,25 +353,7 @@ void polympo_getMPRotLatLon_f(MPMesh_ptr p_mpmesh, } void polympo_setMPMass_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpMassIn) { - Kokkos::Timer timer; - checkMPMeshValid(p_mpmesh); - auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; - PMT_ALWAYS_ASSERT(nComps == 1); //TODO mp_sclr_t - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getCount()); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getMaxAppID()); - - auto mpMass = p_MPs->getData(); - auto mpAppID = p_MPs->getData(); - kkViewHostU mpMassIn_h(mpMassIn,nComps,numMPs); - Kokkos::View mpMassIn_d("mpMassDevice",nComps,numMPs); - Kokkos::deep_copy(mpMassIn_d, mpMassIn_h); - auto setMPMass = PS_LAMBDA(const int& elm, const int& mp, const int& mask){ - if(mask){ - mpMass(mp,0) = mpMassIn_d(0, mpAppID(mp)); - } - }; - p_MPs->parallel_for(setMPMass, "setMPMass"); - pumipic::RecordTime("PolyMPO_setMPMass", timer.seconds()); + setMPData(p_mpmesh, nComps, numMPs, mpMassIn); } void polympo_getMPMass_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, double* mpMassHost) { @@ -415,26 +379,7 @@ void polympo_getMPMass_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs } void polympo_setMPVel_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpVelIn) { - Kokkos::Timer timer; - checkMPMeshValid(p_mpmesh); - auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; - PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getCount()); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getMaxAppID()); - - auto mpVel = p_MPs->getData(); - auto mpAppID = p_MPs->getData(); - kkViewHostU mpVelIn_h(mpVelIn,nComps,numMPs); - Kokkos::View mpVelIn_d("mpVelDevice",vec2d_nEntries,numMPs); - Kokkos::deep_copy(mpVelIn_d, mpVelIn_h); - auto setMPVel = PS_LAMBDA(const int& elm, const int& mp, const int& mask){ - if(mask){ - mpVel(mp,0) = mpVelIn_d(0, mpAppID(mp)); - mpVel(mp,1) = mpVelIn_d(1, mpAppID(mp)); - } - }; - p_MPs->parallel_for(setMPVel, "setMPVel"); - pumipic::RecordTime("PolyMPO_setMPVel", timer.seconds()); + setMPData(p_mpmesh, nComps, numMPs, mpVelIn); } void polympo_getMPVel_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, double* mpVelHost) { @@ -460,30 +405,8 @@ void polympo_getMPVel_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, pumipic::RecordTime("PolyMPO_getMPVel", timer.seconds()); } -//TODO: implement these void polympo_setMPStrainRate_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpStrainRateIn){ - checkMPMeshValid(p_mpmesh); - auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; - PMT_ALWAYS_ASSERT(nComps == 6); //TODO: mp_sym_mat3d_t - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getCount()); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getMaxAppID()); - - auto mpStrainRate = p_MPs->getData(); - auto mpAppID = p_MPs->getData(); - kkViewHostU mpStrainRateIn_h(mpStrainRateIn,nComps,numMPs); - Kokkos::View mpStrainRateIn_d("mpStrainRateDevice",nComps,numMPs); - Kokkos::deep_copy(mpStrainRateIn_d, mpStrainRateIn_h); - auto setMPStrainRate = PS_LAMBDA(const int& elm, const int& mp, const int& mask){ - if(mask){ - mpStrainRate(mp,0) = mpStrainRateIn_d(0, mpAppID(mp)); - mpStrainRate(mp,1) = mpStrainRateIn_d(1, mpAppID(mp)); - mpStrainRate(mp,2) = mpStrainRateIn_d(2, mpAppID(mp)); - mpStrainRate(mp,3) = mpStrainRateIn_d(3, mpAppID(mp)); - mpStrainRate(mp,4) = mpStrainRateIn_d(4, mpAppID(mp)); - mpStrainRate(mp,5) = mpStrainRateIn_d(5, mpAppID(mp)); - } - }; - p_MPs->parallel_for(setMPStrainRate, "setMPStrainRate"); + setMPData(p_mpmesh, nComps, numMPs, mpStrainRateIn); } void polympo_getMPStrainRate_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, double* mpStrainRateHost){ checkMPMeshValid(p_mpmesh); @@ -495,13 +418,7 @@ void polympo_getMPStrainRate_f(MPMesh_ptr p_mpmesh, const int nComps, const int (void)mpStrainRateHost; } void polympo_setMPStress_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpStressIn){ - checkMPMeshValid(p_mpmesh); - std::cerr << "Error: This routine is not implemented yet\n"; - exit(1); - (void)p_mpmesh; - (void)nComps; - (void)numMPs; - (void)mpStressIn; + setMPData(p_mpmesh, nComps, numMPs, mpStressIn); } void polympo_getMPStress_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, double* mpStressHost){ checkMPMeshValid(p_mpmesh); From 29ba5f806d519ec93f313f46ffd7801d85442403 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Wed, 18 Dec 2024 14:31:16 -0500 Subject: [PATCH 03/31] all mp get data --- src/pmpo_c.cpp | 161 ++++++++++++------------------------------------- 1 file changed, 39 insertions(+), 122 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index fb74e92..d52e965 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -232,9 +232,9 @@ void polympo_setMPLatLonRotatedFlag_f(MPMesh_ptr p_mpmesh, const int isRotateFla template void setMPData(MPMesh_ptr p_mpmesh, - const int nComps, - const int numMPs, - const double* mpDataIn){ + const int nComps, + const int numMPs, + const double* mpDataIn){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; @@ -264,6 +264,31 @@ void setMPData(MPMesh_ptr p_mpmesh, pumipic::RecordTime("PolyMPO_setMPData", timer.seconds()); } +template +void getMPData(MPMesh_ptr p_mpmesh, + const int nComps, + const int numMPs, + double* mpDataHost){ + checkMPMeshValid(p_mpmesh); + auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; + PMT_ALWAYS_ASSERT(nComps == polyMPO::mpSliceToNumEntries()); + PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getCount()); + PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getMaxAppID()); + + auto mpData = p_MPs->getData(); + auto mpAppID = p_MPs->getData(); + Kokkos::View mpDataCopy("mpDataCopy",nComps,numMPs); + auto getData = PS_LAMBDA(const int&, const int& mp, const int& mask){ + if(mask){ + for (int i=0; iparallel_for(getData, "getMPData"); + kkDbl2dViewHostU arrayHost(mpDataHost,nComps,numMPs); + Kokkos::deep_copy(arrayHost, mpDataCopy); +} + using setMPFunc = void (*)(MPMesh_ptr, const int, const int, const double*); std::map setMPMap = { {polyMPO::MPF_Cur_Pos_Rot_Lat_Lon, setMPData}, @@ -277,157 +302,49 @@ std::map setMPMap = { {polyMPO::MPF_Stress, setMPData} }; -void polympo_setMPData_f(MPMesh_ptr p_mpmesh, - const int nComps, - const int numMPs, - const double* mpDataIn, - const int mpDataType){ +void polympo_setMPData_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpDataIn, const int mpDataType){ polyMPO::MaterialPointSlice type = static_cast(mpDataType); (*setMPMap[type])(p_mpmesh, nComps, numMPs, mpDataIn); } -void polympo_setMPPositions_f(MPMesh_ptr p_mpmesh, - const int nComps, - const int numMPs, - const double* mpPositionsIn){ +void polympo_setMPPositions_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpPositionsIn){ setMPData(p_mpmesh, nComps, numMPs, mpPositionsIn); } - -void polympo_getMPPositions_f(MPMesh_ptr p_mpmesh, - const int nComps, - const int numMPs, - double* mpPositionsHost){ - checkMPMeshValid(p_mpmesh); - auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; - PMT_ALWAYS_ASSERT(nComps == vec3d_nEntries); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getCount()); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getMaxAppID()); - - auto mpPositions = p_MPs->getData(); - auto mpAppID = p_MPs->getData(); - Kokkos::View mpPositionsCopy("mpPositionsCopy",vec3d_nEntries,numMPs); - auto getPos = PS_LAMBDA(const int&, const int& mp, const int& mask){ - if(mask){ - mpPositionsCopy(0,mpAppID(mp)) = mpPositions(mp,0); - mpPositionsCopy(1,mpAppID(mp)) = mpPositions(mp,1); - mpPositionsCopy(2,mpAppID(mp)) = mpPositions(mp,2); - } - }; - p_MPs->parallel_for(getPos, "getMPPositions"); - kkDbl2dViewHostU arrayHost(mpPositionsHost,nComps,numMPs); - Kokkos::deep_copy(arrayHost, mpPositionsCopy); +void polympo_getMPPositions_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, double* mpPositionsHost){ + getMPData(p_mpmesh, nComps, numMPs, mpPositionsHost); } - -void polympo_setMPRotLatLon_f(MPMesh_ptr p_mpmesh, - const int nComps, - const int numMPs, - const double* mpRotLatLonIn){ +void polympo_setMPRotLatLon_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpRotLatLonIn){ static int callCount = 0; PMT_ALWAYS_ASSERT(callCount == 0); setMPData(p_mpmesh, nComps, numMPs, mpRotLatLonIn); callCount++; } - -void polympo_getMPRotLatLon_f(MPMesh_ptr p_mpmesh, - const int nComps, - const int numMPs, - double* mpRotLatLonHost){ - checkMPMeshValid(p_mpmesh); - auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; - PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getCount()); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getMaxAppID()); - - auto mpRotLatLon = p_MPs->getData(); - auto mpAppID = p_MPs->getData(); - Kokkos::View mpRotLatLonCopy("mpRotLatLonCopy",vec2d_nEntries,numMPs); - auto getPos = PS_LAMBDA(const int& elm, const int& mp, const int& mask){ - if(mask){ - mpRotLatLonCopy(0,mpAppID(mp)) = mpRotLatLon(mp,0); - mpRotLatLonCopy(1,mpAppID(mp)) = mpRotLatLon(mp,1); - } - }; - p_MPs->parallel_for(getPos, "getMPRotLatLon"); - kkDbl2dViewHostU arrayHost(mpRotLatLonHost,nComps,numMPs); - Kokkos::deep_copy(arrayHost, mpRotLatLonCopy); +void polympo_getMPRotLatLon_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, double* mpRotLatLonHost){ + getMPData(p_mpmesh, nComps, numMPs, mpRotLatLonHost); } - void polympo_setMPMass_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpMassIn) { setMPData(p_mpmesh, nComps, numMPs, mpMassIn); } - void polympo_getMPMass_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, double* mpMassHost) { - Kokkos::Timer timer; - checkMPMeshValid(p_mpmesh); - auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; - PMT_ALWAYS_ASSERT(nComps == 1); //TODO mp_sclr_t - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getCount()); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getMaxAppID()); - - auto mpMass = p_MPs->getData(); - auto mpAppID = p_MPs->getData(); - Kokkos::View mpMassCopy("mpMassCopy",nComps,numMPs); - auto getMPMass = PS_LAMBDA(const int& elm, const int& mp, const int& mask){ - if(mask){ - mpMassCopy(0,mpAppID(mp)) = mpMass(mp,0); - } - }; - p_MPs->parallel_for(getMPMass, "getMPMass"); - kkDbl2dViewHostU arrayHost(mpMassHost,nComps,numMPs); - Kokkos::deep_copy(arrayHost, mpMassCopy); - pumipic::RecordTime("PolyMPO_getMPMass", timer.seconds()); + getMPData(p_mpmesh, nComps, numMPs, mpMassHost); } - void polympo_setMPVel_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpVelIn) { setMPData(p_mpmesh, nComps, numMPs, mpVelIn); } - void polympo_getMPVel_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, double* mpVelHost) { - Kokkos::Timer timer; - checkMPMeshValid(p_mpmesh); - auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; - PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getCount()); - PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getMaxAppID()); - - auto mpVel = p_MPs->getData(); - auto mpAppID = p_MPs->getData(); - Kokkos::View mpVelCopy("mpVelCopy",vec2d_nEntries,numMPs); - auto getMPVel = PS_LAMBDA(const int& elm, const int& mp, const int& mask){ - if(mask){ - mpVelCopy(0,mpAppID(mp)) = mpVel(mp,0); - mpVelCopy(1,mpAppID(mp)) = mpVel(mp,1); - } - }; - p_MPs->parallel_for(getMPVel, "getMPVel"); - kkDbl2dViewHostU arrayHost(mpVelHost,nComps,numMPs); - Kokkos::deep_copy(arrayHost, mpVelCopy); - pumipic::RecordTime("PolyMPO_getMPVel", timer.seconds()); + getMPData(p_mpmesh, nComps, numMPs, mpVelHost); } - void polympo_setMPStrainRate_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpStrainRateIn){ setMPData(p_mpmesh, nComps, numMPs, mpStrainRateIn); } void polympo_getMPStrainRate_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, double* mpStrainRateHost){ - checkMPMeshValid(p_mpmesh); - std::cerr << "Error: This routine is not implemented yet\n"; - exit(1); - (void)p_mpmesh; - (void)nComps; - (void)numMPs; - (void)mpStrainRateHost; + getMPData(p_mpmesh, nComps, numMPs, mpStrainRateHost); } void polympo_setMPStress_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpStressIn){ setMPData(p_mpmesh, nComps, numMPs, mpStressIn); } void polympo_getMPStress_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, double* mpStressHost){ - checkMPMeshValid(p_mpmesh); - std::cerr << "Error: This routine is not implemented yet\n"; - exit(1); - (void)p_mpmesh; - (void)nComps; - (void)numMPs; - (void)mpStressHost; + getMPData(p_mpmesh, nComps, numMPs, mpStressHost); } void polympo_startMeshFill_f(MPMesh_ptr p_mpmesh){ From de7e7e7b452eee25de52f8c9b15fc88a704a4cbd Mon Sep 17 00:00:00 2001 From: Angelyr Date: Wed, 18 Dec 2024 17:29:17 -0500 Subject: [PATCH 04/31] setMeshData --- src/pmpo_c.cpp | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index d52e965..f92f347 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -646,21 +646,27 @@ void polympo_getMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, double* u pumipic::RecordTime("PolyMPO_getMeshVtxVel", timer.seconds()); } -void polympo_setMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* vtxMass){ +template +void setMeshData(MPMesh_ptr p_mpmesh, const int nVertices, const double* meshDataIn){ //check mpMesh is valid checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; //check the size - PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); + // PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); + // PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells); //copy the host array to the device - auto coordsArray = p_mesh->getMeshField(); - auto h_coordsArray = Kokkos::create_mirror_view(coordsArray); + auto meshData = p_mesh->getMeshField(); + auto meshData_h = Kokkos::create_mirror_view(meshData); for(int i=0; i(p_mpmesh, nVertices, vtxMass); } void polympo_getMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, double* vtxMass){ @@ -682,21 +688,7 @@ void polympo_getMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, double* } void polympo_setMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, const double* elmMass){ - //check mpMesh is valid - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - - //check the size - PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells); - - //copy the host array to the device - auto coordsArray = p_mesh->getMeshField(); - auto h_coordsArray = Kokkos::create_mirror_view(coordsArray); - kkViewHostU arrayHost(elmMass, nCells); - for(int i=0; i(p_mpmesh, nCells, elmMass); } void polympo_getMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, double* elmMass){ From 0b4cd8688874ebf9cdcfc2999053a6fa709a3ffc Mon Sep 17 00:00:00 2001 From: Angelyr Date: Thu, 19 Dec 2024 14:58:20 -0500 Subject: [PATCH 05/31] most mesh data working --- src/pmpo_c.cpp | 88 ++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 64 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index f92f347..6e6f93d 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -496,25 +496,29 @@ int polympo_getMeshFElmType_f() { return polyMPO::MeshFType_ElmBased; } -void polympo_setMeshVtxCoords_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* xArray, const double* yArray, const double* zArray){ +template +void setMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double** meshDataIn){ Kokkos::Timer timer; - //chech validity checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; //check the size - PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); + // PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); + // PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells); //copy the host array to the device - auto coordsArray = p_mesh->getMeshField(); - auto h_coordsArray = Kokkos::create_mirror_view(coordsArray); - for(int i=0; igetMeshField(); + auto meshData_h = Kokkos::create_mirror_view(meshData); + for(int i=0; i(p_mpmesh, 3, nVertices, dataIn); } void polympo_getMeshVtxCoords_f(MPMesh_ptr p_mpmesh, const int nVertices, double* xArray, double* yArray, double* zArray){ @@ -573,22 +577,8 @@ void polympo_getMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, double } void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, const double* xArray, const double* yArray, const double* zArray){ - //chech validity - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - - //check the size - PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells); - - //copy the host array to the device - auto elmCenter = p_mesh->getMeshField(); - auto h_elmCenter = Kokkos::create_mirror_view(elmCenter); - for(int i=0; i(p_mpmesh, 3, nCells, dataIn); } void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, double* xArray, double* yArray, double* zArray){ @@ -610,21 +600,8 @@ void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, double* x } void polympo_setMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* uVelIn, const double* vVelIn){ - //check mpMesh is valid - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - - //check the size - PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); - - //copy the host array to the device - auto coordsArray = p_mesh->getMeshField(); - auto h_coordsArray = Kokkos::create_mirror_view(coordsArray); - for(int i=0; i(p_mpmesh, 2, nVertices, dataIn); } void polympo_getMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, double* uVelOut, double* vVelOut){ @@ -646,27 +623,9 @@ void polympo_getMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, double* u pumipic::RecordTime("PolyMPO_getMeshVtxVel", timer.seconds()); } -template -void setMeshData(MPMesh_ptr p_mpmesh, const int nVertices, const double* meshDataIn){ - //check mpMesh is valid - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - - //check the size - // PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); - // PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells); - - //copy the host array to the device - auto meshData = p_mesh->getMeshField(); - auto meshData_h = Kokkos::create_mirror_view(meshData); - for(int i=0; i(p_mpmesh, nVertices, vtxMass); + const double* dataIn[] = {vtxMass}; + setMeshData(p_mpmesh, 1, nVertices, dataIn); } void polympo_getMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, double* vtxMass){ @@ -688,7 +647,8 @@ void polympo_getMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, double* } void polympo_setMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, const double* elmMass){ - setMeshData(p_mpmesh, nCells, elmMass); + const double* dataIn[] = {elmMass}; + setMeshData(p_mpmesh, 1, nCells, dataIn); } void polympo_getMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, double* elmMass){ From 43ae61c843b327552524b20ac56e800c62ba9c82 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Thu, 19 Dec 2024 16:34:43 -0500 Subject: [PATCH 06/31] use host space --- src/pmpo_c.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index 6e6f93d..0050095 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -508,7 +508,7 @@ void setMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, con //copy the host array to the device auto meshData = p_mesh->getMeshField(); - auto meshData_h = Kokkos::create_mirror_view(meshData); + auto meshData_h = Kokkos::create_mirror_view(Kokkos::HostSpace(), meshData); for(int i=0; i Date: Thu, 19 Dec 2024 16:53:06 -0500 Subject: [PATCH 07/31] most get mesh data --- src/pmpo_c.cpp | 106 ++++++++++++++----------------------------------- 1 file changed, 29 insertions(+), 77 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index 0050095..b71a5a7 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -516,28 +516,33 @@ void setMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, con pumipic::RecordTime("PolyMPO_setMeshData", timer.seconds()); } -void polympo_setMeshVtxCoords_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* xArray, const double* yArray, const double* zArray){ - const double* dataIn[] = {xArray, yArray, zArray}; - setMeshData(p_mpmesh, 3, nVertices, dataIn); -} - -void polympo_getMeshVtxCoords_f(MPMesh_ptr p_mpmesh, const int nVertices, double* xArray, double* yArray, double* zArray){ - //chech validity +template +void getMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double** meshDataOut_h){ + Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; //check the size - PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); + // PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); + // PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells); //copy the device to host - auto coordsArray = p_mesh->getMeshField(); - auto h_coordsArray = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), - coordsArray); - for(int i=0; igetMeshField(); + auto meshData_h = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), meshData); + for(int i=0; i(p_mpmesh, 3, nVertices, dataIn); +} + +void polympo_getMeshVtxCoords_f(MPMesh_ptr p_mpmesh, const int nVertices, double* xArray, double* yArray, double* zArray){ + double* dataIn[] = {xArray, yArray, zArray}; + getMeshData(p_mpmesh, 3, nVertices, dataIn); } void polympo_setMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* latitude){ @@ -582,21 +587,8 @@ void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, const dou } void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, double* xArray, double* yArray, double* zArray){ - //chech validity - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - - //check the size - PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells); - - //copy the device to host - auto elmCenter = p_mesh->getMeshField(); - auto h_elmCenter = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), elmCenter); - for(int i=0; i(p_mpmesh, 3, nCells, dataIn); } void polympo_setMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* uVelIn, const double* vVelIn){ @@ -605,22 +597,8 @@ void polympo_setMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, const dou } void polympo_getMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, double* uVelOut, double* vVelOut){ - Kokkos::Timer timer; - //check mpMesh is valid - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - - //check the size - PMT_ALWAYS_ASSERT(p_mesh->getNumVertices() == nVertices); - - //copy the device array to the host - auto coordsArray = p_mesh->getMeshField(); - auto h_coordsArray = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),coordsArray); - for(int i=0; i(p_mpmesh, 2, nVertices, dataIn); } void polympo_setMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* vtxMass){ @@ -629,21 +607,8 @@ void polympo_setMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, const do } void polympo_getMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, double* vtxMass){ - Kokkos::Timer timer; - //check mpMesh is valid - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - - //check the size - PMT_ALWAYS_ASSERT(p_mesh->getNumVertices() == nVertices); - - //copy the device array to the host - auto coordsArray = p_mesh->getMeshField(); - auto h_coordsArray = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),coordsArray); - for(int i=0; i(p_mpmesh, 1, nVertices, dataIn); } void polympo_setMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, const double* elmMass){ @@ -652,21 +617,8 @@ void polympo_setMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, const doubl } void polympo_getMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, double* elmMass){ - Kokkos::Timer timer; - //check mpMesh is valid - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - - //check the size - PMT_ALWAYS_ASSERT(p_mesh->getNumElements() == nCells); - - //copy the device array to the host - auto coordsArray = p_mesh->getMeshField(); - auto h_coordsArray = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),coordsArray); - for(int i=0; i(p_mpmesh, 1, nCells, dataIn); } void polympo_setMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* array) { From ce8a5259308c3e0f49f80604282783097e8b0f59 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Thu, 19 Dec 2024 16:55:59 -0500 Subject: [PATCH 08/31] rename mpDataOut --- src/pmpo_c.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index b71a5a7..db7ee4e 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -268,7 +268,7 @@ template void getMPData(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, - double* mpDataHost){ + double* mpDataOut){ checkMPMeshValid(p_mpmesh); auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; PMT_ALWAYS_ASSERT(nComps == polyMPO::mpSliceToNumEntries()); @@ -285,7 +285,7 @@ void getMPData(MPMesh_ptr p_mpmesh, } }; p_MPs->parallel_for(getData, "getMPData"); - kkDbl2dViewHostU arrayHost(mpDataHost,nComps,numMPs); + kkViewHostU arrayHost(mpDataOut,nComps,numMPs); Kokkos::deep_copy(arrayHost, mpDataCopy); } From 9a5266509989684ca1c4d4eae1dc1682376886a5 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Thu, 19 Dec 2024 17:04:11 -0500 Subject: [PATCH 09/31] fixed vtx rot lat --- src/pmpo_c.cpp | 34 ++++------------------------------ src/pmpo_mesh.cpp | 2 +- src/pmpo_mesh.hpp | 2 +- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index db7ee4e..9650297 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -546,39 +546,13 @@ void polympo_getMeshVtxCoords_f(MPMesh_ptr p_mpmesh, const int nVertices, double } void polympo_setMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* latitude){ - Kokkos::Timer timer; - //chech validity - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - - //check the size - PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); - - //copy the host array to the device - auto coordsArray = p_mesh->getMeshField(); - auto h_coordsArray = Kokkos::create_mirror_view(coordsArray); - for(int i=0; i(p_mpmesh, 1, nVertices, dataIn); } void polympo_getMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, double* latitude){ - //chech validity - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - - //check the size - PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); - - //copy the device to host - auto coordsArray = p_mesh->getMeshField(); - auto h_coordsArray = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), - coordsArray); - for(int i=0; i(p_mpmesh, 1, nVertices, dataIn); } void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, const double* xArray, const double* yArray, const double* zArray){ diff --git a/src/pmpo_mesh.cpp b/src/pmpo_mesh.cpp index cdf9b28..8d44393 100644 --- a/src/pmpo_mesh.cpp +++ b/src/pmpo_mesh.cpp @@ -65,7 +65,7 @@ namespace polyMPO{ // Lat [iVtx,0] = dispIncrY [iVtx,1] /R // Lon [iVtx,1] = dispIncrX [iVtx,0] /(R*cos(lat)) rotLatLonIncr(iVtx, 0) = dispIncr(iVtx, 1)/sphereRadius; - rotLatLonIncr(iVtx, 1) = dispIncr(iVtx, 0)/(sphereRadius * std::cos(lat(iVtx))); + rotLatLonIncr(iVtx, 1) = dispIncr(iVtx, 0)/(sphereRadius * std::cos(lat(iVtx, 0))); }); pumipic::RecordTime("PolyMPO_computeRotLatLonIncr", timer.seconds()); } diff --git a/src/pmpo_mesh.hpp b/src/pmpo_mesh.hpp index 3b91dc3..98138d1 100644 --- a/src/pmpo_mesh.hpp +++ b/src/pmpo_mesh.hpp @@ -36,7 +36,7 @@ enum MeshFieldType{ template struct meshFieldToType; template <> struct meshFieldToType < MeshF_VtxCoords > { using type = Kokkos::View; }; -template <> struct meshFieldToType < MeshF_VtxRotLat > { using type = DoubleView; }; +template <> struct meshFieldToType < MeshF_VtxRotLat > { using type = Kokkos::View; }; template <> struct meshFieldToType < MeshF_ElmCenterXYZ > { using type = Kokkos::View; }; template <> struct meshFieldToType < MeshF_Vel > { using type = Kokkos::View; }; template <> struct meshFieldToType < MeshF_VtxMass > { using type = Kokkos::View; }; From 14eec4fe9cd84d88acdcdd493175cfc9ba78a8d4 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Thu, 19 Dec 2024 18:51:42 -0500 Subject: [PATCH 10/31] mesh OnSurfVeloIncr --- src/pmpo_c.cpp | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index 9650297..75357a3 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -269,6 +269,7 @@ void getMPData(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, double* mpDataOut){ + Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; PMT_ALWAYS_ASSERT(nComps == polyMPO::mpSliceToNumEntries()); @@ -287,6 +288,7 @@ void getMPData(MPMesh_ptr p_mpmesh, p_MPs->parallel_for(getData, "getMPData"); kkViewHostU arrayHost(mpDataOut,nComps,numMPs); Kokkos::deep_copy(arrayHost, mpDataCopy); + pumipic::RecordTime("PolyMPO_getMPData", timer.seconds()); } using setMPFunc = void (*)(MPMesh_ptr, const int, const int, const double*); @@ -596,36 +598,17 @@ void polympo_getMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, double* elm } void polympo_setMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* array) { - //check mpMesh is valid - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - kkViewHostU arrayHost(array,nVertices); - - auto vtxField = p_mesh->getMeshField(); - - //check the size - PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); - PMT_ALWAYS_ASSERT(static_cast(nVertices*vec2d_nEntries)==vtxField.size()); - - //copy the host array to the device - Kokkos::deep_copy(vtxField,arrayHost); + const double* dataIn[nComps]; + for(int j=0; j(p_mpmesh, nComps, nVertices, dataIn); } void polympo_getMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* array) { - //check mpMesh is valid - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - kkVec2dViewHostU arrayHost(array,nVertices); - - auto vtxField = p_mesh->getMeshField(); - - //check the size - PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); - PMT_ALWAYS_ASSERT(p_mesh->getNumVertices() == nVertices); - PMT_ALWAYS_ASSERT(static_cast(nVertices*vec2d_nEntries)==vtxField.size()); - - //copy the device array to the host - Kokkos::deep_copy(arrayHost, vtxField); + double* dataIn[nComps]; + for(int j=0; j(p_mpmesh, nComps, nVertices, dataIn); } void polympo_setMeshVtxOnSurfDispIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* array) { From ef97db9da7e9fafcca40a9be20ae9af826a18d39 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Thu, 19 Dec 2024 18:55:30 -0500 Subject: [PATCH 11/31] reduced spacing --- src/pmpo_c.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index 75357a3..b61e0a4 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -541,69 +541,56 @@ void polympo_setMeshVtxCoords_f(MPMesh_ptr p_mpmesh, const int nVertices, const const double* dataIn[] = {xArray, yArray, zArray}; setMeshData(p_mpmesh, 3, nVertices, dataIn); } - void polympo_getMeshVtxCoords_f(MPMesh_ptr p_mpmesh, const int nVertices, double* xArray, double* yArray, double* zArray){ double* dataIn[] = {xArray, yArray, zArray}; getMeshData(p_mpmesh, 3, nVertices, dataIn); } - void polympo_setMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* latitude){ const double* dataIn[] = {latitude}; setMeshData(p_mpmesh, 1, nVertices, dataIn); } - void polympo_getMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, double* latitude){ double* dataIn[] = {latitude}; getMeshData(p_mpmesh, 1, nVertices, dataIn); } - void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, const double* xArray, const double* yArray, const double* zArray){ const double* dataIn[] = {xArray, yArray, zArray}; setMeshData(p_mpmesh, 3, nCells, dataIn); } - void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, double* xArray, double* yArray, double* zArray){ double* dataIn[] = {xArray, yArray, zArray}; getMeshData(p_mpmesh, 3, nCells, dataIn); } - void polympo_setMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* uVelIn, const double* vVelIn){ const double* dataIn[] = {uVelIn, vVelIn}; setMeshData(p_mpmesh, 2, nVertices, dataIn); } - void polympo_getMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, double* uVelOut, double* vVelOut){ double* dataIn[] = {uVelOut, vVelOut}; getMeshData(p_mpmesh, 2, nVertices, dataIn); } - void polympo_setMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* vtxMass){ const double* dataIn[] = {vtxMass}; setMeshData(p_mpmesh, 1, nVertices, dataIn); } - void polympo_getMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, double* vtxMass){ double* dataIn[] = {vtxMass}; getMeshData(p_mpmesh, 1, nVertices, dataIn); } - void polympo_setMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, const double* elmMass){ const double* dataIn[] = {elmMass}; setMeshData(p_mpmesh, 1, nCells, dataIn); } - void polympo_getMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, double* elmMass){ double* dataIn[] = {elmMass}; getMeshData(p_mpmesh, 1, nCells, dataIn); } - void polympo_setMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* array) { const double* dataIn[nComps]; for(int j=0; j(p_mpmesh, nComps, nVertices, dataIn); } - void polympo_getMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* array) { double* dataIn[nComps]; for(int j=0; j Date: Sat, 21 Dec 2024 13:50:01 -0500 Subject: [PATCH 12/31] contiguous data --- src/pmpo_c.cpp | 100 +++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index b61e0a4..5305c27 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -537,6 +537,53 @@ void getMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, dou pumipic::RecordTime("PolyMPO_getMeshData", timer.seconds()); } +template +void setMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* meshDataIn){ + Kokkos::Timer timer; + checkMPMeshValid(p_mpmesh); + auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; + kkViewHostU hostView(meshDataIn,nComps,nVertices); + Kokkos::View deviceView("meshDeviceView",nComps,nVertices); + Kokkos::deep_copy(deviceView, hostView); + + auto vtxField = p_mesh->getMeshField(); + + // //check the size + // PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); + // PMT_ALWAYS_ASSERT(static_cast(nVertices*vec2d_nEntries)==vtxField.size()); + + //copy the host array to the device + Kokkos::parallel_for("set mesh field", nVertices, KOKKOS_LAMBDA(const int iVtx){ + for (int j=0; j +void getMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* meshDataOut){ + Kokkos::Timer timer; + checkMPMeshValid(p_mpmesh); + auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; + kkDbl2dViewHostU hostView(meshDataOut,nComps,nVertices); + Kokkos::View deviceView("meshDeviceView",nComps,nVertices); + + auto vtxField = p_mesh->getMeshField(); + + //check the size + // PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); + // PMT_ALWAYS_ASSERT(p_mesh->getNumVertices() == nVertices); + // PMT_ALWAYS_ASSERT(static_cast(nVertices*vec2d_nEntries)==vtxField.size()); + + //copy the device array to the host + Kokkos::parallel_for("get mesh field", nVertices, KOKKOS_LAMBDA(const int iVtx){ + for (int j=0; j(p_mpmesh, 3, nVertices, dataIn); @@ -586,61 +633,16 @@ void polympo_getMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, double* elm getMeshData(p_mpmesh, 1, nCells, dataIn); } void polympo_setMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* array) { - const double* dataIn[nComps]; - for(int j=0; j(p_mpmesh, nComps, nVertices, dataIn); + setMeshDataContiguous(p_mpmesh, nComps, nVertices, array); } void polympo_getMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* array) { - double* dataIn[nComps]; - for(int j=0; j(p_mpmesh, nComps, nVertices, dataIn); + getMeshDataContiguous(p_mpmesh, nComps, nVertices, array); } - void polympo_setMeshVtxOnSurfDispIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* array) { - Kokkos::Timer timer; - //check mpMesh is valid - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - kkViewHostU arrayHost(array,nComps,nVertices); - Kokkos::View array_d("meshDispIncrDevice",nComps,nVertices); - Kokkos::deep_copy(array_d, arrayHost); - - auto vtxField = p_mesh->getMeshField(); - - //check the size - PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); - PMT_ALWAYS_ASSERT(static_cast(nVertices*vec2d_nEntries)==vtxField.size()); - - //copy the host array to the device - Kokkos::parallel_for("set mesh dispIncr", nVertices, KOKKOS_LAMBDA(const int iVtx){ - vtxField(iVtx,0) = array_d(0,iVtx); - vtxField(iVtx,1) = array_d(1,iVtx); - }); - pumipic::RecordTime("PolyMPO_setMeshVtxOnSurfDispIncr", timer.seconds()); + setMeshDataContiguous(p_mpmesh, nComps, nVertices, array); } - void polympo_getMeshVtxOnSurfDispIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* array) { - //check mpMesh is valid - checkMPMeshValid(p_mpmesh); - auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - kkDbl2dViewHostU arrayHost(array,nComps,nVertices); - Kokkos::View array_d("meshDispIncrDevice",nComps,nVertices); - - auto vtxField = p_mesh->getMeshField(); - - //check the size - PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); - PMT_ALWAYS_ASSERT(p_mesh->getNumVertices() == nVertices); - PMT_ALWAYS_ASSERT(static_cast(nVertices*vec2d_nEntries)==vtxField.size()); - - //copy the device array to the host - Kokkos::parallel_for("get mesh dispIncr", nVertices, KOKKOS_LAMBDA(const int iVtx){ - array_d(0,iVtx) = vtxField(iVtx,0); - array_d(1,iVtx) = vtxField(iVtx,1); - }); - Kokkos::deep_copy(arrayHost, array_d); + getMeshDataContiguous(p_mpmesh, nComps, nVertices, array); } void polympo_push_f(MPMesh_ptr p_mpmesh){ From 105c6a660f4d610f533849181cfa09035dc4beb8 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 21 Dec 2024 14:45:49 -0500 Subject: [PATCH 13/31] simplify mesh data --- src/pmpo_c.cpp | 70 ++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 40 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index 5305c27..60071dc 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -498,51 +498,53 @@ int polympo_getMeshFElmType_f() { return polyMPO::MeshFType_ElmBased; } -template -void setMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double** meshDataIn){ +template +void setMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, Args... arrayArgs){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; + const double* arrayIn[] = {arrayArgs...}; //check the size // PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); // PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells); //copy the host array to the device - auto meshData = p_mesh->getMeshField(); - auto meshData_h = Kokkos::create_mirror_view(Kokkos::HostSpace(), meshData); + auto meshField = p_mesh->getMeshField(); + auto meshField_h = Kokkos::create_mirror_view(Kokkos::HostSpace(), meshField); for(int i=0; i -void getMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double** meshDataOut_h){ +template +void getMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, Args... arrayArgs){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; + double* arrayOut[] = {arrayArgs...}; //check the size // PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); // PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells); //copy the device to host - auto meshData = p_mesh->getMeshField(); - auto meshData_h = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), meshData); + auto meshField = p_mesh->getMeshField(); + auto meshField_h = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), meshField); for(int i=0; i -void setMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* meshDataIn){ +void setMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* arrayIn){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - kkViewHostU hostView(meshDataIn,nComps,nVertices); + kkViewHostU hostView(arrayIn,nComps,nVertices); Kokkos::View deviceView("meshDeviceView",nComps,nVertices); Kokkos::deep_copy(deviceView, hostView); @@ -561,11 +563,11 @@ void setMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVer } template -void getMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* meshDataOut){ +void getMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* arrayOut){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - kkDbl2dViewHostU hostView(meshDataOut,nComps,nVertices); + kkDbl2dViewHostU hostViewOut(arrayOut,nComps,nVertices); Kokkos::View deviceView("meshDeviceView",nComps,nVertices); auto vtxField = p_mesh->getMeshField(); @@ -580,57 +582,45 @@ void getMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVer for (int j=0; j(p_mpmesh, 3, nVertices, dataIn); + setMeshData(p_mpmesh, 3, nVertices, xArray, yArray, zArray); } void polympo_getMeshVtxCoords_f(MPMesh_ptr p_mpmesh, const int nVertices, double* xArray, double* yArray, double* zArray){ - double* dataIn[] = {xArray, yArray, zArray}; - getMeshData(p_mpmesh, 3, nVertices, dataIn); + getMeshData(p_mpmesh, 3, nVertices, xArray, yArray, zArray); } void polympo_setMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* latitude){ - const double* dataIn[] = {latitude}; - setMeshData(p_mpmesh, 1, nVertices, dataIn); + setMeshData(p_mpmesh, 1, nVertices, latitude); } void polympo_getMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, double* latitude){ - double* dataIn[] = {latitude}; - getMeshData(p_mpmesh, 1, nVertices, dataIn); + getMeshData(p_mpmesh, 1, nVertices, latitude); } void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, const double* xArray, const double* yArray, const double* zArray){ - const double* dataIn[] = {xArray, yArray, zArray}; - setMeshData(p_mpmesh, 3, nCells, dataIn); + setMeshData(p_mpmesh, 3, nCells, xArray, yArray, zArray); } void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, double* xArray, double* yArray, double* zArray){ - double* dataIn[] = {xArray, yArray, zArray}; - getMeshData(p_mpmesh, 3, nCells, dataIn); + getMeshData(p_mpmesh, 3, nCells, xArray, yArray, zArray); } void polympo_setMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* uVelIn, const double* vVelIn){ - const double* dataIn[] = {uVelIn, vVelIn}; - setMeshData(p_mpmesh, 2, nVertices, dataIn); + setMeshData(p_mpmesh, 2, nVertices, uVelIn, vVelIn); } void polympo_getMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, double* uVelOut, double* vVelOut){ - double* dataIn[] = {uVelOut, vVelOut}; - getMeshData(p_mpmesh, 2, nVertices, dataIn); + getMeshData(p_mpmesh, 2, nVertices, uVelOut, vVelOut); } void polympo_setMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* vtxMass){ - const double* dataIn[] = {vtxMass}; - setMeshData(p_mpmesh, 1, nVertices, dataIn); + setMeshData(p_mpmesh, 1, nVertices, vtxMass); } void polympo_getMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, double* vtxMass){ - double* dataIn[] = {vtxMass}; - getMeshData(p_mpmesh, 1, nVertices, dataIn); + getMeshData(p_mpmesh, 1, nVertices, vtxMass); } void polympo_setMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, const double* elmMass){ - const double* dataIn[] = {elmMass}; - setMeshData(p_mpmesh, 1, nCells, dataIn); + setMeshData(p_mpmesh, 1, nCells, elmMass); } void polympo_getMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, double* elmMass){ - double* dataIn[] = {elmMass}; - getMeshData(p_mpmesh, 1, nCells, dataIn); + getMeshData(p_mpmesh, 1, nCells, elmMass); } void polympo_setMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* array) { setMeshDataContiguous(p_mpmesh, nComps, nVertices, array); From 8fc3985c8fa379e6f557ee98a8918165153c65bf Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 21 Dec 2024 15:02:55 -0500 Subject: [PATCH 14/31] using common type --- src/pmpo_c.cpp | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index 60071dc..b6458fc 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -230,11 +230,11 @@ void polympo_setMPLatLonRotatedFlag_f(MPMesh_ptr p_mpmesh, const int isRotateFla } -template +template void setMPData(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, - const double* mpDataIn){ + const T* mpDataIn){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; @@ -242,7 +242,7 @@ void setMPData(MPMesh_ptr p_mpmesh, PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getCount()); PMT_ALWAYS_ASSERT(numMPs >= p_MPs->getMaxAppID()); - kkViewHostU mpDataIn_h(mpDataIn,nComps,numMPs); + kkViewHostU mpDataIn_h(mpDataIn,nComps,numMPs); if (mpSlice == polyMPO::MPF_Cur_Pos_XYZ && p_MPs->rebuildOngoing()) { p_MPs->setRebuildMPSlice(mpDataIn_h); @@ -251,7 +251,7 @@ void setMPData(MPMesh_ptr p_mpmesh, auto mpData = p_MPs->getData(); auto mpAppID = p_MPs->getData(); - Kokkos::View mpData_d("mpData_d",nComps,numMPs); + Kokkos::View mpData_d("mpData_d",nComps,numMPs); Kokkos::deep_copy(mpData_d, mpDataIn_h); auto setData = PS_LAMBDA(const int&, const int& mp, const int& mask){ @@ -264,11 +264,11 @@ void setMPData(MPMesh_ptr p_mpmesh, pumipic::RecordTime("PolyMPO_setMPData", timer.seconds()); } -template +template void getMPData(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, - double* mpDataOut){ + T* mpDataOut){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs; @@ -278,7 +278,7 @@ void getMPData(MPMesh_ptr p_mpmesh, auto mpData = p_MPs->getData(); auto mpAppID = p_MPs->getData(); - Kokkos::View mpDataCopy("mpDataCopy",nComps,numMPs); + Kokkos::View mpDataCopy("mpDataCopy",nComps,numMPs); auto getData = PS_LAMBDA(const int&, const int& mp, const int& mask){ if(mask){ for (int i=0; iparallel_for(getData, "getMPData"); - kkViewHostU arrayHost(mpDataOut,nComps,numMPs); + kkViewHostU arrayHost(mpDataOut,nComps,numMPs); Kokkos::deep_copy(arrayHost, mpDataCopy); pumipic::RecordTime("PolyMPO_getMPData", timer.seconds()); } @@ -499,11 +499,12 @@ int polympo_getMeshFElmType_f() { } template -void setMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, Args... arrayArgs){ +void setMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int size, Args... arrayArgs){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - const double* arrayIn[] = {arrayArgs...}; + using T = std::common_type_t; + T arrayIn[] = {arrayArgs...}; //check the size // PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); @@ -512,7 +513,7 @@ void setMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, Arg //copy the host array to the device auto meshField = p_mesh->getMeshField(); auto meshField_h = Kokkos::create_mirror_view(Kokkos::HostSpace(), meshField); - for(int i=0; i -void getMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, Args... arrayArgs){ +void getMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int size, Args... arrayArgs){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - double* arrayOut[] = {arrayArgs...}; + using T = std::common_type_t; + T arrayOut[] = {arrayArgs...}; //check the size // PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); @@ -533,19 +535,19 @@ void getMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, Arg //copy the device to host auto meshField = p_mesh->getMeshField(); auto meshField_h = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), meshField); - for(int i=0; i -void setMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* arrayIn){ +template +void setMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const T* arrayIn){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - kkViewHostU hostView(arrayIn,nComps,nVertices); - Kokkos::View deviceView("meshDeviceView",nComps,nVertices); + kkViewHostU hostView(arrayIn,nComps,nVertices); + Kokkos::View deviceView("meshDeviceView",nComps,nVertices); Kokkos::deep_copy(deviceView, hostView); auto vtxField = p_mesh->getMeshField(); From 29182c58e39cecad6d27d977e22edcea77d3bc16 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 21 Dec 2024 15:09:09 -0500 Subject: [PATCH 15/31] rename getset mesh fields --- src/pmpo_c.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index b6458fc..ab18ce2 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -499,7 +499,7 @@ int polympo_getMeshFElmType_f() { } template -void setMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int size, Args... arrayArgs){ +void setMeshField1D(MPMesh_ptr p_mpmesh, const int nComps, const int size, Args... arrayArgs){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; @@ -517,11 +517,11 @@ void setMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int size, Args... for(int j=0; j -void getMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int size, Args... arrayArgs){ +void getMeshField1D(MPMesh_ptr p_mpmesh, const int nComps, const int size, Args... arrayArgs){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; @@ -538,11 +538,11 @@ void getMeshData(MPMesh_ptr p_mpmesh, const int nComps, const int size, Args... for(int i=0; i -void setMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const T* arrayIn){ +void setMeshField2D(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const T* arrayIn){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; @@ -561,11 +561,11 @@ void setMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVer for (int j=0; j -void getMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* arrayOut){ +void getMeshField2D(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* arrayOut){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; @@ -585,56 +585,56 @@ void getMeshDataContiguous(MPMesh_ptr p_mpmesh, const int nComps, const int nVer deviceView(j,iVtx) = vtxField(iVtx,j); }); Kokkos::deep_copy(hostViewOut, deviceView); - pumipic::RecordTime("PolyMPO_getMeshDataContiguous", timer.seconds()); + pumipic::RecordTime("PolyMPO_getMeshField2D", timer.seconds()); } void polympo_setMeshVtxCoords_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* xArray, const double* yArray, const double* zArray){ - setMeshData(p_mpmesh, 3, nVertices, xArray, yArray, zArray); + setMeshField1D(p_mpmesh, 3, nVertices, xArray, yArray, zArray); } void polympo_getMeshVtxCoords_f(MPMesh_ptr p_mpmesh, const int nVertices, double* xArray, double* yArray, double* zArray){ - getMeshData(p_mpmesh, 3, nVertices, xArray, yArray, zArray); + getMeshField1D(p_mpmesh, 3, nVertices, xArray, yArray, zArray); } void polympo_setMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* latitude){ - setMeshData(p_mpmesh, 1, nVertices, latitude); + setMeshField1D(p_mpmesh, 1, nVertices, latitude); } void polympo_getMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, double* latitude){ - getMeshData(p_mpmesh, 1, nVertices, latitude); + getMeshField1D(p_mpmesh, 1, nVertices, latitude); } void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, const double* xArray, const double* yArray, const double* zArray){ - setMeshData(p_mpmesh, 3, nCells, xArray, yArray, zArray); + setMeshField1D(p_mpmesh, 3, nCells, xArray, yArray, zArray); } void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, double* xArray, double* yArray, double* zArray){ - getMeshData(p_mpmesh, 3, nCells, xArray, yArray, zArray); + getMeshField1D(p_mpmesh, 3, nCells, xArray, yArray, zArray); } void polympo_setMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* uVelIn, const double* vVelIn){ - setMeshData(p_mpmesh, 2, nVertices, uVelIn, vVelIn); + setMeshField1D(p_mpmesh, 2, nVertices, uVelIn, vVelIn); } void polympo_getMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, double* uVelOut, double* vVelOut){ - getMeshData(p_mpmesh, 2, nVertices, uVelOut, vVelOut); + getMeshField1D(p_mpmesh, 2, nVertices, uVelOut, vVelOut); } void polympo_setMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* vtxMass){ - setMeshData(p_mpmesh, 1, nVertices, vtxMass); + setMeshField1D(p_mpmesh, 1, nVertices, vtxMass); } void polympo_getMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, double* vtxMass){ - getMeshData(p_mpmesh, 1, nVertices, vtxMass); + getMeshField1D(p_mpmesh, 1, nVertices, vtxMass); } void polympo_setMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, const double* elmMass){ - setMeshData(p_mpmesh, 1, nCells, elmMass); + setMeshField1D(p_mpmesh, 1, nCells, elmMass); } void polympo_getMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, double* elmMass){ - getMeshData(p_mpmesh, 1, nCells, elmMass); + getMeshField1D(p_mpmesh, 1, nCells, elmMass); } void polympo_setMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* array) { - setMeshDataContiguous(p_mpmesh, nComps, nVertices, array); + setMeshField2D(p_mpmesh, nComps, nVertices, array); } void polympo_getMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* array) { - getMeshDataContiguous(p_mpmesh, nComps, nVertices, array); + getMeshField2D(p_mpmesh, nComps, nVertices, array); } void polympo_setMeshVtxOnSurfDispIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* array) { - setMeshDataContiguous(p_mpmesh, nComps, nVertices, array); + setMeshField2D(p_mpmesh, nComps, nVertices, array); } void polympo_getMeshVtxOnSurfDispIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* array) { - getMeshDataContiguous(p_mpmesh, nComps, nVertices, array); + getMeshField2D(p_mpmesh, nComps, nVertices, array); } void polympo_push_f(MPMesh_ptr p_mpmesh){ From 7089903bcf3307bc072f62f969f9fbf419cf699b Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 21 Dec 2024 15:52:16 -0500 Subject: [PATCH 16/31] removed kkViewTypes --- src/pmpo_c.cpp | 23 ++++++++++++----------- src/pmpo_createTestMPMesh.cpp | 4 ++-- src/pmpo_defines.h | 6 ------ src/pmpo_materialPoints.cpp | 4 ++-- src/pmpo_materialPoints.hpp | 7 +++++-- test/mpUnitTest.cpp | 2 +- 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index ab18ce2..28edd7d 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -211,7 +211,7 @@ void polympo_getMPCurElmID_f(MPMesh_ptr p_mpmesh, auto mpAppID = p_MPs->getData(); auto elmIDoffset = p_MPs->getElmIDoffset(); - kkIntViewHostU arrayHost(elmIDs,numMPs); + polyMPO::MPsViewHostU arrayHost(elmIDs,numMPs); polyMPO::IntView mpCurElmIDCopy("mpCurElmIDNewValue",numMPs); auto getElmId = PS_LAMBDA(const int&, const int& mp, const int& mask){ @@ -552,9 +552,10 @@ void setMeshField2D(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, auto vtxField = p_mesh->getMeshField(); - // //check the size - // PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); - // PMT_ALWAYS_ASSERT(static_cast(nVertices*vec2d_nEntries)==vtxField.size()); + //check the size + PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); + PMT_ALWAYS_ASSERT(p_mesh->getNumVertices() == nVertices); + PMT_ALWAYS_ASSERT(static_cast(nVertices*vec2d_nEntries)==vtxField.size()); //copy the host array to the device Kokkos::parallel_for("set mesh field", nVertices, KOKKOS_LAMBDA(const int iVtx){ @@ -564,20 +565,20 @@ void setMeshField2D(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, pumipic::RecordTime("PolyMPO_setMeshField2D", timer.seconds()); } -template -void getMeshField2D(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* arrayOut){ +template +void getMeshField2D(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, T* arrayOut){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - kkDbl2dViewHostU hostViewOut(arrayOut,nComps,nVertices); - Kokkos::View deviceView("meshDeviceView",nComps,nVertices); + kkViewHostU hostViewOut(arrayOut,nComps,nVertices); + Kokkos::View deviceView("meshDeviceView",nComps,nVertices); auto vtxField = p_mesh->getMeshField(); //check the size - // PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); - // PMT_ALWAYS_ASSERT(p_mesh->getNumVertices() == nVertices); - // PMT_ALWAYS_ASSERT(static_cast(nVertices*vec2d_nEntries)==vtxField.size()); + PMT_ALWAYS_ASSERT(nComps == vec2d_nEntries); + PMT_ALWAYS_ASSERT(p_mesh->getNumVertices() == nVertices); + PMT_ALWAYS_ASSERT(static_cast(nVertices*vec2d_nEntries)==vtxField.size()); //copy the device array to the host Kokkos::parallel_for("get mesh field", nVertices, KOKKOS_LAMBDA(const int iVtx){ diff --git a/src/pmpo_createTestMPMesh.cpp b/src/pmpo_createTestMPMesh.cpp index 3a2ae6c..44b56a8 100644 --- a/src/pmpo_createTestMPMesh.cpp +++ b/src/pmpo_createTestMPMesh.cpp @@ -173,8 +173,8 @@ MaterialPoints* initTestMPs(Mesh* mesh, int testMPOption){ iMP += numMPsPerElement(i); },numMPs); - MPSView positions("MPpositions",numMPs); - MPSView latLonPositions("MPRotLatLonPositions",numMPs); + MPsView positions("MPpositions",numMPs); + MPsView latLonPositions("MPRotLatLonPositions",numMPs); if(geomType == geom_planar_surf){ Kokkos::parallel_for("intializeMPsPositionPlanar", numMPs, KOKKOS_LAMBDA(const int iMP){ int ielm = MPToElement(iMP); diff --git a/src/pmpo_defines.h b/src/pmpo_defines.h index 34857b9..556d292 100644 --- a/src/pmpo_defines.h +++ b/src/pmpo_defines.h @@ -24,12 +24,6 @@ using kkViewHostU = Kokkos::View< Kokkos::DefaultHostExecutionSpace, Kokkos::MemoryTraits>; -typedef kkViewHostU kkDblViewHostU;//TODO:put it to mesh.hpp -typedef kkViewHostU kkVec2dViewHostU;//TODO:put it to mesh.hpp -typedef kkViewHostU kkDbl2dViewHostU;//TODO:put it somewhere else (maybe) -typedef kkViewHostU kkInt2dViewHostU;//TODO:put it somewhere else (maybe) -typedef kkViewHostU kkIntViewHostU;//TODO:put it somewhere else (maybe) - template auto create_mirror_view_and_copy(DataT array, const int size){ kkViewHostU temp_host(array, size); diff --git a/src/pmpo_materialPoints.cpp b/src/pmpo_materialPoints.cpp index c20fe00..86a9cdd 100644 --- a/src/pmpo_materialPoints.cpp +++ b/src/pmpo_materialPoints.cpp @@ -19,7 +19,7 @@ pumipic::MemberTypeViews createInternalMemberViews(int numMPs, View mp2elm, View return mpInfo; } -PS* createDPS(int numElms, int numMPs, MPSView positions, IntView mpsPerElm, IntView mp2elm) { +PS* createDPS(int numElms, int numMPs, MPsView positions, IntView mpsPerElm, IntView mp2elm) { PS::kkGidView elmGids("elementGlobalIds", numElms); //TODO - initialize this to [0..numElms) auto mpInfo = ps::createMemberViews(numMPs); auto mpPositions = ps::getMemberView(mpInfo); @@ -51,7 +51,7 @@ PS* createDPS(int numElms, int numMPs, IntView mpsPerElm, IntView mp2elm, IntVie } //End anonymous namespace -MaterialPoints::MaterialPoints(int numElms, int numMPs, MPSView positions, IntView mpsPerElm, IntView mp2elm) { +MaterialPoints::MaterialPoints(int numElms, int numMPs, MPsView positions, IntView mpsPerElm, IntView mp2elm) { MPs = createDPS(numElms, numMPs, positions, mpsPerElm, mp2elm); maxAppID = numMPs; //this ctor does not support inactive MPs operating_mode = MP_RELEASE; diff --git a/src/pmpo_materialPoints.hpp b/src/pmpo_materialPoints.hpp index 86999eb..2c00766 100644 --- a/src/pmpo_materialPoints.hpp +++ b/src/pmpo_materialPoints.hpp @@ -77,7 +77,10 @@ static constexpr int mpSliceToNumEntries() { } template -using MPSView = Kokkos::View::type*>; +using MPsViewHostU = kkViewHostU::type*>; + +template +using MPsView = Kokkos::View::type*>; const static std::vector> mpSliceSwap = {{MPF_Cur_Elm_ID, MPF_Tgt_Elm_ID}, @@ -129,7 +132,7 @@ class MaterialPoints { public: MaterialPoints() : MPs(nullptr) {}; - MaterialPoints(int numElms, int numMPs, MPSView positions, IntView mpsPerElm, IntView mp2elm); + MaterialPoints(int numElms, int numMPs, MPsView positions, IntView mpsPerElm, IntView mp2elm); MaterialPoints(int numElms, int numMPs, IntView mpsPerElm, IntView mp2elm, IntView mpAppID); ~MaterialPoints(); diff --git a/test/mpUnitTest.cpp b/test/mpUnitTest.cpp index 86821a5..1d24a27 100644 --- a/test/mpUnitTest.cpp +++ b/test/mpUnitTest.cpp @@ -45,7 +45,7 @@ int main(int argc, char** argv) { auto mpToElement_d = copyToDevice(mpToElement, "mpToElement"); auto mpPerElement_d = copyToDevice(mpPerElement, "mpPerElement"); - auto mpPositions = polyMPO::MPSView("positions",numMPs); + auto mpPositions = polyMPO::MPsView("positions",numMPs); Kokkos::parallel_for("intializeMPsPosition", numMPs, KOKKOS_LAMBDA(const int i){ const auto x = mpToElement_d(i)*1.0; const auto y = mpToElement_d(i)*-1.0; From 3584cb42a6ed3bed8db352c4e0158d0194a2ebd2 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 21 Dec 2024 16:07:11 -0500 Subject: [PATCH 17/31] removed nComps for combine mesh fields --- src/pmpo_c.cpp | 56 +++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index 28edd7d..13e230a 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -499,45 +499,41 @@ int polympo_getMeshFElmType_f() { } template -void setMeshField1D(MPMesh_ptr p_mpmesh, const int nComps, const int size, Args... arrayArgs){ +void setMeshField1D(MPMesh_ptr p_mpmesh, const int size, Args... meshArraysIn){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; - using T = std::common_type_t; - T arrayIn[] = {arrayArgs...}; - //check the size - // PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); - // PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells); + using T = std::common_type_t; + T combinedIn[] = {meshArraysIn...}; - //copy the host array to the device auto meshField = p_mesh->getMeshField(); auto meshField_h = Kokkos::create_mirror_view(Kokkos::HostSpace(), meshField); + + int numArrays = sizeof...(meshArraysIn); for(int i=0; i -void getMeshField1D(MPMesh_ptr p_mpmesh, const int nComps, const int size, Args... arrayArgs){ +void getMeshField1D(MPMesh_ptr p_mpmesh, const int size, Args... meshArraysOut){ Kokkos::Timer timer; checkMPMeshValid(p_mpmesh); auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh; + using T = std::common_type_t; - T arrayOut[] = {arrayArgs...}; + T combinedOut[] = {meshArraysOut...}; - //check the size - // PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices); - // PMT_ALWAYS_ASSERT(p_mesh->getNumElements()==nCells); - - //copy the device to host auto meshField = p_mesh->getMeshField(); auto meshField_h = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), meshField); + + int numArrays = sizeof...(meshArraysOut); for(int i=0; i(p_mpmesh, 3, nVertices, xArray, yArray, zArray); + setMeshField1D(p_mpmesh, nVertices, xArray, yArray, zArray); } void polympo_getMeshVtxCoords_f(MPMesh_ptr p_mpmesh, const int nVertices, double* xArray, double* yArray, double* zArray){ - getMeshField1D(p_mpmesh, 3, nVertices, xArray, yArray, zArray); + getMeshField1D(p_mpmesh, nVertices, xArray, yArray, zArray); } void polympo_setMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* latitude){ - setMeshField1D(p_mpmesh, 1, nVertices, latitude); + setMeshField1D(p_mpmesh, nVertices, latitude); } void polympo_getMeshVtxRotLat_f(MPMesh_ptr p_mpmesh, const int nVertices, double* latitude){ - getMeshField1D(p_mpmesh, 1, nVertices, latitude); + getMeshField1D(p_mpmesh, nVertices, latitude); } void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, const double* xArray, const double* yArray, const double* zArray){ - setMeshField1D(p_mpmesh, 3, nCells, xArray, yArray, zArray); + setMeshField1D(p_mpmesh, nCells, xArray, yArray, zArray); } void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, double* xArray, double* yArray, double* zArray){ - getMeshField1D(p_mpmesh, 3, nCells, xArray, yArray, zArray); + getMeshField1D(p_mpmesh, nCells, xArray, yArray, zArray); } void polympo_setMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* uVelIn, const double* vVelIn){ - setMeshField1D(p_mpmesh, 2, nVertices, uVelIn, vVelIn); + setMeshField1D(p_mpmesh, nVertices, uVelIn, vVelIn); } void polympo_getMeshVtxVel_f(MPMesh_ptr p_mpmesh, const int nVertices, double* uVelOut, double* vVelOut){ - getMeshField1D(p_mpmesh, 2, nVertices, uVelOut, vVelOut); + getMeshField1D(p_mpmesh, nVertices, uVelOut, vVelOut); } void polympo_setMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* vtxMass){ - setMeshField1D(p_mpmesh, 1, nVertices, vtxMass); + setMeshField1D(p_mpmesh, nVertices, vtxMass); } void polympo_getMeshVtxMass_f(MPMesh_ptr p_mpmesh, const int nVertices, double* vtxMass){ - getMeshField1D(p_mpmesh, 1, nVertices, vtxMass); + getMeshField1D(p_mpmesh, nVertices, vtxMass); } void polympo_setMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, const double* elmMass){ - setMeshField1D(p_mpmesh, 1, nCells, elmMass); + setMeshField1D(p_mpmesh, nCells, elmMass); } void polympo_getMeshElmMass_f(MPMesh_ptr p_mpmesh, const int nCells, double* elmMass){ - getMeshField1D(p_mpmesh, 1, nCells, elmMass); + getMeshField1D(p_mpmesh, nCells, elmMass); } void polympo_setMeshVtxOnSurfVeloIncr_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, const double* array) { setMeshField2D(p_mpmesh, nComps, nVertices, array); From b0ad3f31e6aea0c2ba7f5eec099c4c7f91770659 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 14:33:53 -0500 Subject: [PATCH 18/31] re wrote github action tests --- .github/actions/install-repo/action.yml | 47 ++++ .github/workflows/cmake.yml | 292 ++++++++---------------- 2 files changed, 137 insertions(+), 202 deletions(-) create mode 100644 .github/actions/install-repo/action.yml diff --git a/.github/actions/install-repo/action.yml b/.github/actions/install-repo/action.yml new file mode 100644 index 0000000..b799586 --- /dev/null +++ b/.github/actions/install-repo/action.yml @@ -0,0 +1,47 @@ +name: Install-Repo + +inputs: + repo-name: + required: true + repo-path: + required: true + repo-ref: + required: true + options: + required: true + cache: + required: true + submodules: + default: '' + +runs: + using: "composite" + steps: + + - name: Check Cache + if: ${{ inputs.cache == 'true'}} + uses: actions/cache@v3 + id: check-cache + with: + key: build-${{ inputs.repo-name }} + path: ${{ runner.temp }}/build-${{ inputs.repo-name }} + + - name: Checkout Repo + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repo-path }} + submodules: ${{ inputs.submodules }} + ref: ${{ inputs.repo-ref }} + path: ${{ inputs.repo-name }} + + - name: Configure CMake + if: ${{ !steps.check-cache.outputs.cache-hit }} + shell: bash + run: cmake -S $GITHUB_WORKSPACE/${{ inputs.repo-name }} -B ${{ runner.temp }}/build-${{ inputs.repo-name }} + -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/build-${{ inputs.repo-name }}/install + ${{ inputs.options }} + + - name: Build Cmake + if: ${{ !steps.check-cache.outputs.cache-hit }} + shell: bash + run: cmake --build ${{ runner.temp }}/build-${{ inputs.repo-name }} -j8 --target install \ No newline at end of file diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 6c9ef06..ae86cd5 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -32,215 +32,103 @@ jobs: - name: Install NetCDF-Fortran run: sudo apt-get install libnetcdff-dev - # Build Kokkos - - name: Cache Kokkos Build - uses: actions/cache@v3 - id: build-kokkos + - name: build kokkos + uses: ./.github/actions/install-repo with: - key: build-kokkos - path: ${{ runner.temp }}/build-kokkos - - - name: Kokkos Checkout repo - if: ${{ steps.build-kokkos.outputs.cache-hit != 'true' }} - uses: actions/checkout@v3 + repo-name: 'kokkos' + repo-path: 'kokkos/kokkos' + repo-ref: '4.2.00' + cache: true + options: '-DCMAKE_CXX_COMPILER=${{ matrix.compiler }} + -DKokkos_ENABLE_SERIAL=ON + -DKokkos_ENABLE_OPENMP=off + -DKokkos_ENABLE_CUDA=off + -DKokkos_ENABLE_CUDA_LAMBDA=off + -DKokkos_ENABLE_DEBUG=on' + + + - name: build Engpar + uses: ./.github/actions/install-repo with: - repository: kokkos/kokkos - ref: 4.1.00 - path: kokkos - - - name: Kokkos Create Directory - if: ${{ steps.build-kokkos.outputs.cache-hit != 'true' }} - run: cmake -E make_directory ${{ runner.temp }}/build-kokkos - - - name: Kokkos Configure CMake - if: ${{ steps.build-kokkos.outputs.cache-hit != 'true' }} - run: cmake -S $GITHUB_WORKSPACE/kokkos -B ${{ runner.temp }}/build-kokkos - -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/build-kokkos/install - -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} - -DKokkos_ENABLE_SERIAL=ON - -DKokkos_ENABLE_OPENMP=off - -DKokkos_ENABLE_CUDA=off - -DKokkos_ENABLE_CUDA_LAMBDA=off - -DKokkos_ENABLE_DEBUG=on - - - name: Kokkos Build - if: ${{ steps.build-kokkos.outputs.cache-hit != 'true' }} - run: cmake --build ${{ runner.temp }}/build-kokkos -j8 --target install - - # Build EnGPar - - - name: Cache Engpar Build - uses: actions/cache@v3 - id: build-engpar + repo-name: 'Engpar' + repo-path: 'SCOREC/EnGPar' + repo-ref: '' + cache: true + options: '-DCMAKE_C_COMPILER=mpicc + -DCMAKE_CXX_COMPILER=mpicxx + -DCMAKE_CXX_FLAGS="-std=c++11" + -DENABLE_PARMETIS=OFF + -DENABLE_PUMI=OFF + -DIS_TESTING=OFF' + + + - name: build omega_h + uses: ./.github/actions/install-repo with: - key: build-engpar - path: ${{ runner.temp }}/build-engpar - - - name: EnGPar Checkout repo - if: ${{ steps.build-engpar.outputs.cache-hit != 'true' }} - uses: actions/checkout@v3 + repo-name: 'omega_h' + repo-path: 'SCOREC/omega_h' + repo-ref: 'scorec-v10.8.0' + cache: true + options: '-DCMAKE_BUILD_TYPE=Release + -DBUILD_SHARED_LIBS=OFF + -DOmega_h_USE_Kokkos=ON + -DOmega_h_USE_CUDA=off + -DOmega_h_USE_MPI=on + -DMPIEXEC_EXECUTABLE=srun + -DBUILD_TESTING=off + -DCMAKE_C_COMPILER=mpicc + -DCMAKE_CXX_COMPILER=mpicxx + -DKokkos_PREFIX=${{ runner.temp }}/build-kokkos/install/lib/cmake' + + + - name: build cabana + uses: ./.github/actions/install-repo with: - repository: SCOREC/EnGPar - path: engpar - - - name: EnGPar Create Directory - if: ${{ steps.build-engpar.outputs.cache-hit != 'true' }} - run: cmake -E make_directory ${{ runner.temp }}/build-engpar - - - name: EnGPar Configure CMake - if: ${{ steps.build-engpar.outputs.cache-hit != 'true' }} - run: cmake -S $GITHUB_WORKSPACE/engpar -B ${{ runner.temp }}/build-engpar - -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/build-engpar/install - -DCMAKE_C_COMPILER="mpicc" - -DCMAKE_CXX_COMPILER="mpicxx" - -DCMAKE_CXX_FLAGS="-std=c++11" - -DENABLE_PARMETIS=OFF - -DENABLE_PUMI=OFF - -DIS_TESTING=OFF - - - name: EnGPar Build - if: ${{ steps.build-engpar.outputs.cache-hit != 'true' }} - run: cmake --build ${{ runner.temp }}/build-engpar -j8 --target install - - # Build Omega_h - - - name: Cache Omega_h Build - uses: actions/cache@v3 - id: build-omega_h + repo-name: 'cabana' + repo-path: 'ECP-copa/cabana' + repo-ref: '0.6.1' + cache: true + options: '-DCMAKE_CXX_COMPILER=${{ matrix.compiler }} + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_DISABLE_FIND_PACKAGE_HDF5=ON + -DCMAKE_PREFIX_PATH=${{ runner.temp }}/build-kokkos/install/lib/cmake' + + + - name: build pumi-pic + uses: ./.github/actions/install-repo with: - key: build-omega_h - path: ${{ runner.temp }}/build-omega_h - - - name: Omega_h Checkout repo - if: ${{ steps.build-omega_h.outputs.cache-hit != 'true' }} - uses: actions/checkout@v3 + repo-name: 'pumi-pic' + repo-path: 'SCOREC/pumi-pic' + repo-ref: '2.0.3' + submodules: 'recursive' + cache: true + options: '-DCMAKE_CXX_COMPILER=mpicxx + -DCMAKE_BUILD_TYPE=Release + -DIS_TESTING=OFF + -DPS_IS_TESTING=OFF + -DTEST_DATA_DIR=$GITHUB_WORKSPACE/pumi-pic/pumipic-data + -DOmega_h_PREFIX=${{ runner.temp }}/build-omega_h/install + -DKokkos_PREFIX=${{ runner.temp }}/build-kokkos/install + -DEnGPar_PREFIX=${{ runner.temp }}/build-engpar/install + -DCabana_PREFIX=${{ runner.temp }}/build-cabana/install + -DENABLE_CABANA=on + -DCMAKE_PREFIX_PATH=${{ runner.temp }}/build-kokkos/install/lib/cmake' + + + - name: build polyMPO + uses: ./.github/actions/install-repo with: - repository: SCOREC/omega_h - ref: scorec-v10.8.0 - path: omega_h - - - name: Omega_h Create Directory - if: ${{ steps.build-omega_h.outputs.cache-hit != 'true' }} - run: cmake -E make_directory ${{ runner.temp }}/build-omega_h - - - name: Omega_h Configure CMake - if: ${{ steps.build-omega_h.outputs.cache-hit != 'true' }} - run: cmake -S $GITHUB_WORKSPACE/omega_h -B ${{ runner.temp }}/build-omega_h - -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/build-omega_h/install - -DCMAKE_PREFIX_PATH=${{ runner.temp }}/build-kokkos/install/lib/cmake - -DBUILD_SHARED_LIBS=OFF - -DOmega_h_USE_Kokkos=ON - -DOmega_h_USE_CUDA=off - -DOmega_h_USE_MPI=on - -DCMAKE_BUILD_TYPE=Release - -DBUILD_TESTING=on - -DCMAKE_CXX_COMPILER="mpicxx" - -DCMAKE_C_COMPILER="mpicc" - - - name: Omega_h Build - if: ${{ steps.build-omega_h.outputs.cache-hit != 'true' }} - run: cmake --build ${{ runner.temp }}/build-omega_h -j8 --target install - - # Build Cabana - - - name: Cache Cabana Build - uses: actions/cache@v3 - id: build-cabana - with: - key: build-cabana - path: ${{ runner.temp }}/build-cabana - - - name: Cabana Checkout repo - if: ${{ steps.build-cabana.outputs.cache-hit != 'true' }} - uses: actions/checkout@v3 - with: - repository: ECP-copa/cabana - ref: 0.6.1 - path: cabana - - - name: Cabana Create Directory - if: ${{ steps.build-cabana.outputs.cache-hit != 'true' }} - run: cmake -E make_directory ${{ runner.temp }}/build-cabana - - - name: Cabana Configure CMake - if: ${{ steps.build-cabana.outputs.cache-hit != 'true' }} - run: cmake -S $GITHUB_WORKSPACE/cabana -B ${{ runner.temp }}/build-cabana - -DCMAKE_BUILD_TYPE="Release" - -DCMAKE_DISABLE_FIND_PACKAGE_HDF5=ON - -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} - -DCMAKE_PREFIX_PATH=${{ runner.temp }}/build-kokkos/install/lib/cmake - -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/build-cabana/install - - - name: Cabana Build - if: ${{ steps.build-cabana.outputs.cache-hit != 'true' }} - run: cmake --build ${{ runner.temp }}/build-cabana -j8 --target install - - # Build PUMI-PIC - - - name: Cache PUMI-PIC Build - uses: actions/cache@v3 - id: build-pumi-pic - with: - key: build-pumi-pic - path: ${{ runner.temp }}/build-pumi-pic - - - name: PUMI-PIC Checkout repo - if: ${{ steps.build-pumi-pic.outputs.cache-hit != 'true' }} - uses: actions/checkout@v3 - with: - submodules: recursive - repository: SCOREC/pumi-pic - ref: 2.0.3 - path: pumi-pic - - - name: PUMI-PIC Create Directory - if: ${{ steps.build-pumi-pic.outputs.cache-hit != 'true' }} - run: cmake -E make_directory ${{ runner.temp }}/build-pumi-pic - - - name: PUMI-PIC Configure CMake - if: ${{ steps.build-pumi-pic.outputs.cache-hit != 'true' }} - run: cmake -S $GITHUB_WORKSPACE/pumi-pic -B ${{ runner.temp }}/build-pumi-pic - -DCMAKE_CXX_COMPILER=mpicxx - -DIS_TESTING=ON - -DPS_IS_TESTING=ON - -DCMAKE_BUILD_TYPE="Release" - -DTEST_DATA_DIR=$GITHUB_WORKSPACE/pumi-pic/pumipic-data - -DOmega_h_PREFIX=${{ runner.temp }}/build-omega_h/install - -DKokkos_PREFIX=${{ runner.temp }}/build-kokkos/install - -DEnGPar_PREFIX=${{ runner.temp }}/build-engpar/install - -DCabana_PREFIX=${{ runner.temp }}/build-cabana/install - -DENABLE_CABANA=on - -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/build-pumi-pic/install - -DCMAKE_PREFIX_PATH=${{ runner.temp }}/build-kokkos/install/lib/cmake - - - name: PUMI-PIC Build - if: ${{ steps.build-pumi-pic.outputs.cache-hit != 'true' }} - run: cmake --build ${{ runner.temp }}/build-pumi-pic -j8 --target install - - # Build PolyMPO - - - name: PolyMPO Checkout repo - uses: actions/checkout@v3 - with: - submodules: recursive - repository: SCOREC/polyMPO - path: polyMPO - - - name: PolyMPO Create Directory - run: cmake -E make_directory ${{ runner.temp }}/build-polyMPO - - - name: PolyMPO Configure CMake - run: cmake -S $GITHUB_WORKSPACE/polyMPO -B ${{ runner.temp }}/build-polyMPO - -DCMAKE_BUILD_TYPE="Debug" - -DKokkos_DIR=${{ runner.temp }}/build-kokkos/install/lib64/cmake/Kokkos - -DCMAKE_PREFIX_PATH=${{ runner.temp }}/build-pumi-pic/install - -DIS_TESTING=on - -DCMAKE_CXX_COMPILER=mpicxx - -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/build-polyMPO/install - - - name: PolyMPO Build - run: cmake --build ${{ runner.temp }}/build-polyMPO -j8 --target install + repo-name: 'polyMPO' + repo-path: 'SCOREC/polyMPO' + repo-ref: '' + cache: false + submodules: 'recursive' + options: '-DCMAKE_CXX_COMPILER=mpicxx + -DCMAKE_BUILD_TYPE=Debug + -DKokkos_DIR=${{ runner.temp }}/build-kokkos/install/lib64/cmake/Kokkos + -DCMAKE_PREFIX_PATH=${{ runner.temp }}/build-pumi-pic/install + -DIS_TESTING=on' - name: PolyMPO Test run: ctest --test-dir ${{ runner.temp }}/build-polyMPO From d822d46aa8c2b36aa4800cccb19e852a38ffcbd8 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 14:36:50 -0500 Subject: [PATCH 19/31] checkout repo --- .github/workflows/cmake.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index ae86cd5..10a422b 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -32,6 +32,8 @@ jobs: - name: Install NetCDF-Fortran run: sudo apt-get install libnetcdff-dev + - uses: actions/checkout@v4 + - name: build kokkos uses: ./.github/actions/install-repo From 0acd332938aa8590645ee2aa8e4ee0ead59e614f Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 14:42:51 -0500 Subject: [PATCH 20/31] update version --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 10a422b..a743e6d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -70,7 +70,7 @@ jobs: with: repo-name: 'omega_h' repo-path: 'SCOREC/omega_h' - repo-ref: 'scorec-v10.8.0' + repo-ref: 'scorec-v10.8.4' cache: true options: '-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF From 910cd90beece7aae4fd80cc46848e70890d3c51b Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 15:26:07 -0500 Subject: [PATCH 21/31] rename engpar --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a743e6d..5d59550 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -112,7 +112,7 @@ jobs: -DTEST_DATA_DIR=$GITHUB_WORKSPACE/pumi-pic/pumipic-data -DOmega_h_PREFIX=${{ runner.temp }}/build-omega_h/install -DKokkos_PREFIX=${{ runner.temp }}/build-kokkos/install - -DEnGPar_PREFIX=${{ runner.temp }}/build-engpar/install + -DEnGPar_PREFIX=${{ runner.temp }}/build-Engpar/install -DCabana_PREFIX=${{ runner.temp }}/build-cabana/install -DENABLE_CABANA=on -DCMAKE_PREFIX_PATH=${{ runner.temp }}/build-kokkos/install/lib/cmake' From ee446805691cd1e3a780d706aacf293bd7dfaf7f Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 15:40:36 -0500 Subject: [PATCH 22/31] update pumi-pic version --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 5d59550..a6a028a 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -102,7 +102,7 @@ jobs: with: repo-name: 'pumi-pic' repo-path: 'SCOREC/pumi-pic' - repo-ref: '2.0.3' + repo-ref: '2.1.2' submodules: 'recursive' cache: true options: '-DCMAKE_CXX_COMPILER=mpicxx From 527e850ea07dca8915ca7f41ca45ec8b7ae2e3c8 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 15:51:36 -0500 Subject: [PATCH 23/31] removed makefiles --- .../Makefile.testFortranInit | 98 ---------------- .../MakefileCPU.testFortranInit | 99 ---------------- .../MakefilePerlmutterCPU.testFortranInit | 107 ------------------ test/use_at_your_own_risk/README.md | 11 -- 4 files changed, 315 deletions(-) delete mode 100644 test/use_at_your_own_risk/Makefile.testFortranInit delete mode 100644 test/use_at_your_own_risk/MakefileCPU.testFortranInit delete mode 100644 test/use_at_your_own_risk/MakefilePerlmutterCPU.testFortranInit delete mode 100644 test/use_at_your_own_risk/README.md diff --git a/test/use_at_your_own_risk/Makefile.testFortranInit b/test/use_at_your_own_risk/Makefile.testFortranInit deleted file mode 100644 index 839c9ed..0000000 --- a/test/use_at_your_own_risk/Makefile.testFortranInit +++ /dev/null @@ -1,98 +0,0 @@ -############################################################################ -# The following is an minimal example of the compile and link commands -# needed on Perlmutter. The Perlmutter build of the polyMPO stack followed -# the build instructions in README.md - **no other configuration was tested**. -# -# Using this Makefile on a different system is not advised as it will require -# editing the paths in the first section **and** modifying the compile and link -# arguments. This is not intended to be portable as there is no logic to -# detect/discover compilers and other system software. -# -# This file was generated in July/Aug 2023. -############################################################################ - - -########################### -## edit the following paths -########################### -FC=gfortran - -CUDA_DIR=/opt/nvidia/hpc_sdk/Linux_x86_64/22.7/cuda/11.7/ - -MPI_DIR=/opt/cray/pe/mpich/8.1.25/ofi/gnu/9.1/ -MPI_LIBS=${MPI_DIR}/lib/libmpifort_gnu_91.so ${MPI_DIR}/lib/libmpi_gnu_91.so - -devRoot=/global/homes/y/yygong/develop - -KOKKOS_DIR=${devRoot}/build-kokkos-login21-cuda/install/ -KOKKOS_LIB_DIR=${KOKKOS_DIR}/lib64 - -OMEGAH_DIR=${devRoot}/build-omegah-login21-cuda/install/ - -ENGPAR_DIR=${devRoot}/build-engpar-login21-cuda/install/ - -PUMIPIC_DIR=${devRoot}/build-pumipic-login21-cuda/install/ - -CABANA_DIR=${devRoot}/build-cabana-login21-cuda/install/ - -POLYMPO_DIR=${devRoot}/buildPolyMPO-GPU/install - -###################################################################################### -## Dont't change the following unless you know exactly what you are doing... -## The following was generated from the CMake generated compile and link commands in -## a CUDA enabled build of polyMPO -###################################################################################### -POLYMPO_LIBS=\ --L${CUDA_DIR}/targets/x86_64-linux/lib/stubs \ --L${CUDA_DIR}/targets/x86_64-linux/lib \ --Wl,-rpath,${CUDA_DIR}/lib64: \ -${POLYMPO_DIR}/lib/libpolympo_fortran.a \ -${POLYMPO_DIR}/lib/libpolyMPO-core.a \ --lm \ -${PUMIPIC_DIR}/lib/libpumipic-core.a \ -${PUMIPIC_DIR}/lib/libparticleStructs.a \ -${PUMIPIC_DIR}/lib/libsupport.a \ -${OMEGAH_DIR}/lib/libomega_h.a \ -${KOKKOS_LIB_DIR}/libkokkoscontainers.a \ -${KOKKOS_LIB_DIR}/libkokkoscore.a \ --lcuda \ --lcudart \ --ldl \ --lz \ -${ENGPAR_DIR}/lib/libengpar.a \ -${ENGPAR_DIR}/lib/libdiffusive.a \ -${ENGPAR_DIR}/lib/libmultilevel.a \ -${ENGPAR_DIR}/lib/libengpar_metrics.a \ -${ENGPAR_DIR}/lib/libcoloring.a \ -${ENGPAR_DIR}/lib/libagi.a \ -${ENGPAR_DIR}/lib/libengpar_support.a \ -${ENGPAR_DIR}/lib/libpcu.a \ -${MPI_LIBS} \ --lcudadevrt \ --lcudart_static \ --lrt \ --lpthread \ --ldl \ --lstdc++ - -POLYMPO_COMPILE_FLAGS=\ --DFP64 \ --DKOKKOS_ENABLED \ --DLOCAL_ID_FTYPE=C_INT32_T \ --DLOCAL_ID_TYPE=int32_t \ --DPP_ENABLE_CAB \ --DPP_USE_CUDA \ --I${POLYMPO_DIR}/include \ --I${PUMIPIC_DIR}/include \ --I${KOKKOS_DIR}/include \ --I${CUDA_DIR}/include \ --I${CABANA_DIR}/include \ --I${MPI_DIR}/include \ --I${OMEGAH_DIR}/include \ --I${ENGPAR_DIR}/include - -testFortranInit: testFortranInit.o - ${FC} testFortranInit.o -o testFortranInit ${POLYMPO_LIBS} - -testFortranInit.o: testFortranInit.f90 - ${FC} ${POLYMPO_COMPILE_FLAGS} -c testFortranInit.f90 -o testFortranInit.o diff --git a/test/use_at_your_own_risk/MakefileCPU.testFortranInit b/test/use_at_your_own_risk/MakefileCPU.testFortranInit deleted file mode 100644 index 87c46af..0000000 --- a/test/use_at_your_own_risk/MakefileCPU.testFortranInit +++ /dev/null @@ -1,99 +0,0 @@ -############################################################################ -# The following is an minimal example of the compile and link commands -# needed on Perlmutter. The Perlmutter build of the polyMPO stack followed -# the build instructions in README.md - **no other configuration was tested**. -# -# Using this Makefile on a different system is not advised as it will require -# editing the paths in the first section **and** modifying the compile and link -# arguments. This is not intended to be portable as there is no logic to -# detect/discover compilers and other system software. -# -# This file was generated in Nov 16 2023. -############################################################################ - - -########################### -## edit the following paths -########################### -FC=/opt/cray/pe/gcc/11.2.0/bin/gfortran - -NETCDF_DIR=/opt/cray/pe/netcdf/4.9.0.3/gnu/9.1/ -HDF5_DIR=/opt/cray/pe/hdf5/1.12.2.7/gnu/9.1/ -MPI_DIR=/opt/cray/pe/mpich/8.1.25/ofi/gnu/9.1/ - -devRoot=/global/homes/c/castia5/cpu-pumi-pic - -KOKKOS_DIR=${devRoot}/build-kokkos-login21-cpu/install/ -KOKKOS_LIB_DIR=${KOKKOS_DIR}/lib64 - -OMEGAH_DIR=${devRoot}/build-omegah-login21-cpu/install/ - -ENGPAR_DIR=${devRoot}/build-engpar-login21-cpu/install/ - -PUMIPIC_DIR=${devRoot}/build-pumipic-login21-cpu/install/ - -CABANA_DIR=${devRoot}/build-cabana-login21-cpu/install/ - -POLYMPO_DIR=${devRoot}/buildPolyMPO-CPU/install - -###################################################################################### -## Dont't change the following unless you know exactly what you are doing... -## The following was generated from the CMake generated compile and link commands in -## a CUDA disabled build of polyMPO -###################################################################################### -POLYMPO_LIBS=\ --L${MPI_DIR}/lib \ --Wl,-rpath,${NETCDF_DIR}/lib:${MPI_DIR}/lib: \ -${POLYMPO_DIR}/lib/libpolympo_fortran.a \ -${POLYMPO_DIR}/lib/libpolyMPO-core.a \ --lm \ -${PUMIPIC_DIR}/lib/libpumipic-core.a \ -${PUMIPIC_DIR}/lib/libparticleStructs.a \ -${PUMIPIC_DIR}/lib/libsupport.a \ -${OMEGAH_DIR}/lib64/libomega_h.a \ -${KOKKOS_LIB_DIR}/libkokkoscontainers.a \ -${KOKKOS_LIB_DIR}/libkokkoscore.a \ --ldl \ -${KOKKOS_LIB_DIR}/libkokkossimd.a \ -/usr/lib64/libz.so \ -${ENGPAR_DIR}/lib/libengpar.a \ -${ENGPAR_DIR}/lib/libdiffusive.a \ -${ENGPAR_DIR}/lib/libmultilevel.a \ -${ENGPAR_DIR}/lib/libengpar_metrics.a \ -${ENGPAR_DIR}/lib/libcoloring.a \ -${ENGPAR_DIR}/lib/libagi.a \ -${ENGPAR_DIR}/lib/libengpar_support.a \ -${ENGPAR_DIR}/lib/libpcu.a \ -${NETCDF_DIR}/lib/libnetcdf.so \ -${POLYMPO_DIR}/lib/libpolympo_fortran.a \ -${MPI_DIR}/lib/libmpifort_gnu_91.so \ -${MPI_DIR}/lib/libmpi_gnu_91.so \ -${NETCDF_DIR}/lib/libnetcdff.so \ --lmpi_gnu_91 \ --lstdc++ - -POLYMPO_COMPILE_FLAGS=\ --DFP64 \ --DKOKKOS_ENABLED \ --DLOCAL_ID_FTYPE=C_INT32_T \ --DLOCAL_ID_TYPE=int32_t \ --DPP_ENABLE_CAB \ --I${devRoot}/polyMPO/src \ --I${devRoot}/polyMPO/test \ --I${devRoot}/buildPolyMPO-CPU/src \ --I${PUMIPIC_DIR}/include \ --I${KOKKOS_DIR}/include \ --I${CABANA_DIR}/include \ --I${OMEGAH_DIR}/include \ --I/usr/include \ --I${ENGPAR_DIR}/include \ --I${MPI_DIR}/include \ --I${NETCDF_DIR}/include \ --I${HDF5_DIR}/include \ --g -J${devRoot}/buildPolyMPO-CPU/mod_files - -testFortranInit: testFortranInit.o - ${FC} testFortranInit.o -o testFortranInit ${POLYMPO_LIBS} - -testFortranInit.o: testFortranInit.f90 - ${FC} ${POLYMPO_COMPILE_FLAGS} -c testFortranInit.f90 -o testFortranInit.o diff --git a/test/use_at_your_own_risk/MakefilePerlmutterCPU.testFortranInit b/test/use_at_your_own_risk/MakefilePerlmutterCPU.testFortranInit deleted file mode 100644 index a515165..0000000 --- a/test/use_at_your_own_risk/MakefilePerlmutterCPU.testFortranInit +++ /dev/null @@ -1,107 +0,0 @@ -############################################################################ -# The following is an minimal example of the compile and link commands -# needed on Perlmutter. The Perlmutter build of the polyMPO stack followed -# the build instructions in README.md - **no other configuration was tested**. -# -# Using this Makefile on a different system is not advised as it will require -# editing the paths in the first section **and** modifying the compile and link -# arguments. This is not intended to be portable as there is no logic to -# detect/discover compilers and other system software. -# -# This file was generated in Nov 16 2023. -############################################################################ - - -########################### -## edit the following paths -########################### -FC=/usr/bin/gfortran - -NETCDF_DIR=/opt/cray/pe/netcdf/4.9.0.9/gnu/12.3/ -HDF5_DIR=/opt/cray/pe/hdf5/1.12.2.9/gnu/12.3/ -MPI_DIR=/opt/cray/pe/mpich/8.1.28/ofi/gnu/12.3/ -CUDA_DIR=/opt/nvidia/hpc_sdk/Linux_x86_64/23.9/cuda/12.2/targets/x86_64-linux/lib - -devRoot=/global/homes/c/castia5/cpu-pumi-pic - -KOKKOS_DIR=${devRoot}/build-kokkos-perlmutter-cpu/install/ -KOKKOS_LIB_DIR=${KOKKOS_DIR}/lib64 - -OMEGAH_DIR=${devRoot}/build-omegah-perlmutter-cpu/install/ - -ENGPAR_DIR=${devRoot}/build-engpar-perlmutter-cpu/install/ - -PUMIPIC_DIR=${devRoot}/build-pumipic-perlmutter-cpu/install/ - -CABANA_DIR=${devRoot}/build-cabana-perlmutter-cpu/install/ - -POLYMPO_DIR=${devRoot}/buildPolyMPO-CPU/install - -###################################################################################### -## Dont't change the following unless you know exactly what you are doing... -## The following was generated from the CMake generated compile and link commands in -## a CUDA disabled build of polyMPO -###################################################################################### -POLYMPO_LIBS=\ --L${MPI_DIR}/lib \ --L${CUDA_DIR}/stubs \ --L${CUDA_DIR} \ --Wl,-rpath,${NETCDF_DIR}/lib:${MPI_DIR}/lib: \ -${POLYMPO_DIR}/lib/libpolympo_fortran.a \ -${POLYMPO_DIR}/lib/libpolyMPO-core.a \ --lm \ -${PUMIPIC_DIR}/lib/libpumipic-core.a \ -${PUMIPIC_DIR}/lib/libparticleStructs.a \ -${PUMIPIC_DIR}/lib/libsupport.a \ -${OMEGAH_DIR}/lib64/libomega_h.a \ -${KOKKOS_LIB_DIR}/libkokkoscontainers.a \ -${KOKKOS_LIB_DIR}/libkokkoscore.a \ --ldl \ -${KOKKOS_LIB_DIR}/libkokkossimd.a \ -/usr/lib64/libz.so \ -${ENGPAR_DIR}/lib/libengpar.a \ -${ENGPAR_DIR}/lib/libdiffusive.a \ -${ENGPAR_DIR}/lib/libmultilevel.a \ -${ENGPAR_DIR}/lib/libengpar_metrics.a \ -${ENGPAR_DIR}/lib/libcoloring.a \ -${ENGPAR_DIR}/lib/libagi.a \ -${ENGPAR_DIR}/lib/libengpar_support.a \ -${ENGPAR_DIR}/lib/libpcu.a \ -${NETCDF_DIR}/lib/libnetcdf.so \ -${POLYMPO_DIR}/lib/libpolympo_fortran.a \ -${MPI_DIR}/lib/libmpifort_gnu_123.so \ -${MPI_DIR}/lib/libmpi_gnu_123.so \ -${NETCDF_DIR}/lib/libnetcdff.so \ --lmpi_gnu_123 \ --lcudadevrt \ --lcudart_static \ --lrt \ --lpthread \ --ldl \ --lstdc++ - -POLYMPO_COMPILE_FLAGS=\ --DFP64 \ --DKOKKOS_ENABLED \ --DLOCAL_ID_FTYPE=C_INT32_T \ --DLOCAL_ID_TYPE=int32_t \ --DPP_ENABLE_CAB \ --I${devRoot}/polyMPO/src \ --I${devRoot}/polyMPO/test \ --I${devRoot}/buildPolyMPO-CPU/src \ --I${PUMIPIC_DIR}/include \ --I${KOKKOS_DIR}/include \ --I${CABANA_DIR}/include \ --I${OMEGAH_DIR}/include \ --I/usr/include \ --I${ENGPAR_DIR}/include \ --I${MPI_DIR}/include \ --I${NETCDF_DIR}/include \ --I${HDF5_DIR}/include \ --g -J${devRoot}/buildPolyMPO-CPU/mod_files - -testFortranInit: testFortranInit.o - ${FC} testFortranInit.o -o testFortranInit ${POLYMPO_LIBS} - -testFortranInit.o: testFortranInit.f90 - ${FC} ${POLYMPO_COMPILE_FLAGS} -c testFortranInit.f90 -o testFortranInit.o diff --git a/test/use_at_your_own_risk/README.md b/test/use_at_your_own_risk/README.md deleted file mode 100644 index 8da17fe..0000000 --- a/test/use_at_your_own_risk/README.md +++ /dev/null @@ -1,11 +0,0 @@ -The Makefiles in this directoery were generated manually by extracting the -compile and link line produced by CMake (`make VERBOSE=1`) for the GPU build. -It was tested by compiling one of our fortran tests that calls polyMPO APIs. - -A big draw back of this approach, which has already bitten us once, is that if -we add new libraries or headers the Makefiles have to be recreated/updated -manually. - -It is a crude approach, but since MPAS/MPM uses a Makefile based system and -isn't using CMake, autotools, pkgconfig etc. we don't have a significantly -better choice. From 69e90c3489d4090acc3e8e14dd1121e8bec78a1b Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 16:50:48 -0500 Subject: [PATCH 24/31] update cmake verison --- .github/workflows/updateCmakeVersion.yml | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/updateCmakeVersion.yml diff --git a/.github/workflows/updateCmakeVersion.yml b/.github/workflows/updateCmakeVersion.yml new file mode 100644 index 0000000..06062be --- /dev/null +++ b/.github/workflows/updateCmakeVersion.yml @@ -0,0 +1,32 @@ +name: Update CMAKE Version +on: + pull_request: + +jobs: + checkVersion: + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + + steps: + + - name: Check out master + uses: actions/checkout@v4 + with: + path: master + ref: '' + + - name: Check out current + uses: actions/checkout@v4 + with: + path: current + + - name: Compare Version + run: | + version1=$(grep -oP '(?<=project\([^\)]+\sVERSION\s)[^\)]+(?=\))' /master/CMakeLists.txt) + version2=$(grep -oP '(?<=project\([^\)]+\sVERSION\s)[^\)]+(?=\))' /current/CMakeLists.txt) + echo $version1 + echo $version2 + \ No newline at end of file From f848e13d98a21385739be383adfa89582c2a2d90 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 16:59:21 -0500 Subject: [PATCH 25/31] update grep command --- .github/workflows/updateCmakeVersion.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/updateCmakeVersion.yml b/.github/workflows/updateCmakeVersion.yml index 06062be..1a5fff6 100644 --- a/.github/workflows/updateCmakeVersion.yml +++ b/.github/workflows/updateCmakeVersion.yml @@ -25,8 +25,8 @@ jobs: - name: Compare Version run: | - version1=$(grep -oP '(?<=project\([^\)]+\sVERSION\s)[^\)]+(?=\))' /master/CMakeLists.txt) - version2=$(grep -oP '(?<=project\([^\)]+\sVERSION\s)[^\)]+(?=\))' /current/CMakeLists.txt) + version1=$(grep -oP 'project\(\s*[\w-]+\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' master/CMakeLists.txt) + version2=$(grep -oP 'project\(\s*[\w-]+\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' current/CMakeLists.txt) echo $version1 echo $version2 \ No newline at end of file From 46ddb8877e7c84142fdc6dbcb320fedc8ca7acec Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 17:10:10 -0500 Subject: [PATCH 26/31] compare versions --- .github/workflows/updateCmakeVersion.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/updateCmakeVersion.yml b/.github/workflows/updateCmakeVersion.yml index 1a5fff6..447b658 100644 --- a/.github/workflows/updateCmakeVersion.yml +++ b/.github/workflows/updateCmakeVersion.yml @@ -16,17 +16,16 @@ jobs: uses: actions/checkout@v4 with: path: master - ref: '' + ref: 'master' - name: Check out current uses: actions/checkout@v4 with: - path: current + path: branch - name: Compare Version run: | - version1=$(grep -oP 'project\(\s*[\w-]+\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' master/CMakeLists.txt) - version2=$(grep -oP 'project\(\s*[\w-]+\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' current/CMakeLists.txt) - echo $version1 - echo $version2 + masterVersion=$(grep -oP 'project\(\s*[\w-]+\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' master/CMakeLists.txt) + branchVersion=$(grep -oP 'project\(\s*[\w-]+\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' branch/CMakeLists.txt) + [ "$masterVersion" != "$branchVersion" ] \ No newline at end of file From 281a187b7272d70b96c43c0b2b0b633731352a1e Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 17:13:55 -0500 Subject: [PATCH 27/31] checkout base ref --- .github/workflows/updateCmakeVersion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/updateCmakeVersion.yml b/.github/workflows/updateCmakeVersion.yml index 447b658..2569cc6 100644 --- a/.github/workflows/updateCmakeVersion.yml +++ b/.github/workflows/updateCmakeVersion.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v4 with: path: master - ref: 'master' + ref: ${{ github.base_ref }} - name: Check out current uses: actions/checkout@v4 From 6f4db480ec30c02bc253e16a6fd550b2ef02806d Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 17:15:33 -0500 Subject: [PATCH 28/31] update version --- .github/workflows/updateCmakeVersion.yml | 3 ++- CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/updateCmakeVersion.yml b/.github/workflows/updateCmakeVersion.yml index 2569cc6..5b5decf 100644 --- a/.github/workflows/updateCmakeVersion.yml +++ b/.github/workflows/updateCmakeVersion.yml @@ -27,5 +27,6 @@ jobs: run: | masterVersion=$(grep -oP 'project\(\s*[\w-]+\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' master/CMakeLists.txt) branchVersion=$(grep -oP 'project\(\s*[\w-]+\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' branch/CMakeLists.txt) - [ "$masterVersion" != "$branchVersion" ] + echo $masterVersion + echo $branchVersion \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 080a418..094d7a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.19) -project(polyMPO VERSION 0.1.0 LANGUAGES CXX Fortran) +project(polyMPO VERSION 0.2.0 LANGUAGES CXX Fortran) include(cmake/bob.cmake) bob_begin_package() From 7fa89ad0bdf9d071d62f8aa1b2cb59b8f7bf8636 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 17:16:59 -0500 Subject: [PATCH 29/31] compare versions again --- .github/workflows/updateCmakeVersion.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/updateCmakeVersion.yml b/.github/workflows/updateCmakeVersion.yml index 5b5decf..64a5779 100644 --- a/.github/workflows/updateCmakeVersion.yml +++ b/.github/workflows/updateCmakeVersion.yml @@ -16,7 +16,6 @@ jobs: uses: actions/checkout@v4 with: path: master - ref: ${{ github.base_ref }} - name: Check out current uses: actions/checkout@v4 @@ -27,6 +26,5 @@ jobs: run: | masterVersion=$(grep -oP 'project\(\s*[\w-]+\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' master/CMakeLists.txt) branchVersion=$(grep -oP 'project\(\s*[\w-]+\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' branch/CMakeLists.txt) - echo $masterVersion - echo $branchVersion + [ "$masterVersion" != "$branchVersion" ] \ No newline at end of file From 972f438e75906fdf454a447531d8b96daf778242 Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 17:18:33 -0500 Subject: [PATCH 30/31] better name --- .github/workflows/updateCmakeVersion.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/updateCmakeVersion.yml b/.github/workflows/updateCmakeVersion.yml index 64a5779..d7a9da9 100644 --- a/.github/workflows/updateCmakeVersion.yml +++ b/.github/workflows/updateCmakeVersion.yml @@ -16,13 +16,14 @@ jobs: uses: actions/checkout@v4 with: path: master + ref: ${{ github.base_ref }} - name: Check out current uses: actions/checkout@v4 with: path: branch - - name: Compare Version + - name: CMake Version Has Updated run: | masterVersion=$(grep -oP 'project\(\s*[\w-]+\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' master/CMakeLists.txt) branchVersion=$(grep -oP 'project\(\s*[\w-]+\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' branch/CMakeLists.txt) From 97434edd7f45912fe36725de1f9b89c91996e87f Mon Sep 17 00:00:00 2001 From: Angelyr Date: Sat, 4 Jan 2025 17:22:11 -0500 Subject: [PATCH 31/31] remove unused code --- src/pmpo_c.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/pmpo_c.cpp b/src/pmpo_c.cpp index 13e230a..8a0038a 100644 --- a/src/pmpo_c.cpp +++ b/src/pmpo_c.cpp @@ -291,24 +291,6 @@ void getMPData(MPMesh_ptr p_mpmesh, pumipic::RecordTime("PolyMPO_getMPData", timer.seconds()); } -using setMPFunc = void (*)(MPMesh_ptr, const int, const int, const double*); -std::map setMPMap = { - {polyMPO::MPF_Cur_Pos_Rot_Lat_Lon, setMPData}, - {polyMPO::MPF_Tgt_Pos_Rot_Lat_Lon, setMPData}, - {polyMPO::MPF_Cur_Pos_XYZ, setMPData}, - {polyMPO::MPF_Tgt_Pos_XYZ, setMPData}, - {polyMPO::MPF_Mass, setMPData}, - {polyMPO::MPF_Vel, setMPData}, - {polyMPO::MPF_Rot_Lat_Lon_Incr, setMPData}, - {polyMPO::MPF_Strain_Rate, setMPData}, - {polyMPO::MPF_Stress, setMPData} -}; - -void polympo_setMPData_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpDataIn, const int mpDataType){ - polyMPO::MaterialPointSlice type = static_cast(mpDataType); - (*setMPMap[type])(p_mpmesh, nComps, numMPs, mpDataIn); -} - void polympo_setMPPositions_f(MPMesh_ptr p_mpmesh, const int nComps, const int numMPs, const double* mpPositionsIn){ setMPData(p_mpmesh, nComps, numMPs, mpPositionsIn); }