Skip to content

Commit

Permalink
Merge pull request #359 from leofang/cython_11_8
Browse files Browse the repository at this point in the history
[Backport] Enable Cython tests for `cuda.bindings`
  • Loading branch information
leofang authored Jan 10, 2025
2 parents 1f01b00 + d32a05c commit e56b97a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/actions/fetch_ctk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,6 @@ runs:
run: |
CUDA_PATH=$(realpath "./cuda_toolkit")
echo "CUDA_PATH=${CUDA_PATH}" >> $GITHUB_ENV
echo "CUDA_HOME=${CUDA_PATH}" >> $GITHUB_ENV
echo "${CUDA_PATH}/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:${CUDA_PATH}/lib" >> $GITHUB_ENV
14 changes: 12 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
env:
# we use self-hosted runners on which setup-python behaves weirdly...
AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache"

- name: Set up mini CTK
uses: ./.github/actions/fetch_ctk
Expand All @@ -255,6 +258,13 @@ jobs:
pushd ./cuda_bindings
pip install -r requirements.txt
pytest -rxXs tests/
# TODO: enable cython tests
#pytest tests/cython
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
# cython tests require gcc
apt install -y build-essential
bash tests_cython/build_tests.sh
elif [[ "${{ matrix.host-platform }}" == win* ]]; then
# TODO: enable this once win-64 runners are up
exit 1
fi
pytest -rxXs tests_cython
popd
4 changes: 4 additions & 0 deletions cuda_bindings/tests_cython/build_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

cd "$(dirname "$0")"
CPLUS_INCLUDE_PATH=$CUDA_HOME/include:$CPLUS_INCLUDE_PATH cythonize -3 -i test_*.pyx
5 changes: 4 additions & 1 deletion cuda_bindings/tests_cython/test_ccuda.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# this software. Any use, reproduction, disclosure, or distribution of
# this software and related documentation outside the terms of the EULA
# is strictly prohibited.

# distutils: language=c++

from libc.string cimport (
memset,
memcmp
Expand Down Expand Up @@ -53,4 +56,4 @@ def test_ccuda_memcpy():
err = ccuda.cuMemFree(dptr)
assert(err == 0)
err = ccuda.cuCtxDestroy(ctx)
assert(err == 0)
assert(err == 0)
3 changes: 3 additions & 0 deletions cuda_bindings/tests_cython/test_ccudart.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# this software. Any use, reproduction, disclosure, or distribution of
# this software and related documentation outside the terms of the EULA
# is strictly prohibited.

# distutils: language=c++

from libc.string cimport (
memset,
memcmp
Expand Down
3 changes: 3 additions & 0 deletions cuda_bindings/tests_cython/test_interoperability_cython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# this software. Any use, reproduction, disclosure, or distribution of
# this software and related documentation outside the terms of the EULA
# is strictly prohibited.

# distutils: language=c++

import pytest
import cuda.cuda as cuda
import cuda.cudart as cudart
Expand Down

0 comments on commit e56b97a

Please sign in to comment.