cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
Classes | Namespaces | Macros | Typedefs
module.hpp File Reference

Wrappers for working with modules of compiled CUDA code. More...

#include "context.hpp"
#include "primary_context.hpp"
#include "kernel.hpp"
#include "memory.hpp"
#include "array.hpp"
#include "link_options.hpp"
#include <array>
Include dependency graph for module.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  cuda::module_t
 Wrapper class for a CUDA code module. More...
 

Namespaces

 cuda
 All definitions and functionality wrapping the CUDA Runtime API.
 

Typedefs

using cuda::module::handle_t = CUmodule
 

Functions

template<typename Locus , typename ContiguousContainer , cuda::detail_::enable_if_t< cuda::detail_::is_kinda_like_contiguous_container< ContiguousContainer >::value, bool > = true>
module_t cuda::module::create (Locus &&locus, ContiguousContainer module_data, const link::options_t &link_options)
 Create a CUDA driver module from raw module image data. More...
 
template<typename Locus , typename ContiguousContainer , cuda::detail_::enable_if_t< cuda::detail_::is_kinda_like_contiguous_container< ContiguousContainer >::value, bool > = true>
module_t cuda::module::create (Locus &&locus, ContiguousContainer module_data)
 
module_t cuda::module::load_from_file (const context_t &context, const char *path)
 Load a module from an appropriate compiled or semi-compiled file, allocating all relevant resources for it. More...
 
module_t cuda::module::load_from_file (const context_t &context, const ::std::string &path)
 
module_t cuda::module::load_from_file (const device_t &device, const char *path)
 
module_t cuda::module::load_from_file (const device_t &device, const ::std::string &path)
 
module_t cuda::module::load_from_file (const char *path)
 
module_t cuda::module::load_from_file (const ::std::string &path)
 

Detailed Description

Wrappers for working with modules of compiled CUDA code.

Function Documentation

◆ create()

template<typename Locus , typename ContiguousContainer , cuda::detail_::enable_if_t< cuda::detail_::is_kinda_like_contiguous_container< ContiguousContainer >::value, bool > = true>
module_t cuda::module::create ( Locus &&  locus,
ContiguousContainer  module_data,
const link::options_t link_options 
)

Create a CUDA driver module from raw module image data.

Parameters
[in]locuseither a context_t or a device_t - an entity for which one can obtain a CUDA context. This is the context into which the module data is to be loaded (and in which the module contents may be used)
[in]module_datathe opaque, raw binary data for the module - in a contiguous container such as a span, a cuda::dynarray etc..

◆ load_from_file()

module_t cuda::module::load_from_file ( const context_t context,
const char *  path 
)
inline

Load a module from an appropriate compiled or semi-compiled file, allocating all relevant resources for it.

Parameters
pathof a cubin, PTX, or fatbin file constituting the module to be loaded.
Returns
the loaded module
Note
this covers cuModuleLoadFatBinary() even though that's not directly used
Todo:

: consider adding load_module methods to context_t

: When switching to the C++17 standard, use string_view's instead of the const char* and ::std::string reference