Skip to content

Commit 682db0f

Browse files
Andy-Jostclaude
andcommitted
cuda.core: compare the descriptor's chunk count with a signed length
The CI wheel build compiles with -Werror and -Wsign-compare, and the VMM import path compared a size_t count with the Py_ssize_t that len() returns. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 2231df7 commit 682db0f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎cuda_core/cuda/core/_memory/_virtual_memory_resource.pyx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,8 @@ cdef class VirtualMemoryResource(MemoryResource):
806806
cdef VaMappingHandle h_map
807807
cdef VmmRangeHandle rng
808808
cdef DevicePtrHandle h_ptr
809-
cdef size_t gran, addr_align, chunk, i, n, total = 0, offset = 0
809+
cdef size_t gran, addr_align, chunk, total = 0, offset = 0
810+
cdef Py_ssize_t n, i
810811
cdef cydriver.CUdeviceptr hint
811812
cdef int handle_type, fd
812813
cdef void* os_handle
@@ -866,11 +867,11 @@ cdef class VirtualMemoryResource(MemoryResource):
866867
_raise_last_error()
867868
for i in range(n):
868869
with nogil:
869-
h_map = create_va_mapping_handle(as_cu(h_res) + offset, allocs[i], h_res)
870+
h_map = create_va_mapping_handle(as_cu(h_res) + offset, allocs[<size_t>i], h_res)
870871
if not h_map:
871872
_raise_last_error()
872873
mappings.push_back(h_map)
873-
offset += mem_allocation_size(allocs[i])
874+
offset += mem_allocation_size(allocs[<size_t>i])
874875
rng = create_vmm_range(mappings)
875876
h_ptr = deviceptr_create_vmm(as_cu(h_res), rng)
876877
if not h_ptr:

0 commit comments

Comments
 (0)