Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
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 src/QsCompiler/Compiler/Templates/CppInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public string CppType()
DataType.RangeType => "InteropRange*",
DataType.ResultType => "char",
DataType.StringType => "const char*",
DataType.ArrayType => "InteropArray *",
DataType.ArrayType => "InteropArray*",
_ => throw new NotSupportedException($"Unsupported argument type {this.Type}")
};
}
Expand Down
6 changes: 5 additions & 1 deletion src/QsCompiler/Compiler/Templates/QirDriverCpp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void TranslateVector(vector<S>& sourceVector, vector<D>& destinationVector, func
{
destinationVector.resize(sourceVector.size());
transform(sourceVector.begin(), sourceVector.end(), destinationVector.begin(), translationFunction);
}
");
}
if (entryPointOperation.ContainsArgumentType(DataType.RangeType) || entryPointOperation.ContainsArrayType(DataType.RangeType)) {
Expand Down Expand Up @@ -170,8 +171,9 @@ unique_ptr<InteropRange> CreateInteropRange(RangeTuple rangeTuple)
if (arg.CppCliVariableInitialValue() != null) {
WriteLine($" {arg.CliValueVariableName()} = {arg.CppCliVariableInitialValue()};");
}
WriteLine($" app.add_option(\"{arg.CliOptionString()}\", {arg.CliValueVariableName()}, \"{arg.CliDescription()}\")->required()");
Write($" app.add_option(\"{arg.CliOptionString()}\", {arg.CliValueVariableName()}, \"{arg.CliDescription()}\")->required()");
if (arg.TransformerMapName() != null) {
WriteLine("");
Write($" ->transform(CLI::CheckedTransformer({arg.TransformerMapName()}, CLI::ignore_case))");
}
WriteLine(";");
Expand Down Expand Up @@ -222,6 +224,7 @@ unique_ptr<InteropRange> CreateInteropRange(RangeTuple rangeTuple)
WriteLine($" {arg.CppCliValueType()} {arg.InteropVariableName()} = {arg.CliValueVariableName()};");
break;
}
WriteLine("");
}
this.Write(@" // Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
Expand All @@ -244,6 +247,7 @@ unique_ptr<InteropRange> CreateInteropRange(RangeTuple rangeTuple)
Write($" {arg.InteropVariableName()}.c_str()");
break;
case DataType.ArrayType:
case DataType.RangeType:
Write($" {arg.InteropVariableName()}.get()");
break;
default:
Expand Down
6 changes: 5 additions & 1 deletion src/QsCompiler/Compiler/Templates/QirDriverCpp.tt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void TranslateVector(vector<S>& sourceVector, vector<D>& destinationVector, func
{
destinationVector.resize(sourceVector.size());
transform(sourceVector.begin(), sourceVector.end(), destinationVector.begin(), translationFunction);
}
<# } #>
<# if (entryPointOperation.ContainsArgumentType(DataType.RangeType) || entryPointOperation.ContainsArrayType(DataType.RangeType)) { #>

Expand Down Expand Up @@ -167,8 +168,9 @@ int main(int argc, char* argv[])
if (arg.CppCliVariableInitialValue() != null) {
WriteLine($" {arg.CliValueVariableName()} = {arg.CppCliVariableInitialValue()};");
}
WriteLine($" app.add_option(\"{arg.CliOptionString()}\", {arg.CliValueVariableName()}, \"{arg.CliDescription()}\")->required()");
Write($" app.add_option(\"{arg.CliOptionString()}\", {arg.CliValueVariableName()}, \"{arg.CliDescription()}\")->required()");
if (arg.TransformerMapName() != null) {
WriteLine("");
Write($" ->transform(CLI::CheckedTransformer({arg.TransformerMapName()}, CLI::ignore_case))");
}
WriteLine(";");
Expand Down Expand Up @@ -221,6 +223,7 @@ int main(int argc, char* argv[])
WriteLine($" {arg.CppCliValueType()} {arg.InteropVariableName()} = {arg.CliValueVariableName()};");
break;
}
WriteLine("");
} #>
// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
Expand All @@ -241,6 +244,7 @@ int main(int argc, char* argv[])
Write($" {arg.InteropVariableName()}.c_str()");
break;
case DataType.ArrayType:
case DataType.RangeType:
Write($" {arg.InteropVariableName()}.get()");
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ int main(int argc, char* argv[])
CLI11_PARSE(app, argc, argv);

