From 983532b87d3c0476757f0653999b866bb9f6922c Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Fri, 28 Aug 2026 15:11:19 +0800 Subject: [PATCH] fix(cuda.core): decode signed long long field values Signed-off-by: Rui Luo --- cuda_core/cuda/core/system/_field_values.pxi | 2 +- cuda_core/tests/system/test_system_device.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cuda_core/cuda/core/system/_field_values.pxi b/cuda_core/cuda/core/system/_field_values.pxi index 4a9e5cc748f..d109bc2bc13 100644 --- a/cuda_core/cuda/core/system/_field_values.pxi +++ b/cuda_core/cuda/core/system/_field_values.pxi @@ -75,7 +75,7 @@ cdef class FieldValue: elif value_type == ValueType.UNSIGNED_LONG_LONG: return int(value.ull_val[0]) elif value_type == ValueType.SIGNED_LONG_LONG: - return int(value.ll_val[0]) + return int(value.sll_val[0]) elif value_type == ValueType.SIGNED_INT: return int(value.si_val[0]) elif value_type == ValueType.UNSIGNED_SHORT: diff --git a/cuda_core/tests/system/test_system_device.py b/cuda_core/tests/system/test_system_device.py index 078ca5a835c..0d55afd6f29 100644 --- a/cuda_core/tests/system/test_system_device.py +++ b/cuda_core/tests/system/test_system_device.py @@ -445,6 +445,19 @@ def test_field_values(subtests): assert field_values[0].value <= old_value +@pytest.mark.agent_authored(model="gpt-5.6-sol") +def test_field_value_decodes_signed_long_long(): + """SIGNED_LONG_LONG decodes from nvmlValue_t.sll_val as a Python int.""" + field_value = nvml.FieldValue() + field_value.nvml_return = int(nvml.Return.SUCCESS) + field_value.value_type = int(nvml.ValueType.SIGNED_LONG_LONG) + field_value.value.sll_val[0] = -45 + + value = _device.FieldValue(field_value).value + assert value == -45 + assert type(value) is int + + @pytest.mark.skipif(helpers.IS_WSL or helpers.IS_WINDOWS, reason="Device attributes not supported on WSL or Windows") def test_get_all_devices_with_cpu_affinity(subtests): for i in range(multiprocessing.cpu_count()):