| 2671 | } |
| 2672 | |
| 2673 | void assertSuperOpFitsInGpuMem(int numQubits, int isEnvGpuAccel, bool isInKrausMap, const char* caller) { |
| 2674 | |
| 2675 | // kraus map GPU memory will always be allocated when env is GPU-accelerated |
| 2676 | if (!isEnvGpuAccel) |
| 2677 | return; |
| 2678 | |
| 2679 | // we consult the current available local GPU memory (being more strict than is possible for RAM) |
| 2680 | size_t localCurrGpuMem = gpu_getCurrentAvailableMemoryInBytes(); |
| 2681 | bool matrFitsInMem = mem_canSuperOpFitInMemory(numQubits, localCurrGpuMem); |
| 2682 | |
| 2683 | tokenSubs vars = { |
| 2684 | {"${NUM_QUBITS}", numQubits}, |
| 2685 | {"${QCOMP_BYTES}", sizeof(qcomp)}, |
| 2686 | {"${VRAM_SIZE}", localCurrGpuMem}}; |
| 2687 | |
| 2688 | auto msg = (isInKrausMap)? |
| 2689 | report::NEW_KRAUS_MAPS_SUPER_OP_CANNOT_FIT_INTO_GPU_MEM: |
| 2690 | report::NEW_SUPER_OP_CANNOT_FIT_INTO_GPU_MEM; |
| 2691 | |
| 2692 | /// @todo |
| 2693 | /// seek expensive node consensus in case of heterogeneous GPU hardware - alas this may |
| 2694 | /// induce unnecessary slowdown (due to sync and broadcast) in applications allocating many |
| 2695 | /// small matrices in the GPU. If this turns out to be the case, we could opt to |
| 2696 | /// enforce consensus only when the needed memory is large (e.g. >1GB) and ergo the |
| 2697 | /// chance of it fitting into some GPU's memory but not others isn't negligible. |
| 2698 | assertAllNodesAgreeThat(matrFitsInMem, msg, vars, caller); |
| 2699 | } |
| 2700 | |
| 2701 | void validate_newSuperOpParams(int numQubits, const char* caller) { |
| 2702 |
no test coverage detected