@@ -15,28 +15,27 @@ module allGather {
1515 serial { HypercubeToSend = thisIndex ^ ((int)pow(2, iter)); }
1616 if (HypercubeToSend < n) {
1717 serial {
18- long int data[hyperCubeStore.size()];
19- for(int i = 0; i < hyperCubeStore.size(); i++) {
20- data[i] = hyperCubeStore[i];
21- }
18+ CkNcpyBuffer data[hyperCubeStore.size()];
2219 int dataIndx[hyperCubeIndx.size()];
23- for(int i = 0; i < hyperCubeIndx.size(); i++) {
20+ int numBuffers = hyperCubeStore.size();
21+ for(int i = 0; i < numBuffers; i++) {
22+ data[i] = hyperCubeStore[i];
2423 dataIndx[i] = hyperCubeIndx[i];
2524 }
2625#ifdef TIMESTAMP
27- thisProxy(HypercubeToSend).recvHypercube(iter, data, hyperCubeStore.size(), dataIndx, hyperCubeIndx.size() , (timeStamp + alpha + beta * hyperCubeStore.size() * 8));
26+ thisProxy(HypercubeToSend).recvHypercube(iter, data, dataIndx, numBuffers , (timeStamp + alpha + beta * hyperCubeStore.size() * 8));
2827 timeStamp += alpha;
2928#else
30- thisProxy(HypercubeToSend).recvHypercube(iter, data, hyperCubeStore.size(), dataIndx, hyperCubeIndx.size() , 0.0);
29+ thisProxy(HypercubeToSend).recvHypercube(iter, data, dataIndx, numBuffers , 0.0);
3130#endif
3231 }
33- when recvHypercube[iter](int ref, long int data[size], int size, int dataIndx[indxSize ], int indxSize , double recvTime) {
32+ when recvHypercube[iter](int ref, CkNcpyBuffer data[size], int dataIndx[size ], int size , double recvTime) {
3433 serial {
3534 for(int m = 0; m < size; m++) {
3635 hyperCubeStore.emplace_back(data[m]);
37- }
38- for(int m = 0; m < indxSize; m++) {
3936 hyperCubeIndx.emplace_back(dataIndx[m]);
37+ CkNcpyBuffer dst(store + dataIndx[m] * k, k * sizeof(long int), zero_copy_callback, CK_BUFFER_UNREG);
38+ dst.get(data[m]);
4039 }
4140#ifdef TIMESTAMP
4241 timeStamp = std::max(recvTime, timeStamp);
@@ -45,17 +44,8 @@ module allGather {
4544 }
4645 }
4746 }
48- serial {
49- for(int m = 0; m < hyperCubeIndx.size(); m++) {
50- int currIndx = hyperCubeIndx[m];
51- for(int j = 0; j < k; j++) {
52- store[k * currIndx + j] = hyperCubeStore[m * k + j];
53- }
54- }
55- lib_done_callback.send(msg);
56- }
5747 };
58- entry void recvHypercube(int ref, long int data[size], int size, int dataIndx[indxSize ], int indxSize , double recvTime);
48+ entry void recvHypercube(int ref, CkNcpyBuffer data[size], int dataIndx[size ], int size , double recvTime);
5949 entry void Flood(int sender, CkNcpyBuffer data, double recvTime);
6050 };
6151};
0 commit comments