Library Management
Kokkos.CLibrary
— TypeCLibrary
A wrapper around a shared library, loaded with Libdl.dlopen
.
Kokkos.handle
— Functionhandle(lib::CLibrary)
Return the handle (a Ptr{Nothing}
) of lib
, for use with Libdl.dlsym
for example.
If lib
is invalid (not loaded), returns C_NULL
.
Kokkos.get_symbol
— Functionget_symbol(lib::CLibrary, symbol::Symbol)
Load the pointer to the given symbol. Symbol pointers are cached: Libdl.dlsym
is called only if the symbol is not already in the cache.
Kokkos.load_lib
— Functionload_lib(lib::Union{String, KokkosProject, CLibrary};
flags=Libdl.RTLD_LAZY | Libdl.RTLD_LOCAL)
Open a shared library.
lib
can be the path to the shared library, an existing CLibrary
or a KokkosProject
. If lib
is a project, its target is supposed to be compiled and up-to-date.
If the library is already loaded, it is not opened another time: this guarantees that calling Libdl.dlclose
once will unload the library from memory, if the library wasn't opened from elsewhere.
Kokkos.unload_lib
— Functionunload_lib(lib::Union{KokkosProject, CLibrary})
Unload a library. Return true if the library has a valid handle and Libdl.dlclose
was called.
Because of the mechanism behind shared library loading, it is not guaranteed that the library is unloaded from memory after this call. is_lib_loaded
is more reliable than the return value of this function.
The symbol cache of the library is cleared by this function.
Kokkos.is_lib_loaded
— Functionis_lib_loaded(lib::Union{KokkosProject, CLibrary})
Return true
if the library was previously loaded by load_lib
and is still present in memory.
If the full path to lib
is still present in Libdl.dllist()
, the library is considered to be loaded.