# | Line 2 | Line 2 | |
---|---|---|
2 | ||
3 | #include <cstdlib> | |
4 | #include <cstring> | |
5 | + | #include <cmath> |
6 | #include <mpi.h> | |
7 | #include <mpi++.h> | |
8 | ||
# | Line 10 | Line 11 | |
11 | #include "fortranWrappers.hpp" | |
12 | #include "randomSPRNG.hpp" | |
13 | ||
14 | + | #define BASE_SEED 123456789 |
15 | ||
16 | mpiSimulation* mpiSim; | |
17 | ||
# | Line 44 | Line 46 | int* mpiSimulation::divideLabor( void ){ | |
46 | ||
47 | int nComponents; | |
48 | MoleculeStamp** compStamps; | |
49 | < | randomSPRNG myRandom; |
49 | > | randomSPRNG *myRandom; |
50 | int* componentsNmol; | |
51 | int* AtomsPerProc; | |
52 | ||
# | Line 58 | Line 60 | int* mpiSimulation::divideLabor( void ){ | |
60 | int molIndex, atomIndex, compIndex, compStart; | |
61 | int done; | |
62 | int nLocal, molLocal; | |
63 | < | int i, index; |
63 | > | int i, j, loops, which_proc, nmol_local, natoms_local; |
64 | > | int nmol_global, natoms_global; |
65 | > | int local_index, index; |
66 | int smallDiff, bigDiff; | |
67 | + | int baseSeed = BASE_SEED; |
68 | ||
69 | int testSum; | |
70 | ||
# | Line 75 | Line 80 | int* mpiSimulation::divideLabor( void ){ | |
80 | mpiPlug->nSRIGlobal = entryPlug->n_SRI; | |
81 | mpiPlug->nMolGlobal = entryPlug->n_mol; | |
82 | ||
83 | < | myRandom = new randomSPRNG(); |
83 | > | myRandom = new randomSPRNG( baseSeed ); |
84 | ||
85 | a = (double)mpiPlug->nMolGlobal / (double)mpiPlug->nAtomsGlobal; | |
86 | ||
# | Line 120 | Line 125 | int* mpiSimulation::divideLabor( void ){ | |
125 | ||
126 | // Pick a processor at random | |
127 | ||
128 | < | which_proc = (int) (myRandom.getRandom() * mpiPlug->numberProcessors); |
128 | > | which_proc = (int) (myRandom->getRandom() * mpiPlug->numberProcessors); |
129 | ||
130 | // How many atoms does this processor have? | |
131 | ||
# | Line 131 | Line 136 | int* mpiSimulation::divideLabor( void ){ | |
136 | ||
137 | if (old_atoms >= nTarget) continue; | |
138 | ||
139 | < | add_atoms = compStamps[MolComponentType[i]]->getNatoms(); |
139 | > | add_atoms = compStamps[MolComponentType[i]]->getNAtoms(); |
140 | new_atoms = old_atoms + add_atoms; | |
141 | ||
142 | // If we can add this molecule to this processor without sending | |
# | Line 180 | Line 185 | int* mpiSimulation::divideLabor( void ){ | |
185 | // where a = 1 / (average atoms per molecule) | |
186 | ||
187 | x = (double) (new_atoms - nTarget); | |
188 | < | y = myRandom.getRandom(); |
188 | > | y = myRandom->getRandom(); |
189 | ||
190 | if (exp(- a * x) > y) { | |
191 | MolToProcMap[i] = which_proc; | |
# | Line 281 | Line 286 | int* mpiSimulation::divideLabor( void ){ | |
286 | globalIndex[local_index] = i; | |
287 | } | |
288 | } | |
289 | < | |
290 | < | |
286 | < | |
287 | < | |
288 | < | index = mpiPlug->myAtomStart; |
289 | < | // for( i=0; i<mpiPlug->myNlocal; i++){ |
290 | < | // globalIndex[i] = index; |
291 | < | // index++; |
292 | < | // } |
293 | < | |
294 | < | // return globalIndex; |
289 | > | |
290 | > | return globalIndex; |
291 | } | |
292 | ||
293 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |