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

Function SECTION

tests/unit/qureg.cpp:51–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49TEST_CASE( "createQureg", TEST_CATEGORY ) {
50
51 SECTION( LABEL_CORRECTNESS ) {
52
53 int numQubits = GENERATE( range(1, 10) );
54 CAPTURE( numQubits );
55
56 Qureg qureg = createQureg(numQubits);
57 QuESTEnv env = getQuESTEnv();
58
59 // check fixed fields
60 REQUIRE( qureg.numQubits == numQubits );
61 REQUIRE( qureg.isDensityMatrix == 0 );
62 REQUIRE( qureg.numAmps == getPow2(numQubits) );
63 REQUIRE( qureg.logNumAmps == getLog2(qureg.numAmps) );
64 REQUIRE( qureg.logNumAmpsPerNode == getLog2(qureg.numAmpsPerNode) );
65 REQUIRE( (qureg.isMultithreaded == 0 || qureg.isMultithreaded == 1) );
66 REQUIRE( (qureg.isGpuAccelerated == 0 || qureg.isGpuAccelerated == 1) );
67 REQUIRE( (qureg.isDistributed == 0 || qureg.isDistributed == 1) );
68
69 // check deployment-specific fields
70 if (qureg.isDistributed) {
71 REQUIRE( qureg.rank == env.rank );
72 REQUIRE( qureg.numNodes == env.numNodes );
73 REQUIRE( qureg.logNumNodes == getLog2(env.numNodes) );
74 REQUIRE( qureg.numAmpsPerNode == qureg.numAmps / env.numNodes );
75 } else {
76 REQUIRE( qureg.rank == 0 );
77 REQUIRE( qureg.numNodes == 1 );
78 REQUIRE( qureg.logNumNodes == 0 );
79 REQUIRE( qureg.numAmpsPerNode == qureg.numAmps );
80 }
81
82 // check memory allocs
83 REQUIRE( qureg.cpuAmps != nullptr );
84 if (qureg.isGpuAccelerated)
85 REQUIRE( qureg.gpuAmps != nullptr );
86 if (qureg.isDistributed)
87 REQUIRE( qureg.cpuCommBuffer != nullptr );
88 if (qureg.isGpuAccelerated && qureg.isDistributed)
89 REQUIRE( qureg.gpuCommBuffer != nullptr );
90
91 /// @todo check autodeployments
92
93 // check begins in zero state
94 qvector ref = getZeroVector(qureg.numAmps); ref[0] = 1; // |0>
95 REQUIRE_AGREE( qureg, ref );
96
97 destroyQureg(qureg);
98 }
99
100 SECTION( LABEL_VALIDATION ) {
101

Calls 15

createQuregFunction · 0.85
getQuESTEnvFunction · 0.85
getPow2Function · 0.85
getLog2Function · 0.85
getZeroVectorFunction · 0.85
REQUIRE_AGREEFunction · 0.85
destroyQuregFunction · 0.85
createDensityQuregFunction · 0.85
createForcedQuregFunction · 0.85
createForcedDensityQuregFunction · 0.85
getSupportedDeploymentsFunction · 0.85
createCustomQuregFunction · 0.85

Tested by

no test coverage detected