-
Notifications
You must be signed in to change notification settings - Fork 171
Implement Kernel.num_arguments, and Kernel.arguments_info #612
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
Conversation
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
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.
Thanks, Sasha! Looks great except for the docstrings, see my comment below.
We also need to add a feature entry to cuda_core/docs/source/release/0.3.0-notes.rst
.
…erties Also parametrize test to check arguments_info to check with all int, and all short arguments.
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
/ok to test |
This comment has been minimized.
This comment has been minimized.
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.
LGTM although I'd use a dataclass
for better ergonomics.
I fixed pre-commit, and added a line to |
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.
Two minor suggestions, please see here for background:
https://chatgpt.com/share/681d1a68-97d0-8008-bad5-40ae287f7d55
(When I wrote the first prompt I had "module scope" in mind, but I think class scope is better.)
Used modern namedtuple instance constructor.
This perplexes me:
|
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.
This looks perfect to me. Caveat: I cannot explain the ipython observation.
Let me look into it tmr |
nit: as much as I love credit attribution (thanks), let's not do |
/ok to test 2ca9704 |
This required moving ParamInfo definition from class scope to module scope, since referencing Kernel.ParamInfo from annotations of methods of the Kernel class results in error that Kernel class does not yet exist.
/ok to test 55f6d31 |
Test that
Did I misunderstand the intent of |
I feel |
I meant it to ensure that cuda is not initialized at the start of this test. Kind of like opposite of |
Yes feel free to implement any fixture you need. No need to refactor the existing fixtures if you don't want to sweat in this PR -- but then we should create an issue to track it (to the very least, we should rename To make sure we understand "initialized" in the same way -- You don't mean |
Use in test_module.py::test_num_args_error_handling Add comments
/ok to test |
/ok to test |
1. Changed fixture to provide a function that empties the stack of contexts. The function has hidden max_iters bound. If exceeded, a RuntimeError is raised 2. Modified _device_unset_current utility function to return a boolean. True is returned is a context was popped, False if the stack was already empty.
/ok to test |
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.
Just a couple cosmetic suggestions. Optional.
raise NotImplementedError("New backend is required") | ||
arg_pos = 0 | ||
param_info_data = [] | ||
while True: |
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.
Maybe (sorry I overlooked this before):
for arg_pos in itertools.count():
Then you don't need arg_pos = 0
above and arg_pos = arg_pos + 1
below.
if _device_unset_current(): | ||
# context was popped, continue until stack is empty | ||
continue | ||
# no active context, we are ready | ||
break |
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.
Maybe shorter (replace 5 lines with 2):
if not _device_unset_current():
break
|
Description
closes #568
This PR implements
Kernel.num_arguments
andKernel.argument_info
properties:Kernel.num_arguments
returns the number of arguments in the kernel instanceKernel.argument_info
returns a list of tuples(offset, size)
which describes layout of the struct containing all kernel arguments,Checklist