// This does the exchange of the gauge field ghost zone and places it // into the ghost array. // This should be optimized so it is reused if called multiple times void cpuGaugeField::exchangeGhost() const { void **send = (void**)malloc(sizeof(void*)*QUDA_MAX_DIM); for (int d=0; d<nDim; d++) { send[d] = malloc(nFace * surface[d] * reconstruct * precision); } // get the links into a contiguous buffer if (precision == QUDA_DOUBLE_PRECISION) { packGhost((double**)gauge, (double**)send, nFace, x, volumeCB, surfaceCB); } else { packGhost((float**)gauge, (float**)send, nFace, x, volumeCB, surfaceCB); } // communicate between nodes FaceBuffer faceBuf(x, nDim, reconstruct, nFace, precision); faceBuf.exchangeCpuLink(ghost, send); for (int i=0; i<4; i++) { double sum = 0.0; for (int j=0; j<nFace*surface[i]*reconstruct; j++) { sum += ((double*)(ghost[i]))[j]; } } for (int d=0; d<nDim; d++) free(send[d]); free(send); }
void cpuColorSpinorField::exchangeGhost(QudaParity parity, int nFace, int dagger, const MemoryLocation *dummy1, const MemoryLocation *dummy2, bool dummy3, bool dummy4) const { // allocate ghost buffer if not yet allocated allocateGhostBuffer(nFace); void **sendbuf = static_cast<void**>(safe_malloc(nDimComms * 2 * sizeof(void*))); for (int i=0; i<nDimComms; i++) { sendbuf[2*i + 0] = backGhostFaceSendBuffer[i]; sendbuf[2*i + 1] = fwdGhostFaceSendBuffer[i]; ghost_buf[2*i + 0] = backGhostFaceBuffer[i]; ghost_buf[2*i + 1] = fwdGhostFaceBuffer[i]; } packGhost(sendbuf, parity, nFace, dagger); exchange(ghost_buf, sendbuf, nFace); host_free(sendbuf); }