From 4d6e280b5a082c7f73706fb632ac22339929bbf9 Mon Sep 17 00:00:00 2001 From: Chin-Yun Yu Date: Wed, 29 Jan 2025 16:30:19 +0000 Subject: [PATCH 1/9] fix: update linker flag for OpenMP support in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f476167..c72ce9e 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ # check if openmp is available if torch.backends.openmp.is_available(): extra_compile_args["cxx"] = ["-fopenmp"] - extra_link_args.append("-lgomp") + extra_link_args.append("-fopenmp") setuptools.setup( name=NAME, From 287235d96f90bead6ec19af4a6364047bf325575 Mon Sep 17 00:00:00 2001 From: Chin-Yun Yu Date: Wed, 29 Jan 2025 16:38:19 +0000 Subject: [PATCH 2/9] feat: add homebrew clang setup for macOS in CI workflow --- .github/workflows/python-package.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a996e44..543a192 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -25,6 +25,12 @@ jobs: uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} + - name: Use homebrew clang + if: matrix.os == 'macos-13' + run: | + brew install libomp + export CC=$(brew --prefix llvm@15)/bin/clang + export CXX=$(brew --prefix llvm@15)/bin/clang++ - name: Install dependencies run: | python -m pip install --upgrade pip From 31111803585ef3701955fa0a0e82ed03ee826325 Mon Sep 17 00:00:00 2001 From: Chin-Yun Yu Date: Wed, 29 Jan 2025 16:44:32 +0000 Subject: [PATCH 3/9] fix: change export statement order --- .github/workflows/python-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 543a192..d65d216 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -29,8 +29,6 @@ jobs: if: matrix.os == 'macos-13' run: | brew install libomp - export CC=$(brew --prefix llvm@15)/bin/clang - export CXX=$(brew --prefix llvm@15)/bin/clang++ - name: Install dependencies run: | python -m pip install --upgrade pip @@ -45,6 +43,8 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Build CPP extension run: | + export CC=$(brew --prefix llvm)/bin/clang + export CXX=$(brew --prefix llvm)/bin/clang++ python setup.py build find build/ -name "_C*.so" -exec cp {} ./torchlpc/ \; - name: Test with pytest From 49c18ce65e2e22c48593a89ab86888f5f6eb3e75 Mon Sep 17 00:00:00 2001 From: Chin-Yun Yu Date: Wed, 29 Jan 2025 16:47:06 +0000 Subject: [PATCH 4/9] fix: specify llvm15 --- .github/workflows/python-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index d65d216..b24fbb2 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -43,8 +43,8 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Build CPP extension run: | - export CC=$(brew --prefix llvm)/bin/clang - export CXX=$(brew --prefix llvm)/bin/clang++ + export CC=$(brew --prefix llvm@15)/bin/clang + export CXX=$(brew --prefix llvm@15)/bin/clang++ python setup.py build find build/ -name "_C*.so" -exec cp {} ./torchlpc/ \; - name: Test with pytest From 173a1304ea0512af69d2e1a7fb17bcc657dde035 Mon Sep 17 00:00:00 2001 From: Chin-Yun Yu Date: Wed, 29 Jan 2025 16:53:56 +0000 Subject: [PATCH 5/9] only export cxx falg --- .github/workflows/python-package.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index b24fbb2..74c51dd 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -43,8 +43,9 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Build CPP extension run: | - export CC=$(brew --prefix llvm@15)/bin/clang - export CXX=$(brew --prefix llvm@15)/bin/clang++ + if [ ${{ matrix.os }} == 'macos-13' ]; then + export CXX=$(brew --prefix llvm@15)/bin/clang++ + fi python setup.py build find build/ -name "_C*.so" -exec cp {} ./torchlpc/ \; - name: Test with pytest From 0881668b4ad37123ec84f8fa61f0590fc493a6f1 Mon Sep 17 00:00:00 2001 From: Chin-Yun Yu Date: Wed, 29 Jan 2025 17:02:24 +0000 Subject: [PATCH 6/9] fix: update macOS CI workflow to install libomp and clarify build steps --- .github/workflows/python-package.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 74c51dd..04d44ee 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -25,7 +25,7 @@ jobs: uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - - name: Use homebrew clang + - name: Install libomp on macOS if: matrix.os == 'macos-13' run: | brew install libomp @@ -41,11 +41,15 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Build CPP extension + - name: Build CPP extension with clang++ + if: matrix.os == 'macos-13' + run: | + export CXX=$(brew --prefix llvm@15)/bin/clang++ + python setup.py build + find build/ -name "_C*.so" -exec cp {} ./torchlpc/ \; + - name: Build CPP extension with g++ + if: matrix.os == 'ubuntu-latest' run: | - if [ ${{ matrix.os }} == 'macos-13' ]; then - export CXX=$(brew --prefix llvm@15)/bin/clang++ - fi python setup.py build find build/ -name "_C*.so" -exec cp {} ./torchlpc/ \; - name: Test with pytest From 22b045135174bb1f8afadb57af255337447ef2b1 Mon Sep 17 00:00:00 2001 From: YCY Date: Tue, 3 Jun 2025 06:25:44 +0800 Subject: [PATCH 7/9] cfg: update include paths --- .github/workflows/python-package.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 87c58e9..74d8b20 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -45,6 +45,8 @@ jobs: if: matrix.os == 'macos-13' run: | export CXX=$(brew --prefix llvm@15)/bin/clang++ + export LDFLAGS="-L/usr/local/opt/libomp/lib" + export CPPFLAGS="-I/usr/local/opt/libomp/include" python setup.py build find build/ -name "_C*.so" -exec cp {} ./torchlpc/ \; - name: Build CPP extension with g++ From 57a3dc93f47893c40b5f7584a969e135fe9e6779 Mon Sep 17 00:00:00 2001 From: YCY Date: Tue, 3 Jun 2025 06:38:49 +0800 Subject: [PATCH 8/9] cfg: use different index-url for different OS --- .github/workflows/python-package.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 74d8b20..7232b21 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -34,7 +34,12 @@ jobs: python -m pip install --upgrade pip python -m pip install flake8 pytest pip install "numpy<2.0" numba - pip install torch --index-url https://download.pytorch.org/whl/cpu + - name: Install torch (mac) + if: matrix.os == 'macos-13' + run: pip install torch + - name: Install torch (ubuntu) + if: matrix.os == 'ubuntu-latest' + run: pip install torch --index-url https://download.pytorch.org/whl/cpu - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From 0d484d71900e7df1a272a413f537b5a2d5cdf98e Mon Sep 17 00:00:00 2001 From: YCY Date: Tue, 3 Jun 2025 06:44:32 +0800 Subject: [PATCH 9/9] test arm macos builds --- .github/workflows/python-package.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 7232b21..6a609c7 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: python-version: ["3.9", "3.10", "3.11", "3.12"] - os: [ubuntu-latest, macos-13] + os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v3 @@ -26,7 +26,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install libomp on macOS - if: matrix.os == 'macos-13' + if: matrix.os == 'macos-latest' run: | brew install libomp - name: Install dependencies @@ -35,7 +35,7 @@ jobs: python -m pip install flake8 pytest pip install "numpy<2.0" numba - name: Install torch (mac) - if: matrix.os == 'macos-13' + if: matrix.os == 'macos-latest' run: pip install torch - name: Install torch (ubuntu) if: matrix.os == 'ubuntu-latest' @@ -47,7 +47,7 @@ jobs: # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Build CPP extension with clang++ - if: matrix.os == 'macos-13' + if: matrix.os == 'macos-latest' run: | export CXX=$(brew --prefix llvm@15)/bin/clang++ export LDFLAGS="-L/usr/local/opt/libomp/lib"