Skip to content
Open
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
abdec47
wip
rparolin Mar 17, 2026
c418050
wip
rparolin Mar 17, 2026
b879fa5
fixing ci compiler errors
rparolin Mar 17, 2026
04ee3de
skipping tests that aren't supported
rparolin Mar 17, 2026
9ab3f46
cu12 support
rparolin Mar 17, 2026
bd75bc3
Merge branch 'main' into rparolin/managed_mem_advise_prefetch
rparolin Mar 17, 2026
1b1343b
Merge branch 'main' into rparolin/managed_mem_advise_prefetch
rparolin Mar 17, 2026
a948066
Moving to function from Buffer class methods to free standing functio…
rparolin Mar 17, 2026
1457599
precommit format
rparolin Mar 17, 2026
acb4024
iterating on implementation
rparolin Mar 18, 2026
d10ab07
Simplify managed-memory helpers: remove long-form aliases, cache look…
rparolin Mar 18, 2026
ae1de36
Merge branch 'main' into rparolin/managed_mem_advise_prefetch
rparolin Mar 18, 2026
c250c92
fix(test): reset _V2_BINDINGS cache so legacy-signature tests take th…
rparolin Mar 18, 2026
89329d9
fix(test): require concurrent_managed_access for advise tests that hi…
rparolin Mar 18, 2026
8a75d1b
fix: validate managed buffer before checking discard_prefetch binding…
rparolin Mar 18, 2026
9e9b1e0
refactor: extract managed memory ops into dedicated _managed_memory_o…
rparolin Mar 18, 2026
90f0711
pre-commit fix
rparolin Mar 18, 2026
b4d252c
Removing blank file
rparolin Mar 19, 2026
faaa1d8
wip
rparolin Mar 19, 2026
18786be
Merge branch 'main' into rparolin/managed_mem_advise_prefetch
rparolin Apr 6, 2026
9766ddc
Merge remote-tracking branch 'upstream/main' into rparolin/managed_me…
rparolin Apr 27, 2026
cf2f20d
fix(cuda.core): update binding_version import after upstream merge
rparolin Apr 27, 2026
db3bac2
revert: drop managed_memory shim in cuda.core.experimental
rparolin Apr 27, 2026
20d036e
feat(cuda.core): add Location dataclass for managed memory
rparolin Apr 27, 2026
c2dae53
feat(cuda.core): add _coerce_location helper
rparolin Apr 28, 2026
935c8ba
test(cuda.core): update monkeypatch target after binding_version rename
rparolin Apr 28, 2026
dc46535
refactor(cuda.core): tighten memory-attr query
rparolin Apr 28, 2026
818f5d2
feat(cuda.core): unified 1..N managed_memory.prefetch with cydriver
rparolin Apr 28, 2026
e296e72
feat(cuda.core): add managed_memory.discard
rparolin Apr 28, 2026
e697131
feat(cuda.core): unified 1..N managed_memory.discard_prefetch with cy…
rparolin Apr 28, 2026
3bc1021
feat(cuda.core): unified 1..N managed_memory.advise + drop legacy app…
rparolin Apr 28, 2026
fa23869
refactor(cuda.core): use Buffer.is_managed property in managed_memory…
rparolin Apr 28, 2026
68bdd14
docs(cuda.core): document Location, discard, and 1..N managed_memory ops
rparolin Apr 28, 2026
b4d9cbf
chore(cuda.core): drop narrative comments and tighten _coerce_locatio…
rparolin Apr 28, 2026
ee96758
chore(cuda.core): satisfy pre-commit hooks
rparolin Apr 28, 2026
d6f60f2
refactor(cuda.core): move managed_memory ops to cuda.core.utils
rparolin Apr 28, 2026
3176271
chore(cuda.core): use __all__ in utils instead of per-import noqa
rparolin Apr 28, 2026
782f6a9
chore(cuda.core): collapse nested if in Location.__post_init__ (SIM102)
rparolin Apr 28, 2026
0789bf6
test(cuda.core): share one DummyUnifiedMemoryResource per batched test
rparolin Apr 28, 2026
e0c782a
test(cuda.core): query all buffers before closing in test_batched_sam…
rparolin Apr 28, 2026
10de998
review(cuda.core): address PR #1775 feedback
rparolin Apr 30, 2026
ab9a3ab
test(cuda.core): split managed-memory ops tests into tests/memory/
rparolin Apr 30, 2026
a3f342f
test(cuda.core): fix options regex for AdviseOptions ("an" vs "a")
rparolin Apr 30, 2026
c2a9662
chore(cuda.core): drop unused utils import + trailing blank lines
rparolin Apr 30, 2026
bede674
feat(cuda.core): add ManagedBuffer subclass + Host location
rparolin Apr 30, 2026
f59af4e
chore(cuda.core): simplify ManagedBuffer per /simplify review
rparolin Apr 30, 2026
5147a7d
ci: re-trigger CI (transient cuInit INVALID_DEVICE on l4 runner)
rparolin Apr 30, 2026
2151e61
refactor(cuda.core): use libcpp.vector for batched-op C arrays (R14)
rparolin May 1, 2026
5c6d054
fix(cuda.core): restore CUDA_ERROR_NOT_INITIALIZED auto-init in _quer…
rparolin May 1, 2026
47d5609
refactor(cuda.core): make Host a plain class instead of a dataclass (R1)
rparolin May 1, 2026
a40bb81
feat(cuda.core)!: drop int location shorthand from managed-memory ops…
rparolin May 1, 2026
c43e81e
docs(cuda.core): add AccessedBySet to api_private.rst (R5)
rparolin May 1, 2026
71e9daa
docs(cuda.core): note the legacy NUMA round-trip limitation on prefer…
rparolin May 1, 2026
df928a0
refactor(cuda.core): use collections.abc.Sequence for input checks (R…
rparolin May 1, 2026
f522916
refactor(cuda.core): narrow Buffer.from_handle to Buffer-only (R3)
rparolin May 1, 2026
6204c57
refactor(cuda.core): single API surface per operation (R9, R10, R11)
rparolin May 1, 2026
36012fd
refactor(cuda.core): build advise reverse-lookup eagerly at module lo…
rparolin May 1, 2026
067fb15
refactor(cuda.core): factor shared body of _do_batch_{prefetch,discar…
rparolin May 1, 2026
a9cd713
test(cuda.core): reuse production _get_int_attr in managed-memory tes…
rparolin May 1, 2026
d75a7bd
feat(cuda.core): cu12 fallback for prefetch_batch (N3)
rparolin May 1, 2026
0af5bd4
test(cuda.core): cover AccessedBySet read methods (N7)
rparolin May 1, 2026
b0d1a21
feat(cuda.core): cu13 NUMA round-trip for ManagedBuffer.preferred_loc…
rparolin May 1, 2026
4c228eb
docs(cuda.core): replace stale utils autosummary entries
rparolin May 1, 2026
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(cuda.core): build advise reverse-lookup eagerly at module lo…
…ad (N4)

Per Leo's review on PR #1775 (_managed_memory_ops.pyx:23), drop the
lazy-init plumbing for the enum→alias reverse lookup table. The forward
table _MANAGED_ADVICE_ALIASES has six entries; building the inverse at
module load via a dict comprehension is the same data without the
mutable-global pattern, the `if None` check, or the `global` declaration
inside the function body.

Forward lookup table (_MANAGED_ADVICE_ALIASES) is preserved as the source
of truth — explicit alias→CUDA-name mapping, grep-friendly, no implicit
naming-convention coupling.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
  • Loading branch information
rparolin and claude committed May 1, 2026
commit 36012fd3ae8fefca20d9ccb2cdbd853a6ff84ed2
15 changes: 6 additions & 9 deletions cuda_core/cuda/core/_memory/_managed_memory_ops.pyx
Comment thread
rparolin marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ cdef dict _MANAGED_ADVICE_ALLOWED_LOCTYPES = {
"unset_accessed_by": _DEVICE_HOST_ONLY,
}

# Lazily cached: maps driver.CUmem_advise enum value → string alias.
cdef dict _ADVICE_ENUM_TO_ALIAS = None
# Reverse lookup: enum value → alias. Built once at module load.
cdef dict _ADVICE_ENUM_TO_ALIAS = {
getattr(driver.CUmem_advise, attr_name): alias
for alias, attr_name in _MANAGED_ADVICE_ALIASES.items()
if hasattr(driver.CUmem_advise, attr_name)
}


cdef tuple _normalize_managed_advice(object advice):
Expand All @@ -65,13 +69,6 @@ cdef tuple _normalize_managed_advice(object advice):
return alias, getattr(driver.CUmem_advise, attr_name)

if isinstance(advice, driver.CUmem_advise):
global _ADVICE_ENUM_TO_ALIAS
if _ADVICE_ENUM_TO_ALIAS is None:
_ADVICE_ENUM_TO_ALIAS = {}
for alias, attr_name in _MANAGED_ADVICE_ALIASES.items():
enum_val = getattr(driver.CUmem_advise, attr_name, None)
if enum_val is not None:
_ADVICE_ENUM_TO_ALIAS[enum_val] = alias
alias = _ADVICE_ENUM_TO_ALIAS.get(advice)
if alias is None:
raise ValueError(f"Unsupported advice value: {advice!r}")
Expand Down
Loading