Skip to content

Commit 9883354

Browse files
committed
add test for get_parameter_min_max and add pytest marker
1 parent 2beaf11 commit 9883354

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

cuda_bindings/tests/test_cufile.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,9 @@ def test_set_get_parameter_bool():
18201820
finally:
18211821
cuda.cuDevicePrimaryCtxRelease(device)
18221822

1823-
1823+
@pytest.mark.skipif(
1824+
cufileVersionLessThan(1140), reason="cuFile parameter APIs require cuFile library version 1.14.0 or later"
1825+
)
18241826
def test_set_get_parameter_string():
18251827
"""Test setting and getting string parameters with cuFile validation."""
18261828

@@ -1957,6 +1959,47 @@ def test_set_stats_level():
19571959
cuda.cuDevicePrimaryCtxRelease(device)
19581960

19591961

1962+
@pytest.mark.skipif(
1963+
cufileVersionLessThan(1140), reason="cuFile parameter APIs require cuFile library version 13.0 or later"
1964+
)
1965+
def test_get_parameter_min_max_value():
1966+
"""Test getting minimum and maximum values for size_t parameters."""
1967+
(err,) = cuda.cuInit(0)
1968+
assert err == cuda.CUresult.CUDA_SUCCESS
1969+
1970+
err, device = cuda.cuDeviceGet(0)
1971+
assert err == cuda.CUresult.CUDA_SUCCESS
1972+
1973+
err, ctx = cuda.cuDevicePrimaryCtxRetain(device)
1974+
assert err == cuda.CUresult.CUDA_SUCCESS
1975+
(err,) = cuda.cuCtxSetCurrent(ctx)
1976+
assert err == cuda.CUresult.CUDA_SUCCESS
1977+
1978+
cufile.driver_open()
1979+
1980+
try:
1981+
# Test with poll threshold parameter
1982+
param = cufile.SizeTConfigParameter.POLLTHRESHOLD_SIZE_KB
1983+
1984+
# Allocate ctypes variables for min and max values
1985+
min_value = ctypes.c_size_t()
1986+
max_value = ctypes.c_size_t()
1987+
1988+
# Get min/max values
1989+
cufile.get_parameter_min_max_value(param, ctypes.addressof(min_value), ctypes.addressof(max_value))
1990+
1991+
# Verify that min <= max and both are reasonable values
1992+
assert min_value.value >= 0, f"Invalid min value: {min_value.value}"
1993+
assert max_value.value >= min_value.value, f"Max value {max_value.value} < min value {min_value.value}"
1994+
assert max_value.value > 0, f"Invalid max value: {max_value.value}"
1995+
1996+
logging.info(f"POLLTHRESHOLD_SIZE_KB: min={min_value.value}, max={max_value.value}")
1997+
1998+
finally:
1999+
cufile.driver_close()
2000+
cuda.cuDevicePrimaryCtxRelease(device)
2001+
2002+
19602003
@pytest.mark.skipif(
19612004
cufileVersionLessThan(1150), reason="cuFile parameter APIs require cuFile library version 13.0 or later"
19622005
)

0 commit comments

Comments
 (0)