Commit 029affec authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

fixing bug in lambda visitor test, moved algorithm and optimizer to xacc


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent c17b8200
Pipeline #78610 canceled with stage
......@@ -16,21 +16,10 @@ QCORASTConsumer::QCORASTConsumer(CompilerInstance &c, Rewriter &rw)
rewriter(rw) {}
bool QCORASTConsumer::HandleTopLevelDecl(DeclGroupRef DR) {
using namespace std::chrono;
auto start = std::chrono::high_resolution_clock::now();
LambdaVisitor visitor(ci, rewriter);
for (DeclGroupRef::iterator b = DR.begin(), e = DR.end(); b != e; ++b) {
// if (std::string((*b)->getDeclKindName()) == "Function") {
// std::cout << (*b)->getDeclKindName() << "\n";
// (*b)->dumpColor();
visitor.TraverseDecl(*b);
// }
}
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<microseconds>(stop - start);
// std::cout << "Visitor time: " << duration.count() << ", " << std::endl;
return true;
}
} // namespace compiler
......
......@@ -69,6 +69,7 @@ protected:
for (auto& p : pragmaHandlers) {
CI.getSema().getPreprocessor().RemovePragmaHandler(p.get());
}
CI.getDiagnosticClient().EndSourceFile();
std::string outName(fileName);
......
......@@ -49,6 +49,7 @@ protected:
CompilerInstance &CI = getCompilerInstance();
CI.createSema(getTranslationUnitKind(), nullptr);
compiler::FuzzyParsingExternalSemaSource fuzzyParser;
fuzzyParser.initialize();
fuzzyParser.setASTContext(&CI.getASTContext());
CI.getSema().addExternalSource(&fuzzyParser);
......
......@@ -31,9 +31,9 @@ else()
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-shared")
endif()
file(GLOB HEADERS *.hpp)
file(GLOB HEADERS qcor.hpp qpu_handler.hpp)
install(FILES ${HEADERS} DESTINATION include/qcor)
install(TARGETS ${LIBRARY_NAME} DESTINATION lib)
add_subdirectory(algorithms)
add_subdirectory(nlopt-optimizers)
\ No newline at end of file
#add_subdirectory(algorithms)
#add_subdirectory(nlopt-optimizers)
\ No newline at end of file
......@@ -200,7 +200,7 @@ submit(HandlerLambda &&totalJob, std::shared_ptr<AcceleratorBuffer> buffer) {
std::shared_ptr<Optimizer> getOptimizer(const std::string &name) {
return xacc::getService<qcor::Optimizer>(name);
return xacc::getService<xacc::Optimizer>(name);
}
std::shared_ptr<Optimizer>
getOptimizer(const std::string &name,
......@@ -241,8 +241,8 @@ getObservable(const std::string &type,
observable->fromOptions(options);
return observable;
}
std::shared_ptr<algorithm::Algorithm> getAlgorithm(const std::string name) {
return xacc::getService<qcor::algorithm::Algorithm>(name);
std::shared_ptr<xacc::Algorithm> getAlgorithm(const std::string name) {
return xacc::getService<xacc::Algorithm>(name);
}
} // namespace qcor
......@@ -3,8 +3,8 @@
#include <future>
#include "optimizer.hpp"
#include "algorithm.hpp"
#include "Optimizer.hpp"
#include "Algorithm.hpp"
#include "Observable.hpp"
......@@ -54,7 +54,7 @@ std::shared_ptr<Observable> getObservable();
std::shared_ptr<Observable> getObservable(const std::string &representation);
std::shared_ptr<Observable> getObservable(const std::string &type, std::map<std::string, InstructionParameter> &&options);
std::shared_ptr<algorithm::Algorithm> getAlgorithm(const std::string name);
std::shared_ptr<Algorithm> getAlgorithm(const std::string name);
} // namespace qcor
#include "qpu_handler.hpp"
......
......@@ -32,8 +32,10 @@ public:
}
auto vqeAlgo = qcor::getAlgorithm("vqe");
vqeAlgo->initialize(function, accelerator, buffer);
vqeAlgo->execute(*observable.get(), *optimizer.get());
if(!vqeAlgo->initialize({{"ansatz",function}, {"accelerator",accelerator}, {"observable",observable},{"optimizer",optimizer}})) {
xacc::error("Error initializing VQE algorithm.");
}
vqeAlgo->execute(buffer);
}
template <typename QuantumKernel> void execute(QuantumKernel &&kernel) {
......
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