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

Function validateAndPrintMatrix

quest/src/api/matrices.cpp:744–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

742// type T can be CompMatr1, CompMatr2, CompMatr, DiagMatr1, DiagMatr2, DiagMatr, FullStateDiagMatr
743template<class T>
744void validateAndPrintMatrix(T matr, const char* caller) {
745 validate_matrixFields(matr, caller);
746 validate_numReportedNewlinesAboveZero(__func__); // because trailing newline mandatory
747
748 // syncable matrices must be synced before reporting (though only CPU elems are printed)
749 if constexpr (util_isHeapMatrixType<T>())
750 validate_matrixIsSynced(matr, caller);
751
752 // calculate the total memory (in bytes) consumed by the matrix on each
753 // node, which will depend on whether the matrix is distributed, and
754 // includes the size of the matrix struct itself. Note that GPU memory
755 // is not included since it is less than or equal to the CPU memory, and
756 // occupies different memory spaces, confusing capacity accounting
757 int numNodes = (util_isDistributedMatrix(matr))? comm_getNumNodes() : 1;
758 size_t elemMem = mem_getLocalMatrixMemoryRequired(matr.numQubits, util_isDenseMatrixType<T>(), numNodes);
759 size_t structMem = sizeof(matr);
760
761 // struct memory includes fixed-size arrays (qcomp[][]), so we undo double-counting
762 if (util_isFixedSizeMatrixType<T>())
763 structMem -= elemMem;
764
765 size_t numBytesPerNode = elemMem + structMem;
766 print_header(matr, numBytesPerNode);
767 print_elems(matr);
768
769 // exclude mandatory newline above
770 print_oneFewerNewlines();
771}
772
773
774// all reporters are C and C++ accessible, so are de-mangled

Callers 7

reportCompMatr1Function · 0.85
reportCompMatr2Function · 0.85
reportCompMatrFunction · 0.85
reportDiagMatr1Function · 0.85
reportDiagMatr2Function · 0.85
reportDiagMatrFunction · 0.85
reportFullStateDiagMatrFunction · 0.85

Calls 9

validate_matrixFieldsFunction · 0.85
validate_matrixIsSyncedFunction · 0.85
util_isDistributedMatrixFunction · 0.85
comm_getNumNodesFunction · 0.85
print_headerFunction · 0.85
print_elemsFunction · 0.85
print_oneFewerNewlinesFunction · 0.85

Tested by

no test coverage detected