-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Alternative options for creating a serial copy of alpaka modules #43803
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
Changes from 1 commit
ddda404
3f668a2
66176a1
80e5540
64b8cc1
c1d92e9
52d6ef2
a0bbd42
98d4fec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| def makeSerialClone(module, **kwargs): | ||
| type = module._TypedParameterizable__type | ||
| if type.endswith('@alpaka'): | ||
| # alpaka module with automatic backend selection | ||
| base = type.removesuffix('@alpaka') | ||
| elif type.startswith('alpaka_serial_sync::'): | ||
| # alpaka module with explicit serial_sync backend | ||
| base = type.removeprefix('alpaka_serial_sync::') | ||
|
Comment on lines
+6
to
+8
Contributor
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. The |
||
| elif type.startswith('alpaka_cuda_async::'): | ||
| # alpaka module with explicit cuda_async backend | ||
| base = type.removeprefix('alpaka_cuda_async::') | ||
| elif type.startswith('alpaka_rocm_async::'): | ||
| # alpaka module with explicit rocm_async backend | ||
| base = type.removeprefix('alpaka_rocm_async::') | ||
|
Comment on lines
+6
to
+14
Contributor
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. The if-else chain could be replaced with e.g. a regex to remove the |
||
| else: | ||
| # non-alpaka module | ||
| raise TypeError('%s is not an alpaka-based module, and cannot be used with makeSerialClone()' % str(module)) | ||
|
|
||
| copy = module.clone(**kwargs) | ||
| copy._TypedParameterizable__type = 'alpaka_serial_sync::' + base | ||
| if 'alpaka' in copy.parameterNames_(): | ||
| del copy.alpaka | ||
| return copy | ||
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.
@makortel what do you think ?
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 this is much better than spreading around the direct modification
copy._TypedParameterizable__type, and a reasonable way for immediate needs. For the longer term I'd still like to solve the problem in different way, with which I'll follow up in #43780