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

Setting DWKernel to take a name

parent 6eecbec4
......@@ -46,7 +46,6 @@ std::shared_ptr<IR> DWQMICompiler::compile(const std::string& src,
auto runtimeOptions = RuntimeOptions::instance();
auto hardwareGraph = acc->getAcceleratorConnectivity();
auto dwKernel = std::make_shared<DWKernel>();
std::set<int> qubits;
std::vector<std::shared_ptr<DWQMI>> instructions;
int nHardwareVerts = hardwareGraph->order();
......@@ -61,8 +60,14 @@ std::shared_ptr<IR> DWQMICompiler::compile(const std::string& src,
// brackets are, and then get the text between them.
// First off, split the string into lines
std::vector<std::string> lines;
std::vector<std::string> lines, fLineSpaces;
boost::split(lines, src, boost::is_any_of("\n"));
auto functionLine = lines[0];
boost::split(fLineSpaces, functionLine, boost::is_any_of(" "));
auto fName = fLineSpaces[1];
boost::trim(fName);
fName = fName.substr(0, fName.find_first_of("("));
auto dwKernel = std::make_shared<DWKernel>(fName);
auto firstCodeLine = lines.begin() + 1;
auto lastCodeLine = lines.end() - 1;
std::vector<std::string> qmiStrVec(firstCodeLine, lastCodeLine);
......
......@@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(checkSimpleCompile) {
auto ir = compiler->compile(simpleQMI, acc);
auto qmi = ir->getKernel("dw-kernel")->toString("");
auto qmi = ir->getKernel("dwaveKernel")->toString("");
const std::string expectedQMI = "0 0 0.49\n"
"4 4 0.49\n"
......@@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(checkShor15OneToOneMapping) {
auto ir = compiler->compile(shor15QMI, acc);
auto qmi = ir->getKernel("dw-kernel")->toString("");
auto qmi = ir->getKernel("shor15")->toString("");
std::cout << qmi << "\n";
......
......@@ -9,6 +9,7 @@
#define QUANTUM_AQC_IR_DWGRAPH_HPP_
#include "Graph.hpp"
#include "Accelerator.hpp"
namespace xacc {
......@@ -94,10 +95,10 @@ public:
virtual ~CompleteGraph() {}
};
class Chimera : public DWGraph {
class ChimeraGraph : public DWGraph {
public:
Chimera(int gridSize) : DWGraph(8 * gridSize * gridSize) {
ChimeraGraph(int gridSize) : DWGraph(8 * gridSize * gridSize) {
// We are going to assign a tuple of ints to each vertex
std::map<std::tuple<int, int, int, int>, int> vertexTuples;
int i, j, k, l, v = 0;
......@@ -156,7 +157,7 @@ public:
}
}
virtual ~Chimera() {}
virtual ~ChimeraGraph() {}
};
}
......
......@@ -49,6 +49,8 @@ protected:
std::list<InstPtr> instructions;
std::string name;
public:
/**
......@@ -57,7 +59,7 @@ public:
* @param id
* @param name
*/
DWKernel() {
DWKernel(std::string kernelName) : name(kernelName) {
}
virtual const int nInstructions() {
......@@ -112,7 +114,7 @@ public:
* @return
*/
virtual const std::string getName() {
return "dw-kernel";
return name;
}
/**
......
......@@ -43,13 +43,13 @@ BOOST_AUTO_TEST_CASE(checkDWKernelConstruction) {
auto qmi2 = std::make_shared<DWQMI>(0);
auto qmi3 = std::make_shared<DWQMI>(22, 3.3);
DWKernel kernel;
DWKernel kernel("foo");
kernel.addInstruction(qmi);
kernel.addInstruction(qmi2);
kernel.addInstruction(qmi3);
BOOST_VERIFY(kernel.nInstructions() == 3);
BOOST_VERIFY(kernel.getName() == "dw-kernel");
BOOST_VERIFY(kernel.getName() == "foo");
BOOST_VERIFY(kernel.getInstruction(0) == qmi);
BOOST_VERIFY(kernel.getInstruction(1) == qmi2);
BOOST_VERIFY(kernel.getInstruction(2) == qmi3);
......
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