| 1829 | } |
| 1830 | |
| 1831 | void assertMatrixLocalMemDoesntExceedMaxSizeof(int numQubits, bool isDense, int isDistrib, int numEnvNodes, const char* caller) { |
| 1832 | |
| 1833 | // 'isDistrib' can be 0 (user-disabled, or matrix is a local type), 1 (user-forced) |
| 1834 | // or modeflag::USE_AUTO=-1 (automatic; the type can be distributed but the user has |
| 1835 | // not forced it). Currently, only distributed diagonal matrices are supported, so |
| 1836 | // isDistrib must be specifically 0 for dense matrices. |
| 1837 | if (isDense && isDistrib != 0) |
| 1838 | error_validationEncounteredUnsupportedDistributedDenseMatrix(); |
| 1839 | |
| 1840 | // assume distributed (unless it is force disabled), because that reduces the memory required |
| 1841 | // per node and is ergo more permissive - and the auto-deployer would never choose non-distribution |
| 1842 | // in a distributed env if the memory would exceed the max sizeof! |
| 1843 | int numMatrNodes = (isDistrib == 0)? 1 : numEnvNodes; |
| 1844 | int maxNumQubits = mem_getMaxNumMatrixQubitsBeforeGlobalMemSizeofOverflow(isDense, numMatrNodes); |
| 1845 | |
| 1846 | // make error message specific to whether the matrix is distributed or non-distributed type; |
| 1847 | // non-distributed matrices (e.g. CompMatr) should only ever cause the local error message |
| 1848 | string msg = (numMatrNodes > 1)? |
| 1849 | report::NEW_DISTRIB_DIAG_MATR_LOCAL_MEM_WOULD_EXCEED_SIZEOF : |
| 1850 | ((isDense)? |
| 1851 | report::NEW_LOCAL_COMP_MATR_MEM_WOULD_EXCEED_SIZEOF : |
| 1852 | report::NEW_LOCAL_DIAG_MATR_MEM_WOULD_EXCEED_SIZEOF); |
| 1853 | |
| 1854 | tokenSubs vars = { |
| 1855 | {"${NUM_QUBITS}", numQubits}, |
| 1856 | {"${MAX_QUBITS}", maxNumQubits}}; |
| 1857 | if (numMatrNodes > 1) |
| 1858 | vars["${NUM_NODES}"] = numMatrNodes; |
| 1859 | |
| 1860 | assertThat(numQubits <= maxNumQubits, msg, vars, caller); |
| 1861 | } |
| 1862 | |
| 1863 | void assertMatrixNotDistributedOverTooManyNodes(int numQubits, bool isDense, int isDistrib, int numEnvNodes, const char* caller) { |
| 1864 |
no test coverage detected