Commit f5e68b73 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

Adding runtime kernels to Program

parent bc3c58bd
......@@ -63,8 +63,7 @@ std::list<std::shared_ptr<DWQMI>> DefaultParameterSetter::setParameters(
for (auto& embKv : embedding) {
auto probVert = embKv.first;
auto hardwareMapping = embKv.second;
auto newBias = std::get<0>(problemGraph->getVertexProperties(probVert))
/ hardwareMapping.size();
auto newBias = std::get<0>(problemGraph->getVertexProperties(probVert)) / hardwareMapping.size();
for (auto h : hardwareMapping) {
auto embeddedInst = std::make_shared<DWQMI>(h, h, newBias);
instList.push_back(embeddedInst);
......
......@@ -117,7 +117,7 @@ public:
return bufferId;
}
void resetBuffer() {
virtual void resetBuffer() {
measurements.clear();
}
......@@ -125,11 +125,11 @@ public:
bits[idx].update(zeroOrOne);
}
void appendMeasurement(const boost::dynamic_bitset<>& measurement) {
virtual void appendMeasurement(const boost::dynamic_bitset<>& measurement) {
measurements.push_back(measurement);
}
double getAverage() const {
virtual double getAverage() const {
//std::assert(measurements.size()>0);
std::stringstream ss;
double aver = 0.;
......
......@@ -103,6 +103,10 @@ public:
return false;
}
virtual const int getNQubitsUsed() const {
return 0;
}
/**
* The destructor
*/
......
......@@ -47,9 +47,22 @@ public:
accelerator->execute(buffer, function);
}
void operator()(std::shared_ptr<AcceleratorBuffer> buffer, std::vector<InstructionParameter> parameters) {
function->evaluateVariableParameters(parameters);
accelerator->execute(buffer, function);
}
void prepend(const std::shared_ptr<Function> prependFunction) {
function->insertInstruction(0, prependFunction);
}
const int getNumberOfKernelParameters() {
return function->nParameters();
}
std::shared_ptr<Function> getIRFunction() {
return function;
}
};
}
......
......@@ -185,6 +185,13 @@ public:
return;
}
void transformIR(std::shared_ptr<IRTransformation> transformation) {
if (xaccIR) {
xaccIR = transformation->transform(xaccIR);
}
}
/**
* Return an executable version of the kernel
* referenced by the kernelName string.
......@@ -224,6 +231,19 @@ public:
return kernels;
}
auto getRuntimeKernels() -> std::vector<Kernel<>> {
std::vector<Kernel<>> kernels;
if (!xaccIR) {
build();
}
for (auto k : xaccIR->getKernels()) {
kernels.push_back(Kernel<>(accelerator, k));
}
return kernels;
}
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment