Skip to content

Commit 6d955c9

Browse files
Support numba 0.62+ (#45)
Support numba 0.62+ versions and migrate to LLVM 20 Numba 0.62+ migration: - Migrate to new pass manager and update IR codegen - Add LLVM IR debug output for the outputs of the LLVM plugin pass - Update libomptarget nvptx device RTL path for the new pass manager - Enable and optimize toolchain binary generation by default for the CUDA target to match LLVM runtime ELF loader expectations - Improve detection for openmp libraries to include system libraries and better error checking LLVM 20 migration: - Update to opaque pointer types and modernize LLVM API usage - Use tgt_target_kernel interface for offloading codegen to match ABI conventions - Update pass to use LLVM 20 APIs - Replace deprecated CUDA nvvm.annotations with ptx_kernel calling convention - Update tgt_register_lib and tgt_unregister_lib handling in ctor Packaging improvements: - Add ninja build system requirement for faster, more reliable builds - Build openmp libraries conditionally via environment variables, to re-use existing packages and avoid conflicts - Build manylinux wheels using native Clang/LLVM 20.1.8 version - Update cibuildwheel to 3.3.1 - Ensure building for the macos 11.0 deployment target Additional improvements: - Set CUDA context flag CU_CTX_SCHED_BLOCKING_SYNC to match openmp runtime expectations - Fix thread_limit semantics to align with omptarget defaults - Improve build system with better CC/CXX flag handling - Update Python version support and CI configuration - Fix tests to be resilient to different thread configurations on test platforms - Fix ploop.1.py example
1 parent d8780ff commit 6d955c9

32 files changed

Lines changed: 556 additions & 390 deletions

.github/workflows/build-upload-wheels.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ jobs:
3535
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
3636

3737
- name: Install cibuildwheel
38-
run: python -m pip install cibuildwheel==3.1.4
38+
run: python -m pip install cibuildwheel==3.3.1
3939

4040
- name: Build wheels {{ matrix.os }}
4141
# Set LLVM_VERSION for the host to forward to the cibuildwheel
4242
# environment.
4343
env:
44-
LLVM_VERSION: "15.0.7"
44+
LLVM_VERSION: "20.1.8"
4545
run: python -m cibuildwheel --output-dir wheelhouse
4646

4747
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
@@ -58,7 +58,7 @@ jobs:
5858

5959
- name: Build sdist
6060
env:
61-
LLVM_VERSION: "15.0.7"
61+
LLVM_VERSION: "20.1.8"
6262
run: pipx run build --sdist
6363

6464
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
@@ -73,8 +73,14 @@ jobs:
7373
strategy:
7474
matrix:
7575
os: [ubuntu-latest, macos-latest, ubuntu-24.04-arm]
76-
python-version: ['3.10', '3.11', '3.12', '3.13']
77-
numba-version: ['0.61.0', '0.61.2']
76+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
77+
numba-version: ['0.62.0', '0.62.1', '0.63.0', '0.63.1']
78+
exclude:
79+
- python-version: '3.14'
80+
numba-version: '0.62.0'
81+
- python-version: '3.14'
82+
numba-version: '0.62.1'
83+
7884
steps:
7985
- name: Download built wheels
8086
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0

.gitlab/jobs/tioga.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ variables:
5656
- "3.11"
5757
- "3.12"
5858
- "3.13"
59+
- "3.14"
5960

6061
build-and-test-tioga:
6162
extends: [.base-job, .python-variants]

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
recursive-include src/numba/openmp/libs *
1+
recursive-include src/numba/openmp/libs *.py *.so *.a *.bc

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ conda install -c python-for-hpc -c conda-forge pyomp
4545

4646
| PyOMP | Numba |
4747
| ----- | --------------- |
48+
| 0.5.x | 0.62.x - 0.63.x |
4849
| 0.4.x | 0.61.x |
4950
| 0.3.x | 0.57.x - 0.60.x |
5051

buildscripts/cibuildwheel/setup-miniconda3.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ echo "Miniconda installed"
2323
source "_stage/miniconda3/bin/activate" base
2424
export CONDA_PLUGINS_AUTO_ACCEPT_TOS=true
2525

26-
# Create clangdev ${LLVM_VERSION}
27-
echo "Installing manylinux llvmdev ${LLVM_VERSION}..."
28-
conda create -n llvmdev-${LLVM_VERSION} -c conda-forge -q -y clang=${LLVM_VERSION} clang-tools=${LLVM_VERSION} llvmdev=${LLVM_VERSION}
26+
# Create conda environment with tools and libraries for the LLVM_VERSION.
27+
echo "Installing llvmdev ${LLVM_VERSION}..."
28+
conda create -n llvmdev-${LLVM_VERSION} -c conda-forge -q -y clang=${LLVM_VERSION} clangxx=${LLVM_VERSION} clang-tools=${LLVM_VERSION} llvmdev=${LLVM_VERSION} zstd

buildscripts/conda-recipes/pyomp/meta.yaml

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0').lstrip('v') %}
2-
{% set LLVM_VERSION = environ.get('LLVM_VERSION', '15.0.7') %}
2+
{% set LLVM_VERSION = environ.get('LLVM_VERSION', '20.1.8') %}
33

44
package:
55
name: pyomp
@@ -15,8 +15,11 @@ build:
1515
script:
1616
- export LLVM_VERSION={{ LLVM_VERSION }}
1717
- export LLVM_DIR=${PREFIX}
18+
- export CC=${PREFIX}/bin/clang
19+
- export CXX=${PREFIX}/bin/clang++
1820
- export VERBOSE=1
1921
- export CPPFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} -isystem ${PREFIX}/include -D_FORTIFY_SOURCE=2" # [osx]
22+
- export ENABLE_BUNDLED_LIBOMPTARGET=1 # [linux]
2023
- rm -rf build dist src/*.egg-info
2124
- {{ PYTHON }} -m pip install -v .
2225

@@ -28,6 +31,7 @@ requirements:
2831
- sysroot_linux-64 # [linux64]
2932
- sysroot_linux-aarch64 # [aarch64]
3033
- cmake
34+
- ninja
3135
- setuptools_scm
3236
- elfutils # [linux]
3337
- libffi # [linux]
@@ -39,55 +43,32 @@ requirements:
3943
- sysroot_linux-aarch64 # [aarch64]
4044
- setuptools
4145
- setuptools_scm
42-
- numba >=0.61, <0.62
46+
- numba >=0.62, <0.64
4347
- clang {{ LLVM_VERSION }}
48+
- clangxx {{ LLVM_VERSION }}
4449
- clang-tools {{ LLVM_VERSION }}
4550
- llvmdev {{ LLVM_VERSION }}
4651
- zlib
52+
# require llvm-openmp for the openmp cpu runtime.
53+
- llvm-openmp {{ LLVM_VERSION }}
4754
- elfutils # [linux]
4855
- libffi # [linux]
4956
run:
5057
- python
5158
- setuptools
52-
- numba >=0.61, <0.62
59+
- numba >=0.62, <0.64
60+
# require llvm-openmp for the openmp cpu runtime.
61+
- llvm-openmp {{ LLVM_VERSION }}
5362
- lark
5463
- cffi
5564

5665
test:
5766
commands:
58-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomp.dylib # [osx]
59-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomp.so # [linux]
60-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-amdgpu-gfx1010.bc # [linux]
61-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-amdgpu-gfx1030.bc # [linux]
62-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-amdgpu-gfx1031.bc # [linux]
63-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-amdgpu-gfx700.bc # [linux]
64-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-amdgpu-gfx701.bc # [linux]
65-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-amdgpu-gfx801.bc # [linux]
66-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-amdgpu-gfx803.bc # [linux]
67-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-amdgpu-gfx900.bc # [linux]
68-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-amdgpu-gfx902.bc # [linux]
69-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-amdgpu-gfx906.bc # [linux]
70-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-amdgpu-gfx908.bc # [linux]
71-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-amdgpu-gfx90a.bc # [linux]
72-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_35.bc # [linux]
73-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_37.bc # [linux]
74-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_50.bc # [linux]
75-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_52.bc # [linux]
76-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_53.bc # [linux]
77-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_60.bc # [linux]
78-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_61.bc # [linux]
79-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_62.bc # [linux]
80-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_70.bc # [linux]
81-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_72.bc # [linux]
82-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_75.bc # [linux]
83-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_80.bc # [linux]
84-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget-nvptx-sm_86.bc # [linux]
85-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget.rtl.amdgpu.so # [linux]
86-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget.rtl.cuda.so # [linux]
87-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget.rtl.ppc64.so # [linux and ppc64le]
88-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget.rtl.x86_64.so # [linux and x86_64]
89-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget.rtl.aarch64.so # [linux and aarch64]
90-
- test -f $SP_DIR/numba/openmp/libs/libomp/lib/libomptarget.so # [linux]
67+
- test -f $SP_DIR/numba/openmp/libs/pass/libIntrinsicsOpenMP.dylib # [osx]
68+
- test -f $SP_DIR/numba/openmp/libs/pass/libIntrinsicsOpenMP.so # [linux]
69+
- test -f $SP_DIR/numba/openmp/libs/openmp/lib/libomptarget-amdgpu.bc # [linux]
70+
- test -f $SP_DIR/numba/openmp/libs/openmp/lib/libomptarget-nvptx.bc # [linux]
71+
- test -f $SP_DIR/numba/openmp/libs/openmp/lib/libomptarget.so # [linux]
9172

9273
about:
9374
home: https://github.com/Python-for-HPC/PyOMP

buildscripts/gitlab/build-and-test.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ set -e
44

55
# Create a unique temporary directory for this job.
66
TMPDIR=/tmp/pyomp/${CI_JOB_ID}
7+
rm -rf ${TMPDIR}
78
mkdir -p ${TMPDIR}
89
pushd ${TMPDIR}
910

1011
# Set the LLVM_VERSION to use.
11-
export LLVM_VERSION="15.0.7"
12+
export LLVM_VERSION="20.1.8"
1213

1314
# Set the envs directory under the temporary directory.
1415
export CONDA_ENVS_DIRS="${TMPDIR}/_stage/miniconda3/envs"
@@ -17,14 +18,18 @@ export CONDA_ENVS_DIRS="${TMPDIR}/_stage/miniconda3/envs"
1718
source ${CI_PROJECT_DIR}/buildscripts/cibuildwheel/setup-miniconda3.sh
1819

1920
# Export environment variables for building and testing.
21+
export ENABLE_BUNDLED_LIBOMP="1"
22+
export ENABLE_BUNDLED_LIBOMPTARGET="1"
2023
export LLVM_DIR="${CONDA_ENVS_DIRS}/llvmdev-${LLVM_VERSION}"
21-
export PATH="${CONDA_ENVS_DIRS}/llvmdev-${LLVM_VERSION}/bin:${PATH}"
24+
export CMAKE_PREFIX_PATH="${CONDA_PREFIX}"
2225
export USE_CXX11_ABI="1"
2326
export PIP_NO_INPUT="1"
2427

2528
# Create and activate a conda environment with the desired Python version.
2629
conda create -n py-${PYOMP_CI_PYTHON_VERSION} -c conda-forge -y python=${PYOMP_CI_PYTHON_VERSION}
2730
conda activate py-${PYOMP_CI_PYTHON_VERSION}
31+
# Add extra packages needed to build openmp libraries.
32+
conda install -c conda-forge -y zstd libffi
2833

2934
# Clone and fetch the commit with history for package versioning.
3035
git clone https://github.com/${GITHUB_PROJECT_ORG}/${GITHUB_PROJECT_NAME}.git --single-branch
@@ -33,7 +38,7 @@ git fetch origin ${CI_COMMIT_SHA}
3338
git checkout ${CI_COMMIT_SHA}
3439

3540
# Install pyomp.
36-
CC=gcc CXX=g++ python -m pip install -v .
41+
CC=clang CXX=clang++ python -m pip install -v .
3742

3843
# Run host OpenMP tests.
3944
TEST_DEVICES=0 RUN_TARGET=0 python -m numba.runtests -v -- numba.openmp.tests.test_openmp

examples/ploop.1.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import numba
1+
from numba.openmp import njit
22
from numba.openmp import openmp_context as openmp
3-
from numba.openmp import omp_set_num_threads, omp_get_thread_num, omp_get_num_threads, omp_get_wtime
43
import numpy as np
54

6-
@numba.njit
5+
6+
@njit
77
def simple(n, a, b):
88
with openmp("parallel for"):
99
for i in range(1, n):
10-
b[i] = (a[i] + a[i-1]) / 2.0
10+
b[i] = (a[i] + a[i - 1]) / 2.0
11+
1112

1213
a = np.ones(100)
1314
b = np.empty(len(a))

pyproject.toml

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[build-system]
2-
requires = ["setuptools>=75.3", "wheel", "setuptools-scm>=8", "cmake>=3.20"]
2+
requires = ["setuptools>=75.3", "setuptools-scm>=8", "cmake>=3.20", "ninja"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pyomp"
77
dynamic = ["version"]
88
description = "Python OpenMP library based on Numba"
99
readme = "README.md"
10-
requires-python = ">=3.10, <3.14"
10+
requires-python = ">=3.10, <3.15"
1111
license = "BSD-2-Clause"
1212
license-files = ["LICENSE", "LICENSE-OPENMP.txt"]
1313
classifiers = [
@@ -17,7 +17,7 @@ classifiers = [
1717
"Intended Audience :: Developers",
1818
"Topic :: Software Development :: Compilers",
1919
]
20-
dependencies = ["numba>=0.61, <0.62", "lark", "cffi", "setuptools"]
20+
dependencies = ["numba>=0.62, <0.64", "lark", "cffi", "setuptools"]
2121
maintainers = [
2222
{ name = "Giorgis Georgakoudis", email = "georgakoudis1@llnl.gov" },
2323
]
@@ -37,7 +37,7 @@ include = ["numba.openmp*"]
3737

3838
# Bundle the CMake-installed artifacts into the wheel.
3939
[tool.setuptools.package-data]
40-
"numba.openmp.libs" = ["pass/*", "libomp/**/*"]
40+
"numba.openmp.libs" = ["pass/*", "openmp/**/*"]
4141

