- unsigned int myCoords[dimensions_.size()];
- rankId_to_coords(src->id(), dimensions_, myCoords);
- unsigned int targetCoords[dimensions_.size()];
- rankId_to_coords(dst->id(), dimensions_, targetCoords);
+ const unsigned int dsize = dimensions_.size();
+ unsigned int* myCoords = new unsigned int[dsize];
+ unsigned int* targetCoords= new unsigned int[dsize];
+ unsigned int dim_size_product = 1;
+ for (unsigned i = 0; i < dsize; i++) {
+ unsigned cur_dim_size = dimensions_[i];
+ myCoords[i] = (src->id() / dim_size_product) % cur_dim_size;
+ targetCoords[i] = (dst->id() / dim_size_product) % cur_dim_size;
+ dim_size_product *= cur_dim_size;
+ }
+