Skip to content

Commit 8bc0780

Browse files
committed
Running on multiple processors
1 parent fefd5e5 commit 8bc0780

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

src/pmpo_MPMesh.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,13 @@ void MPMesh::CVTTrackingElmCenterBased(const int printVTPIndex){
129129
auto elm2Process = p_mesh->getElm2Process();
130130
auto elm2global = p_mesh->getElmGlobal();
131131

132-
133132
MPI_Comm comm = p_MPs->getMPIComm();
134133
int comm_rank;
135134
MPI_Comm_rank(comm, &comm_rank);
136-
assert(cudaDeviceSynchronize() == cudaSuccess);
137-
MPI_Barrier(MPI_COMM_WORLD);
138-
printf("FooTracking \n");
139135
Kokkos::parallel_for("countProcess", numElms, KOKKOS_LAMBDA(const int iElm){
140136
int pp_id=elm2Process(iElm);
141-
if(iElm<3 || iElm==1470 || iElm==1471 || iElm==1472 )
142-
printf("Mesh elm %d Process %d owning proc %d global %d \n", iElm, comm_rank, pp_id, elm2global(iElm));
143137
});
144138

145-
146139
if(printVTPIndex>=0) {
147140
printVTP_mesh(printVTPIndex);
148141
}
@@ -341,8 +334,9 @@ bool getAnyIsMigrating(MaterialPoints* p_MPs, bool isMigrating) {
341334
void MPMesh::push(){
342335

343336
static int count=0;
344-
std::cout<<__FUNCTION__<<" "<<count<<std::endl;
337+
std::cout<<"Push"<<" "<<count<<std::endl;
345338
count++;
339+
346340
Kokkos::Timer timer;
347341

348342
p_mesh->computeRotLatLonIncr();
@@ -357,14 +351,16 @@ void MPMesh::push(){
357351
do {
358352
CVTTrackingElmCenterBased(); // move to Tgt_XYZ
359353
assert(cudaDeviceSynchronize() == cudaSuccess);
360-
printf("FooPushDoWhile\n");
361354
p_MPs->updateMPSlice<MPF_Cur_Pos_XYZ, MPF_Tgt_Pos_XYZ>(); // Tgt_XYZ becomes Cur_XYZ
362355
p_MPs->updateMPSlice<MPF_Cur_Pos_Rot_Lat_Lon, MPF_Tgt_Pos_Rot_Lat_Lon>(); // Tgt becomes Cur
363-
if (elm2Process.size() > 0)
364-
anyIsMigrating = getAnyIsMigrating(p_MPs, p_MPs->migrate());
356+
357+
bool anyIsMigrating = getAnyIsMigrating(p_MPs, p_MPs->check_migrate());
358+
359+
if(anyIsMigrating)
360+
p_MPs->migrate();
365361
else
366-
p_MPs->rebuild(); //rebuild pumi-pic
367-
printf("Is migrating %d \n", anyIsMigrating);
362+
p_MPs->rebuild();
363+
368364
p_MPs->updateMPElmID(); //update mpElm IDs slices
369365
reconstructSlices();
370366
}

src/pmpo_c.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ void polympo_createMPs_f(MPMesh_ptr p_mpmesh,
6666
const int* mp2Elm,
6767
const int* isMPActive) {
6868
checkMPMeshValid(p_mpmesh);
69-
std::cout<<__FUNCTION__<<std::endl;
7069
//the mesh must be fixed/set before adding MPs
7170
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh;
7271
PMT_ALWAYS_ASSERT(!p_mesh->meshEditable());
73-
//PMT_ALWAYS_ASSERT(p_mesh->getNumElements() == numElms);
72+
PMT_ALWAYS_ASSERT(p_mesh->getNumElements() == numElms);
7473

7574
//Find the total no of MPs across all ranks
7675
//And loop over all MPs and find the smallest element id associated across a MP
@@ -100,7 +99,7 @@ void polympo_createMPs_f(MPMesh_ptr p_mpmesh,
10099
int globalFirstElmWithMPs;
101100
MPI_Allreduce(&firstElmWithMPs, &globalFirstElmWithMPs, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
102101

103-
printf("With a MP, globally smallest mesh elm %d and first elm %d \n", globalMinElmID, globalFirstElmWithMPs);
102+
//printf("With a MP, globally smallest mesh elm %d and first elm %d \n", globalMinElmID, globalFirstElmWithMPs);
104103

105104
int offset = -1;
106105
if(globalMinElmID-globalFirstElmWithMPs==1) {

src/pmpo_materialPoints.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,22 +113,41 @@ void MaterialPoints::setMPIComm(MPI_Comm comm) {
113113
mpi_comm = comm;
114114
}
115115

116-
bool MaterialPoints::migrate() {
116+
bool MaterialPoints::check_migrate(){
117+
Kokkos::Timer timer;
118+
auto MPs2Elm = getData<MPF_Tgt_Elm_ID>();
119+
auto MPs2Proc = getData<MPF_Tgt_Proc_ID>();
120+
121+
IntView isMigrating("isMigrating", 1);
122+
123+
int rank;
124+
MPI_Comm_rank(mpi_comm, &rank);
125+
auto setMigrationFields = PS_LAMBDA(const int& e, const int& mp, const bool& mask) {
126+
if (mask) {
127+
if (MPs2Proc(mp) != rank) isMigrating(0) = 1;
128+
}
129+
};
130+
parallel_for(setMigrationFields, "setMigrationFields");
131+
if (getOpMode() == polyMPO::MP_DEBUG)
132+
printf("Material point check migration: %f\n", timer.seconds());
133+
pumipic::RecordTime("PolyMPO_check_migrate", timer.seconds());
134+
return pumipic::getLastValue(isMigrating) > 0;
135+
}
136+
137+
void MaterialPoints::migrate() {
117138
Kokkos::Timer timer;
118139
auto MPs2Elm = getData<MPF_Tgt_Elm_ID>();
119140
auto MPs2Proc = getData<MPF_Tgt_Proc_ID>();
120141

121142
IntView new_elem("new_elem", MPs->capacity());
122143
IntView new_process("new_process", MPs->capacity());
123-
IntView isMigrating("isMigrating", 1);
124144

125145
int rank;
126146
MPI_Comm_rank(mpi_comm, &rank);
127147
auto setMigrationFields = PS_LAMBDA(const int& e, const int& mp, const bool& mask) {
128148
if (mask) {
129149
new_elem(mp) = MPs2Elm(mp);
130150
new_process(mp) = MPs2Proc(mp);
131-
if (new_process(mp) != rank) isMigrating(0) = 1;
132151
}
133152
};
134153
parallel_for(setMigrationFields, "setMigrationFields");
@@ -137,7 +156,6 @@ bool MaterialPoints::migrate() {
137156
if (getOpMode() == polyMPO::MP_DEBUG)
138157
printf("Material point migration: %f\n", timer.seconds());
139158
pumipic::RecordTime("PolyMPO_migrate", timer.seconds());
140-
return pumipic::getLastValue(isMigrating) > 0;
141159
}
142160

143161
bool MaterialPoints::rebuildOngoing() { return rebuildFields.ongoing; }

src/pmpo_materialPoints.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ class MaterialPoints {
138138
void finishRebuild();
139139
bool rebuildOngoing();
140140

141-
bool migrate();
141+
bool check_migrate();
142+
void migrate();
142143
MPI_Comm getMPIComm();
143144
void setMPIComm(MPI_Comm comm);
144145

0 commit comments

Comments
 (0)