| 2400 | // type T can be CompMatr, DiagMatr or FullStateDiagMatr |
| 2401 | template <class T> |
| 2402 | void assertMatrixIsSynced(T matr, string errMsg, const char* caller) { |
| 2403 | |
| 2404 | // we don't need to perform any sync check in CPU-only mode |
| 2405 | if (!mem_isAllocated(util_getGpuMemPtr(matr))) |
| 2406 | return; |
| 2407 | |
| 2408 | // check if GPU amps have EVER been overwritten; we sadly cannot check the LATEST changes were pushed though. |
| 2409 | // note we check this whenever the matrix has GPU memory, even if it is being applied upon a Qureg which is |
| 2410 | // NOT GPU-accelerated and ergo the GPU memory is not consulted. It's best to build the habit in the user! |
| 2411 | assertThat(*(matr.wasGpuSynced) == 1, errMsg, caller); |
| 2412 | } |
| 2413 | void validate_matrixIsSynced(CompMatr matr, const char* caller) { assertMatrixIsSynced(matr, report::COMP_MATR_NOT_SYNCED_TO_GPU, caller);} |
| 2414 | void validate_matrixIsSynced(DiagMatr matr, const char* caller) { assertMatrixIsSynced(matr, report::DIAG_MATR_NOT_SYNCED_TO_GPU, caller); } |
| 2415 | void validate_matrixIsSynced(FullStateDiagMatr matr, const char* caller) { assertMatrixIsSynced(matr, report::FULL_STATE_DIAG_MATR_NOT_SYNCED_TO_GPU, caller); } |
no test coverage detected