Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Simulator Refactor #386

Merged
merged 17 commits into from
Apr 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,8 @@ out/*

# CMake generates this file on the fly
setup.py
qiskit/backends/qiskit_simulator
qiskit/backends/qasm_simulator_cpp

src/qasm-simulator-cpp/test/qubit_vector_tests

*.o
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ jobs:
python: 3.6

# OSX, Python 3.latest (brew does not support versioning)
# - stage: test
# <<: *stage_osx
- stage: test
<<: *stage_osx

# "deploy" stage.
###########################################################################
Expand All @@ -168,11 +168,11 @@ jobs:
<<: *deploy_pypi

# OSX, Python 3.latest (brew does not support versions)
# - stage: deploy doc and pypi
# <<: *stage_osx
# if: branch = stable and repo = QISKit/qiskit-sdk-py and type = push
# install: mkdir out && cd out && cmake $CMAKE_FLAGS ..
# script: cd ..
# deploy:
# <<: *deploy_pypi
# distributions: "bdist_wheel"
- stage: deploy doc and pypi
<<: *stage_osx
if: branch = stable and repo = QISKit/qiskit-sdk-py and type = push
install: mkdir out && cd out && cmake $CMAKE_FLAGS ..
script: cd ..
deploy:
<<: *deploy_pypi
distributions: "bdist_wheel"
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (ENABLE_TARGETS_NON_PYTHON)
include(cmake/toolchain-utils.cmake)

# Add C++ Qiskit Simulator
add_subdirectory(${PROJECT_SOURCE_DIR}/src/qiskit-simulator)
add_subdirectory(${PROJECT_SOURCE_DIR}/src/qasm-simulator-cpp)

# Add Python distributable package generator
include(cmake/python-build.cmake)
Expand Down
6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include qiskit/qasm/libs/*.inc
recursive-include src/qiskit-simulator *
include qiskit/backends/qiskit_simulator
include qiskit/backends/qiskit_simulator.exe
recursive-include src/qasm-simulator-cpp *
include qiskit/backends/qasm_simulator_cpp
include qiskit/backends/qasm_simulator_cpp.exe
include qiskit/backends/*.dll
include CMakeLists.txt
include cmake/*.cmake
Expand Down
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,19 @@ doc:
done

sim:
make -C src/cpp-simulator/src clean
make -C src/cpp-simulator/src
make -C src/qasm-simulator-cpp/src clean
make -C src/qasm-simulator-cpp/src

# Build dependencies for the simulator target
depend:
make -C src/qasm-simulator-cpp depend

coverage_erase:
coverage erase

clean: coverage_erase
make -C doc clean
make -C doc -e BUILDDIR="_build/ja" -e SOURCEDIR="./ja" clean
make -C src/cpp-simulator/src clean
make -C src/qasm-simulator-cpp/src clean
rm -f test/python/test_latex_drawer.tex test/python/test_qasm_python_simulator.pdf \
test/python/test_save.json test/python/test_teleport.tex
22 changes: 11 additions & 11 deletions cmake/python-build.cmake
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,28 @@ function(add_pypi_package_target TARGET_NAME PACKAGE_TYPE)
add_custom_target(${TARGET_NAME_SDIST})
add_custom_command(TARGET ${TARGET_NAME_SDIST}
COMMAND ${CMAKE_COMMAND} -E remove
${CMAKE_CURRENT_SOURCE_DIR}/qiskit/backends/qiskit_simulator${EXECUTABLE_FILE_EXTENSION}
${CMAKE_CURRENT_SOURCE_DIR}/qiskit/backends/qasm_simulator_cpp${EXECUTABLE_FILE_EXTENSION}
COMMAND ${PYTHON} ${SETUP_PY} ${PIP_PACKAGE_SOURCE_DIST}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif()

if(PIP_PACKAGE_PLATFORM_WHEELS)
set(COPY_QISKIT_SIM_TARGET ${TARGET_NAME}_copy_qiskit_simulator)
set(COPY_QASM_SIM_CPP_TARGET ${TARGET_NAME}_copy_qasm_simulator_cpp)
# We create a target which will depend on TARGET_NAME_WHEELS for
# copying all the binaries to their final locations
add_custom_target(${COPY_QISKIT_SIM_TARGET})
add_custom_command(TARGET ${COPY_QISKIT_SIM_TARGET}
add_custom_target(${COPY_QASM_SIM_CPP_TARGET})
add_custom_command(TARGET ${COPY_QASM_SIM_CPP_TARGET}
COMMAND ${CMAKE_COMMAND} -E copy
${QISKIT_SIMULATOR_OUTPUT_DIR}/qiskit_simulator${EXECUTABLE_FILE_EXTENSION}
${QASM_SIMULATOR_CPP_OUTPUT_DIR}/qasm_simulator_cpp${EXECUTABLE_FILE_EXTENSION}
${CMAKE_CURRENT_SOURCE_DIR}/qiskit/backends)
# For ' make clean' target
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
${CMAKE_CURRENT_SOURCE_DIR}/qiskit/backends/qiskit_simulator${EXECUTABLE_FILE_EXTENSION})
${CMAKE_CURRENT_SOURCE_DIR}/qiskit/backends/qasm_simulator_cpp${EXECUTABLE_FILE_EXTENSION})
# For Windows, we need to copy external .dll dependencies too
if(MINGW)
foreach(dll_file ${QISKIT_SIMULATOR_THIRD_PARTY_DLLS})
add_custom_command(TARGET ${COPY_QISKIT_SIM_TARGET}
foreach(dll_file ${QASM_SIMULATOR_CPP_THIRD_PARTY_DLLS})
add_custom_command(TARGET ${COPY_QASM_SIM_CPP_TARGET}
COMMAND ${CMAKE_COMMAND} -E copy
${dll_file}
${CMAKE_CURRENT_SOURCE_DIR}/qiskit/backends)
Expand All @@ -91,14 +91,14 @@ function(add_pypi_package_target TARGET_NAME PACKAGE_TYPE)
if(PIP_PACKAGE_SOURCE_DIST)
add_dependencies(${TARGET_NAME}
${TARGET_NAME_SDIST}
qiskit_simulator)
qasm_simulator_cpp)
endif()

if(PIP_PACKAGE_PLATFORM_WHEELS)
add_dependencies(${TARGET_NAME}
${TARGET_NAME_WHEELS}
${COPY_QISKIT_SIM_TARGET}
qiskit_simulator)
${COPY_QASM_SIM_CPP_TARGET}
qasm_simulator_cpp)
endif()

endfunction()
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
sys.path.insert(0, os.path.abspath('.'))

# Imported manually, as otherwise it will not be fully imported.
import qiskit.extensions.qiskit_simulator
import qiskit.extensions.qasm_simulator_cpp

# -- General configuration ------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion qiskit/_quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def _gate_string(self, name):
if self.definitions[name]["opaque"]:
out += ";"
else:
out += "\n{\n" + self.definitions[name]["body"].qasm() + "}"
out += "\n{\n" + self.definitions[name]["body"].qasm() + "}\n"
return out

def qasm(self):
Expand Down
Loading