4242
# setuptools-scm config
4343
[tool.setuptools_scm]
@@ -49,7 +49,6 @@ archs = ["native"]
4949
# Pass LLVM_VERSION from the host environment to cibuildwheel.
5050
environment-pass = ["LLVM_VERSION"]
5151
# We use miniconda3 to get the clang/llvm toolchain on Linux.
52-
before-all = ["bash buildscripts/cibuildwheel/setup-miniconda3.sh"]
5352
before-build = ["rm -rf build dist src/*.egg-info"]
5453
skip = ["*-musllinux_*", "cp38-*"]
5554
test-command = [
@@ -59,14 +58,32 @@ test-command = [
5958
"OMP_TARGET_OFFLOAD=mandatory TEST_DEVICES=1 RUN_TARGET=1 python -m numba.runtests -v -- numba.openmp.tests.test_openmp.TestOpenmpTarget",
6059
]
6160

61+
[tool.cibuildwheel.environment]
62+
USE_CXX11_ABI = "1"
63+
PIP_NO_INPUT = "1"
64+
6265
[tool.cibuildwheel.linux]
6366
before-all = [
64-
"yum install -y elfutils-libelf-devel libffi-devel",
65-
"bash buildscripts/cibuildwheel/setup-miniconda3.sh",
67+
"yum install -y elfutils-libelf-devel libffi-devel clang-devel-20.1.8 llvm-devel-20.1.8",
6668
]
6769

68-
[tool.cibuildwheel.environment]
69-
LLVM_DIR = "${PWD}/_stage/miniconda3/envs/llvmdev-${LLVM_VERSION}"
70-
PATH = "${PWD}/_stage/miniconda3/envs/llvmdev-${LLVM_VERSION}/bin:${PATH}"
71-
USE_CXX11_ABI = "1"
72-
PIP_NO_INPUT = "1"
70+
[tool.cibuildwheel.linux.environment]
71+
ENABLE_BUNDLED_LIBOMP = "1"
72+
ENABLE_BUNDLED_LIBOMPTARGET = "1"
73+
LLVM_DIR = "/usr/lib64/cmake/llvm"
74+
CC = "/usr/bin/clang"
75+
CXX = "/usr/bin/clang++"
76+
77+
[tool.cibuildwheel.macos]
78+
before-all = ["bash buildscripts/cibuildwheel/setup-miniconda3.sh"]
79+
80+
[tool.cibuildwheel.macos.environment]
81+
ENABLE_BUNDLED_LIBOMP = "1"
82+
LLVM_DIR = "${PWD}/_stage/miniconda3/envs/llvmdev-${LLVM_VERSION}/lib/cmake/llvm"
83+
CC = "${PWD}/_stage/miniconda3/envs/llvmdev-${LLVM_VERSION}/bin/clang"
84+
CXX = "${PWD}/_stage/miniconda3/envs/llvmdev-${LLVM_VERSION}/bin/clang++"
85+
# Set the deplioyment target to macOS 11.0.
86+
MACOSX_DEPLOYMENT_TARGET = "11.0"
87+
# Set the cmake prefix path to find libraries in the conda environment which is
88+
# compatible with the macos target.
89+
CMAKE_PREFIX_PATH = "${PWD}/_stage/miniconda3/envs/llvmdev-${LLVM_VERSION}/"

0 commit comments

Comments
 (0)