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

Function validate_newQuregAllocs

quest/src/core/validation.cpp:1718–1738  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1716}
1717
1718void validate_newQuregAllocs(Qureg qureg, const char* caller) {
1719
1720 // this validation is called AFTER the caller has checked for failed
1721 // allocs and (in that scenario) freed every pointer, but does not
1722 // overwrite any pointers to nullptr, so the failed alloc is known.
1723 // This is only safe to do so (rather than making the caller set ptrs
1724 // to nullptr) because the struct contains only 1D pointers (no nesting)
1725
1726 // we get node consensus in case mallocs fail on some nodes but not others, as may occur
1727 // in heterogeneous settings, or where nodes may have other processes and loads hogging RAM.
1728 assertAllNodesAgreeThat(mem_isAllocated(qureg.cpuAmps), report::NEW_QUREG_CPU_AMPS_ALLOC_FAILED, caller);
1729
1730 if (qureg.isGpuAccelerated)
1731 assertAllNodesAgreeThat(mem_isAllocated(qureg.gpuAmps), report::NEW_QUREG_GPU_AMPS_ALLOC_FAILED, caller);
1732
1733 if (qureg.isDistributed)
1734 assertAllNodesAgreeThat(mem_isAllocated(qureg.cpuCommBuffer), report::NEW_QUREG_CPU_COMM_BUFFER_ALLOC_FAILED, caller);
1735
1736 if (qureg.isDistributed && qureg.isGpuAccelerated)
1737 assertAllNodesAgreeThat(mem_isAllocated(qureg.gpuCommBuffer), report::NEW_QUREG_GPU_COMM_BUFFER_ALLOC_FAILED, caller);
1738}
1739
1740
1741

Callers 1

Calls 2

assertAllNodesAgreeThatFunction · 0.85
mem_isAllocatedFunction · 0.85

Tested by

no test coverage detected