| 492 | |
| 493 | |
| 494 | void copyArrayIfGpuCompiled(qcomp* cpuArr, qcomp* gpuArr, qindex numElems, enum CopyDirection direction) { |
| 495 | #if COMPILE_CUDA |
| 496 | |
| 497 | // must ensure gpu amps are up to date |
| 498 | gpu_sync(); |
| 499 | |
| 500 | auto flag = (direction == TO_HOST)? |
| 501 | cudaMemcpyDeviceToHost: |
| 502 | cudaMemcpyHostToDevice; |
| 503 | |
| 504 | auto src = (direction == TO_HOST)? gpuArr : cpuArr; |
| 505 | auto dst = (direction == TO_HOST)? cpuArr : gpuArr; |
| 506 | |
| 507 | // synchronous memory copy |
| 508 | size_t numBytes = numElems * sizeof(qcomp); |
| 509 | CUDA_CHECK( cudaMemcpy(dst, src, numBytes, flag) ); |
| 510 | |
| 511 | #else |
| 512 | error_gpuCopyButGpuNotCompiled(); |
| 513 | #endif |
| 514 | } |
| 515 | |
| 516 | |
| 517 | void copyMatrixIfGpuCompiled(qcomp** cpuMatr, qcomp* gpuArr, qindex matrDim, enum CopyDirection direction) { |
no test coverage detected