char BoolArgInteropValue = BoolArgCliValue;

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ int main(int argc, char* argv[])
CLI11_PARSE(app, argc, argv);

char BoolArgInteropValue = BoolArgCliValue;

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ void TranslateVector(vector<S>& sourceVector, vector<D>& destinationVector, func
{
destinationVector.resize(sourceVector.size());
transform(sourceVector.begin(), sourceVector.end(), destinationVector.begin(), translationFunction);
}

// This is the function corresponding to the QIR entry-point.
extern "C" void UseBoolArrayArg( // NOLINT
InteropArray * BoolArrayArgInteropValue
InteropArray* BoolArrayArgInteropValue
);


Expand Down Expand Up @@ -84,6 +85,7 @@ int main(int argc, char* argv[])
// Translate values to its final form after parsing.
// Create an interop array of values.
unique_ptr<InteropArray> BoolArrayArgInteropValue = CreateInteropArray(BoolArrayArgCliValue);

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ void TranslateVector(vector<S>& sourceVector, vector<D>& destinationVector, func
{
destinationVector.resize(sourceVector.size());
transform(sourceVector.begin(), sourceVector.end(), destinationVector.begin(), translationFunction);
}

// This is the function corresponding to the QIR entry-point.
extern "C" void UseBoolArrayArgWithValues( // NOLINT
InteropArray * BoolArrayArgInteropValue
InteropArray* BoolArrayArgInteropValue
);


Expand Down Expand Up @@ -84,6 +85,7 @@ int main(int argc, char* argv[])
// Translate values to its final form after parsing.
// Create an interop array of values.
unique_ptr<InteropArray> BoolArrayArgInteropValue = CreateInteropArray(BoolArrayArgCliValue);

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ int main(int argc, char* argv[])

double_t DoubleArgCliValue;
DoubleArgCliValue = 0.0;
app.add_option("--DoubleArg", DoubleArgCliValue, "A double value for the DoubleArg argument")->required()
;
app.add_option("--DoubleArg", DoubleArgCliValue, "A double value for the DoubleArg argument")->required();

// With all the options added, parse arguments from the command line.
CLI11_PARSE(app, argc, argv);

double_t DoubleArgInteropValue = DoubleArgCliValue;

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ int main(int argc, char* argv[])

double_t DoubleArgCliValue;
DoubleArgCliValue = 0.0;
app.add_option("--DoubleArg", DoubleArgCliValue, "A double value for the DoubleArg argument")->required()
;
app.add_option("--DoubleArg", DoubleArgCliValue, "A double value for the DoubleArg argument")->required();

// With all the options added, parse arguments from the command line.
CLI11_PARSE(app, argc, argv);

double_t DoubleArgInteropValue = DoubleArgCliValue;

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ void TranslateVector(vector<S>& sourceVector, vector<D>& destinationVector, func
{
destinationVector.resize(sourceVector.size());
transform(sourceVector.begin(), sourceVector.end(), destinationVector.begin(), translationFunction);
}

// This is the function corresponding to the QIR entry-point.
extern "C" void UseDoubleArrayArg( // NOLINT
InteropArray * DoubleArrayArgInteropValue
InteropArray* DoubleArrayArgInteropValue
);


Expand All @@ -67,15 +68,15 @@ int main(int argc, char* argv[])
"File where the output produced during the simulation is written");

vector<double_t> DoubleArrayArgCliValue;
app.add_option("--DoubleArrayArg", DoubleArrayArgCliValue, "A double array value for the DoubleArrayArg argument")->required()
;
app.add_option("--DoubleArrayArg", DoubleArrayArgCliValue, "A double array value for the DoubleArrayArg argument")->required();

// With all the options added, parse arguments from the command line.
CLI11_PARSE(app, argc, argv);

// Translate values to its final form after parsing.
// Create an interop array of values.
unique_ptr<InteropArray> DoubleArrayArgInteropValue = CreateInteropArray(DoubleArrayArgCliValue);

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ void TranslateVector(vector<S>& sourceVector, vector<D>& destinationVector, func
{
destinationVector.resize(sourceVector.size());
transform(sourceVector.begin(), sourceVector.end(), destinationVector.begin(), translationFunction);
}

// This is the function corresponding to the QIR entry-point.
extern "C" void UseDoubleArrayArgWithValues( // NOLINT
InteropArray * DoubleArrayArgInteropValue
InteropArray* DoubleArrayArgInteropValue
);


Expand All @@ -67,15 +68,15 @@ int main(int argc, char* argv[])
"File where the output produced during the simulation is written");

vector<double_t> DoubleArrayArgCliValue;
app.add_option("--DoubleArrayArg", DoubleArrayArgCliValue, "A double array value for the DoubleArrayArg argument")->required()
;
app.add_option("--DoubleArrayArg", DoubleArrayArgCliValue, "A double array value for the DoubleArrayArg argument")->required();

// With all the options added, parse arguments from the command line.
CLI11_PARSE(app, argc, argv);

// Translate values to its final form after parsing.
// Create an interop array of values.
unique_ptr<InteropArray> DoubleArrayArgInteropValue = CreateInteropArray(DoubleArrayArgCliValue);

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ int main(int argc, char* argv[])

int64_t IntegerArgCliValue;
IntegerArgCliValue = 0;
app.add_option("--IntegerArg", IntegerArgCliValue, "A integer value for the IntegerArg argument")->required()
;
app.add_option("--IntegerArg", IntegerArgCliValue, "A integer value for the IntegerArg argument")->required();

// With all the options added, parse arguments from the command line.
CLI11_PARSE(app, argc, argv);

int64_t IntegerArgInteropValue = IntegerArgCliValue;

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ int main(int argc, char* argv[])

int64_t IntegerArgCliValue;
IntegerArgCliValue = 0;
app.add_option("--IntegerArg", IntegerArgCliValue, "A integer value for the IntegerArg argument")->required()
;
app.add_option("--IntegerArg", IntegerArgCliValue, "A integer value for the IntegerArg argument")->required();

// With all the options added, parse arguments from the command line.
CLI11_PARSE(app, argc, argv);

int64_t IntegerArgInteropValue = IntegerArgCliValue;

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ void TranslateVector(vector<S>& sourceVector, vector<D>& destinationVector, func
{
destinationVector.resize(sourceVector.size());
transform(sourceVector.begin(), sourceVector.end(), destinationVector.begin(), translationFunction);
}

// This is the function corresponding to the QIR entry-point.
extern "C" void UseIntegerArrayArg( // NOLINT
InteropArray * IntegerArrayArgInteropValue
InteropArray* IntegerArrayArgInteropValue
);


Expand All @@ -67,15 +68,15 @@ int main(int argc, char* argv[])
"File where the output produced during the simulation is written");

vector<int64_t> IntegerArrayArgCliValue;
app.add_option("--IntegerArrayArg", IntegerArrayArgCliValue, "A integer array value for the IntegerArrayArg argument")->required()
;
app.add_option("--IntegerArrayArg", IntegerArrayArgCliValue, "A integer array value for the IntegerArrayArg argument")->required();

// With all the options added, parse arguments from the command line.
CLI11_PARSE(app, argc, argv);

// Translate values to its final form after parsing.
// Create an interop array of values.
unique_ptr<InteropArray> IntegerArrayArgInteropValue = CreateInteropArray(IntegerArrayArgCliValue);

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ void TranslateVector(vector<S>& sourceVector, vector<D>& destinationVector, func
{
destinationVector.resize(sourceVector.size());
transform(sourceVector.begin(), sourceVector.end(), destinationVector.begin(), translationFunction);
}

// This is the function corresponding to the QIR entry-point.
extern "C" void UseIntegerArrayArgWithValues( // NOLINT
InteropArray * IntegerArrayArgInteropValue
InteropArray* IntegerArrayArgInteropValue
);


Expand All @@ -67,15 +68,15 @@ int main(int argc, char* argv[])
"File where the output produced during the simulation is written");

vector<int64_t> IntegerArrayArgCliValue;
app.add_option("--IntegerArrayArg", IntegerArrayArgCliValue, "A integer array value for the IntegerArrayArg argument")->required()
;
app.add_option("--IntegerArrayArg", IntegerArrayArgCliValue, "A integer array value for the IntegerArrayArg argument")->required();

// With all the options added, parse arguments from the command line.
CLI11_PARSE(app, argc, argv);

// Translate values to its final form after parsing.
// Create an interop array of values.
unique_ptr<InteropArray> IntegerArrayArgInteropValue = CreateInteropArray(IntegerArrayArgCliValue);

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ void TranslateVector(vector<S>& sourceVector, vector<D>& destinationVector, func
{
destinationVector.resize(sourceVector.size());
transform(sourceVector.begin(), sourceVector.end(), destinationVector.begin(), translationFunction);
}

// This is the function corresponding to the QIR entry-point.
extern "C" void UseMiscArgs( // NOLINT
char IntegerArgInteropValue,
char PauliArgInteropValue,
InteropArray * ResultArrayArgInteropValue
InteropArray* ResultArrayArgInteropValue
);


Expand Down Expand Up @@ -115,11 +116,14 @@ int main(int argc, char* argv[])
CLI11_PARSE(app, argc, argv);

char IntegerArgInteropValue = IntegerArgCliValue;

// Translate a PauliID value to its char representation.
char PauliArgInteropValue = TranslatePauliToChar(PauliArgCliValue);

// Translate values to its final form after parsing.
// Create an interop array of values.
unique_ptr<InteropArray> ResultArrayArgInteropValue = CreateInteropArray(ResultArrayArgCliValue);

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ int main(int argc, char* argv[])

// Translate a PauliID value to its char representation.
char PauliArgInteropValue = TranslatePauliToChar(PauliArgCliValue);

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ int main(int argc, char* argv[])

// Translate a PauliID value to its char representation.
char PauliArgInteropValue = TranslatePauliToChar(PauliArgCliValue);

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ void TranslateVector(vector<S>& sourceVector, vector<D>& destinationVector, func
{
destinationVector.resize(sourceVector.size());
transform(sourceVector.begin(), sourceVector.end(), destinationVector.begin(), translationFunction);
}

// This is the function corresponding to the QIR entry-point.
extern "C" void UsePauliArrayArg( // NOLINT
InteropArray * PauliArrayArgInteropValue
InteropArray* PauliArrayArgInteropValue
);


Expand Down Expand Up @@ -89,6 +90,7 @@ int main(int argc, char* argv[])
vector<char> PauliArrayArgIntermediateValue;
TranslateVector<PauliId, char>(PauliArrayArgCliValue, PauliArrayArgIntermediateValue, TranslatePauliToChar);
unique_ptr<InteropArray> PauliArrayArgInteropValue = CreateInteropArray(PauliArrayArgIntermediateValue);

// Redirect the simulator output from std::cout if the --simulation-output option is present.
ostream* simulatorOutputStream = &cout;
ofstream simulationOutputFileStream;
Expand Down
Loading