MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / copyArrayIfGpuCompiled

Function copyArrayIfGpuCompiled

quest/src/gpu/gpu_config.cpp:494–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

492
493
494void 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
517void copyMatrixIfGpuCompiled(qcomp** cpuMatr, qcomp* gpuArr, qindex matrDim, enum CopyDirection direction) {

Callers 2

gpu_copyCpuToGpuFunction · 0.85
gpu_copyGpuToCpuFunction · 0.85

Calls 2

gpu_syncFunction · 0.85

Tested by

no test coverage detected