MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / mem_canMatrixFitInMemory

Function mem_canMatrixFitInMemory

quest/src/core/memory.cpp:360–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358
359
360bool 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
381bool mem_canSuperOpFitInMemory(int numQubits, qindex numBytesPerNode) {

Callers 3

assertMatrixFitsInCpuMemFunction · 0.85
assertMatrixFitsInGpuMemFunction · 0.85

Calls 1

logBase2Function · 0.85

Tested by

no test coverage detected