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

[WIP] Cython based building and linking of C++ simulator #387

Closed
wants to merge 3 commits into from

Conversation

chriseclectic
Copy link
Member

@chriseclectic chriseclectic commented Apr 4, 2018

Example of building and linking the C++ simulator using cython. Based on PR #386

Description

Adds an cython-build-example folder into the qasm-simulator-cpp folder which contains an example_setup.py script for building and wrapping the simulator using cython, and an example_simulation.py for running the simulator.

This can be run using

cd src/qasm_simulator_cpp/cython-build-example
python example_setup.py build_ext --inplace
python example_simulation.py

Motivation and Context

This allows cross platform building of the simulator by linking to the BLAS libraries already used by Numpy (such as MLK if python is installed with Anaconda).
It allows calling as a native python class without needing to use subprocess, and forwards C++ exceptions to python exceptions.

How Has This Been Tested?

  • It has been tested with a simple example script
  • The build has been tested on MacOS 10.13 building with xcode developer tools, homebrew gcc-7, and linking against anaconda MKL or apple accelerate framework, on Windows 10 using MSVC 2015 and anaconda MKL, on Ubuntu 16.04 using GCC 5 and anaconda MKL.

@nonhermitian
Copy link
Contributor

Not sure why the tests cannot find the qasm_simulator_cpp file. Builds and tests pass locally for me.

Copy link
Contributor

@nonhermitian nonhermitian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least with regards to the Cython wrapping, Chris and I tested it in every standard configuration possible, and it works.

The next step would be to either move to setuptools, or take the source generated by Cython and do the build via the make file.

@chriseclectic
Copy link
Member Author

Rebased after merge of #386

@diego-plan9
Copy link
Member

Closing after the discussion at the meeting, as it seems superseded by #412.

@diego-plan9 diego-plan9 closed this Jun 5, 2018
@chriseclectic chriseclectic deleted the cpp-cython-build branch September 14, 2018 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants