-
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 cuda.core.experiemental.Linker class #229
base: main
Are you sure you want to change the base?
Conversation
1916359
to
81086e0
Compare
|
||
__slots__ = ("_handle") | ||
|
||
def __init__(self, options: LinkerOptions, object_codes = None): |
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 think we need to revert the order:
def __init__(self, options: LinkerOptions, object_codes = None): | |
def __init__(self, *object_codes, options: LinkerOptions = None): |
Taking *object_codes
also allows us to loop over it later.
cuda_core/tests/test_linker.py
Outdated
linker.add_code_object(functions[0]) | ||
linker.add_code_object(functions[1]) | ||
linker.add_code_object(functions[2]) |
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.
for func in compile_ptx_functions:
linker.add_code_object(func)
But I think I'd go beyond this:
- Add
Linker.add_code_objects(self, iterable):
in _linker.py and then use that here:
linker.add_code_objects(compile_ptx_functions)
- I'd try hard to find something here to
assert
, or (probably best) just drop this particulartest_linker_add_code_object()
function, because it's the exact same code as in the next two functions.
linker.add_code_object(functions[1]) | ||
linker.add_code_object(functions[2]) | ||
|
||
def test_linker_link_ptx(compile_ltoir_functions): |
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'm unclear about what combinations of functions {ptx
, ltoir
} and target_type
s {ptx
, cubin
} are valid.
To reduce the code duplication, could this work as a general idea?
@pytest.mark.parametrize("functions", [compile_ptx_functions, compile_ltoir_functions])
@pytest.mark.parametrize("target_type", ["ptx", "cubin"])
I'm not sure if/how that works with fixtures though.
I'd also add these right here:
log = linker.get_error_log()
assert isinstance(log, str)
log = linker.get_info_log()
assert isinstance(log, str)
I think that could consolidate four test functions into one.
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 like the idea of using parameterize, so I added it to the linker init test. In general I write tests to be as minimal as possible, and then to build on each other. ie I like to test add_code_object() in isolation before calling it in another test such as test_linker_link_ptx. This is just something I picked up when working on my last project, as there were a lot of fragile components, and it made it a faster process to determine where the issue was. That said, you have a lot more experience than me, so I am tempted to go with your suggestion of consolidating tests. I've left it as is for now
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.
actually, considering the removal of add_codeObject as a public entrypoint that test can go.
wrap nvjitlink into the object model.
Depends on #224