Build Everything from Source
Table of Contents ¶
- Install Dependencies
- XACC and QCOR on Ubuntu
- XACC and QCOR on Mac OS X and Linux x86_64 with Homebrew
- Build the LLVM Clang SyntaxHandler Fork
For the adventurous out there, or if your system does not support the above prebuilt binary instructions, you can build the AIDE-QC components from source.
Install Dependencies ¶
Run the package installer commands for your system to get all requisite dependencies:
OS | Command |
---|---|
Ubuntu 18.04 |
|
Ubuntu 20.04 |
|
Mac OS X Linux x86_64 (not Ubuntu) |
|
The following instructions assume that you have run the above commands for your OS to ensure all requisite dependencies are available.
XACC and QCOR on Ubuntu ¶
To build and install xacc
, run the following:
git clone --recursive https://github.com/aide-qc/xacc
cd xacc && mkdir build && cd build
cmake .. -G Ninja
# Optional flags
-DXACC_BUILD_TESTS=TRUE
-DCMAKE_INSTALL_PREFIX=/desired/path/to/install
-DXACC_BUILD_EXAMPLES=TRUE
# Build and install to $HOME/.xacc (if CMAKE_INSTALL_PREFIX not specified)
cmake --build . --target install
This will install xacc
to $HOME/.xacc
(by default, will be your specified CMAKE_INSTALL_PREFIX
if provided) with Python bindings for your python3
installation (from the above apt-get
dependencies install). You will need to set your PYTHONPATH
to the xacc
install directory in order to use the xacc
python bindings
export PYTHONPATH=$PYTHONPATH:$HOME/.xacc
It is usually a good idea to add this to your .bashrc
file.
Next, build and install qcor
:
(if in xacc/build) cd ../../
git clone https://github.com/aide-qc/qcor
cd qcor && mkdir build && cd build
cmake .. -G Ninja -DLLVM_ROOT=/usr/local/aideqc/llvm
# Optional flags
-DQCOR_BUILD_TESTS=TRUE
-DCMAKE_INSTALL_PREFIX=/desired/path/to/install
-DXACC_DIR=/path/to/xacc/install (if not $HOME/.xacc)
-DMLIR_DIR=/path/to/mlir/install/lib/cmake/mlir (if lib/cmake/mlir not in LLVM_ROOT)
# Build and install to $HOME/.xacc (if CMAKE_INSTALL_PREFIX not specified)
cmake --build . --target install
This will install qcor
to $HOME/.xacc
(by default, will be your specified CMAKE_INSTALL_PREFIX
if provided) with Python bindings for your python3
installation. Update your PYTHONPATH
if you did not install to $HOME/.xacc
. You will also want to update your PATH
variable to point to $HOME/.xacc/bin
or CMAKE_INSTALL_PREFIX/bin
export PATH=$PATH:$HOME/.xacc/bin
It is usually a good idea to add this command to your .bashrc
file.
Test out your install by compiling and executing the following simple qcor
code:
printf "__qpu__ void f(qreg q) {
H(q[0]);
Measure(q[0]);
}
int main() {
auto q = qalloc(1);
f(q);
q.print();
} " | qcor -qpu qpp -shots 1024 -x c++ -
./a.out
XACC and QCOR on Mac OS X and Linux x86_64 with Homebrew (not Ubuntu) ¶
To build xacc
git clone --recursive https://github.com/aide-qc/xacc
cd xacc && mkdir build && cd build
# Need to point build to Homebrew installed OpenSSL and Curl libs
cmake .. -DOPENSSL_ROOT_DIR=$(brew --prefix openssl) -DCMAKE_PREFIX_PATH=$(brew --prefix curl) -G Ninja
# Optional flags
-DXACC_BUILD_TESTS=TRUE
-DCMAKE_INSTALL_PREFIX=/desired/path/to/install
-DXACC_BUILD_EXAMPLES=TRUE
# Build and install to $HOME/.xacc (if CMAKE_INSTALL_PREFIX not specified)
cmake --build . --target install
This will install XACC to $HOME/.xacc
with Python bindings for your python3
installation (from the above brew
dependencies install, located in $(brew --prefix python3)
). You will need to set your PYTHONPATH
in order to use the XACC python bindings
export PYTHONPATH=$PYTHONPATH:$HOME/.xacc
It is usually a good idea to add this to your .bash_profile
file.
Next, build and install qcor
:
(if in xacc/build) cd ../../
git clone https://github.com/aide-qc/qcor
cd qcor && mkdir build && cd build
cmake .. -G Ninja \
-DLLVM_ROOT=$(brew --prefix llvm-csp) \
# Pass the next flags on Mac OS X only
-DQCOR_EXTRA_HEADERS="/Library/Developer/CommandLineTools/usr/include/c++/v1;/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
# Optional flags
-DQCOR_BUILD_TESTS=TRUE
-DCMAKE_INSTALL_PREFIX=/desired/path/to/install
-DXACC_DIR=/path/to/xacc/install (if not $HOME/.xacc)
-DMLIR_DIR=/path/to/mlir/install/lib/cmake/mlir (if lib/cmake/mlir not in LLVM_ROOT)
# Build and install to $HOME/.xacc (if CMAKE_INSTALL_PREFIX not specified)
cmake --build . --target install
This will install qcor
to $HOME/.xacc
, or CMAKE_INSTALL_PREFIX
if specified, with Python bindings for your python3
installation. Update your PYTHONPATH
if you did not install to $HOME/.xacc
. You will also want to update your PATH
variable to point to $HOME/.xacc/bin
or CMAKE_INSTALL_PREFIX/bin
export PATH=$PATH:$HOME/.xacc/bin
It is usually a good idea to add this command to your .bash_profile
file.
Test out your install by compiling and executing the following simple qcor
code:
printf "__qpu__ void f(qreg q) {
H(q[0]);
Measure(q[0]);
}
int main() {
auto q = qalloc(1);
f(q);
q.print();
} " | qcor -qpu qpp -shots 1024 -x c++ -
./a.out
Build the LLVM-CSP Fork ¶
NOTE: This is a long build and not recommended for most users. We have binaries built and distributed with
apt-get
and Homebrew, these should be your first choice. The following is mainly for book-keeping and due diligence.
If you would like to build a custom install of our LLVM fork containing the Clang SyntaxHandler
, run the following:
git clone https://github.com/ornl-qci/llvm-project-csp llvm
cd llvm && mkdir build && cd build
cmake ../llvm -G Ninja -DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DLLVM_ENABLE_DUMP=ON \
-DLLVM_ENABLE_PROJECTS="clang;mlir" \
-DCMAKE_INSTALL_PREFIX=$HOME/.llvm
cmake --build . --target install