You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following environment variables affect the cache behavior:
179
+
180
+
| Environment variable | Values | Description |
181
+
| -------------------- | ------ | ----------- |
182
+
|`SYCL_CACHE_DIR`| Path | Path to persistent cache root directory. Default values are `%AppData%\libsycl_cache` for Windows and `$XDG_CACHE_HOME/libsycl_cache` on Linux, if `XDG_CACHE_HOME` is not set then `$HOME/.cache/libsycl_cache`. When none of the environment variables are set SYCL persistent cache is disabled. |
183
+
|`SYCL_CACHE_PERSISTENT`| '1' or '0' | Controls persistent device compiled code cache. Turns it on if set to '1' and turns it off if set to '0'. When cache is enabled SYCL runtime will try to cache and reuse JIT-compiled binaries. Default is off. |
184
+
|`SYCL_CACHE_IN_MEM`| '1' or '0' | Enable ('1') or disable ('0') in-memory caching of device compiled code. When cache is enabled SYCL runtime will try to cache and reuse JIT-compiled binaries. Default is '1'. |
185
+
|`SYCL_IN_MEM_CACHE_EVICTION_THRESHOLD`| Positive integer |`SYCL_IN_MEM_CACHE_EVICTION_THRESHOLD` accepts an integer that specifies the maximum size of the in-memory program cache in bytes. Eviction is performed when the cache size exceeds the threshold. The default value is 0 which means that eviction is disabled. |
186
+
|`SYCL_CACHE_EVICTION_DISABLE`| Any(\*) | Switches persistent cache eviction off when the variable is set. |
187
+
|`SYCL_CACHE_MAX_SIZE`| Positive integer | Persistent cache eviction is triggered once total size of cached images exceeds the value in megabytes (default - 8 192 for 8 GB). Set to 0 to disable size-based cache eviction. |
188
+
|`SYCL_CACHE_THRESHOLD`| Positive integer | Persistent cache eviction threshold in days (default value is 7 for 1 week). Set to 0 for disabling time-based cache eviction. |
189
+
|`SYCL_CACHE_MIN_DEVICE_IMAGE_SIZE`| Positive integer | Minimum size of device code image in bytes which is reasonable to cache on disk because disk access operation may take more time than do JIT compilation for it. Applicable only for persistent cache. Default value is 0 to cache all images. |
190
+
|`SYCL_CACHE_MAX_DEVICE_IMAGE_SIZE`| Positive integer | Maximum size of device image in bytes which is cached. Caching big kernels may overload the disk very fast. Applicable only for persistent cache. Default value is 1 GB. |
-`<device_hash>` - hash out of device information used to identify target
356
354
device;
357
355
-`<device_image_hash>` - hash made out of device image used as input for the
@@ -408,10 +406,12 @@ LRU (least recently used) strategy both for in-memory and persistent cache.
408
406
409
407
#### In-memory cache eviction
410
408
411
-
It is initiated on program/kernel maps access/add item operation. When cache
412
-
size exceeds storage threshold the items which are least recently used are
413
-
deleted.
414
-
TODO: add detailed description of in-memory cache eviction mechanism.
409
+
Eviction in in-memory cache is disabled by default but can be controlled by SYCL_IN_MEM_CACHE_EVICTION_THRESHOLD
410
+
environment variable. The threshold is set in bytes and when the cache size exceeds the threshold the eviction process is initiated. The eviction process is based on LRU strategy. The cache is walked through and the least recently used items are deleted until the cache size is below the threshold.
411
+
To implement eviction for in-memory cache efficiently, we store the programs in a linked-list, called the eviction list. When the program is first added to the cache, it is also added to the back of the eviction list. When a program is fetched from cache, we move the program to the end of the eviction list. This way, we ensure that the programs at the beginning of the eviction list are always the least recently used.
412
+
When adding a new program to cache, we check if the size of the program cache exceeds the threshold, if so, we iterate through the eviction list starting from the front and delete the programs until the cache size is below the threshold. When a program is deleted from the cache, we also evict its corresponding kernels from both of the kernel caches.
413
+
414
+
***If the application runs out-of-memory,*** either due to cache eviction being disabled or the cache eviction threshold being too high, we will evict all the items from program and kernel caches.
0 commit comments