diff --git a/.bazelrc b/.bazelrc index 79fe3007b..16c8a51dc 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,6 +1,7 @@ # Default build options -build --copt -std=c++11 -build --copt -D_GLIBCXX_USE_CXX11_ABI=0 +build --copt -std=c++17 +build --copt -D_GLIBCXX_USE_CXX11_ABI=1 +build --experimental_repo_remote_exec ##### Sanitizers (choose one, or nosan for none) ##### @@ -55,3 +56,7 @@ build:malloc -- # Test flags test --test_output=errors + +# CUDA options +build:cuda --@local_config_cuda//:enable_cuda +build:cuda --define=using_cuda=true --define=using_cuda_nvcc=true diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 000000000..831446cbd --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +5.1.0 diff --git a/.github/workflows/bazeltest.yml b/.github/workflows/bazeltest.yml index 5284ca3de..6eb6a2611 100644 --- a/.github/workflows/bazeltest.yml +++ b/.github/workflows/bazeltest.yml @@ -9,7 +9,7 @@ on: pull_request: jobs: - # Run tests with Bazel v0.26. + # Run tests with Bazel v5.3.0. test: name: Test with Bazel runs-on: ubuntu-20.04 @@ -26,8 +26,11 @@ jobs: run: git submodule update --init --recursive - name: Install Bazel on CI run: | - wget https://github.com/bazelbuild/bazel/releases/download/3.7.2/bazel_3.7.2-linux-x86_64.deb - sudo dpkg -i bazel_3.7.2-linux-x86_64.deb + wget https://github.com/bazelbuild/bazel/releases/download/5.3.0/bazel_5.3.0-linux-x86_64.deb + sudo dpkg -i bazel_5.3.0-linux-x86_64.deb + - name: Install requirements + run: | + python3 -m pip install -r requirements.txt - name: Run C++ tests run: | bazel test --config=${{ matrix.hardware_opt }} \ @@ -52,8 +55,11 @@ jobs: run: git submodule update --init --recursive - name: Install Bazel on CI run: | - wget https://github.com/bazelbuild/bazel/releases/download/3.7.2/bazel_3.7.2-linux-x86_64.deb - sudo dpkg -i bazel_3.7.2-linux-x86_64.deb + wget https://github.com/bazelbuild/bazel/releases/download/5.3.0/bazel_5.3.0-linux-x86_64.deb + sudo dpkg -i bazel_5.3.0-linux-x86_64.deb + - name: Install requirements + run: | + python3 -m pip install -r requirements.txt - name: Run C++ tests run: | bazel test --config=avx --config=openmp \ @@ -69,8 +75,11 @@ jobs: run: git submodule update --init --recursive - name: Install Bazel on CI run: | - wget https://github.com/bazelbuild/bazel/releases/download/3.7.2/bazel_3.7.2-linux-x86_64.deb - sudo dpkg -i bazel_3.7.2-linux-x86_64.deb + wget https://github.com/bazelbuild/bazel/releases/download/5.3.0/bazel_5.3.0-linux-x86_64.deb + sudo dpkg -i bazel_5.3.0-linux-x86_64.deb + - name: Install requirements + run: | + python3 -m pip install -r requirements.txt - name: Install google-perftools for tcmalloc run: sudo apt-get install libgoogle-perftools-dev - name: Run C++ tests diff --git a/.github/workflows/release_wheels.yml b/.github/workflows/release_wheels.yml index 735079ade..5463f5ce1 100644 --- a/.github/workflows/release_wheels.yml +++ b/.github/workflows/release_wheels.yml @@ -49,6 +49,9 @@ jobs: - name: Install cibuildwheel and twine run: python -m pip install cibuildwheel==2.2.2 + - name: Install requirements + run: python -m pip install -r requirements.txt + - name: Run C++ tests run: bash build_tools/test_libs.sh diff --git a/.github/workflows/testing_wheels.yml b/.github/workflows/testing_wheels.yml index 7c4aa911d..e63671f58 100644 --- a/.github/workflows/testing_wheels.yml +++ b/.github/workflows/testing_wheels.yml @@ -54,6 +54,9 @@ jobs: - name: Install cibuildwheel and twine run: python -m pip install cibuildwheel==2.2.2 + - name: Install requirements + run: python -m pip install -r requirements.txt + - name: Run C++ tests run: bash build_tools/test_libs.sh diff --git a/.gitignore b/.gitignore index c71e8399f..4ef0dcb89 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,9 @@ bazel-* # Eigen library eigen + +# vscode +.vscode/* + +# Bazel files +/bazel-* \ No newline at end of file diff --git a/Makefile b/Makefile index 7cdaa4149..2a585b5ce 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -EIGEN_PREFIX = "d10b27fe37736d2944630ecd7557cefa95cf87c9" +EIGEN_PREFIX = "3bb6a48d8c171cf20b5f8e48bfb4e424fbd4f79e" EIGEN_URL = "https://gitlab.com/libeigen/eigen/-/archive/" TARGETS = qsim diff --git a/WORKSPACE b/WORKSPACE index f85022766..15b3d57c8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -20,16 +20,32 @@ http_archive( # https://github.com/tensorflow/quantum http_archive( name = "org_tensorflow", - sha256 = "e82f3b94d863e223881678406faa5071b895e1ff928ba18578d2adbbc6b42a4c", - strip_prefix = "tensorflow-2.1.0", + sha256 = "e52cda3bae45f0ae0fccd4055e9fa29892b414f70e2df94df9a3a10319c75fff", + strip_prefix = "tensorflow-2.11.0", urls = [ - "https://github.com/tensorflow/tensorflow/archive/v2.1.0.zip", + "https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.11.0.zip", ], ) +load("@org_tensorflow//tensorflow:workspace3.bzl", "workspace") -EIGEN_COMMIT = "12e8d57108c50d8a63605c6eb0144c838c128337" -EIGEN_SHA256 = "f689246e342c3955af48d26ce74ac34d21b579a00675c341721a735937919b02" +workspace() + +load("@org_tensorflow//tensorflow:workspace2.bzl", "workspace") + +workspace() + +load("@org_tensorflow//tensorflow:workspace1.bzl", "workspace") + +workspace() + +load("@org_tensorflow//tensorflow:workspace0.bzl", "workspace") + +workspace() + + +EIGEN_COMMIT = "3bb6a48d8c171cf20b5f8e48bfb4e424fbd4f79e" +EIGEN_SHA256 = "eca9847b3fe6249e0234a342b78f73feec07d29f534e914ba5f920f3e09383a3" http_archive( diff --git a/build_tools/test_libs.sh b/build_tools/test_libs.sh old mode 100644 new mode 100755 index cfb90f66c..e360f0290 --- a/build_tools/test_libs.sh +++ b/build_tools/test_libs.sh @@ -19,7 +19,7 @@ fi set e # Ignore errors until artifacts are collected. EXIT_CODE=0 for TARGET in bitstring_test channels_cirq_test circuit_qsim_parser_test expect_test \ - fuser_basic_test gates_qsim_test hybrid_test matrix_test qtrajectory_test \ + fuser_basic_test gates_qsim_test hybrid_avx_test matrix_test qtrajectory_avx_test \ run_qsim_test run_qsimh_test simulator_basic_test simulator_sse_test statespace_basic_test \ statespace_sse_test unitary_calculator_basic_test unitary_calculator_sse_test \ unitaryspace_basic_test unitaryspace_sse_test vectorspace_test; do \ diff --git a/lib/BUILD b/lib/BUILD index 9be39dea9..452de649f 100644 --- a/lib/BUILD +++ b/lib/BUILD @@ -1,3 +1,5 @@ +load("@local_config_cuda//cuda:build_defs.bzl", "cuda_library") + package(default_visibility = ["//visibility:public"]) # Libraries of the following form: @@ -67,8 +69,7 @@ cc_library( ) # Full qsim library, including CUDA -# cuda_library -cc_library( +cuda_library( name = "qsim_cuda_lib", hdrs = [ "bits.h", @@ -247,8 +248,7 @@ cc_library( hdrs = ["util_cpu.h"], ) -# cuda_library -cc_library( +cuda_library( name = "util_cuda", hdrs = ["util_cuda.h"], ) @@ -408,8 +408,7 @@ cc_library( hdrs = ["vectorspace.h"], ) -# cuda_library -cc_library( +cuda_library( name = "vectorspace_cuda", hdrs = ["vectorspace_cuda.h"], ) @@ -462,8 +461,7 @@ cc_library( ], ) -# cuda_library -cc_library( +cuda_library( name = "statespace_cuda", hdrs = [ "statespace_cuda.h", @@ -520,8 +518,7 @@ cc_library( ], ) -# cuda_library -cc_library( +cuda_library( name = "simulator_cuda", hdrs = [ "simulator_cuda.h", diff --git a/pybind_interface/Makefile b/pybind_interface/Makefile index 8450bd17b..1a3ca4ae0 100644 --- a/pybind_interface/Makefile +++ b/pybind_interface/Makefile @@ -14,7 +14,7 @@ PYBINDFLAGS_AVX2 = -mavx2 -mfma -Wall -shared -std=c++17 -fPIC `python3 -m pybin PYBINDFLAGS_AVX512 = -mavx512f -mbmi2 -Wall -shared -std=c++17 -fPIC `python3 -m pybind11 --includes` # The flags for the compilation of GPU-specific Pybind11 interfaces -PYBINDFLAGS_CUDA = -std=c++14 -x cu -Xcompiler "-Wall -shared -fPIC `python3 -m pybind11 --includes`" +PYBINDFLAGS_CUDA = -std=c++17 -x cu -Xcompiler "-Wall -shared -fPIC `python3 -m pybind11 --includes`" # The flags for the compilation of cuStateVec-specific Pybind11 interfaces PYBINDFLAGS_CUSTATEVEC = $(CUSTATEVECFLAGS) $(PYBINDFLAGS_CUDA) diff --git a/requirements.txt b/requirements.txt index 26173852a..056b76c61 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ absl-py cirq-core~=1.0 -numpy~=1.16 +numpy==1.21.1 pybind11 typing_extensions diff --git a/tests/BUILD b/tests/BUILD index eda93a3ec..9b31c1187 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -5,12 +5,12 @@ sse_copts = ['-msse4'] windows_copts = [ "/arch:AVX", - "/std:c++14", + "/std:c++17", ] windows_avx512_copts = [ "/arch:AVX512", - "/std:c++14", + "/std:c++17", ] config_setting(