Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quest/include/operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ void applyMultiControlledCompMatr2(Qureg qureg, std::vector<int> controls, int t
/// @notyetdoced
/// @cppvectoroverload
/// @see applyMultiStateControlledCompMatr2()
void applyMultiStateControlledCompMatr2(Qureg qureg, std::vector<int> controls, std::vector<int> states, int numControls, int target1, int target2, CompMatr2 matr);
void applyMultiStateControlledCompMatr2(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target1, int target2, CompMatr2 matr);


#endif // __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion quest/src/api/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void applyMultiControlledCompMatr2(Qureg qureg, vector<int> controls, int target
applyMultiControlledCompMatr2(qureg, controls.data(), controls.size(), target1, target2, matr);
}

void applyMultiStateControlledCompMatr2(Qureg qureg, vector<int> controls, vector<int> states, int numControls, int target1, int target2, CompMatr2 matr) {
void applyMultiStateControlledCompMatr2(Qureg qureg, vector<int> controls, vector<int> 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);
Expand Down
16 changes: 8 additions & 8 deletions quest/src/api/trotterisation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__);
Expand All @@ -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__);
Expand All @@ -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__);
Expand All @@ -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__);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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__);

Expand Down
12 changes: 6 additions & 6 deletions quest/src/core/accelerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) \
Expand All @@ -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 ) \
Expand All @@ -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 ) \
Expand Down
4 changes: 4 additions & 0 deletions quest/src/core/printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
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".
Expand Down
15 changes: 12 additions & 3 deletions quest/src/core/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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).";

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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},
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion quest/src/core/validation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);



Expand Down
2 changes: 1 addition & 1 deletion tests/unit/experimental.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) {
Expand Down
Loading