Commit 1ca6e9f5 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

major core infrastructure updates, removed all of boost except graph. added...


major core infrastructure updates, removed all of boost except graph. added new variant tpl and cxxopts, updated optionsprovider

Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent ea52c33a
Pipeline #43697 failed with stages
in 4 minutes and 55 seconds
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
# Copyright (c) 2017 UT-Battelle, LLC. # Copyright (c) 2017 UT-Battelle, LLC.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# and Eclipse Distribution License v.10 which accompany this distribution. # and Eclipse Distribution License v.10 which accompany this distribution.
# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html # The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
# and the Eclipse Distribution License is available at # and the Eclipse Distribution License is available at
# https://eclipse.org/org/documents/edl-v10.php # https://eclipse.org/org/documents/edl-v10.php
# #
# Contributors: # Contributors:
# Alexander J. McCaskey - initial API and implementation # Alexander J. McCaskey - initial API and implementation
# *******************************************************************************/ # *******************************************************************************/
project(xacc LANGUAGES CXX) project(xacc LANGUAGES CXX)
cmake_minimum_required(VERSION 3.2 FATAL_ERROR) cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
...@@ -34,7 +34,7 @@ IF("${isSystemDir}" STREQUAL "-1") ...@@ -34,7 +34,7 @@ IF("${isSystemDir}" STREQUAL "-1")
ENDIF("${isSystemDir}" STREQUAL "-1") ENDIF("${isSystemDir}" STREQUAL "-1")
if (NOT CMAKE_BUILD_TYPE) if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug, Release, RelWithDebInfo, MinSizeRel" "Choose the type of build, options are: Debug, Release, RelWithDebInfo, MinSizeRel"
FORCE FORCE
) )
...@@ -70,53 +70,29 @@ endif() ...@@ -70,53 +70,29 @@ endif()
message(STATUS "${BoldGreen}Installing XACC to ${CMAKE_INSTALL_PREFIX}. Override with -DCMAKE_INSTALL_PREFIX=...${ColorReset}") message(STATUS "${BoldGreen}Installing XACC to ${CMAKE_INSTALL_PREFIX}. Override with -DCMAKE_INSTALL_PREFIX=...${ColorReset}")
if (XACC_BUILD_TESTS) #if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.0.0")
enable_testing() # set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wimplicit-fallthrough=0")
macro(add_xacc_test _TEST_NAME) #endif()
add_executable(${_TEST_NAME}Tester ${_TEST_NAME}Tester.cpp)
add_test(NAME xacc_${_TEST_NAME}Tester COMMAND ${_TEST_NAME}Tester)
target_link_libraries(${_TEST_NAME}Tester ${GTEST_LIBRARIES} xacc xacc-quantum-gate xacc-quantum-aqc)
endmacro()
macro(set_cache_variable VAR_NAME VAR_DESCRIPTION)
set(${VAR_NAME} ${${VAR_NAME}} CACHE INTERNAL ${VAR_DESCRIPTION})
message(STATUS "Set ${VAR_NAME} to ${${VAR_NAME}}.")
endmacro()
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.0.0")
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wimplicit-fallthrough=0")
endif()
include_directories(${CMAKE_BINARY_DIR}/tpls/cppmicroservices/include) include_directories(${CMAKE_BINARY_DIR}/tpls/cppmicroservices/include)
add_subdirectory(tpls) add_subdirectory(tpls)
include_directories(${CPR_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR}/tpls/spdlog)
include_directories(${CMAKE_SOURCE_DIR}/tpls/eigen)
set(XACC_HAS_ANTLR FALSE)
if(TARGET antlr4_shared)
message (STATUS "XACC Building with Antlr4 support")
set(XACC_HAS_ANTLR TRUE)
endif()
add_subdirectory(xacc) add_subdirectory(xacc)
add_subdirectory(quantum) add_subdirectory(quantum)
if(PYTHON_INCLUDE_DIR) if(PYTHON_INCLUDE_DIR)
add_subdirectory(python) add_subdirectory(python)
endif() endif()
# Install the config file for external projects to use # Install the config file for external projects to use
# This is cool, users just add find_package(XACC REQUIRED) to # This is cool, users just add find_package(XACC REQUIRED) to
# their CMake builds, and pass -DXACC_DIR=/path/to/install/xacc # their CMake builds, and pass -DXACC_DIR=/path/to/install/xacc
# and CMake loads include paths, libs, etc # and CMake loads include paths, libs, etc
configure_file("${CMAKE_SOURCE_DIR}/cmake/xacc-config.cmake.in" "${CMAKE_BINARY_DIR}/xacc-config.cmake" @ONLY) configure_file("${CMAKE_SOURCE_DIR}/cmake/xacc-config.cmake.in" "${CMAKE_BINARY_DIR}/xacc-config.cmake" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/xacc-config.cmake" DESTINATION .) install(FILES "${CMAKE_BINARY_DIR}/xacc-config.cmake" DESTINATION .)
install(FILES "${CMAKE_SOURCE_DIR}/cmake/Modules/tests.cmake" DESTINATION share/xacc/) install(FILES "${CMAKE_SOURCE_DIR}/cmake/Modules/tests.cmake" DESTINATION share/xacc/)
install(FILES "${CMAKE_SOURCE_DIR}/cmake/Modules/format.cmake" DESTINATION share/xacc/) install(FILES "${CMAKE_SOURCE_DIR}/cmake/Modules/format.cmake" DESTINATION share/xacc/)
install(FILES "${CMAKE_SOURCE_DIR}/tpls/mpark-variant/variant.hpp" DESTINATION include/xacc/)
install( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/spdlog" DESTINATION include ) install( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/spdlog" DESTINATION include )
install( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/exprtk" DESTINATION include ) install( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/exprtk" DESTINATION include )
install( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/eigen" DESTINATION include ) install( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/eigen" DESTINATION include )
......
# - Config file for XACC # - Config file for XACC
# To point to your install of XACC, pass the # To point to your install of XACC, pass the
# XACC_ROOT flag to your cmake configure. # XACC_ROOT flag to your cmake configure.
# #
# It defines the following variables # It defines the following variables
# XACC_INCLUDE_DIRS - include directories for XACC # XACC_INCLUDE_DIRS - include directories for XACC
# XACC_LIBRARIES - libraries to link against # XACC_LIBRARIES - libraries to link against
# XACC_LIBRARY_DIR - the XACC library directory # XACC_LIBRARY_DIR - the XACC library directory
include(CTest) include(CTest)
if (NOT XACC_ROOT) if (NOT XACC_ROOT)
get_filename_component(XACC_ROOT "${CMAKE_CURRENT_LIST_FILE}" PATH) get_filename_component(XACC_ROOT "${CMAKE_CURRENT_LIST_FILE}" PATH)
...@@ -18,13 +18,10 @@ set (XACC_LIBRARY_DIR "${XACC_ROOT}/lib") ...@@ -18,13 +18,10 @@ set (XACC_LIBRARY_DIR "${XACC_ROOT}/lib")
link_directories("${XACC_ROOT}/lib") link_directories("${XACC_ROOT}/lib")
set(XACC_INCLUDE_ROOT "${XACC_ROOT}/include") set(XACC_INCLUDE_ROOT "${XACC_ROOT}/include")
set(XACC_HAS_ANTLR @XACC_HAS_ANTLR@) set(XACC_HAS_ANTLR @XACC_HAS_ANTLR@)
if (${XACC_HAS_ANTLR})
set (XACC_INCLUDE_DIRS "${XACC_INCLUDE_ROOT}/antlr4-runtime;${XACC_INCLUDE_ROOT}/cppmicroservices4;${XACC_INCLUDE_ROOT}/xacc;${XACC_INCLUDE_ROOT}/quantum/gate;${XACC_INCLUDE_ROOT}/quantum/aqc;${XACC_INCLUDE_ROOT}/spdlog;${XACC_INCLUDE_ROOT}/exprtk;${XACC_INCLUDE_ROOT}/eigen;${XACC_INCLUDE_ROOT}/rapidjson/include;${XACC_INCLUDE_ROOT};${XACC_INCLUDE_ROOT}/gtest") set (XACC_INCLUDE_DIRS "${XACC_INCLUDE_ROOT}/antlr4-runtime;${XACC_INCLUDE_ROOT}/cppmicroservices4;${XACC_INCLUDE_ROOT}/xacc;${XACC_INCLUDE_ROOT}/quantum/gate;${XACC_INCLUDE_ROOT}/quantum/utils;${XACC_INCLUDE_ROOT}/quantum/aqc;${XACC_INCLUDE_ROOT}/spdlog;${XACC_INCLUDE_ROOT}/exprtk;${XACC_INCLUDE_ROOT}/eigen;${XACC_INCLUDE_ROOT}/rapidjson/include;${XACC_INCLUDE_ROOT};${XACC_INCLUDE_ROOT}/gtest")
set (XACC_LIBRARIES "xacc;xacc-quantum-gate;xacc-quantum-aqc;antlr4-runtime;CppMicroServices;boost_system;boost_filesystem;boost_regex;boost_graph;boost_program_options") set (XACC_LIBRARIES "xacc;xacc-quantum-gate;xacc-quantum-aqc;antlr4-runtime;CppMicroServices;boost_system;boost_filesystem;boost_regex;boost_graph;boost_program_options")
else()
set (XACC_INCLUDE_DIRS "${XACC_INCLUDE_ROOT}/cppmicroservices4;${XACC_INCLUDE_ROOT}/xacc;${XACC_INCLUDE_ROOT}/quantum/gate;${XACC_INCLUDE_ROOT}/quantum/aqc;${XACC_INCLUDE_ROOT}/spdlog;${XACC_INCLUDE_ROOT}/exprtk;${XACC_INCLUDE_ROOT}/eigen;${XACC_INCLUDE_ROOT}/rapidjson/include;${XACC_INCLUDE_ROOT};${XACC_INCLUDE_ROOT}/gtest")
set (XACC_LIBRARIES "xacc;xacc-quantum-gate;xacc-quantum-aqc;CppMicroServices;boost_system;boost_filesystem;boost_regex;boost_graph;boost_program_options")
endif()
set (XACC_TEST_LIBRARIES "${XACC_LIBRARIES};gtest;gtest_main") set (XACC_TEST_LIBRARIES "${XACC_LIBRARIES};gtest;gtest_main")
set(BOOST_ROOT ${XACC_ROOT}) set(BOOST_ROOT ${XACC_ROOT})
macro(add_xacc_test _TEST_NAME) macro(add_xacc_test _TEST_NAME)
......
...@@ -13,15 +13,15 @@ include_directories(${CMAKE_SOURCE_DIR}/tpls/exprtk) ...@@ -13,15 +13,15 @@ include_directories(${CMAKE_SOURCE_DIR}/tpls/exprtk)
include_directories(${CMAKE_SOURCE_DIR}/tpls/spdlog) include_directories(${CMAKE_SOURCE_DIR}/tpls/spdlog)
include_directories(${CMAKE_SOURCE_DIR}/tpls/eigen) include_directories(${CMAKE_SOURCE_DIR}/tpls/eigen)
include_directories(${CMAKE_SOURCE_DIR}/quantum/utils)
include_directories(${CMAKE_SOURCE_DIR}/quantum/aqc/ir) include_directories(${CMAKE_SOURCE_DIR}/quantum/aqc/ir)
include_directories(${CMAKE_SOURCE_DIR}/quantum/aqc/compiler) include_directories(${CMAKE_SOURCE_DIR}/quantum/aqc/compiler)
include_directories(${CMAKE_SOURCE_DIR}/quantum/gate/ir) include_directories(${CMAKE_SOURCE_DIR}/quantum/gate/ir)
include_directories(${CMAKE_SOURCE_DIR}/quantum/gate/ir/instructions) include_directories(${CMAKE_SOURCE_DIR}/quantum/gate/ir/instructions)
include_directories(${CMAKE_SOURCE_DIR}/quantum/gate/utils) include_directories(${CMAKE_SOURCE_DIR}/quantum/gate/utils)
if (${XACC_HAS_ANTLR})
add_subdirectory(compiler) add_subdirectory(compiler)
endif()
include_directories(${PYTHON_INCLUDE_DIR}) include_directories(${PYTHON_INCLUDE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/tpls/pybind11/include) include_directories(${CMAKE_SOURCE_DIR}/tpls/pybind11/include)
...@@ -35,7 +35,7 @@ add_library(_pyxacc SHARED xacc-py.cpp) ...@@ -35,7 +35,7 @@ add_library(_pyxacc SHARED xacc-py.cpp)
set_target_properties(_pyxacc PROPERTIES PREFIX "") set_target_properties(_pyxacc PROPERTIES PREFIX "")
target_link_libraries(_pyxacc PUBLIC CppMicroServices xacc) target_link_libraries(_pyxacc PUBLIC CppMicroServices xacc Boost::graph)
if(APPLE) if(APPLE)
set_target_properties(_pyxacc PROPERTIES INSTALL_RPATH "@loader_path/lib") set_target_properties(_pyxacc PROPERTIES INSTALL_RPATH "@loader_path/lib")
......
...@@ -67,19 +67,6 @@ public: ...@@ -67,19 +67,6 @@ public:
*/ */
virtual std::shared_ptr<xacc::IR> compile(const std::string &src); virtual std::shared_ptr<xacc::IR> compile(const std::string &src);
/**
* Return the command line options for this compiler
*
* @return options Description of command line options.
*/
virtual std::shared_ptr<options_description> getOptions() {
auto desc =
std::make_shared<options_description>("PyXACC Compiler Options");
return desc;
}
virtual bool handleOptions(variables_map &map) { return false; }
/** /**
* We don't allow translations for the PyXACC Compiler. * We don't allow translations for the PyXACC Compiler.
* @param bufferVariable * @param bufferVariable
......
...@@ -41,21 +41,21 @@ struct type_caster<Variant<Ts...>> : variant_caster<Variant<Ts...>> {}; ...@@ -41,21 +41,21 @@ struct type_caster<Variant<Ts...>> : variant_caster<Variant<Ts...>> {};
// of `visit` // of `visit`
template <> struct visit_helper<Variant> { template <> struct visit_helper<Variant> {
template <typename... Args> template <typename... Args>
static auto call(Args &&... args) -> decltype(boost::apply_visitor(args...)) { static auto call(Args &&... args) -> decltype(mpark::visit(args...)) {
return boost::apply_visitor(args...); return mpark::visit(args...);
} }
}; };
template <typename... Ts> template <typename... Ts>
struct type_caster<boost::variant<Ts...>> struct type_caster<mpark::variant<Ts...>>
: variant_caster<boost::variant<Ts...>> {}; : variant_caster<mpark::variant<Ts...>> {};
// Specifies the function used to visit the variant -- `apply_visitor` instead // Specifies the function used to visit the variant -- `apply_visitor` instead
// of `visit` // of `visit`
template <> struct visit_helper<boost::variant> { template <> struct visit_helper<mpark::variant> {
template <typename... Args> template <typename... Args>
static auto call(Args &&... args) -> decltype(boost::apply_visitor(args...)) { static auto call(Args &&... args) -> decltype(mpark::visit(args...)) {
return boost::apply_visitor(args...); return mpark::visit(args...);
} }
}; };
} // namespace detail } // namespace detail
...@@ -340,8 +340,8 @@ PYBIND11_MODULE(_pyxacc, m) { ...@@ -340,8 +340,8 @@ PYBIND11_MODULE(_pyxacc, m) {
(void (xacc::AcceleratorBuffer::*)(const std::string &)) & (void (xacc::AcceleratorBuffer::*)(const std::string &)) &
xacc::AcceleratorBuffer::appendMeasurement, xacc::AcceleratorBuffer::appendMeasurement,
"Append the measurement string") "Append the measurement string")
.def("getMeasurementStrings", .def("getMeasurements",
&xacc::AcceleratorBuffer::getMeasurementStrings, &xacc::AcceleratorBuffer::getMeasurements,
"Return observed measurement bit strings") "Return observed measurement bit strings")
.def("computeMeasurementProbability", .def("computeMeasurementProbability",
&xacc::AcceleratorBuffer::computeMeasurementProbability, &xacc::AcceleratorBuffer::computeMeasurementProbability,
...@@ -445,6 +445,8 @@ PYBIND11_MODULE(_pyxacc, m) { ...@@ -445,6 +445,8 @@ PYBIND11_MODULE(_pyxacc, m) {
m.def("Initialize", (void (*)()) & xacc::Initialize, m.def("Initialize", (void (*)()) & xacc::Initialize,
"Initialize the framework. Use this if there are no command line " "Initialize the framework. Use this if there are no command line "
"arguments to pass."); "arguments to pass.");
m.def("PyInitialize", &xacc::PyInitialize,
"Initialize the framework from Python.");
// m.def("help", ) // m.def("help", )
m.def("getAccelerator", m.def("getAccelerator",
(std::shared_ptr<xacc::Accelerator>(*)(const std::string &)) & (std::shared_ptr<xacc::Accelerator>(*)(const std::string &)) &
...@@ -472,18 +474,9 @@ PYBIND11_MODULE(_pyxacc, m) { ...@@ -472,18 +474,9 @@ PYBIND11_MODULE(_pyxacc, m) {
py::return_value_policy::reference, py::return_value_policy::reference,
"Return the IRGenerator of given name."); "Return the IRGenerator of given name.");
m.def("getConnectivity", m.def("getConnectivity",
[](const std::string acc) -> std::vector<std::vector<int>> { [](const std::string acc) -> std::vector<std::pair<int,int>> {
auto a = xacc::getAccelerator(acc); auto a = xacc::getAccelerator(acc);
auto connectivity = a->getAcceleratorConnectivity(); return a->getAcceleratorConnectivity();
std::vector<std::vector<int>> edges;
for (int i = 0; i < connectivity->order(); ++i) {
for (int j = i; j < connectivity->order(); ++j) {
if (connectivity->edgeExists(i, j)) {
edges.push_back({i, j});
}
}
}
return edges;
}); });
m.def("translate", &xacc::translate, m.def("translate", &xacc::translate,
"Translate the provided IR Function to the given language."); "Translate the provided IR Function to the given language.");
...@@ -647,7 +640,19 @@ PYBIND11_MODULE(_pyxacc, m) { ...@@ -647,7 +640,19 @@ PYBIND11_MODULE(_pyxacc, m) {
[](std::shared_ptr<Function> f, std::shared_ptr<Accelerator> acc, [](std::shared_ptr<Function> f, std::shared_ptr<Accelerator> acc,
const std::string algo) -> std::map<int, std::vector<int>> { const std::string algo) -> std::map<int, std::vector<int>> {
auto a = xacc::getService<xacc::quantum::EmbeddingAlgorithm>(algo); auto a = xacc::getService<xacc::quantum::EmbeddingAlgorithm>(algo);
auto hardware = acc->getAcceleratorConnectivity(); auto hardwareconnections = acc->getAcceleratorConnectivity();
std::set<int> nUniqueBits;
for (auto& edge : hardwareconnections) {
nUniqueBits.insert(edge.first);
nUniqueBits.insert(edge.second);
}
int nBits = *std::max_element(nUniqueBits.begin(), nUniqueBits.end()) + 1;
auto hardware = std::make_shared<AcceleratorGraph>(nBits);
for (auto& edge : hardwareconnections) {
hardware->addEdge(edge.first, edge.second);
}
int maxBitIdx = 0; int maxBitIdx = 0;
for (auto inst : f->getInstructions()) { for (auto inst : f->getInstructions()) {
......
...@@ -107,6 +107,7 @@ def initialize(): ...@@ -107,6 +107,7 @@ def initialize():
file.write(contents) file.write(contents)
file.close() file.close()
setIsPyApi() setIsPyApi()
PyInitialize(xaccLocation)
def setCredentials(opts): def setCredentials(opts):
...@@ -163,9 +164,9 @@ class DecoratorFunction(ABC): ...@@ -163,9 +164,9 @@ class DecoratorFunction(ABC):
self.__dict__.update(kwargs) self.__dict__.update(kwargs)
self.accelerator = None self.accelerator = None
self.src = '\n'.join(inspect.getsource(self.function).split('\n')[1:]) self.src = '\n'.join(inspect.getsource(self.function).split('\n')[1:])
self.processVariables() self.processVariables()
compiler = getCompiler('xacc-py') compiler = getCompiler('xacc-py')
if self.accelerator == None: if self.accelerator == None:
if 'accelerator' in self.kwargs: if 'accelerator' in self.kwargs:
...@@ -182,17 +183,17 @@ class DecoratorFunction(ABC): ...@@ -182,17 +183,17 @@ class DecoratorFunction(ABC):
else: else:
print('Setting accelerator: ', self.accelerator.name()) print('Setting accelerator: ', self.accelerator.name())
self.qpu = self.accelerator self.qpu = self.accelerator
ir = compiler.compile(self.src, self.qpu) ir = compiler.compile(self.src, self.qpu)
program = Program(self.qpu, ir) program = Program(self.qpu, ir)
self.compiledKernel = program.getKernels()[0] self.compiledKernel = program.getKernels()[0]
def overrideAccelerator(self, acc): def overrideAccelerator(self, acc):
self.accelerator = acc self.accelerator = acc
def processVariables(self): def processVariables(self):
g = re.findall('=(\w+)', self.src) g = re.findall('=(\w+)', self.src)
frame = inspect.currentframe() frame = inspect.currentframe()
for thing in g: for thing in g:
if thing in frame.f_back.f_locals['f'].__globals__: if thing in frame.f_back.f_locals['f'].__globals__:
if isinstance(frame.f_back.f_locals['f'].__globals__[thing], str): if isinstance(frame.f_back.f_locals['f'].__globals__[thing], str):
...@@ -200,8 +201,8 @@ class DecoratorFunction(ABC): ...@@ -200,8 +201,8 @@ class DecoratorFunction(ABC):
else: else:
real = str(frame.f_back.f_locals['f'].__globals__[thing]) real = str(frame.f_back.f_locals['f'].__globals__[thing])
self.src = self.src.replace('='+thing, '='+real) self.src = self.src.replace('='+thing, '='+real)
del frame del frame
def nParameters(self): def nParameters(self):
return self.getFunction().nParameters() return self.getFunction().nParameters()
......
...@@ -2,31 +2,36 @@ ...@@ -2,31 +2,36 @@
# Copyright (c) 2017 UT-Battelle, LLC. # Copyright (c) 2017 UT-Battelle, LLC.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# and Eclipse Distribution License v.10 which accompany this distribution. # and Eclipse Distribution License v.10 which accompany this distribution.
# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html # The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
# and the Eclipse Distribution License is available at # and the Eclipse Distribution License is available at
# https://eclipse.org/org/documents/edl-v10.php # https://eclipse.org/org/documents/edl-v10.php
# #
# Contributors: # Contributors:
# Alexander J. McCaskey - initial API and implementation # Alexander J. McCaskey - initial API and implementation
# *******************************************************************************/ # *******************************************************************************/
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_BINARY_DIR}/tpls/cppmicroservices") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_BINARY_DIR}/tpls/cppmicroservices")
include(CppMicroServicesConfig) include(CppMicroServicesConfig)
include_directories(${CMAKE_BINARY_DIR}) #include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/xacc) #include_directories(${CMAKE_SOURCE_DIR}/xacc)
include_directories(${CMAKE_SOURCE_DIR}/xacc/ir) #include_directories(${CMAKE_SOURCE_DIR}/xacc/ir)
include_directories(${CMAKE_SOURCE_DIR}/xacc/compiler) #include_directories(${CMAKE_SOURCE_DIR}/xacc/compiler)
include_directories(${CMAKE_SOURCE_DIR}/xacc/program) #include_directories(${CMAKE_SOURCE_DIR}/xacc/program)
include_directories(${CMAKE_SOURCE_DIR}/xacc/accelerator) #include_directories(${CMAKE_SOURCE_DIR}/xacc/accelerator)
include_directories(${CMAKE_SOURCE_DIR}/xacc/utils) #include_directories(${CMAKE_SOURCE_DIR}/xacc/utils)
include_directories(${CMAKE_SOURCE_DIR}/tpls/rapidjson/include) #include_directories(${CMAKE_SOURCE_DIR}/tpls/rapidjson/include)
include_directories(${CMAKE_SOURCE_DIR}/tpls/exprtk) #include_directories(${CMAKE_SOURCE_DIR}/tpls/exprtk)
include_directories(${CMAKE_SOURCE_DIR}/tpls/spdlog) #include_directories(${CMAKE_SOURCE_DIR}/tpls/spdlog)
include_directories(${CMAKE_SOURCE_DIR}/tpls/eigen) #include_directories(${CMAKE_SOURCE_DIR}/tpls/eigen)
include_directories(${GTEST_INCLUDE_DIRS}) #include_directories(${GTEST_INCLUDE_DIRS})
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/utils)
add_subdirectory(utils)
add_subdirectory(gate) add_subdirectory(gate)
add_subdirectory(aqc) add_subdirectory(aqc)
file (GLOB HEADERS utils/*.hpp)
install(FILES ${HEADERS} DESTINATION include/quantum/utils)
# ******************************************************************************* # ******************************************************************************
# Copyright (c) 2017 UT-Battelle, LLC. # * Copyright (c) 2017 UT-Battelle, LLC. All rights reserved. This program and
# All rights reserved. This program and the accompanying materials # the accompanying materials are made available under the terms of the Eclipse
# are made available under the terms of the Eclipse Public License v1.0 # Public License v1.0 and Eclipse Distribution License v.10 which accompany
# and Eclipse Distribution License v.10 which accompany this distribution. # this distribution. The Eclipse Public License is available at
# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html # http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
# and the Eclipse Distribution License is available at # License is available at https://eclipse.org/org/documents/edl-v10.php
# https://eclipse.org/org/documents/edl-v10.php
# #
# Contributors: # Contributors: Alexander J. McCaskey - initial API and implementation
# Alexander J. McCaskey - initial API and implementation # ******************************************************************************
# *******************************************************************************/ # */
set (LIBRARY_NAME xacc-quantum-aqc) set(LIBRARY_NAME xacc-quantum-aqc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ir) # include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ir)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/compiler) # include_directories(${CMAKE_CURRENT_SOURCE_DIR}/compiler)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/compiler/default) # include_directories(${CMAKE_CURRENT_SOURCE_DIR}/compiler/default)
file (GLOB_RECURSE HEADERS *.hpp) file(GLOB_RECURSE HEADERS *.hpp)
file (GLOB SRC *.cpp ir/*.cpp compiler/default/*.cpp) file(GLOB SRC
*.cpp
ir/*.cpp
compiler/default/*.cpp)
add_library(${LIBRARY_NAME} SHARED ${SRC})
target_include_directories(${LIBRARY_NAME}
PRIVATE ir
compiler
compiler/default
${CMAKE_SOURCE_DIR}/quantum/utils
${CMAKE_SOURCE_DIR}/tpls/exprtk
${CMAKE_BINARY_DIR})
# Set up dependencies to resources to track changes # Set up dependencies to resources to track changes
usFunctionGetResourceSource(TARGET ${LIBRARY_NAME} OUT SRC) usfunctiongetresourcesource(TARGET ${LIBRARY_NAME} OUT SRC)
# Generate bundle initialization code # Generate bundle initialization code
usFunctionGenerateBundleInit(TARGET ${LIBRARY_NAME} OUT SRC) usfunctiongeneratebundleinit(TARGET ${LIBRARY_NAME} OUT SRC)
#---- # ----
add_library(${LIBRARY_NAME} SHARED ${SRC})
set(_bundle_name xacc_quantum_aqc) set(_bundle_name xacc_quantum_aqc)
set_target_properties(${LIBRARY_NAME} PROPERTIES set_target_properties(${LIBRARY_NAME}
# This is required for every bundle PROPERTIES # This is required for every bundle
COMPILE_DEFINITIONS US_BUNDLE_NAME=${_bundle_name} COMPILE_DEFINITIONS
# This is for convenience, used by other CMake functions US_BUNDLE_NAME=${_bundle_name}
US_BUNDLE_NAME ${_bundle_name} # This is for convenience, used by other CMake
) # functions
US_BUNDLE_NAME ${_bundle_name})
#if(BUILD_SHARED_LIBS)
# set_target_properties(${LIBRARY_NAME} PROPERTIES
# CXX_VISIBILITY_PRESET hidden
# VISIBILITY_INLINES_HIDDEN 1
# )
#endif()
# Embed meta-data from a manifest.json file # Embed meta-data from a manifest.json file
usFunctionEmbedResources(TARGET ${LIBRARY_NAME} usfunctionembedresources(TARGET
WORKING_DIRECTORY ${LIBRARY_NAME}
${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY
FILES ${CMAKE_CURRENT_SOURCE_DIR}
manifest.json FILES
) manifest.json)
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc) target_link_libraries(${LIBRARY_NAME} PUBLIC xacc Boost::graph)
if(APPLE) if(APPLE)
set_target_properties(xacc-quantum-aqc PROPERTIES INSTALL_RPATH "@loader_path") set_target_properties(xacc-quantum-aqc
set_target_properties(xacc-quantum-aqc PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") PROPERTIES INSTALL_RPATH "@loader_path")
set_target_properties(xacc-quantum-aqc
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else() else()
set_target_properties(xacc-quantum-aqc PROPERTIES INSTALL_RPATH "$ORIGIN") set_target_properties(xacc-quantum-aqc PROPERTIES INSTALL_RPATH "$ORIGIN")
set_target_properties(xacc-quantum-aqc PROPERTIES LINK_FLAGS "-shared") set_target_properties(xacc-quantum-aqc PROPERTIES LINK_FLAGS "-shared")
endif() endif()
add_subdirectory(ir) add_subdirectory(ir)
...@@ -66,5 +71,3 @@ add_subdirectory(compiler) ...@@ -66,5 +71,3 @@ add_subdirectory(compiler)
install(FILES ${HEADERS} DESTINATION include/quantum/aqc) install(FILES ${HEADERS} DESTINATION include/quantum/aqc)
install(TARGETS ${LIBRARY_NAME} DESTINATION lib) install(TARGETS ${LIBRARY_NAME} DESTINATION lib)