| 742 | // type T can be CompMatr1, CompMatr2, CompMatr, DiagMatr1, DiagMatr2, DiagMatr, FullStateDiagMatr |
| 743 | template<class T> |
| 744 | void 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 |
no test coverage detected