-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add the options data class to program #237
base: main
Are you sure you want to change the base?
Conversation
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 some drive-by observations. Feel free to ignore!
device_stack_protector: Optional[bool] = None # /**< --device-stack-protector (-device-stack-protector) Enable stack canaries in device code. */ | ||
|
||
def __post_init__(self): | ||
# Format options into a list of strings |
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.
I don't think this comment is correct. Because of all the .encode()
calls, won't self.formatted_options
be a list of bytes objects? Is that really intended?
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.
We could consider keeping strings and deferring the .encode()
conversion to bytes in Program
ctor. This way ProgramOptions
can be easily inspected/debugged by human. WDYT?
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.
You're right about that being a bad comment. I will fix it. WRT your suggestion Leo, I used bytes so that we didn't need to duplicate the list of options, but perhaps that efficiency vs usability tradeoff is not worth it
if self.diag_warn is not None: | ||
self.formatted_options.append(f"--diag-warn={self.diag_warn}".encode()) | ||
if self.brief_diagnostics is not None: | ||
self.formatted_options.append(f"--brief-diagnostics={'true' if self.brief_diagnostics else 'false'}".encode()) |
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.
The ternary statement seems like a pattern that might benefit from a helper function.
from dataclasses import dataclass | ||
|
||
@dataclass | ||
class ProgramOptions: |
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.
TODO:
- As we discussed briefly offline, let's find out if we can autogen the docstrings. It should contain the description for the option, the default value if unset, acceptable value type, and then explain what the underlying C option it maps to, something like (no need to take this literally)
gpu_architecture : Specify the name of the class of GPU architectures for which the input must be compiled.
.. seealso:: ` --gpu-architecture`, `-arch`
- There are some options we might have to tweak/combine, e.g.
device_c
vsrelocatable_device_code
. Let's chat offline about this. - For
gpu_architecture
I think we should detect the current device's CC if it's unset, instead of falling back to NVRTC default
Thanks, Berry 🙏 We welcome feedbacks and won't ignore anyone! |
Another TODO: Let's also update the code samples and show the best practice! |
Is there a way to add these as doctests so that the code samples must always be kept in working order? |
@warsawnv Totally. I'm actively working on getting github actions working, and the examples are invoked as part of the testsuite. |
closes #221
Add the options class to Program.
TODO modify the test so that it compiles the program with options once the CI is in place. I was running into compile issues that seemed related to my environment.