Skip to content
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

Use more descriptive ElementwiseKernel names in cucim.skimage #75

Conversation

grlee77
Copy link
Contributor

@grlee77 grlee77 commented Jul 21, 2021

This PR is mainly for convenience when profiling or otherwise inspecting custom kernels produced by the cucim.skimage package.

This PR makes all kernel names start with cucim_skimage_ which helps to differentiate them from kernels originating elsewhere.

Most CuPy kernels start with cupy_ or cupyx_. I opened a similar PR upstream to fix some inconsistencies there: cupy/cupy#5551

@grlee77 grlee77 added improvement Improves an existing functionality non-breaking Introduces a non-breaking change labels Jul 21, 2021
@grlee77 grlee77 requested a review from a team as a code owner July 21, 2021 20:29
@jakirkham
Copy link
Member

Thanks Greg! 😄

This seems like a nice change. Would these be picked up by NVTX?

Am curious if we can automate the name generation a bit like using the module and function __names__. WDYT?

@grlee77
Copy link
Contributor Author

grlee77 commented Jul 22, 2021

Would these be picked up by NVTX?

I think so, but haven't tried it. I wrote a script that would create a temporary CuPy cache directory and then run the full CuCIM test suite, saving any runtime-generated kernels. Each .cu file ends up named with a hash generated by CuPy, but it is fairly easy to extract the kernel name from the file (since there is only one kernel defined per file) and rename the files accordingly. I was doing this just out of curiosity of how many kernels get generated at runtime from local kernels vs. cupy vs. cupyx.scipy, etc.

It turns out about 2,000 kernels get generated while running the test suite! This doesn't count the use of precompiled kernels in libraries like cuBLAS or cuFFT, just the ones compiled by NVRTC at run time.

Am curious if we can automate the name generation a bit like using the module and function names. WDYT?

We could, but I'm not sure it is worth the trouble at this point. It is still sometimes helpful to append some additional info such as boundary mode or number of dimensions, etc to kernel names.

@jakirkham
Copy link
Member

jakirkham commented Jul 22, 2021

Gotcha. Well I'd hope we wouldn't need to understand the hashes used to read an NVTX trace, but maybe this is a separate discussion.

That doesn't surprise me. Particularly with the combination of different types, shapes (if relevant), etc.

Just for context, am thinking something like this...

def func():
    pass

print("_".join([__name__, func.__name__, ...]))

@quasiben
Copy link
Member

Is this now ready to be merged in ?

@grlee77
Copy link
Contributor Author

grlee77 commented Jul 27, 2021

I think so

@quasiben
Copy link
Member

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 0a6b9dc into rapidsai:branch-21.08 Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improves an existing functionality non-breaking Introduces a non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants