Commit 513ebfc
committed
fix(core): compare CUdeviceptr as int so the VMM grow fast path can run
`modify_allocation()` asks `cuMemAddressReserve` for the address immediately
after the current range, then checks whether the driver granted that exact
address before taking the fast path.
`cuMemAddressReserve` returns `new_ptr` as a `CUdeviceptr`. That type defines
`__int__` and `__repr__` but no `__eq__` or `__richcmp__`, so `new_ptr != <int>`
falls back to identity comparison and is unconditionally true. The guard is
therefore always taken and `_grow_allocation_fast_path` is unreachable: every
grow runs the slow path, re-reserving the whole range and remapping it, so the
buffer's base pointer changes even when a contiguous extension was available.
Convert with `int()` before comparing. Reported as defect 2 in #2388.
Two tests cover this:
- `test_cudeviceptr_is_never_equal_to_plain_int` pins the underlying pitfall,
that `CUdeviceptr(x) == x` is False and call sites must go through `int()`.
- `test_vmm_allocator_grow_dispatches_to_fast_path` stubs `cuMemAddressReserve`
to grant the requested address and asserts the dispatch reaches the fast path.
It fails on the current code, which records "slow".
Note this makes a previously unreachable code path live, so it is a behavior
change rather than a pure cleanup: successful contiguous grows now preserve the
base pointer instead of moving it. The existing
`test_vmm_allocator_grow_allocation_fast_path` already exercised
`_grow_allocation_fast_path` directly, so the helper itself is covered; what was
missing was coverage of the dispatch decision that reaches it.
Signed-off-by: Aryan Putta <aryansputta@gmail.com>1 parent 76bac4e commit 513ebfc
2 files changed
Lines changed: 64 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
269 | 273 | | |
270 | 274 | | |
271 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1035 | 1035 | | |
1036 | 1036 | | |
1037 | 1037 | | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
1038 | 1097 | | |
1039 | 1098 | | |
1040 | 1099 | | |
| |||
0 commit comments