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

Fixing minor bugs, left out scaffold registerCompiler

parent 282edf72
......@@ -29,7 +29,7 @@
*
**********************************************************************************/
#ifndef QUANTUM_GATE_ACCELERATORS_QPUGATE_HPP_
#define QUANTUM_GATE_ACCELERATORS_QPU_HPP_
#define QUANTUM_GATE_ACCELERATORS_QPUGATE_HPP_
#include "Accelerator.hpp"
......
/***********************************************************************************
* Copyright (c) 2016, UT-Battelle
* Copyright (c) 2017, UT-Battelle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -32,19 +32,12 @@
#define QUANTUM_GATE_ACCELERATORS_EIGENACCELERATOR_HPP_
#include <boost/dll/alias.hpp>
#include "Hadamard.hpp"
#include "Measure.hpp"
#include "CNOT.hpp"
#include "Rz.hpp"
#include "Z.hpp"
#include "X.hpp"
#include "ConditionalFunction.hpp"
#include "Z.hpp"
#include "QPUGate.hpp"
#include "QuantumCircuit.hpp"
#include "SimulatedQubits.hpp"
#include <random>
#include "InstructionIterator.hpp"
#include "FunctionalGateInstructionVisitor.hpp"
#include <random>
using namespace xacc;
......@@ -55,50 +48,6 @@ double sqrt2 = std::sqrt(2.0);
using ProductList = std::vector<fire::Tensor<2, fire::EigenProvider, std::complex<double>>>;
using ComplexTensor = fire::Tensor<2, fire::EigenProvider, std::complex<double>>;
class FunctionalGateInstructionVisitor: public BaseInstructionVisitor,
public InstructionVisitor<CNOT>,
public InstructionVisitor<Hadamard>,
public InstructionVisitor<X>,
public InstructionVisitor<Z>,
public InstructionVisitor<Measure>,
public InstructionVisitor<ConditionalFunction> {
protected:
std::function<void(Hadamard&)> hAction;
std::function<void(CNOT&)> cnotAction;
std::function<void(X&)> xAction;
std::function<void(Z&)> zAction;
std::function<void(Measure&)> measureAction;
std::function<void(ConditionalFunction&)> condAction;
public:
template<typename HF, typename CNF, typename XF, typename MF, typename ZF,
typename CF>
FunctionalGateInstructionVisitor(HF h, CNF cn, XF x, MF m, ZF z, CF c) :
hAction(h), cnotAction(cn), xAction(x), zAction(z), measureAction(
m), condAction(c) {
}
void visit(Hadamard& h) {
hAction(h);
}
void visit(CNOT& cn) {
cnotAction(cn);
}
void visit(X& x) {
xAction(x);
}
void visit(Z& z) {
zAction(z);
}
void visit(Measure& m) {
measureAction(m);
}
void visit(ConditionalFunction& c) {
condAction(c);
}
virtual ~FunctionalGateInstructionVisitor() {}
};
/**
* The FireTensorAccelerator is an XACC Accelerator that simulates
* gate based quantum computing circuits. It models the QPUGate Accelerator
......@@ -148,10 +97,14 @@ public:
*/
virtual void execute(std::shared_ptr<AcceleratorBuffer> buffer, const std::shared_ptr<xacc::Function> kernel);
/**
* Register this Accelerator with the framework.
*/
static void registerAccelerator() {
xacc::RegisterAccelerator<xacc::quantum::FireTensorAccelerator> FIRETEMP(
"firetensor");
}
/**
* The destructor
*/
......@@ -159,6 +112,7 @@ public:
};
// Create an alias to search for.
BOOST_DLL_ALIAS(
xacc::quantum::FireTensorAccelerator::registerAccelerator,
registerAccelerator
......
/***********************************************************************************
* Copyright (c) 2017, UT-Battelle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the xacc nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Contributors:
* Initial API and implementation - Alex McCaskey
*
**********************************************************************************/
#ifndef FUNCTIONALGATEINSTRUCTIONVISITOR_HPP_
#define FUNCTIONALGATEINSTRUCTIONVISITOR_HPP_
#include "Hadamard.hpp"
#include "Measure.hpp"
#include "CNOT.hpp"
#include "Rz.hpp"
#include "Z.hpp"
#include "X.hpp"
#include "ConditionalFunction.hpp"
#include "Z.hpp"
using namespace xacc;
namespace xacc {
namespace quantum {
class FunctionalGateInstructionVisitor: public BaseInstructionVisitor,
public InstructionVisitor<CNOT>,
public InstructionVisitor<Hadamard>,
public InstructionVisitor<X>,
public InstructionVisitor<Z>,
public InstructionVisitor<Measure>,
public InstructionVisitor<ConditionalFunction> {
protected:
std::function<void(Hadamard&)> hAction;
std::function<void(CNOT&)> cnotAction;
std::function<void(X&)> xAction;
std::function<void(Z&)> zAction;
std::function<void(Measure&)> measureAction;
std::function<void(ConditionalFunction&)> condAction;
public:
template<typename HF, typename CNF, typename XF, typename MF, typename ZF,
typename CF>
FunctionalGateInstructionVisitor(HF h, CNF cn, XF x, MF m, ZF z, CF c) :
hAction(h), cnotAction(cn), xAction(x), zAction(z), measureAction(
m), condAction(c) {
}
void visit(Hadamard& h) {
hAction(h);
}
void visit(CNOT& cn) {
cnotAction(cn);
}
void visit(X& x) {
xAction(x);
}
void visit(Z& z) {
zAction(z);
}
void visit(Measure& m) {
measureAction(m);
}
void visit(ConditionalFunction& c) {
condAction(c);
}
virtual ~FunctionalGateInstructionVisitor() {}
};
}
}
#endif
......@@ -30,7 +30,7 @@
**********************************************************************************/
#include <regex>
#include "GateQIR.hpp"
#include "Scaffold.hpp"
#include "ScaffoldCompiler.hpp"
using namespace clang;
......@@ -169,7 +169,6 @@ std::shared_ptr<IR> ScaffoldCompiler::compile(const std::string& src) {
auto qir = std::make_shared<GateQIR>();
std::cout << "HELLO WORLD ADDING : " << qirFunction->getName() << "\n";
qir->addKernel(qirFunction);
return qir;
......@@ -178,5 +177,5 @@ std::shared_ptr<IR> ScaffoldCompiler::compile(const std::string& src) {
}
}
static xacc::RegisterCompiler<xacc::quantum::ScaffoldCompiler> X(
"scaffold");
//static xacc::RegisterCompiler<xacc::quantum::ScaffoldCompiler> X(
// "scaffold");
......@@ -34,6 +34,7 @@
#include "Compiler.hpp"
#include "Utils.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/dll/alias.hpp>
#include "ScaffoldASTConsumer.hpp"
#include "Accelerator.hpp"
......@@ -78,6 +79,14 @@ public:
return "Scaffold";
}
/**
* Register this Compiler with the framework.
*/
static void registerCompiler() {
xacc::RegisterCompiler<xacc::quantum::ScaffoldCompiler> Scaffold(
"scaffold");
}
/**
* The destructor
*/
......@@ -98,6 +107,14 @@ protected:
};
// Create an alias to search for.
BOOST_DLL_ALIAS(
xacc::quantum::ScaffoldCompiler::registerCompiler,
registerCompiler
)
}
}
......
......@@ -33,7 +33,7 @@
#define BOOST_TEST_MODULE ScaffoldCompilerTester
#include <boost/test/included/unit_test.hpp>
#include "Scaffold.hpp"
#include "ScaffoldCompiler.hpp"
#include "GateQIR.hpp"
using namespace xacc::quantum;
......
Supports Markdown
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