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

Refactor/kernel interfaces #804

Merged
merged 51 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
85f6b93
Move passbuilder into core.
Oct 22, 2022
9dcbd7d
Add a compiler module into core.
Oct 22, 2022
96e5e87
Adds an arg_pack_unpack module to kernel_interface
Oct 22, 2022
2939444
Change exception behavior
Oct 26, 2022
f91e278
Refactored kernel dispatch API.
Oct 18, 2022
87b3d99
Temp commit to add a driver.py to run refactored code base.
Oct 24, 2022
2b7267b
Improve exceptions.
Oct 28, 2022
390da76
Update the temporary driver.
Nov 4, 2022
d9b6ffa
Added global range checks, kernel now uses dispatcher.
Nov 4, 2022
cd5d48e
Fix the pack/repack of Numpy arrays
Nov 8, 2022
c4a4749
Update existing compute follows data unit test.
Nov 8, 2022
8e0403c
Fix failing test_sycl_usm_array_iface_interop tests.
Nov 8, 2022
3c997b8
Rewrite test to use refactored API.
Nov 8, 2022
782069e
Update tests to check DI tag generation.
Nov 9, 2022
bce61d2
Fix to address failing unit test for strided numpy array support.
Nov 9, 2022
c193533
move pass pipelines into compiler.py
Nov 20, 2022
fb677db
Incorporate review comments.
Nov 20, 2022
43bb3da
Port func decorator to new API.
Nov 21, 2022
e447f10
Migrate functionality in numba_dpex.compiler module to new compiler.
Dec 7, 2022
ce53d58
Mark the caching tests as xfail.
Dec 7, 2022
5ffc555
A new LRU cache backed by numba's pickling mechanism
chudur-budur Dec 8, 2022
53c5f80
Added rst for caching
chudur-budur Dec 13, 2022
c3e661b
Fix type import.
Dec 19, 2022
d718a0e
Bring back support for kernel specialization.
Dec 27, 2022
c70795b
Update driver.py with specialization.
Jan 5, 2023
b19d715
Fix driver
Jan 6, 2023
63490a8
Fix formatting issues.
Jan 6, 2023
4d0dd19
Improvements to USMNdArrayType.
Jan 6, 2023
1b6b452
Remove the function signature from the cache composite key.
Jan 6, 2023
3e14764
Add unit tests for kernel specialization.
Jan 6, 2023
539adff
Mark all vectorize tests as xfail.
Jan 6, 2023
7d35b62
Improve support for SUAI arrays as kernel arguments.
Jan 7, 2023
3639f61
Fix failing test_barrier tests and add checks to disallow specializat…
Jan 7, 2023
b1ad49c
Fix test_kernel_has_return_value_error test case.
Jan 7, 2023
bca00c5
Address review comments.
Jan 8, 2023
876d4d2
Use new compiler to compiler parfors.
Jan 10, 2023
da1440f
Fully remove numba_dpex.compiler module.
Jan 7, 2023
1d3a529
Remove the temporary driver.py file.
Jan 10, 2023
020da9e
Added ndarray setup check.
mingjie-intel Jan 9, 2023
12fa8a3
Added tests for ndrange exceptions.
mingjie-intel Jan 10, 2023
f341ab2
Add an example for aot kernel specialization.
Jan 10, 2023
d275e1d
Fix deprecation warnings.
Jan 10, 2023
8150a96
Add docsstrings.
Jan 11, 2023
6ef8212
Switched to dpctl.tensor in test_ndrange_exceptions.py.
mingjie-intel Jan 10, 2023
40d85fb
Changes to compute-follows-data implementation and specialization.
Jan 11, 2023
42958f4
Rename AOT to eager compilation.
Jan 13, 2023
20a8f7d
Formatting changes to error message.
Jan 17, 2023
e6924fc
Deprecate DEFAULT_LOCAL_SIZE as kernel launch arg.
Jan 17, 2023
75f269b
Update tests after changes to kernel lauch params.
Jan 18, 2023
664d57e
Update kernel examples based on latest changes.
Jan 18, 2023
c74ea24
Improve dispatcher checks for laych args and add unit test.
Jan 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/developer_guides/caching.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.. _caching:

Caching Mechanism in Numba-dpex
================================

Caching is done by saving the compiled kernel code, the ELF object of the executable code. By using the kernel code, cached kernels have minimal overhead because no compilation is needed.

Unlike Numba, we do not perform file-based caching, instead we use an Least Recently Used (LRU) caching mechanism. However when a kernel needs to be evicted, we utilize numba's file-based caching mechanism described `here <https://numba.pydata.org/numba-doc/latest/developer/caching.html>`_.

Algorithm
==========

The caching mechanism for Numba-dpex works as follows: The cache is an LRU cache backed by an ordered dictionary mapped onto a doubly linked list. The tail of the list contains the most recently used (MRU) kernel and the head of the list contains the least recently used (LRU) kernel. The list has a fixed size. If a new kernel arrives to be cached and if the size is already on the maximum limit, the algorithm evicts the LRU kernel to make room for the MRU kernel. The evicted item will be serialized and pickled into a file using Numba's caching mechanism.

Everytime whenever a kernel needs to be retrieved from the cache, the mechanism will look for the kernel in the cache and will be loaded if it's already present. However, if the program is seeking for a kernel that has been evicted, the algorithm will load it from the file and enqueue in the cache.

Settings
========

Therefore, we employ similar environment variables as used in Numba, i.e. ``NUMBA_CACHE_DIR`` etc. However we add three more environment variables to control the caching mechanism.

- In order to specify cache capacity, one can use ``NUMBA_DPEX_CACHE_SIZE``. By default, it's set to 10.
- ``NUMBA_DPEX_ENABLE_CACHE`` can be used to enable/disable the caching mechanism. By default it's enabled, i.e. set to 1.
- In order to enable the debugging messages related to caching, one can set ``NUMBA_DPEX_DEBUG_CACHE`` to 1. All environment variables are defined in :file:`numba_dpex/config.py`.
3 changes: 3 additions & 0 deletions numba_dpex/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def _init(self, llvm_module):
assert list(llvm_module.global_variables) == [], "Module isn't empty"
self._data_layout = SPIR_DATA_LAYOUT[utils.MACHINE_BITS]
self._target_data = ll.create_target_data(self._data_layout)
self._tm_features = (
"" # We need this for chaching, not sure about this value for now
)

def _create_empty_module(self, name):
ir_module = lc.Module(name)
Expand Down
Loading