| 57 | |
| 58 | |
| 59 | void rand_setSeeds(vector<unsigned> seeds) { |
| 60 | |
| 61 | // this function consults only root-node seeds, broadcasting |
| 62 | // to other nodes which might not have the existing space to |
| 63 | // receive them, so we explicitly reserve the needed space |
| 64 | |
| 65 | // all nodes learn root node's #seeds |
| 66 | unsigned numRootSeeds = seeds.size(); |
| 67 | if (comm_isInit()) |
| 68 | comm_broadcastUnsignedsFromRoot(&numRootSeeds, 1); |
| 69 | |
| 70 | // all nodes ensure they have space to receive root node's seeds |
| 71 | seeds.resize(numRootSeeds); |
| 72 | |
| 73 | // all nodes receive root seeds |
| 74 | if (comm_isInit()) |
| 75 | comm_broadcastUnsignedsFromRoot(seeds.data(), seeds.size()); |
| 76 | |
| 77 | // all nodes remember seeds (in case user wishes to later recall them) |
| 78 | currentSeeds = seeds; |
| 79 | |
| 80 | // all nodes pass all seeds to RNG |
| 81 | std::seed_seq seq(seeds.begin(), seeds.end()); |
| 82 | mainGenerator.seed(seq); |
| 83 | } |
| 84 | |
| 85 | |
| 86 | void rand_setSeedsToDefault() { |
no test coverage detected