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

Enable SPIR-V to device caching #1236

Merged
merged 3 commits into from
Dec 12, 2023
Merged

Conversation

ZzEeKkAa
Copy link
Contributor

@ZzEeKkAa ZzEeKkAa commented Dec 7, 2023

Add kernel reference caching for the SPIRV to device compilation. This is a critical change to make experimental kernels usable.

Should we remove comment from kernel_dispatcher.py?

# TODO: Enable caching
# Add code to enable on disk caching of a binary spirv kernel.
# Refer: https://github.com/IntelPython/numba-dpex/issues/1197

I've add simple test to check if second run does not crash XD. I've made sure that kernel reference is taking from cache by enabling logs and making sure it reached right place.

Since we can not implement caching on kernel dispatcher level due to missing information about context that is available only at runtime, I guess we can close this issue.

Closes: #1070

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • If this PR is a work in progress, are you filing the PR as a draft?

@ZzEeKkAa ZzEeKkAa self-assigned this Dec 7, 2023
@ZzEeKkAa ZzEeKkAa changed the title Enable SPIR-V to device caching WIP: Enable SPIR-V to device caching Dec 7, 2023
@ZzEeKkAa ZzEeKkAa force-pushed the feature/enable_spirv_to_device_caching branch 2 times, most recently from 94bfb6a to f441804 Compare December 7, 2023 21:26
@ZzEeKkAa ZzEeKkAa changed the base branch from main to feature/use_numpy_as_python_sublibrary_in_cmake December 7, 2023 21:26
@ZzEeKkAa ZzEeKkAa force-pushed the feature/enable_spirv_to_device_caching branch from f441804 to 3c19872 Compare December 7, 2023 21:58
@ZzEeKkAa ZzEeKkAa changed the title WIP: Enable SPIR-V to device caching Enable SPIR-V to device caching Dec 7, 2023
@ZzEeKkAa ZzEeKkAa marked this pull request as ready for review December 7, 2023 22:07
@ZzEeKkAa ZzEeKkAa requested a review from diptorupd as a code owner December 7, 2023 22:07
@ZzEeKkAa ZzEeKkAa force-pushed the feature/enable_spirv_to_device_caching branch from 3c19872 to e68ada4 Compare December 7, 2023 22:09
Base automatically changed from feature/use_numpy_as_python_sublibrary_in_cmake to main December 7, 2023 22:19
@ZzEeKkAa ZzEeKkAa force-pushed the feature/enable_spirv_to_device_caching branch 3 times, most recently from d298a22 to 471ced0 Compare December 8, 2023 21:08
@diptorupd
Copy link
Contributor

Should we remove comment from kernel_dispatcher.py?

# TODO: Enable caching
# Add code to enable on disk caching of a binary spirv kernel.
# Refer: https://github.com/IntelPython/numba-dpex/issues/1197

No, that is a different issue. Numba supports ahead of time (AOT) compilation using on disk caching of compiled binaries. That way if you run a function with cache=True flag the function gets serialized to disk and the next time Numba is started the on disk cached function is de-serialized and used. In our case, that will mean we serialize the SPIRV binary generated for a kernel to disk and next time de-serialize and use it. KernelBundle caching comes after that and unrelated.

@ZzEeKkAa ZzEeKkAa force-pushed the feature/enable_spirv_to_device_caching branch 2 times, most recently from 28dd515 to 1c9dbcf Compare December 11, 2023 21:56
@diptorupd diptorupd force-pushed the feature/enable_spirv_to_device_caching branch from 1c9dbcf to 9a2f1a0 Compare December 12, 2023 02:25
@ZzEeKkAa ZzEeKkAa enabled auto-merge December 12, 2023 02:51
@ZzEeKkAa ZzEeKkAa force-pushed the feature/enable_spirv_to_device_caching branch from 9a2f1a0 to a8178c6 Compare December 12, 2023 17:26
Copy link
Contributor

@diptorupd diptorupd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! One step closer to making the experimental kernel really usable. :)

@ZzEeKkAa ZzEeKkAa merged commit 8fc7fbd into main Dec 12, 2023
30 of 38 checks passed
@ZzEeKkAa ZzEeKkAa deleted the feature/enable_spirv_to_device_caching branch December 12, 2023 19:16
github-actions bot added a commit that referenced this pull request Dec 12, 2023
github-actions bot added a commit to chudur-budur/numba-dpex that referenced this pull request Dec 12, 2023
…pirv_to_device_caching

Enable SPIR-V to device caching 8fc7fbd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overhead on running dpex kernels
2 participants