-
Notifications
You must be signed in to change notification settings - Fork 263
Add managed-memory advise, prefetch, and discard-prefetch free functions #1775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
abdec47
c418050
b879fa5
04ee3de
9ab3f46
bd75bc3
1b1343b
a948066
1457599
acb4024
d10ab07
ae1de36
c250c92
89329d9
8a75d1b
9e9b1e0
90f0711
b4d252c
faaa1d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ | |
| finally: | ||
| del bindings, importlib, subdir, cuda_major, cuda_minor | ||
|
|
||
| from cuda.core import system, utils | ||
| from cuda.core import managed_memory, system, utils | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure I like this new module to collect just 3 functions TBH. How about we just move the functions to |
||
| from cuda.core._device import Device | ||
| from cuda.core._event import Event, EventOptions | ||
| from cuda.core._graph import ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,7 @@ A type union of :obj:`~driver.CUdeviceptr`, `int` and `None` for hinting | |
| :attr:`Buffer.handle`. | ||
| """ | ||
|
|
||
|
|
||
| cdef class Buffer: | ||
| """Represent a handle to allocated memory. | ||
|
|
||
|
|
@@ -420,14 +421,14 @@ cdef class Buffer: | |
|
|
||
| # Memory Attribute Query Helpers | ||
| # ------------------------------ | ||
| cdef inline void _init_mem_attrs(Buffer self): | ||
| cdef void _init_mem_attrs(Buffer self): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: Why do we remove |
||
| """Initialize memory attributes by querying the pointer.""" | ||
| if not self._mem_attrs_inited: | ||
| _query_memory_attrs(self._mem_attrs, as_cu(self._h_ptr)) | ||
| self._mem_attrs_inited = True | ||
|
|
||
|
|
||
| cdef inline int _query_memory_attrs( | ||
| cdef int _query_memory_attrs( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
| _MemAttrs& out, | ||
| cydriver.CUdeviceptr ptr | ||
| ) except -1 nogil: | ||
|
|
@@ -459,6 +460,7 @@ cdef inline int _query_memory_attrs( | |
| out.is_host_accessible = True | ||
| out.is_device_accessible = False | ||
| out.device_id = -1 | ||
| out.is_managed = False | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: This is where it gets tricky. As explained during the team sync, on a system with HMM/ATS enabled,
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmm I am now confused, why don't we just unconditionally set |
||
| elif ( | ||
| is_managed | ||
| or memory_type == cydriver.CUmemorytype.CU_MEMORYTYPE_HOST | ||
|
|
@@ -467,10 +469,12 @@ cdef inline int _query_memory_attrs( | |
| out.is_host_accessible = True | ||
| out.is_device_accessible = True | ||
| out.device_id = device_id | ||
| out.is_managed = is_managed != 0 | ||
| elif memory_type == cydriver.CUmemorytype.CU_MEMORYTYPE_DEVICE: | ||
| out.is_host_accessible = False | ||
| out.is_device_accessible = True | ||
| out.device_id = device_id | ||
| out.is_managed = False | ||
| else: | ||
| with cython.gil: | ||
| raise ValueError(f"Unsupported memory type: {memory_type}") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: This PR only touches cuda-core, why do we need to touch cuda-bindings?