Changeset 5d57155 for GenericIOBenchmarkWrite.cxx
- Timestamp:
- 09/25/17 16:15:39 (7 years ago)
- Branches:
- master, pympi
- Children:
- b02d091
- Parents:
- fb69232
- git-author:
- Hal Finkel <hfinkel@…> (09/25/17 16:15:39)
- git-committer:
- Hal Finkel <hfinkel@…> (09/25/17 16:15:39)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GenericIOBenchmarkWrite.cxx
rcda87e9 r5d57155 70 70 }; 71 71 72 struct pos_t { 73 POSVEL_T x, y, z, w; 74 }; 75 76 template <> 77 struct Generator<pos_t> { 78 Generator(POSVEL_T start, POSVEL_T inc) : 79 GenX(start, inc), GenY(start, inc), GenZ(start, inc), GenW(start, inc) {} 80 81 pos_t operator()() { 82 pos_t v; 83 v.x = GenX(); 84 v.y = GenY(); 85 v.z = GenZ(); 86 v.w = GenW(); 87 88 return v; 89 } 90 91 Generator<POSVEL_T> GenX, GenY, GenZ, GenW; 92 }; 93 72 94 int main(int argc, char *argv[]) { 73 95 MPI_Init(&argc, &argv); … … 77 99 MPI_Comm_size(MPI_COMM_WORLD, &commRanks); 78 100 101 bool UseAOS = false; 79 102 int a = 1; 103 if (argc > 1 && string(argv[a]) == "-a") { 104 UseAOS = true; 105 --argc; 106 ++a; 107 } 108 80 109 if (argc > 1 && string(argv[a]) == "-c") { 81 110 GenericIO::setDefaultShouldCompress(true); … … 85 114 86 115 if(argc != 4) { 87 fprintf(stderr,"USAGE: %s [- c] <mpiioName> <NP> <seed>\n", argv[0]);116 fprintf(stderr,"USAGE: %s [-a] [-c] <mpiioName> <NP> <seed>\n", argv[0]); 88 117 exit(-1); 89 118 } … … 103 132 vector<ID_T> id; 104 133 vector<MASK_T> mask; 134 135 vector<pos_t> pos, vel; 105 136 106 137 assert(sizeof(ID_T) == 8); … … 123 154 GIO.setPhysScale(256.0); 124 155 125 xx.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 126 yy.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 127 zz.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 128 vx.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 129 vy.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 130 vz.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 131 phi.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 156 if (UseAOS) { 157 pos.resize(Np + (GIO.requestedExtraSpace() + sizeof(pos_t) - 1)/sizeof(pos_t)); 158 vel.resize(Np + (GIO.requestedExtraSpace() + sizeof(pos_t) - 1)/sizeof(pos_t)); 159 } else { 160 xx.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 161 yy.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 162 zz.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 163 vx.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 164 vy.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 165 vz.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 166 phi.resize(Np + GIO.requestedExtraSpace()/sizeof(POSVEL_T)); 167 } 132 168 id.resize(Np + GIO.requestedExtraSpace()/sizeof(ID_T)); 133 169 mask.resize(Np + GIO.requestedExtraSpace()/sizeof(MASK_T)); 134 170 135 std::generate(xx.begin(), xx.end(), Generator<POSVEL_T>(25, 3)); 136 std::generate(yy.begin(), yy.end(), Generator<POSVEL_T>(25, 3)); 137 std::generate(zz.begin(), zz.end(), Generator<POSVEL_T>(25, 3)); 138 std::generate(vx.begin(), vx.end(), Generator<POSVEL_T>(25, 3)); 139 std::generate(vy.begin(), vy.end(), Generator<POSVEL_T>(25, 3)); 140 std::generate(vz.begin(), vz.end(), Generator<POSVEL_T>(25, 3)); 141 std::generate(phi.begin(), phi.end(), Generator<POSVEL_T>(25, 3)); 171 if (UseAOS) { 172 std::generate(pos.begin(), pos.end(), Generator<pos_t>(25, 3)); 173 std::generate(vel.begin(), vel.end(), Generator<pos_t>(25, 3)); 174 } else { 175 std::generate(xx.begin(), xx.end(), Generator<POSVEL_T>(25, 3)); 176 std::generate(yy.begin(), yy.end(), Generator<POSVEL_T>(25, 3)); 177 std::generate(zz.begin(), zz.end(), Generator<POSVEL_T>(25, 3)); 178 std::generate(vx.begin(), vx.end(), Generator<POSVEL_T>(25, 3)); 179 std::generate(vy.begin(), vy.end(), Generator<POSVEL_T>(25, 3)); 180 std::generate(vz.begin(), vz.end(), Generator<POSVEL_T>(25, 3)); 181 std::generate(phi.begin(), phi.end(), Generator<POSVEL_T>(25, 3)); 182 } 142 183 std::generate(id.begin(), id.end(), Generator<ID_T>(25, 3)); 143 184 std::fill(mask.begin(), mask.end(), 25); 144 185 145 GIO.addVariable("x", xx, CoordFlagsX | GenericIO::VarHasExtraSpace); 146 GIO.addVariable("y", yy, CoordFlagsY | GenericIO::VarHasExtraSpace); 147 GIO.addVariable("z", zz, CoordFlagsZ | GenericIO::VarHasExtraSpace); 148 GIO.addVariable("vx", vx, GenericIO::VarHasExtraSpace); 149 GIO.addVariable("vy", vy, GenericIO::VarHasExtraSpace); 150 GIO.addVariable("vz", vz, GenericIO::VarHasExtraSpace); 151 GIO.addVariable("phi", phi, GenericIO::VarHasExtraSpace); 186 if (UseAOS) { 187 GIO.addVariable("pos", pos, CoordFlagsX | CoordFlagsY | CoordFlagsZ | 188 GenericIO::VarHasExtraSpace); 189 GIO.addVariable("vel", vel, GenericIO::VarHasExtraSpace); 190 } else { 191 GIO.addVariable("x", xx, CoordFlagsX | GenericIO::VarHasExtraSpace); 192 GIO.addVariable("y", yy, CoordFlagsY | GenericIO::VarHasExtraSpace); 193 GIO.addVariable("z", zz, CoordFlagsZ | GenericIO::VarHasExtraSpace); 194 GIO.addVariable("vx", vx, GenericIO::VarHasExtraSpace); 195 GIO.addVariable("vy", vy, GenericIO::VarHasExtraSpace); 196 GIO.addVariable("vz", vz, GenericIO::VarHasExtraSpace); 197 GIO.addVariable("phi", phi, GenericIO::VarHasExtraSpace); 198 } 152 199 GIO.addVariable("id", id, GenericIO::VarHasExtraSpace); 153 200 GIO.addVariable("mask", mask, GenericIO::VarHasExtraSpace); … … 156 203 } // destroy GIO prior to calling MPI_Finalize 157 204 158 xx.resize(Np); 159 yy.resize(Np); 160 zz.resize(Np); 161 vx.resize(Np); 162 vy.resize(Np); 163 vz.resize(Np); 164 phi.resize(Np); 205 if (UseAOS) { 206 pos.resize(Np); 207 vel.resize(Np); 208 } else { 209 xx.resize(Np); 210 yy.resize(Np); 211 zz.resize(Np); 212 vx.resize(Np); 213 vy.resize(Np); 214 vz.resize(Np); 215 phi.resize(Np); 216 } 165 217 id.resize(Np); 166 218 mask.resize(Np);
Note: See TracChangeset
for help on using the changeset viewer.