Kernel caching#
It might be necessary to recreate the same plan multiple times. To facilitate fast plan creation, kernels might be cached and looked up at plan creation.
JIT cache interface#
The general interface of a JIT cache is defined below. Users may derive from jit_cache in order to implement their own caching strategies should the provided caching strategies be insufficent.
-
class jit_cache#
Interface for jit_caches.
- Template Parameters:
backend-specific – kernel bundle type
Subclassed by bbfft::aot_cache, bbfft::jit_cache_all
Public Functions
-
virtual ~jit_cache()#
Destructor.
-
virtual auto get(jit_cache_key const &key) const -> shared_handle<module_handle_t> = 0#
Get FFT kernel bundle.
- Parameters:
key – FFT kernel identifier
- Returns:
kernel bundle
Store FFT kernel bundle.
- Parameters:
key – FFT kernel identifier
mod – kernel bundle
Cache keys#
-
struct jit_cache_key#
Unique identifier for fft kernel.
Public Functions
-
bool operator==(jit_cache_key const &other) const#
equality check
-
bool operator==(jit_cache_key const &other) const#
-
struct jit_cache_key_hash#
Hash function for jit_cache_key.
Public Functions
-
std::size_t operator()(jit_cache_key const &key) const noexcept#
Compute hash.
- Parameters:
key – cache key
- Returns:
hash
-
std::size_t operator()(jit_cache_key const &key) const noexcept#
JIT cache all#
Simple cache that stores all encountered kernels.
-
class jit_cache_all : public bbfft::jit_cache#
Cache that stores all kernels.
Public Functions
-
virtual auto get(jit_cache_key const &key) const -> shared_handle<module_handle_t> override#
Get FFT kernel bundle.
- Parameters:
key – FFT kernel identifier
- Returns:
kernel bundle
Store FFT kernel bundle.
- Parameters:
key – FFT kernel identifier
mod – kernel bundle
-
auto kernel_names() const -> std::vector<std::string>#
Get all kernel names stored in this cache.
-
virtual auto get(jit_cache_key const &key) const -> shared_handle<module_handle_t> override#
Ahead-of-time cache#
Kernels may be compiled ahead-of-time. The ahead-of-time “cache” is used to look-up kernels at plan creation time.
-
class aot_cache : public bbfft::jit_cache#
Cache to look up ahead-of-time compiled FFT kernels.
Public Functions
-
virtual auto get(jit_cache_key const &key) const -> shared_handle<module_handle_t> override#
Get FFT kernel bundle.
- Parameters:
key – FFT kernel identifier
- Returns:
kernel bundle
Store FFT kernel bundle.
- Parameters:
key – FFT kernel identifier
mod – kernel bundle
-
void register_module(aot_module aot_mod)#
register module with this cache
-
virtual auto get(jit_cache_key const &key) const -> shared_handle<module_handle_t> override#
-
struct aot_module#
Collection of native module handle, set of kernel names stored in the native module, and a device identifier.