| 2825 | */ |
| 2826 | |
| 2827 | void assertSuperOpFieldsAreValid(SuperOp op, bool isInKrausMap, const char* caller) { |
| 2828 | |
| 2829 | tokenSubs vars = { |
| 2830 | {"${NUM_QUBITS}", op.numQubits}, |
| 2831 | {"${NUM_ROWS}", op.numRows} |
| 2832 | }; |
| 2833 | |
| 2834 | // assert valid fields |
| 2835 | auto msg = (isInKrausMap)? report::INVALID_KRAUS_MAPS_SUPER_OP_FIELDS : report::INVALID_SUPER_OP_FIELDS; |
| 2836 | assertThat(op.numQubits >= 1, msg, vars, caller); |
| 2837 | assertThat(op.numRows == powerOf2(2 * op.numQubits), msg, vars, caller); |
| 2838 | |
| 2839 | // only check outer point is allocated, to avoid inefficiently enumerating matrix rows |
| 2840 | msg = (isInKrausMap)? report::INVALID_KRAUS_MAPS_SUPER_OP_CPU_MEM_PTR : report::INVALID_SUPER_OP_CPU_MEM_PTR; |
| 2841 | assertThat(mem_isOuterAllocated(op.cpuElems), msg, caller); |
| 2842 | |
| 2843 | validate_envIsInit(caller); |
| 2844 | msg = (isInKrausMap)? report::INVALID_KRAUS_MAPS_SUPER_OP_GPU_MEM_PTR : report::INVALID_SUPER_OP_GPU_MEM_PTR; |
| 2845 | if (getQuESTEnv().isGpuAccelerated) |
| 2846 | assertThat(mem_isOuterAllocated(util_getGpuMemPtr(op)), msg, caller); |
| 2847 | |
| 2848 | // check the teeny tiny heap pointer is not NULL |
| 2849 | assertThat(mem_isAllocated(op.wasGpuSynced), report::INVALID_HEAP_FLAG_PTR, caller); |
| 2850 | |
| 2851 | // and that its value is a boolean |
| 2852 | int flag = *op.wasGpuSynced; |
| 2853 | tokenSubs moreVars = {{"${BAD_FLAG}", flag}, {"${UNKNOWN_FLAG}", validate_STRUCT_PROPERTY_UNKNOWN_FLAG}}; |
| 2854 | assertThat(flag == 0 || flag == 1, report::INVALID_HEAP_FLAG_VALUE, moreVars, caller); |
| 2855 | |
| 2856 | } |
| 2857 | |
| 2858 | void validate_superOpFields(SuperOp op, const char* caller) { |
| 2859 |
no test coverage detected