Skip to content

[Backport] Enable Cython tests for cuda.bindings #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading