Skip to content
Open
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
6 changes: 3 additions & 3 deletions cuda_bindings/pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cuda_bindings/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ repair-wheel-command = "delvewheel repair --namespace-pkg cuda -w {dest_dir} {wh
required_plugins = "pytest-benchmark"
addopts = "--benchmark-disable"
norecursedirs = ["tests/cython", "examples"]
xfail_strict = true
41 changes: 36 additions & 5 deletions cuda_bindings/tests/test_cufile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import tempfile
from contextlib import suppress
from functools import cache
from pathlib import Path

import cuda.bindings.driver as cuda
import pytest
Expand All @@ -24,7 +25,9 @@
try:
from cuda.bindings import cufile
except ImportError:
cufile = None
cufile = cuFileError = None
else:
from cuda.bindings.cufile import cuFileError


def platform_is_wsl():
Expand Down Expand Up @@ -90,24 +93,32 @@ def cufileVersionLessThan(target):
return True # Assume old version if any error occurs


def find_mount_point(path):
return next((str(parent) for parent in Path(path).absolute().parents if parent.is_mount()), None)


@cache
def isSupportedFilesystem():
"""Check if the current filesystem is supported (ext4 or xfs)."""

try:
current_dir = os.getcwd()
# Try to get filesystem type from /proc/mounts
curdir_mount = find_mount_point(current_dir)
assert curdir_mount is not None
with open("/proc/mounts") as f:
for line in f:
parts = line.split()
if len(parts) >= 2:
if len(parts) >= 3:
mount_point = parts[1]
fs_type = parts[2]

# Check if current directory is under this mount point
current_dir = os.path.abspath(".")
if current_dir.startswith(mount_point):
if curdir_mount == mount_point:
fs_type_lower = fs_type.lower()
logging.info(f"Current filesystem type: {fs_type_lower}")
return fs_type_lower in ["ext4", "xfs"]
if fs_type_lower in ("ext4", "xfs"):
return True

# If we get here, we couldn't determine the filesystem type
logging.warning("Could not determine filesystem type from /proc/mounts")
Expand All @@ -132,7 +143,15 @@ def test_driver_open():
cufile.driver_close()


xfail_handle_register = pytest.mark.xfail(
condition=isSupportedFilesystem() and os.environ.get("CI") is not None,
raises=cuFileError,
reason="handle_register call fails in CI for unknown reasons",
)


@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_handle_register():
"""Test file handle registration with cuFile."""
# Initialize CUDA
Expand Down Expand Up @@ -452,6 +471,7 @@ def test_buf_register_already_registered():


@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_cufile_read_write():
"""Test cuFile read and write operations."""
# Initialize CUDA
Expand Down Expand Up @@ -559,6 +579,7 @@ def test_cufile_read_write():


@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_cufile_read_write_host_memory():
"""Test cuFile read and write operations using host memory."""
# Initialize CUDA
Expand Down Expand Up @@ -662,6 +683,7 @@ def test_cufile_read_write_host_memory():


@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_cufile_read_write_large():
"""Test cuFile read and write operations with large data."""
# Initialize CUDA
Expand Down Expand Up @@ -772,6 +794,7 @@ def test_cufile_read_write_large():


@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_cufile_write_async(cufile_env_json):
"""Test cuFile asynchronous write operations."""
# Initialize CUDA
Expand Down Expand Up @@ -865,6 +888,7 @@ def test_cufile_write_async(cufile_env_json):


@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_cufile_read_async(cufile_env_json):
"""Test cuFile asynchronous read operations."""
# Initialize CUDA
Expand Down Expand Up @@ -971,6 +995,7 @@ def test_cufile_read_async(cufile_env_json):


@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_cufile_async_read_write(cufile_env_json):
"""Test cuFile asynchronous read and write operations in sequence."""
# Initialize CUDA
Expand Down Expand Up @@ -1100,6 +1125,7 @@ def test_cufile_async_read_write(cufile_env_json):


@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_batch_io_basic():
"""Test basic batch IO operations with multiple read/write operations."""
# Initialize CUDA
Expand Down Expand Up @@ -1319,6 +1345,7 @@ def test_batch_io_basic():


@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_batch_io_cancel():
"""Test batch IO cancellation."""
# Initialize CUDA
Expand Down Expand Up @@ -1419,6 +1446,7 @@ def test_batch_io_cancel():


@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_batch_io_large_operations():
"""Test batch IO with large buffer operations."""

Expand Down Expand Up @@ -1932,6 +1960,7 @@ def test_stats_start_stop():
cufileVersionLessThan(1150), reason="cuFile parameter APIs require cuFile library version 13.0 or later"
)
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_get_stats_l1():
"""Test cuFile L1 statistics retrieval with file operations."""
# Initialize CUDA
Expand Down Expand Up @@ -2031,6 +2060,7 @@ def test_get_stats_l1():
cufileVersionLessThan(1150), reason="cuFile parameter APIs require cuFile library version 13.0 or later"
)
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_get_stats_l2():
"""Test cuFile L2 statistics retrieval with file operations."""
# Initialize CUDA
Expand Down Expand Up @@ -2134,6 +2164,7 @@ def test_get_stats_l2():
cufileVersionLessThan(1150), reason="cuFile parameter APIs require cuFile library version 13.0 or later"
)
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@xfail_handle_register
def test_get_stats_l3():
"""Test cuFile L3 statistics retrieval with file operations."""
# Initialize CUDA
Expand Down
Loading