nvrtc_cache Derived Type

type, private :: nvrtc_cache

Cache for compiled kernels


Inherits

type~~nvrtc_cache~~InheritsGraph type~nvrtc_cache nvrtc_cache type~nvrtc_cache_entry nvrtc_cache_entry type~nvrtc_cache->type~nvrtc_cache_entry cache type~cufunction CUfunction type~nvrtc_cache_entry->type~cufunction cuda_kernel type~cumodule CUmodule type~nvrtc_cache_entry->type~cumodule cuda_module type~dtfft_transpose_t dtfft_transpose_t type~nvrtc_cache_entry->type~dtfft_transpose_t transpose_type type~kernel_type_t kernel_type_t type~nvrtc_cache_entry->type~kernel_type_t kernel_type c_ptr c_ptr type~cufunction->c_ptr ptr type~cumodule->c_ptr ptr

Components

Type Visibility Attributes Name Initial
logical, private :: is_created = .false.

Flag indicating if cache is created

type(nvrtc_cache_entry), private, allocatable :: cache(:)

Cache entries

integer(kind=int32), private :: size

Number of entries in cache


Type-Bound Procedures

procedure, public, pass(self) :: create

Creates cache

  • private subroutine create(self)

    Creates cache

    Arguments

    Type IntentOptional Attributes Name
    class(nvrtc_cache), intent(inout) :: self

    Cache instance

procedure, public, pass(self) :: add

Adds new entry to cache

  • private subroutine add(self, cuda_module, cuda_kernel, kernel_type, transpose_type, tile_size, padding, base_storage)

    Adds new entry to cache

    Arguments

    Type IntentOptional Attributes Name
    class(nvrtc_cache), intent(inout) :: self

    Cache instance

    type(CUmodule), intent(in) :: cuda_module

    Compiled CUDA module

    type(CUfunction), intent(in) :: cuda_kernel

    Extracted CUDA kernel

    type(kernel_type_t), intent(in) :: kernel_type

    Kernel type

    type(dtfft_transpose_t), intent(in) :: transpose_type

    Transpose type

    integer(kind=int32), intent(in) :: tile_size

    Tile size

    integer(kind=int32), intent(in) :: padding

    Padding

    integer(kind=int64), intent(in) :: base_storage

    Base storage

procedure, public, pass(self) :: get

Gets entry from cache

  • private function get(self, transpose_type, kernel_type, base_storage, tile_size, padding) result(kernel)

    Returns cached kernel if it exists. If not returns null pointer.

    Arguments

    Type IntentOptional Attributes Name
    class(nvrtc_cache), intent(inout) :: self

    Cache instance

    type(dtfft_transpose_t), intent(in) :: transpose_type

    Type of transposition to perform

    type(kernel_type_t), intent(in) :: kernel_type

    Type of kernel to build

    integer(kind=int64), intent(in) :: base_storage

    Number of bytes needed to store single element

    integer(kind=int32), intent(in) :: tile_size

    Tile size

    integer(kind=int32), intent(in) :: padding

    Padding

    Return Value type(CUfunction)

    Cached kernel

procedure, public, pass(self) :: remove

Removes entry from cache

  • private subroutine remove(self, kernel)

    Takes CUDA kernel as an argument and searches for it in cache If kernel is found than reduces ref_count of such entry and kernel becomes a null pointer

    Arguments

    Type IntentOptional Attributes Name
    class(nvrtc_cache), intent(inout) :: self

    Cache instance

    type(CUfunction), intent(inout) :: kernel

    CUDA kernel to search for

procedure, public, pass(self) :: cleanup

Cleans up cache

  • private subroutine cleanup(self)

    Removes unused modules from cuda context

    Arguments

    Type IntentOptional Attributes Name
    class(nvrtc_cache), intent(inout) :: self

    Cache instance