| 2907 | } |
| 2908 | |
| 2909 | void validate_newKrausMapParams(int numQubits, int numMatrices, const char* caller) { |
| 2910 | |
| 2911 | // some of the below validation involves getting distributed node consensus, which |
| 2912 | // can be an expensive synchronisation, which we avoid if validation is anyway disabled |
| 2913 | if (!global_isValidationEnabled) |
| 2914 | return; |
| 2915 | |
| 2916 | validate_envIsInit(caller); |
| 2917 | QuESTEnv env = getQuESTEnv(); |
| 2918 | |
| 2919 | // first ensure that numQubits is >0 so below validation algebra is correct/safe |
| 2920 | assertKrausMapNonEmpty(numQubits, caller); |
| 2921 | |
| 2922 | // then ensure the Kraus map's superoperator has safe non-overflowing dimensions |
| 2923 | bool isInKrausMap = true; |
| 2924 | assertSuperOpTotalNumElemsDontExceedMaxIndex(numQubits, isInKrausMap, caller); |
| 2925 | assertSuperOpLocalMemDoesntExceedMaxSizeof(numQubits, isInKrausMap, caller); |
| 2926 | |
| 2927 | // ensure the superoperator can fit into current memory - we do NOT bother checking |
| 2928 | // whether the Kraus operator matrix list fits in memory since that's a very rare |
| 2929 | // scenario (the memory is linear with the user's numMatrices parameter, so they will |
| 2930 | // not be asonisthed) and will be posteriori caught after memory allocation failure |
| 2931 | assertSuperOpFitsInCpuMem(numQubits, isInKrausMap, caller); |
| 2932 | assertSuperOpFitsInGpuMem(numQubits, env.isGpuAccelerated, isInKrausMap, caller); |
| 2933 | |
| 2934 | // ensure the number of Kraus operators isn't invalid, nor will cause overflows/seg-faults |
| 2935 | assertKrausMapValidNumMatrices(numQubits, numMatrices, caller); |
| 2936 | } |
| 2937 | |
| 2938 | void validate_newKrausMapAllocs(KrausMap map, const char* caller) { |
| 2939 |
no test coverage detected