ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/mpiSimulation.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/mpiSimulation.cpp (file contents):
Revision 422 by mmeineke, Thu Mar 27 19:21:42 2003 UTC vs.
Revision 432 by chuckv, Thu Mar 27 23:33:40 2003 UTC

# Line 1 | Line 1
1   #ifdef IS_MPI
2 <
2 > #include <iostream>
3   #include <cstdlib>
4   #include <cstring>
5   #include <cmath>
# Line 133 | Line 133 | int* mpiSimulation::divideLabor( void ){
133          // How many atoms does this processor have?
134          
135          old_atoms = AtomsPerProc[which_proc];
136 +        add_atoms = compStamps[MolComponentType[i]]->getNAtoms();
137 +        new_atoms = old_atoms + add_atoms;
138  
139          // If the processor already had too many atoms, just skip this
140          // processor and try again.
139
140        if (old_atoms >= nTarget) continue;
141
142        add_atoms = compStamps[MolComponentType[i]]->getNAtoms();
143        new_atoms = old_atoms + add_atoms;
144    
145        // If we can add this molecule to this processor without sending
146        // it above nTarget, then go ahead and do it:
147    
148        if (new_atoms <= nTarget) {
149          MolToProcMap[i] = which_proc;
150          AtomsPerProc[which_proc] += add_atoms;
151          for (j = 0 ; j < add_atoms; j++ ) {
152            AtomToProcMap[atomIndex] = which_proc;
153            atomIndex++;
154          }
155          done = 1;
156          continue;
157        }
141  
142          // If we've been through this loop too many times, we need
143          // to just give up and assign the molecule to this processor
# Line 179 | Line 162 | int* mpiSimulation::divideLabor( void ){
162            continue;
163          }
164  
165 +        if (old_atoms >= nTarget) continue;
166 +    
167 +        // If we can add this molecule to this processor without sending
168 +        // it above nTarget, then go ahead and do it:
169 +    
170 +        if (new_atoms <= nTarget) {
171 +          MolToProcMap[i] = which_proc;
172 +          AtomsPerProc[which_proc] += add_atoms;
173 +          for (j = 0 ; j < add_atoms; j++ ) {
174 +            AtomToProcMap[atomIndex] = which_proc;
175 +            atomIndex++;
176 +          }
177 +          done = 1;
178 +          continue;
179 +        }
180 +
181 +
182          // The only situation left is where old_atoms < nTarget, but
183          // new_atoms > nTarget.   We want to accept this with some
184          // probability that dies off the farther we are from nTarget
# Line 234 | Line 234 | int* mpiSimulation::divideLabor( void ){
234      
235      MPI::COMM_WORLD.Bcast(AtomsPerProc, mpiPlug->numberProcessors,
236                            MPI_INT, 0);
237 +
238 +
239    }
240  
241  
# Line 253 | Line 255 | int* mpiSimulation::divideLabor( void ){
255      }
256    }
257  
258 +  std::cerr << "proc = " << mpiPlug->myNode << " atoms = " << natoms_local << "\n";
259 +
260    MPI::COMM_WORLD.Allreduce(&nmol_local,&nmol_global,1,MPI_INT,MPI_SUM);
261    MPI::COMM_WORLD.Allreduce(&natoms_local,&natoms_global,1,MPI_INT,MPI_SUM);
262    
# Line 289 | Line 293 | int* mpiSimulation::divideLabor( void ){
293        local_index++;
294      }
295    }
296 <
296 >  
297    return globalIndex;
298   }
299  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines