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