| 358 | |
| 359 | |
| 360 | bool mem_canMatrixFitInMemory(int numQubits, bool isDense, int numNodes, qindex memBytesPerNode) { |
| 361 | |
| 362 | // this function's logic is similar to mem_canQuregFitInMemory(), where diagonal matrices are |
| 363 | // like statevectors and dense matrices are like density-matrices, except that distributed |
| 364 | // matrices (numNodes > 1) do not store (nor need to account for) communication buffers |
| 365 | |
| 366 | // distributing the matrix shrinks the local number of qubits stored, effectively |
| 367 | int localNumQubits = numQubits - logBase2(numNodes); |
| 368 | |
| 369 | // work out the maximum "local" qubits that can fit in memory |
| 370 | qindex maxLocalNumElems = memBytesPerNode / sizeof(qcomp); // floors |
| 371 | int maxLocalNumQubits = std::floor(std::log2(maxLocalNumElems)); |
| 372 | |
| 373 | // dense matrices (as opposed to diagonals) require square more memory |
| 374 | if (isDense) |
| 375 | maxLocalNumQubits /= 2; // floors |
| 376 | |
| 377 | return localNumQubits <= maxLocalNumQubits; |
| 378 | } |
| 379 | |
| 380 | |
| 381 | bool mem_canSuperOpFitInMemory(int numQubits, qindex numBytesPerNode) { |
no test coverage detected