ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/math/ParallelRandNumGen.cpp
(Generate patch)

Comparing trunk/src/math/ParallelRandNumGen.cpp (file contents):
Revision 1793 by gezelter, Fri Aug 31 21:16:10 2012 UTC vs.
Revision 1969 by gezelter, Wed Feb 26 14:14:50 2014 UTC

# Line 35 | Line 35
35   *                                                                      
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 < * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39   * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40   * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42
43 #include "math/ParallelRandNumGen.hpp"
42   #ifdef IS_MPI
43   #include <mpi.h>
44   #endif
45  
46 + #include "math/ParallelRandNumGen.hpp"
47 +
48   namespace OpenMD {
49  
50    int ParallelRandNumGen::nCreatedRNG_ = 0;
# Line 69 | Line 69 | namespace OpenMD {
69   #ifdef IS_MPI
70      MPI_Comm_size( MPI_COMM_WORLD, &nProcessors);
71      MPI_Comm_rank( MPI_COMM_WORLD, &myRank_);
72 +
73   #else
74      nProcessors = 1;
75      myRank_ = 0;
# Line 85 | Line 86 | namespace OpenMD {
86  
87    ParallelRandNumGen::ParallelRandNumGen() {
88  
88    std::vector<uint32> bigSeed;
89      int nProcessors;
90   #ifdef IS_MPI
91    const int masterNode = 0;
91      MPI_Comm_size( MPI_COMM_WORLD, &nProcessors);
92      MPI_Comm_rank( MPI_COMM_WORLD, &myRank_);
93   #else
# Line 125 | Line 124 | namespace OpenMD {
124    void ParallelRandNumGen::seed() {
125  
126      std::vector<uint32> bigSeed;
128    int size;
127  
128   #ifdef IS_MPI
129 +    int size;
130      const int masterNode = 0;
131      if (worldRank == masterNode) {
132   #endif
133  
134        bigSeed = mtRand_->generateSeeds();
136      size = bigSeed.size();
135  
136   #ifdef IS_MPI
137 <      MPI_Bcast(&size, 1, MPI_INT, masterNode, MPI_COMM_WORLD);        
138 <      MPI_Bcast(&bigSeed[0], size, MPI_UNSIGNED_LONG, masterNode, MPI_COMM_WORLD);
137 >      size = bigSeed.size();
138 >      MPI_Bcast(&size, 1, MPI_INT, masterNode, MPI_COMM_WORLD);
139 >      MPI_Bcast(&bigSeed[0], size, MPI_UNSIGNED_LONG, masterNode,
140 >                MPI_COMM_WORLD);
141      }else {
142 <      MPI_Bcast(&size, 1, MPI_INT, masterNode, MPI_COMM_WORLD);        
142 >      MPI_Bcast(&size, 1, MPI_INT, masterNode, MPI_COMM_WORLD);
143        bigSeed.resize(size);
144 <      MPI_Bcast(&bigSeed[0], size, MPI_UNSIGNED_LONG, masterNode, MPI_COMM_WORLD);
144 >      MPI_Bcast(&bigSeed[0], size, MPI_UNSIGNED_LONG, masterNode,
145 >                MPI_COMM_WORLD);
146      }
147   #endif
148      

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines