From 59acbd74653a332ed459dd054cdcd20f62a3eed5 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 17 Sep 2024 12:54:53 +0900 Subject: [PATCH 01/34] add macos ci --- .github/workflows/ci_ubuntu.yml | 93 ++++++++++++--------------------- .github/workflows/format.yml | 40 ++++++++++++++ 2 files changed, 72 insertions(+), 61 deletions(-) create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/ci_ubuntu.yml b/.github/workflows/ci_ubuntu.yml index 3f1a341a..98e149d3 100644 --- a/.github/workflows/ci_ubuntu.yml +++ b/.github/workflows/ci_ubuntu.yml @@ -1,4 +1,4 @@ -name: Ubuntu CI +name: Build check on: push: @@ -15,20 +15,33 @@ on: - "*.md" jobs: - gcc11-build: + build: name: GCC11 build strategy: matrix: + os: ["linux", "macos"] + device: ["cpu", "cuda"] python-version: ["3.10"] - runs-on: "ubuntu-22.04" + exclude: + - os: "macos" + device: "cuda" + runs-on: | + ${{ + matrix.os == "linux" && "ubuntu-22.04" || + matrix.os == "macos" && "macos-13" || + "error" + }} env: CXX_COMPILER: "/usr/lib/ccache/g++" C_COMPILER: "/usr/lib/ccache/gcc" SCALUQ_USE_TEST: "Yes" + SCALUQ_USE_CUDA: ${{ matrix.device == "cuda" && "Yes" || "No" }} + SCALUQ_CUDA_ARCH: "PASCAL61" steps: - uses: actions/checkout@v4 - name: Install gcc-11/g++-11 + if: ${{ matrix.os == "linux" }} run: | sudo apt update && \ sudo apt install -y software-properties-common && \ @@ -46,9 +59,23 @@ jobs: - name: Setup ccache uses: hendrikmuhs/ccache-action@v1.2 with: - key: "${{ github.job }}-ubuntu-22.04" + key: "${{ github.job }}-${{ matrix.device }}" verbose: 2 + - name: Install CUDA toolkit + if: ${{ matrix.device == "cuda" }} + uses: Jimver/cuda-toolkit@v0.2.11 + with: + cuda: "12.2.0" + method: "network" + + - name: Show installed Compiler version + run: | + nvcc --version + gcc --version + g++ --version + cmake --version + - name: Install scaluq for Ubuntu run: CMAKE_BUILD_TYPE=Debug ./script/build_gcc.sh @@ -63,6 +90,7 @@ jobs: run: pip install .[ci] - name: Test in Ubuntu + if: ${{ matrix.device == "cpu" }} # currently GPU runner is not supported run: | OMP_PROC_BIND=false ninja test -C build -j $(nproc) @@ -70,60 +98,3 @@ jobs: run: | echo -e "from scaluq import StateVector\nfrom scaluq.gate import I" > /tmp/stub_sample.py mypy /tmp/stub_sample.py - - nvcc-build: - name: NVCC build - strategy: - matrix: - python-version: ["3.10"] - runs-on: "ubuntu-22.04" - env: - CXX_COMPILER: "/usr/lib/ccache/g++" - C_COMPILER: "/usr/lib/ccache/gcc" - SCALUQ_USE_TEST: "Yes" - SCALUQ_USE_CUDA: "Yes" - SCALUQ_CUDA_ARCH: "PASCAL61" - steps: - - uses: actions/checkout@v4 - - - name: Install gcc-11/g++-11 - run: | - sudo apt update && \ - sudo apt install -y software-properties-common && \ - sudo apt update && \ - sudo apt install -y gcc-11 g++-11 && \ - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 && \ - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100 - - - name: Setup cmake - uses: lukka/get-cmake@latest - - - name: Install Ninja - run: sudo apt install ninja-build - - - name: Setup ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: "${{ github.job }}-ubuntu-22.04" - verbose: 2 - - - name: Install CUDA toolkit - uses: Jimver/cuda-toolkit@v0.2.11 - with: - cuda: "12.2.0" - method: "network" - - - name: Show installed Compiler version - run: | - nvcc --version - gcc --version - g++ --version - cmake --version - - - name: Install scaluq for Ubuntu - run: ./script/build_gcc.sh - - - name: Install scaluq Python module - run: SCALUQ_USE_CUDA=ON pip install .[ci] - - # GitHub Actions cannot run CUDA program diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..b9e42836 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,40 @@ +name: Ubuntu CI + +on: + push: + paths-ignore: + - ".devcontainer/**" + - ".vscode/**" + - "doc/**" + - "*.md" + pull_request: + paths-ignore: + - ".devcontainer/**" + - ".vscode/**" + - "doc/**" + - "*.md" + +jobs: + check-format: + name: Check Format + runs-on: "ubuntu-22.04" + steps: + - uses: actions/checkout@v4 + + - name: Setup cmake + uses: lukka/get-cmake@latest + + - name: Install Ninja + run: sudo apt install ninja-build + + - name: Configure + run: | + mkdir -p ./build + cmake -B build -G Ninja + + - name: Check format + run: | + ninja -C build format + diff=$(git diff) + echo -n "$diff" + test $(echo -n "$diff" | wc -l) -eq 0 From 7903a1f7a0802a3ad56368ffb3858da7e6e78b29 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 17 Sep 2024 12:59:50 +0900 Subject: [PATCH 02/34] add macos ci --- .github/workflows/{ci_ubuntu.yml => test.yml} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename .github/workflows/{ci_ubuntu.yml => test.yml} (90%) diff --git a/.github/workflows/ci_ubuntu.yml b/.github/workflows/test.yml similarity index 90% rename from .github/workflows/ci_ubuntu.yml rename to .github/workflows/test.yml index 98e149d3..ee401bbb 100644 --- a/.github/workflows/ci_ubuntu.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Build check +name: Build and Test on: push: @@ -15,8 +15,8 @@ on: - "*.md" jobs: - build: - name: GCC11 build + test: + name: Build and Test strategy: matrix: os: ["linux", "macos"] @@ -27,21 +27,21 @@ jobs: device: "cuda" runs-on: | ${{ - matrix.os == "linux" && "ubuntu-22.04" || - matrix.os == "macos" && "macos-13" || + matrix.os == 'linux' && 'ubuntu-22.04' || + matrix.os == 'macos' && 'macos-13' || "error" }} env: CXX_COMPILER: "/usr/lib/ccache/g++" C_COMPILER: "/usr/lib/ccache/gcc" SCALUQ_USE_TEST: "Yes" - SCALUQ_USE_CUDA: ${{ matrix.device == "cuda" && "Yes" || "No" }} + SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'Yes' || 'No' }} SCALUQ_CUDA_ARCH: "PASCAL61" steps: - uses: actions/checkout@v4 - name: Install gcc-11/g++-11 - if: ${{ matrix.os == "linux" }} + if: ${{ matrix.os == 'linux' }} run: | sudo apt update && \ sudo apt install -y software-properties-common && \ From 49e46e6e07f00cd785141cabf1f5eab94c2f271d Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 17 Sep 2024 13:01:17 +0900 Subject: [PATCH 03/34] fix literal --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ee401bbb..72962330 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: ${{ matrix.os == 'linux' && 'ubuntu-22.04' || matrix.os == 'macos' && 'macos-13' || - "error" + 'error' }} env: CXX_COMPILER: "/usr/lib/ccache/g++" From 9216b63dbc72c449fbf2641177cecb69fa02cc2b Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 17 Sep 2024 13:02:15 +0900 Subject: [PATCH 04/34] fix literal --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 72962330..de10f10b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,7 +63,7 @@ jobs: verbose: 2 - name: Install CUDA toolkit - if: ${{ matrix.device == "cuda" }} + if: ${{ matrix.device == 'cuda' }} uses: Jimver/cuda-toolkit@v0.2.11 with: cuda: "12.2.0" @@ -90,7 +90,7 @@ jobs: run: pip install .[ci] - name: Test in Ubuntu - if: ${{ matrix.device == "cpu" }} # currently GPU runner is not supported + if: ${{ matrix.device == 'cpu' }} # currently GPU runner is not supported run: | OMP_PROC_BIND=false ninja test -C build -j $(nproc) From a099156fa012f5174e2682f0e00ee7d2c1d42165 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 17 Sep 2024 13:03:37 +0900 Subject: [PATCH 05/34] rename format CI --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index b9e42836..14010729 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,4 +1,4 @@ -name: Ubuntu CI +name: Format on: push: From 1487db0974217924af6a44cf8275aaf6420c7101 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 11:17:50 +0900 Subject: [PATCH 06/34] fix runs-on variable --- .github/workflows/test.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index de10f10b..49457ba0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,17 +20,20 @@ jobs: strategy: matrix: os: ["linux", "macos"] + architecture: ["x86_64"] device: ["cpu", "cuda"] python-version: ["3.10"] exclude: - os: "macos" device: "cuda" - runs-on: | - ${{ - matrix.os == 'linux' && 'ubuntu-22.04' || - matrix.os == 'macos' && 'macos-13' || - 'error' - }} + include: + - os: "linux" + architecture: "x86_64" + runs-on: "ubuntu-22.04" + - os: "macos" + architecture: "x86_64" + runs-on: "macos-13" + runs-on: ${{ matrix.runs-on }} env: CXX_COMPILER: "/usr/lib/ccache/g++" C_COMPILER: "/usr/lib/ccache/gcc" From 541ffc9dbedf63aff14b8031b1d3c6028c134752 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 11:26:37 +0900 Subject: [PATCH 07/34] fix ninja installation --- .github/workflows/test.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 49457ba0..a85a6956 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,21 +43,13 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install gcc-11/g++-11 + - name: Install Ninja if: ${{ matrix.os == 'linux' }} - run: | - sudo apt update && \ - sudo apt install -y software-properties-common && \ - sudo apt update && \ - sudo apt install -y gcc-11 g++-11 && \ - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 && \ - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100 - - - name: Setup cmake - uses: lukka/get-cmake@latest + run: sudo apt update && sudo apt install ninja-build - name: Install Ninja - run: sudo apt install ninja-build + if: ${{ matrix.os == 'macos' }} + run: brew install ninja - name: Setup ccache uses: hendrikmuhs/ccache-action@v1.2 @@ -74,10 +66,11 @@ jobs: - name: Show installed Compiler version run: | - nvcc --version + [ SCALUQ_USE_CUDA = 'Yes' ] && nvcc --version gcc --version g++ --version cmake --version + ninja --version - name: Install scaluq for Ubuntu run: CMAKE_BUILD_TYPE=Debug ./script/build_gcc.sh From 51a83e9f74d858ae9cd9ffeefa4813ba951bb159 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 11:34:43 +0900 Subject: [PATCH 08/34] fix ccache specification --- .github/workflows/test.yml | 3 +-- script/build_gcc.sh | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a85a6956..e10c8b63 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,8 +35,7 @@ jobs: runs-on: "macos-13" runs-on: ${{ matrix.runs-on }} env: - CXX_COMPILER: "/usr/lib/ccache/g++" - C_COMPILER: "/usr/lib/ccache/gcc" + CMAKE_CXX_COMPILER_LAUNCHER: "ccache" SCALUQ_USE_TEST: "Yes" SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'Yes' || 'No' }} SCALUQ_CUDA_ARCH: "PASCAL61" diff --git a/script/build_gcc.sh b/script/build_gcc.sh index 75bcf6ca..d35cce84 100755 --- a/script/build_gcc.sh +++ b/script/build_gcc.sh @@ -2,7 +2,8 @@ set -eux -GXX_COMMAND=${CXX_COMPILER:-"g++"} +CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER:-""} +CMAKE_CXX_COMPILER=${CXX_COMPILER:-"g++"} SCALUQ_USE_OMP=${SCALUQ_USE_OMP:-"ON"} SCALUQ_USE_CUDA=${SCALUQ_USE_CUDA:-"OFF"} @@ -11,7 +12,8 @@ SCALUQ_USE_EXE=${SCALUQ_USE_EXE:-"ON"} CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-"Release"} -CMAKE_OPS="-D CMAKE_CXX_COMPILER=${GXX_COMMAND} \ +CMAKE_OPS="-D CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} + -D CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} \ -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ -D SCALUQ_USE_OMP=${SCALUQ_USE_OMP} \ -D SCALUQ_USE_CUDA=${SCALUQ_USE_CUDA} \ From f1e8a310739614bca4b4040205b20100db733264 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 11:41:14 +0900 Subject: [PATCH 09/34] fix CMAKE_CXX_COMPILER --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e10c8b63..4e2b0d15 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,6 +36,7 @@ jobs: runs-on: ${{ matrix.runs-on }} env: CMAKE_CXX_COMPILER_LAUNCHER: "ccache" + CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'g++-14' || 'g++' }} SCALUQ_USE_TEST: "Yes" SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'Yes' || 'No' }} SCALUQ_CUDA_ARCH: "PASCAL61" From 64335d4a1063bcba17651bcb40e82a7b2a4e95e6 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 11:44:37 +0900 Subject: [PATCH 10/34] add C, not only CXX --- .github/workflows/test.yml | 7 +++++-- script/build_gcc.sh | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e2b0d15..a46a4dfa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,6 +35,8 @@ jobs: runs-on: "macos-13" runs-on: ${{ matrix.runs-on }} env: + CMAKE_C_COMPILER_LAUNCHER: "ccache" + CMAKE_C_COMPILER: ${{ matrix.os == 'macos' && 'gcc-14' || 'gcc' }} CMAKE_CXX_COMPILER_LAUNCHER: "ccache" CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'g++-14' || 'g++' }} SCALUQ_USE_TEST: "Yes" @@ -67,8 +69,9 @@ jobs: - name: Show installed Compiler version run: | [ SCALUQ_USE_CUDA = 'Yes' ] && nvcc --version - gcc --version - g++ --version + ccache --version + $CMAKE_C_COMPILER --version + $CMAKE_CXX_COMPILER --version cmake --version ninja --version diff --git a/script/build_gcc.sh b/script/build_gcc.sh index d35cce84..4cfce193 100755 --- a/script/build_gcc.sh +++ b/script/build_gcc.sh @@ -2,6 +2,8 @@ set -eux +CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER:-""} +CMAKE_C_COMPILER=${C_COMPILER:-"gcc"} CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER:-""} CMAKE_CXX_COMPILER=${CXX_COMPILER:-"g++"} @@ -12,7 +14,9 @@ SCALUQ_USE_EXE=${SCALUQ_USE_EXE:-"ON"} CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-"Release"} -CMAKE_OPS="-D CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} +CMAKE_OPS="-D CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} + -D CMAKE_C_COMPILER=${CMAKE_C_COMPILER} \ + -D CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} -D CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} \ -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ -D SCALUQ_USE_OMP=${SCALUQ_USE_OMP} \ From 1649f43828ad7a5eb068f128091faa3a33c393d5 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 11:50:49 +0900 Subject: [PATCH 11/34] add CMAKE_ prefix on C*_COMPILER --- script/build_gcc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/build_gcc.sh b/script/build_gcc.sh index 4cfce193..0305a71b 100755 --- a/script/build_gcc.sh +++ b/script/build_gcc.sh @@ -3,9 +3,9 @@ set -eux CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER:-""} -CMAKE_C_COMPILER=${C_COMPILER:-"gcc"} +CMAKE_C_COMPILER=${CMAKE_C_COMPILER:-"gcc"} CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER:-""} -CMAKE_CXX_COMPILER=${CXX_COMPILER:-"g++"} +CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER:-"g++"} SCALUQ_USE_OMP=${SCALUQ_USE_OMP:-"ON"} SCALUQ_USE_CUDA=${SCALUQ_USE_CUDA:-"OFF"} From 10aa422f384037dd163908ea79e62c5d8afcfa69 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 12:01:44 +0900 Subject: [PATCH 12/34] PROCS for macos --- script/build_gcc.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/script/build_gcc.sh b/script/build_gcc.sh index 0305a71b..14fa2333 100755 --- a/script/build_gcc.sh +++ b/script/build_gcc.sh @@ -27,6 +27,12 @@ if [ -n "${SCALUQ_CUDA_ARCH:-""}" ]; then CMAKE_OPS="${CMAKE_OPS} -D SCALUQ_CUDA_ARCH=${SCALUQ_CUDA_ARCH}" fi +if [ "$(uname)" == 'Darwin' ]; then + NPROCS=$(sysctl -n hw.logicalcpu) +else + NPROCS=$(nprocs) +fi + mkdir -p ./build cmake -B build -G Ninja ${CMAKE_OPS} -ninja -C build -j $(nproc) +ninja -C build -j ${NPROCS} From 72cb44cc6980070a400bea44a011b9f1ecc8bc9d Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 12:03:35 +0900 Subject: [PATCH 13/34] nprocs -> nproc --- script/build_gcc.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script/build_gcc.sh b/script/build_gcc.sh index 14fa2333..39643b56 100755 --- a/script/build_gcc.sh +++ b/script/build_gcc.sh @@ -28,11 +28,11 @@ if [ -n "${SCALUQ_CUDA_ARCH:-""}" ]; then fi if [ "$(uname)" == 'Darwin' ]; then - NPROCS=$(sysctl -n hw.logicalcpu) + NPROC=$(sysctl -n hw.logicalcpu) else - NPROCS=$(nprocs) + NPROC=$(nproc) fi mkdir -p ./build cmake -B build -G Ninja ${CMAKE_OPS} -ninja -C build -j ${NPROCS} +ninja -C build -j ${NPROC} From 81933e0fcc5d8bf9aa07f3c32045c5b634fcf24c Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 12:11:53 +0900 Subject: [PATCH 14/34] no asan on macos --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f930b27..7e110278 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,8 +140,12 @@ if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQ endif() # Debug options - target_compile_options(scaluq PUBLIC $,-O0 -g -fsanitize=address$undefined,-O3>) - target_link_options(scaluq PUBLIC $<$:-fsanitize=address$undefined>) + if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + target_compile_options(scaluq PUBLIC $,-O0 -g -O3>) + else() + target_compile_options(scaluq PUBLIC $,-O0 -g -fsanitize=address$undefined,-O3>) + target_link_options(scaluq PUBLIC $<$:-fsanitize=address$undefined>) + endif() endif() ### Add subdirectories ### From 78eb233f174d25ca363c4d04d1a5e94e31593bc8 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 12:15:53 +0900 Subject: [PATCH 15/34] comma --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e110278..ff083b40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,7 +141,7 @@ if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQ # Debug options if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - target_compile_options(scaluq PUBLIC $,-O0 -g -O3>) + target_compile_options(scaluq PUBLIC $,-O0 -g,-O3>) else() target_compile_options(scaluq PUBLIC $,-O0 -g -fsanitize=address$undefined,-O3>) target_link_options(scaluq PUBLIC $<$:-fsanitize=address$undefined>) From 8e461acf83ea277d7a864661bec47943a4d11ce4 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 12:19:57 +0900 Subject: [PATCH 16/34] remove format check --- .github/workflows/test.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a46a4dfa..d0cdb64f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -78,13 +78,6 @@ jobs: - name: Install scaluq for Ubuntu run: CMAKE_BUILD_TYPE=Debug ./script/build_gcc.sh - - name: Check format - run: | - ninja -C build format - diff=$(git diff) - echo -n "$diff" - test $(echo -n "$diff" | wc -l) -eq 0 - - name: Install scaluq Python module run: pip install .[ci] From 87ef4069076f01d9851097cd45d45b3caa22284d Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 12:26:49 +0900 Subject: [PATCH 17/34] add CMAKE_* property to pyproject.toml --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 939ee578..206e9e66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,10 @@ metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" sdist.include = ["python/scaluq/_version.py"] [tool.scikit-build.cmake.define] +CMAKE_C_COMPILER_LAUNCHER = {env="CMAKE_C_COMPILER_LAUNCHER", default=""} +CMAKE_C_COMPILER = {env="CMAKE_C_COMPILER", default="gcc"} +CMAKE_CXX_COMPILER_LAUNCHER = {env="CMAKE_CXX_COMPILER_LAUNCHER", default=""} +CMAKE_CXX_COMPILER = {env="CMAKE_CXX_COMPILER", default="g++"} SCALUQ_USE_OMP = {env="SCALUQ_USE_OMP", default="Yes"} SCALUQ_USE_CUDA = {env="SCALUQ_USE_CUDA", default="No"} SCALUQ_CUDA_ARCH = {env="SCALUQ_CUDA_ARCH"} From 585251b7c84cc2697fc75b8da57ed7ef1a639835 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 12:52:35 +0900 Subject: [PATCH 18/34] use nvcc when cuda --- .github/workflows/test.yml | 4 ++-- .github/workflows/wheel.yml | 4 +++- pyproject.toml | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d0cdb64f..aa929b18 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,9 +36,9 @@ jobs: runs-on: ${{ matrix.runs-on }} env: CMAKE_C_COMPILER_LAUNCHER: "ccache" - CMAKE_C_COMPILER: ${{ matrix.os == 'macos' && 'gcc-14' || 'gcc' }} + CMAKE_C_COMPILER: ${{ matrix.os == 'macos' && 'gcc-14' || matrix.device == 'cuda' && 'nvcc' || 'gcc' }} CMAKE_CXX_COMPILER_LAUNCHER: "ccache" - CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'g++-14' || 'g++' }} + CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'g++-14' || matrix.device == 'cuda' && 'nvcc' || 'g++' }} SCALUQ_USE_TEST: "Yes" SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'Yes' || 'No' }} SCALUQ_CUDA_ARCH: "PASCAL61" diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index 9fe3aa55..ea6824f9 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -18,11 +18,13 @@ jobs: strategy: fail-fast: false matrix: - os-arch: ["manylinux_x86_64"] + os-arch: ["manylinux_x86_64", "macosx_x86_64"] cibw-python: ["cp38", "cp39", "cp310", "cp311", "cp312"] include: - os-arch: "manylinux_x86_64" os: "ubuntu-22.04" + - os-arch: "macosx_x86_64" + os: "macos-13" - cibw-python: "cp38" python-version: "3.8" - cibw-python: "cp39" diff --git a/pyproject.toml b/pyproject.toml index 206e9e66..05a9da07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,7 @@ CMAKE_C_COMPILER_LAUNCHER = {env="CMAKE_C_COMPILER_LAUNCHER", default=""} CMAKE_C_COMPILER = {env="CMAKE_C_COMPILER", default="gcc"} CMAKE_CXX_COMPILER_LAUNCHER = {env="CMAKE_CXX_COMPILER_LAUNCHER", default=""} CMAKE_CXX_COMPILER = {env="CMAKE_CXX_COMPILER", default="g++"} +CMAKE_BUILD_TYPE = {env="CMAKE_BUILD_TYPE", default="Release"} SCALUQ_USE_OMP = {env="SCALUQ_USE_OMP", default="Yes"} SCALUQ_USE_CUDA = {env="SCALUQ_USE_CUDA", default="No"} SCALUQ_CUDA_ARCH = {env="SCALUQ_CUDA_ARCH"} From 0f72a69ca99187545e828d1b4f7a5e1c28ea1c71 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 13:00:04 +0900 Subject: [PATCH 19/34] NPROC on macos --- .github/workflows/test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa929b18..aba5e17d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -84,7 +84,12 @@ jobs: - name: Test in Ubuntu if: ${{ matrix.device == 'cpu' }} # currently GPU runner is not supported run: | - OMP_PROC_BIND=false ninja test -C build -j $(nproc) + if [ "$(uname)" == 'Darwin' ]; then + NPROC=$(sysctl -n hw.logicalcpu) + else + NPROC=$(nproc) + fi + OMP_PROC_BIND=false ninja test -C build -j ${NPROC} - name: Test if stub exists run: | From 74fe505261fae59fc94e93f09bcbacd00cc136e5 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Fri, 20 Sep 2024 13:07:14 +0900 Subject: [PATCH 20/34] correct integer type --- scaluq/util/utility.hpp | 4 ++-- tests/state/state_vector_test.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scaluq/util/utility.hpp b/scaluq/util/utility.hpp index aab4f5d1..e4e267b6 100644 --- a/scaluq/util/utility.hpp +++ b/scaluq/util/utility.hpp @@ -144,8 +144,8 @@ inline std::vector> convert_2d_device_view_to_host_vector( const Kokkos::View& view_d) { auto view_h = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), view_d); std::vector> result(view_d.extent(0), std::vector(view_d.extent(1), 0)); - for (size_t i = 0; i < view_d.extent(0); ++i) { - for (size_t j = 0; j < view_d.extent(1); ++j) { + for (std::size_t i = 0; i < view_d.extent(0); ++i) { + for (std::size_t j = 0; j < view_d.extent(1); ++j) { result[i][j] = view_h(i, j); } } diff --git a/tests/state/state_vector_test.cpp b/tests/state/state_vector_test.cpp index e40356d1..6cc5ed38 100644 --- a/tests/state/state_vector_test.cpp +++ b/tests/state/state_vector_test.cpp @@ -217,7 +217,7 @@ TEST(StateVectorTest, SamplingSuperpositionState) { state.add_state_vector_with_coef(1 << i, tmp_state); } state.normalize(); - std::vector res = state.sampling(nshot); + std::vector res = state.sampling(nshot); std::array cnt = {}; for (std::uint64_t i = 0; i < nshot; ++i) { From 16c7810bcd46d3ccf7f9c8ae0a4f75b0660d3cd5 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 09:27:32 +0900 Subject: [PATCH 21/34] do not use ccache when cuda is used --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aba5e17d..5ea82c49 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,10 +35,10 @@ jobs: runs-on: "macos-13" runs-on: ${{ matrix.runs-on }} env: - CMAKE_C_COMPILER_LAUNCHER: "ccache" - CMAKE_C_COMPILER: ${{ matrix.os == 'macos' && 'gcc-14' || matrix.device == 'cuda' && 'nvcc' || 'gcc' }} - CMAKE_CXX_COMPILER_LAUNCHER: "ccache" - CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'g++-14' || matrix.device == 'cuda' && 'nvcc' || 'g++' }} + CMAKE_C_COMPILER_LAUNCHER: ${{ matrix.device == 'cuda' && '' || 'ccache' }} + CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'gcc-14' || 'gcc' }} + CMAKE_C_COMPILER_LAUNCHER: ${{ matrix.device == 'cuda' && '' || 'ccache' }} + CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'g++-14' || 'g++' }} SCALUQ_USE_TEST: "Yes" SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'Yes' || 'No' }} SCALUQ_CUDA_ARCH: "PASCAL61" From e603b997a7d42ebb5e137f99e2611184bb45250e Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 09:28:52 +0900 Subject: [PATCH 22/34] correct C/CXX --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5ea82c49..1ca8ce8e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,8 +36,8 @@ jobs: runs-on: ${{ matrix.runs-on }} env: CMAKE_C_COMPILER_LAUNCHER: ${{ matrix.device == 'cuda' && '' || 'ccache' }} - CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'gcc-14' || 'gcc' }} - CMAKE_C_COMPILER_LAUNCHER: ${{ matrix.device == 'cuda' && '' || 'ccache' }} + CMAKE_C_COMPILER: ${{ matrix.os == 'macos' && 'gcc-14' || 'gcc' }} + CMAKE_CXX_COMPILER_LAUNCHER: ${{ matrix.device == 'cuda' && '' || 'ccache' }} CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'g++-14' || 'g++' }} SCALUQ_USE_TEST: "Yes" SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'Yes' || 'No' }} From b5e7824bc16fb5cc1448f3b0e821834e8facbc59 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 09:41:14 +0900 Subject: [PATCH 23/34] reverse generate expression --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ca8ce8e..cdac20c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,9 +35,9 @@ jobs: runs-on: "macos-13" runs-on: ${{ matrix.runs-on }} env: - CMAKE_C_COMPILER_LAUNCHER: ${{ matrix.device == 'cuda' && '' || 'ccache' }} + CMAKE_C_COMPILER_LAUNCUER: ${{ matrix.device == 'cpu' && 'ccache' }} CMAKE_C_COMPILER: ${{ matrix.os == 'macos' && 'gcc-14' || 'gcc' }} - CMAKE_CXX_COMPILER_LAUNCHER: ${{ matrix.device == 'cuda' && '' || 'ccache' }} + CMAKE_CXX_COMPILER_LAUNCUER: ${{ matrix.device == 'cpu' && 'ccache' }} CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'g++-14' || 'g++' }} SCALUQ_USE_TEST: "Yes" SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'Yes' || 'No' }} From 68aa5dd73da66135136fcf7aeecca96200da7e28 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 09:55:43 +0900 Subject: [PATCH 24/34] do not use compiler launcher --- .github/workflows/test.yml | 6 ++---- script/build_gcc.sh | 6 +----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cdac20c3..7b51e4b2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,10 +35,8 @@ jobs: runs-on: "macos-13" runs-on: ${{ matrix.runs-on }} env: - CMAKE_C_COMPILER_LAUNCUER: ${{ matrix.device == 'cpu' && 'ccache' }} - CMAKE_C_COMPILER: ${{ matrix.os == 'macos' && 'gcc-14' || 'gcc' }} - CMAKE_CXX_COMPILER_LAUNCUER: ${{ matrix.device == 'cpu' && 'ccache' }} - CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'g++-14' || 'g++' }} + CMAKE_C_COMPILER: ${{ matrix.os == 'macos' && '/usr/local/opt/ccache/libexec/gcc-14' || '/usr/lib/ccache/gcc' }} + CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && '/usr/local/opt/ccache/libexec/g++-14' || '/usr/lib/ccache/g++' }} SCALUQ_USE_TEST: "Yes" SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'Yes' || 'No' }} SCALUQ_CUDA_ARCH: "PASCAL61" diff --git a/script/build_gcc.sh b/script/build_gcc.sh index 39643b56..a4e37088 100755 --- a/script/build_gcc.sh +++ b/script/build_gcc.sh @@ -2,9 +2,7 @@ set -eux -CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER:-""} CMAKE_C_COMPILER=${CMAKE_C_COMPILER:-"gcc"} -CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER:-""} CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER:-"g++"} SCALUQ_USE_OMP=${SCALUQ_USE_OMP:-"ON"} @@ -14,9 +12,7 @@ SCALUQ_USE_EXE=${SCALUQ_USE_EXE:-"ON"} CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-"Release"} -CMAKE_OPS="-D CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} - -D CMAKE_C_COMPILER=${CMAKE_C_COMPILER} \ - -D CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} +CMAKE_OPS="-D CMAKE_C_COMPILER=${CMAKE_C_COMPILER} -D CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} \ -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ -D SCALUQ_USE_OMP=${SCALUQ_USE_OMP} \ From 09a51e7995cfc40a4eff3bf7cc6f19bc7eb135a1 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 10:27:36 +0900 Subject: [PATCH 25/34] distinct os ccache --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7b51e4b2..70ff3492 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,7 +54,7 @@ jobs: - name: Setup ccache uses: hendrikmuhs/ccache-action@v1.2 with: - key: "${{ github.job }}-${{ matrix.device }}" + key: "${{ github.job }}-${{ matrix.os }}-${{ matrix.device }}" verbose: 2 - name: Install CUDA toolkit From 1a51d3b70c5ce6e8a3db693b01688e65ea7770c9 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 10:32:38 +0900 Subject: [PATCH 26/34] add $ --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 70ff3492..ad33abc4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -66,7 +66,7 @@ jobs: - name: Show installed Compiler version run: | - [ SCALUQ_USE_CUDA = 'Yes' ] && nvcc --version + [ $SCALUQ_USE_CUDA = 'Yes' ] && nvcc --version ccache --version $CMAKE_C_COMPILER --version $CMAKE_CXX_COMPILER --version From 7c0b4aec83a031d7a3431b983ff0c140e6985e78 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 10:33:31 +0900 Subject: [PATCH 27/34] Yes/No -> ON/OFF --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad33abc4..edfafd4c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,8 +37,8 @@ jobs: env: CMAKE_C_COMPILER: ${{ matrix.os == 'macos' && '/usr/local/opt/ccache/libexec/gcc-14' || '/usr/lib/ccache/gcc' }} CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && '/usr/local/opt/ccache/libexec/g++-14' || '/usr/lib/ccache/g++' }} - SCALUQ_USE_TEST: "Yes" - SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'Yes' || 'No' }} + SCALUQ_USE_TEST: "ON" + SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'ON' || 'OFF' }} SCALUQ_CUDA_ARCH: "PASCAL61" steps: - uses: actions/checkout@v4 @@ -66,7 +66,7 @@ jobs: - name: Show installed Compiler version run: | - [ $SCALUQ_USE_CUDA = 'Yes' ] && nvcc --version + [ $SCALUQ_USE_CUDA = 'ON' ] && nvcc --version ccache --version $CMAKE_C_COMPILER --version $CMAKE_CXX_COMPILER --version From 01dbb5dcc33f2a10ab1bd4aa351e9ccb99aaa74e Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 10:53:56 +0900 Subject: [PATCH 28/34] Release type on CUDA --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index edfafd4c..8f77a44e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,6 +37,7 @@ jobs: env: CMAKE_C_COMPILER: ${{ matrix.os == 'macos' && '/usr/local/opt/ccache/libexec/gcc-14' || '/usr/lib/ccache/gcc' }} CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && '/usr/local/opt/ccache/libexec/g++-14' || '/usr/lib/ccache/g++' }} + CMAKE_BUILD_TYPE: ${{ matrix.device == 'cuda' && 'Release' || 'Debug' }} SCALUQ_USE_TEST: "ON" SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'ON' || 'OFF' }} SCALUQ_CUDA_ARCH: "PASCAL61" @@ -74,7 +75,7 @@ jobs: ninja --version - name: Install scaluq for Ubuntu - run: CMAKE_BUILD_TYPE=Debug ./script/build_gcc.sh + run: ./script/build_gcc.sh - name: Install scaluq Python module run: pip install .[ci] From 51f0f9d4681255f86e3ce65b6dcd04dfbb967ea9 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 11:00:10 +0900 Subject: [PATCH 29/34] remove useless property from pyproject.toml --- pyproject.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 05a9da07..1dbdd207 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,11 +37,8 @@ metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" sdist.include = ["python/scaluq/_version.py"] [tool.scikit-build.cmake.define] -CMAKE_C_COMPILER_LAUNCHER = {env="CMAKE_C_COMPILER_LAUNCHER", default=""} CMAKE_C_COMPILER = {env="CMAKE_C_COMPILER", default="gcc"} -CMAKE_CXX_COMPILER_LAUNCHER = {env="CMAKE_CXX_COMPILER_LAUNCHER", default=""} CMAKE_CXX_COMPILER = {env="CMAKE_CXX_COMPILER", default="g++"} -CMAKE_BUILD_TYPE = {env="CMAKE_BUILD_TYPE", default="Release"} SCALUQ_USE_OMP = {env="SCALUQ_USE_OMP", default="Yes"} SCALUQ_USE_CUDA = {env="SCALUQ_USE_CUDA", default="No"} SCALUQ_CUDA_ARCH = {env="SCALUQ_CUDA_ARCH"} From d1b72e8db35ee66d3f957398ba408626c86b6541 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 11:07:27 +0900 Subject: [PATCH 30/34] FetchContent_Populate -> FetchContent_MakeAvailable --- CMakeLists.txt | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff083b40..b34d6aab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,30 +43,20 @@ endif(SCALUQ_USE_CUDA) ### Fetch dependencies ### # Kokkos FetchContent_Declare( - kokkos_fetch + kokkos GIT_REPOSITORY https://github.com/kokkos/kokkos GIT_TAG 4.2.00 ) -FetchContent_GetProperties(kokkos_fetch) -if(NOT kokkos_fetch_POPULATED) - message(STATUS "Fetch Kokkos for parallel execution") - FetchContent_Populate(kokkos_fetch) - add_subdirectory(${kokkos_fetch_SOURCE_DIR}) - set_property(TARGET kokkoscore PROPERTY POSITION_INDEPENDENT_CODE ON) -endif(NOT kokkos_fetch_POPULATED) +FetchContent_MakeAvailable(kokkos) +set_property(TARGET kokkoscore PROPERTY POSITION_INDEPENDENT_CODE ON) # Eigen FetchContent_Declare( - eigen_fetch + eigen GIT_REPOSITORY https://gitlab.com/libeigen/eigen GIT_TAG 3.4.0 ) -FetchContent_GetProperties(eigen_fetch) -if(NOT eigen_fetch_POPULATED) - message(STATUS "Fetch Eigen for matrix operation") - FetchContent_Populate(eigen_fetch) - add_subdirectory(${eigen_fetch_SOURCE_DIR}) -endif(NOT eigen_fetch_POPULATED) +FetchContent_MakeAvailable(eigen) # nanobind if(SKBUILD) @@ -88,16 +78,11 @@ endif(SKBUILD) # Google test if(SCALUQ_USE_TEST) FetchContent_Declare( - googletest_fetch + googletest GIT_REPOSITORY https://github.com/google/googletest GIT_TAG release-1.12.1 ) - FetchContent_GetProperties(googletest_fetch) - if(NOT googletest_fetch_POPULATED) - message(STATUS "Fetch googletest for C++ testing") - FetchContent_Populate(googletest_fetch) - add_subdirectory(${googletest_fetch_SOURCE_DIR}) - endif() + FetchContent_MakeAvailable(googletest) else() message(STATUS "Skip downloding googletest") endif(SCALUQ_USE_TEST) From 2ee81b818d6840684f37bf649411103d6173205c Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 11:18:15 +0900 Subject: [PATCH 31/34] do not check stub if cuda --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8f77a44e..68605fad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -91,6 +91,7 @@ jobs: OMP_PROC_BIND=false ninja test -C build -j ${NPROC} - name: Test if stub exists + if: ${{ matrix.device == 'cpu' }} # currently GPU runner is not supported run: | echo -e "from scaluq import StateVector\nfrom scaluq.gate import I" > /tmp/stub_sample.py mypy /tmp/stub_sample.py From cdda8468101b2e93ba93d2d209a65959cf1ec13f Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 11:18:29 +0900 Subject: [PATCH 32/34] specify compiler --- .github/workflows/wheel.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index ea6824f9..6061b5c4 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -37,6 +37,8 @@ jobs: python-version: "3.12" runs-on: ${{ matrix.os }} env: + CMAKE_C_COMPILER: ${{ matrix.os == 'macos' && 'gcc-14' || 'gcc' }} + CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'g++-14' || 'g++' }} CIBW_BUILD: ${{ matrix.cibw-python }}-${{ matrix.os-arch }} PYTHON: ${{ matrix.python-version }} steps: From 453bdc706c883a9013cf1ff36553c816a6b6a5bb Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 11:24:31 +0900 Subject: [PATCH 33/34] correct env --- .github/workflows/wheel.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index 6061b5c4..4f197fbc 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -18,13 +18,18 @@ jobs: strategy: fail-fast: false matrix: - os-arch: ["manylinux_x86_64", "macosx_x86_64"] + os: ["linux", "macos"] + arch: ["x86_64"] cibw-python: ["cp38", "cp39", "cp310", "cp311", "cp312"] include: - - os-arch: "manylinux_x86_64" - os: "ubuntu-22.04" - - os-arch: "macosx_x86_64" - os: "macos-13" + - os: "linux" + arch: "x86_64" + runs-on: "ubuntu-22.04" + cibw-os-arch: "manylinux_x86_64" + - os: "macos" + arch: "x86_64" + runs-on: "macos-13" + cibw-os-arch: "macosx_x86_64" - cibw-python: "cp38" python-version: "3.8" - cibw-python: "cp39" @@ -35,11 +40,11 @@ jobs: python-version: "3.11" - cibw-python: "cp312" python-version: "3.12" - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.runs-on }} env: CMAKE_C_COMPILER: ${{ matrix.os == 'macos' && 'gcc-14' || 'gcc' }} CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'g++-14' || 'g++' }} - CIBW_BUILD: ${{ matrix.cibw-python }}-${{ matrix.os-arch }} + CIBW_BUILD: ${{ matrix.cibw-python }}-${{ matrix.cibw-os-arch }} PYTHON: ${{ matrix.python-version }} steps: - uses: actions/checkout@v4 @@ -57,7 +62,7 @@ jobs: - name: Upload wheel to GitHub uses: actions/upload-artifact@v4 with: - name: ${{ matrix.cibw-python }}-${{ matrix.os-arch }} + name: ${{ matrix.cibw-python }}-${{ matrix.cibw-os-arch }} path: ./wheels/*.whl - name: Upload wheel data if the Git tag is set From fc09b84a1a1607d8c35bf7f3debbef359f3908d4 Mon Sep 17 00:00:00 2001 From: KowerKoint Date: Tue, 24 Sep 2024 11:32:16 +0900 Subject: [PATCH 34/34] MACOSX_DEPLOYMENT_TARGET=13.0 --- .github/workflows/wheel.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index 4f197fbc..4e4e32fc 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -46,6 +46,7 @@ jobs: CMAKE_CXX_COMPILER: ${{ matrix.os == 'macos' && 'g++-14' || 'g++' }} CIBW_BUILD: ${{ matrix.cibw-python }}-${{ matrix.cibw-os-arch }} PYTHON: ${{ matrix.python-version }} + MACOSX_DEPLOYMENT_TARGET: "13.0" steps: - uses: actions/checkout@v4