diff --git a/quest/include/operations.h b/quest/include/operations.h index ff81ad7a..3c97d2c6 100644 --- a/quest/include/operations.h +++ b/quest/include/operations.h @@ -573,7 +573,7 @@ void applyMultiControlledCompMatr2(Qureg qureg, std::vector controls, int t /// @notyetdoced /// @cppvectoroverload /// @see applyMultiStateControlledCompMatr2() -void applyMultiStateControlledCompMatr2(Qureg qureg, std::vector controls, std::vector states, int numControls, int target1, int target2, CompMatr2 matr); +void applyMultiStateControlledCompMatr2(Qureg qureg, std::vector controls, std::vector states, int target1, int target2, CompMatr2 matr); #endif // __cplusplus diff --git a/quest/src/api/operations.cpp b/quest/src/api/operations.cpp index 9c664026..15574b28 100644 --- a/quest/src/api/operations.cpp +++ b/quest/src/api/operations.cpp @@ -144,7 +144,7 @@ void applyMultiControlledCompMatr2(Qureg qureg, vector controls, int target applyMultiControlledCompMatr2(qureg, controls.data(), controls.size(), target1, target2, matr); } -void applyMultiStateControlledCompMatr2(Qureg qureg, vector controls, vector states, int numControls, int target1, int target2, CompMatr2 matr) { +void applyMultiStateControlledCompMatr2(Qureg qureg, vector controls, vector states, int target1, int target2, CompMatr2 matr) { validate_controlsMatchStates(controls.size(), states.size(), __func__); applyMultiStateControlledCompMatr2(qureg, controls.data(), states.data(), controls.size(), target1, target2, matr); diff --git a/quest/src/api/trotterisation.cpp b/quest/src/api/trotterisation.cpp index 30c3ccfd..6fd5781b 100644 --- a/quest/src/api/trotterisation.cpp +++ b/quest/src/api/trotterisation.cpp @@ -168,7 +168,7 @@ void applyTrotterizedNonUnitaryPauliStrSumGadget(Qureg qureg, PauliStrSum sum, q validate_quregFields(qureg, __func__); validate_pauliStrSumFields(sum, __func__); validate_pauliStrSumTargets(sum, qureg, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); // sum is permitted to be non-Hermitian // |psi> -> U |psi>, rho -> U rho U^dagger @@ -181,7 +181,7 @@ void applyTrotterizedPauliStrSumGadget(Qureg qureg, PauliStrSum sum, qreal angle validate_pauliStrSumFields(sum, __func__); validate_pauliStrSumTargets(sum, qureg, __func__); validate_pauliStrSumIsHermitian(sum, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); bool onlyLeftApply = false; internal_applyAllTrotterRepetitions(qureg, nullptr, nullptr, 0, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__); @@ -195,7 +195,7 @@ void applyTrotterizedControlledPauliStrSumGadget( validate_pauliStrSumFields(sum, __func__); validate_pauliStrSumIsHermitian(sum, __func__); validate_controlAndPauliStrSumTargets(qureg, control, sum, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); bool onlyLeftApply = false; internal_applyAllTrotterRepetitions(qureg, &control, nullptr, 1, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__); @@ -209,7 +209,7 @@ void applyTrotterizedMultiControlledPauliStrSumGadget( validate_pauliStrSumFields(sum, __func__); validate_pauliStrSumIsHermitian(sum, __func__); validate_controlsAndPauliStrSumTargets(qureg, controls, numControls, sum, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); bool onlyLeftApply = false; internal_applyAllTrotterRepetitions(qureg, controls, nullptr, numControls, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__); @@ -224,7 +224,7 @@ void applyTrotterizedMultiStateControlledPauliStrSumGadget( validate_pauliStrSumIsHermitian(sum, __func__); validate_controlsAndPauliStrSumTargets(qureg, controls, numControls, sum, __func__); validate_controlStates(states, numControls, __func__); // permits states==nullptr - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); bool onlyLeftApply = false; internal_applyAllTrotterRepetitions(qureg, controls, states, numControls, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__); @@ -261,7 +261,7 @@ void applyTrotterizedUnitaryTimeEvolution(Qureg qureg, PauliStrSum hamil, qreal validate_pauliStrSumFields(hamil, __func__); validate_pauliStrSumTargets(hamil, qureg, __func__); validate_pauliStrSumIsHermitian(hamil, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); // exp(-i t H) = exp(x i H) | x=-t qcomp angle = - time; @@ -274,7 +274,7 @@ void applyTrotterizedImaginaryTimeEvolution(Qureg qureg, PauliStrSum hamil, qrea validate_pauliStrSumFields(hamil, __func__); validate_pauliStrSumTargets(hamil, qureg, __func__); validate_pauliStrSumIsHermitian(hamil, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); // exp(-tau H) = exp(x i H) | x=tau*i qcomp angle = qcomp(0, tau); @@ -301,7 +301,7 @@ void applyTrotterizedNoisyTimeEvolution( validate_pauliStrSumFields(hamil, __func__); validate_pauliStrSumTargets(hamil, qureg, __func__); validate_pauliStrSumIsHermitian(hamil, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); validate_lindbladJumpOps(jumps, numJumps, qureg, __func__); validate_lindbladDampingRates(damps, numJumps, __func__); diff --git a/quest/src/core/accelerator.cpp b/quest/src/core/accelerator.cpp index c813c105..677e6c74 100644 --- a/quest/src/core/accelerator.cpp +++ b/quest/src/core/accelerator.cpp @@ -80,8 +80,8 @@ using std::array; array {&f<0>, &f<1>, &f<2>, &f<3>, &f<4>, &f<5>, &f<-1>} #define GET_FUNC_OPTIMISED_FOR_ONE_PARAM( outvar, funcname, param ) \ - static constexpr auto (_ARRAY_##funcname) = GET_ONE_PARAM_TEMPLATED_FUNC_ARRAY( funcname ); \ - const auto outvar = (_ARRAY_##funcname)[GET_TEMPLATE_PARAM( param )]; + static constexpr auto _ARRAY_##funcname = GET_ONE_PARAM_TEMPLATED_FUNC_ARRAY( funcname ); \ + const auto outvar = _ARRAY_##funcname[GET_TEMPLATE_PARAM( param )]; #define GET_CPU_OR_GPU_FUNC_OPTIMISED_FOR_ONE_PARAM( outvar, funcsuffix, qureg, param ) \ GET_FUNC_OPTIMISED_FOR_ONE_PARAM( _GPU_FUNC, gpu_##funcsuffix, param ) \ @@ -100,8 +100,8 @@ using std::array; array {&f<-1,0>, &f<-1,1>, &f<-1,2>, &f<-1,3>, &f<-1,4>, &f<-1,5>, &f<-1,-1>}} #define GET_FUNC_OPTIMISED_FOR_TWO_PARAMS( outvar, funcname, param1, param2 ) \ - static constexpr auto (_MATRIX_##funcname) = GET_TWO_PARAM_TEMPLATED_FUNC_MATRIX( funcname ); \ - const auto outvar = (_MATRIX_##funcname)[GET_TEMPLATE_PARAM( param1 )][GET_TEMPLATE_PARAM( param2 )]; + static constexpr auto _MATRIX_##funcname = GET_TWO_PARAM_TEMPLATED_FUNC_MATRIX( funcname ); \ + const auto outvar = _MATRIX_##funcname[GET_TEMPLATE_PARAM( param1 )][GET_TEMPLATE_PARAM( param2 )]; #define GET_CPU_OR_GPU_FUNC_OPTIMISED_FOR_TWO_PARAMS( outvar, funcsuffix, qureg, param1, param2 ) \ GET_FUNC_OPTIMISED_FOR_TWO_PARAMS( _GPU_FUNC, gpu_##funcsuffix, param1, param2 ) \ @@ -125,8 +125,8 @@ using std::array; array{ GET_TWO_PARAM_TWO_BOOL_SUB_MATRIX( f, 1, 0 ), GET_TWO_PARAM_TWO_BOOL_SUB_MATRIX( f, 1, 1 ) }} #define GET_FUNC_OPTIMISED_FOR_TWO_PARAMS_TWO_BOOLS( outvar, funcname, param1, param2, bool1, bool2 ) \ - static constexpr auto (_MATRIX_##funcname) = GET_TWO_PARAM_TWO_BOOL_TEMPLATED_FUNC_MATRIX( funcname ); \ - const auto outvar = (_MATRIX_##funcname)[bool1][bool2][GET_TEMPLATE_PARAM( param1 )][GET_TEMPLATE_PARAM( param2 )]; + static constexpr auto _MATRIX_##funcname = GET_TWO_PARAM_TWO_BOOL_TEMPLATED_FUNC_MATRIX( funcname ); \ + const auto outvar = _MATRIX_##funcname[bool1][bool2][GET_TEMPLATE_PARAM( param1 )][GET_TEMPLATE_PARAM( param2 )]; #define GET_CPU_OR_GPU_FUNC_OPTIMISED_FOR_TWO_PARAMS_TWO_BOOLS( outvar, funcsuffix, qureg, param1, param2, bool1, bool2 ) \ GET_FUNC_OPTIMISED_FOR_TWO_PARAMS_TWO_BOOLS( _GPU_FUNC, gpu_##funcsuffix, param1, param2, bool1, bool2 ) \ diff --git a/quest/src/core/printer.cpp b/quest/src/core/printer.cpp index 283f51a4..863317c8 100644 --- a/quest/src/core/printer.cpp +++ b/quest/src/core/printer.cpp @@ -249,6 +249,10 @@ inline std::string demangleTypeName(const char* mangledName) { // type T can be anything in principle, although it's currently only used for qcomp template std::string getTypeName(T _unused) { + + // Shut those obnovioux compilers right up + (void) _unused; + // For MSVC, typeid(T).name() typically returns something like "class Foo" // or "struct Foo", but it's still not exactly "Foo". // For GCC/Clang, you get a raw "mangled" name, e.g. "N3FooE". diff --git a/quest/src/core/validation.cpp b/quest/src/core/validation.cpp index 30119f2d..62ff9316 100644 --- a/quest/src/core/validation.cpp +++ b/quest/src/core/validation.cpp @@ -144,6 +144,9 @@ namespace report { string INVALID_NUM_REPORTED_SIG_FIGS = "Invalid number of significant figures (${NUM_SIG_FIGS}). Cannot be less than one."; + string RANDOM_SEEDS_PTR_IS_NULL = + "The given seeds list pointer is NULL."; + string INVALID_NUM_RANDOM_SEEDS = "Invalid number of random seeds (${NUM_SEEDS}). Must specify one or more. In distributed settings, only the root node needs to pass a valid number of seeds (other node arguments are ignored)."; @@ -1609,11 +1612,14 @@ void validate_randomSeeds(unsigned* seeds, int numSeeds, const char* caller) { // only the root node's seeds are consulted, so we permit all non-root // nodes to have invalid parameters. All nodes however must know/agree // when the root node's seeds are invalid, to synchronise validation - + int isNull = (seeds == nullptr); int numRootSeeds = numSeeds; - if (getQuESTEnv().isDistributed) + if (getQuESTEnv().isDistributed) { + comm_broadcastIntsFromRoot(&isNull, 1); comm_broadcastIntsFromRoot(&numRootSeeds, 1); + } + assertThat(!isNull, report::RANDOM_SEEDS_PTR_IS_NULL, caller); assertThat(numRootSeeds > 0, report::INVALID_NUM_RANDOM_SEEDS, {{"${NUM_SEEDS}", numSeeds}}, caller); } @@ -3819,6 +3825,7 @@ void validate_parsedPauliStrSumLineIsInterpretable(bool isInterpretable, string return; /// @todo we cannot yet report 'line' because tokenSubs so far only accepts integers :( + (void) line; tokenSubs vars = {{"${LINE_NUMBER}", lineIndex + 1}}; // line numbers begin at 1 assertThat(isInterpretable, report::PARSED_PAULI_STR_SUM_UNINTERPRETABLE_LINE, vars, caller); @@ -3830,6 +3837,7 @@ void validate_parsedPauliStrSumLineHasConsistentNumPaulis(int numPaulis, int num return; /// @todo we cannot yet report 'line' because tokenSubs so far only accepts integers :( + (void) line; tokenSubs vars = { {"${NUM_PAULIS}", numPaulis}, @@ -3844,6 +3852,7 @@ void validate_parsedPauliStrSumCoeffWithinQcompRange(bool isCoeffValid, string l return; /// @todo we cannot yet report 'line' because tokenSubs so far only accepts integers :( + (void) line; tokenSubs vars = {{"${LINE_NUMBER}", lineIndex + 1}}; // lines begin at 1 assertThat(isCoeffValid, report::PARSED_PAULI_STR_SUM_COEFF_EXCEEDS_QCOMP_RANGE, vars, caller); @@ -4426,7 +4435,7 @@ void validate_mixedAmpsFitInNode(Qureg qureg, int numTargets, const char* caller * TROTTERISATION PARAMETERS */ -void validate_trotterParams(Qureg qureg, int order, int reps, const char* caller) { +void validate_trotterParams(int order, int reps, const char* caller) { if (!global_isValidationEnabled) return; diff --git a/quest/src/core/validation.hpp b/quest/src/core/validation.hpp index 58a0b632..87f81a0d 100644 --- a/quest/src/core/validation.hpp +++ b/quest/src/core/validation.hpp @@ -428,7 +428,7 @@ void validate_mixedAmpsFitInNode(Qureg qureg, int numTargets, const char* caller * TROTTERISATION PARAMETERS */ -void validate_trotterParams(Qureg qureg, int order, int reps, const char* caller); +void validate_trotterParams(int order, int reps, const char* caller); diff --git a/tests/unit/experimental.cpp b/tests/unit/experimental.cpp index b36f67ad..94364583 100644 --- a/tests/unit/experimental.cpp +++ b/tests/unit/experimental.cpp @@ -79,7 +79,7 @@ TEST_CASE( "setQuESTNumGpuThreadsPerBlock", TEST_CATEGORY ) { int badNumTPB = GENERATE_COPY( warpSize - 1, warpSize + 1, warpSize + warpSize/2, 3*warpSize + warpSize/2 ); - REQUIRE_THROWS_WITH( setQuESTNumGpuThreadsPerBlock(badNumTPB), ContainsSubstring( "Number does not divide evenly into the warp size" ) ); + REQUIRE_THROWS_WITH( setQuESTNumGpuThreadsPerBlock(badNumTPB), ContainsSubstring( "does not divide evenly into the warp size" ) ); } SECTION( "Exceeds device maximum" ) {