cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
cuda::rtc::program_t< cuda_cpp > Class Template Reference

Wrapper class for a CUDA runtime-compilable program. More...

#include <program.hpp>

Inheritance diagram for cuda::rtc::program_t< cuda_cpp >:
Collaboration diagram for cuda::rtc::program_t< cuda_cpp >:

Public Types

using parent = base_t< source_kind >
 

Public Member Functions

const_cstrings_span header_names () const
 Names of the "memoized"/off-file-system headers made available to the program (and usable as identifiers for #include directives)
 
const_cstrings_span header_sources () const
 Sources of the "memoized"/off-file-system headers made available to the program (and usable as identifiers for #include directives) More...
 
size_t num_headers () const
 
program_tset_target (device::compute_capability_t target_compute_capability)
 Have the compilation produce code for devices with a given compute capability.
 
program_tset_target (const device_t &device)
 Have the compilation produce code for devices with the same compute capability as a given device.
 
program_tset_target (const context_t &context)
 Have the compilation produce code for devices with the same compute capability as the device of a given context.
 
program_tclear_targets ()
 Remove all compute capabilities which were chosen to have code produced for them by the compilation.
 
template<typename Container >
program_tset_targets (Container target_compute_capabilities)
 Remove all compute capabilities which were chosen to have code produced for them by the compilation.
 
program_tadd_target (device::compute_capability_t target_compute_capability)
 Have the compilation also produce code for devices with a given compute capability.
 
void add_target (const device_t &device)
 Have the compilation also produce code for devices with the same compute capability as a given device.
 
void add_target (const context_t &context)
 Have the compilation also produce code for devices with the same compute capability as the device of a given context.
 
program_tset_source (const char *source)
 
program_tset_source (const ::std::string &source)
 
program_tset_options (const compilation_options_t< source_kind > &options)
 
program_tset_options (compilation_options_t< source_kind > &&options)
 
template<typename String1 , typename String2 >
program_tadd_header (String1 &&name, String2 &&source)
 Adds another "memoized" header to the program. More...
 
template<typename String1 , typename String2 >
program_tadd_header (const ::std::pair< String1, String2 > &name_and_source)
 Adds another "memoized" header to the program. More...
 
template<typename String1 , typename String2 >
program_tadd_header (::std::pair< String1, String2 > &&name_and_source)
 String2>(String1&&, String2&&) More...
 
template<typename RangeOfNames , typename RangeOfSources >
const program_tadd_headers (RangeOfNames header_names, RangeOfSources header_sources)
 Adds multiple "memoized" headers to the program. More...
 
template<typename RangeOfNameAndSourcePairs >
program_tadd_headers (RangeOfNameAndSourcePairs &&named_header_pairs)
 Adds multiple "memoized" headers to the program. More...
 
template<typename RangeOfNames , typename RangeOfSources >
const program_tset_headers (RangeOfNames &&names, RangeOfSources &&sources)
 Replaces the set of "memoized" headers used in the program's compilation. More...
 
template<typename RangeOfNameAndSourcePairs >
program_tset_headers (RangeOfNameAndSourcePairs &&named_header_pairs)
 Replaces the set of "memoized" headers used in the program's compilation. More...
 
program_tclear_headers ()
 Removes all "memoized" headers to be used in the program's compilation.
 
program_tclear_options ()
 Clears any forced values of compilation options, reverting the compilation to the default values.
 
compilation_output_t< cuda_cppcompile () const
 Compiles the program represented by this object (which, until this point, is just a bunch of unrelated sources and options). More...
 
program_tadd_registered_global (const char *unmangled_name)
 Register a pre-mangled name of a global, to make available for use after compilation. More...
 
program_tadd_registered_global (const ::std::string &unmangled_name)
 Register a pre-mangled name of a global, to make available for use after compilation. More...
 
template<typename Container >
program_tadd_registered_globals (const Container &globals_to_register)
 Register multiple pre-mangled names of global, to make available for use after compilation. More...
 
template<typename Container >
program_tadd_registered_globals (Container &&globals_to_register)
 add_registered_globals(const Container&)
 
 program_t (::std::string name)
 
 program_t (const program_t &)=default
 
 program_t (program_t &&)=default
 

Detailed Description

template<>
class cuda::rtc::program_t< cuda_cpp >

Wrapper class for a CUDA runtime-compilable program.

Note
This class is a "reference type", not a "value type". Therefore, making changes to the program is a const-respecting operation on this class.
Many of this class' methods could have been placed in the base class, and are "duplicated" in program_t<ptx> - except that they return the program object itself, allowing for builder-pattern-like use.

Member Function Documentation

◆ add_header() [1/3]

template<typename String1 , typename String2 >
program_t& cuda::rtc::program_t< cuda_cpp >::add_header ( String1 &&  name,
String2 &&  source 
)
inline

Adds another "memoized" header to the program.

Parameters
nameThe header name for use in #include directives
sourceThe full source code of the header "file", possibly with its own preprocessor directives (e.g. #include).
Note
"names" with path separators can be used, but are discouraged

◆ add_header() [2/3]

template<typename String1 , typename String2 >
program_t& cuda::rtc::program_t< cuda_cpp >::add_header ( const ::std::pair< String1, String2 > &  name_and_source)
inline

Adds another "memoized" header to the program.

Parameters
name_and_sourceA pair of strings, one being the name for use in #include directives, the other being the full source code of the header "file", possibly with its own preprocessor directives (e.g. #include).
Note
"names" with path separators can be used, but are discouraged

◆ add_header() [3/3]

template<typename String1 , typename String2 >
program_t& cuda::rtc::program_t< cuda_cpp >::add_header ( ::std::pair< String1, String2 > &&  name_and_source)
inline

String2>(String1&&, String2&&)

String2>(String1&&, String2&&)

◆ add_headers() [1/2]

template<typename RangeOfNames , typename RangeOfSources >
const program_t& cuda::rtc::program_t< cuda_cpp >::add_headers ( RangeOfNames  header_names,
RangeOfSources  header_sources 
)
inline

Adds multiple "memoized" headers to the program.

Parameters
nameNames of the headers, for use in #include directives
sourceThe full source code of each of the header "file", possibly with their own preprocessor directivess.
Note
"names" with path separators can be used, but are discouraged

◆ add_headers() [2/2]

template<typename RangeOfNameAndSourcePairs >
program_t& cuda::rtc::program_t< cuda_cpp >::add_headers ( RangeOfNameAndSourcePairs &&  named_header_pairs)
inline

Adds multiple "memoized" headers to the program.

Parameters
name_and_source_pairsA container of pairs of strings, each being made up of a name for use in #include directives, and the full source code of the header "file", possibly with its own preprocessor directives.
Note
"names" with path separators can be used, but are discouraged

◆ add_registered_global() [1/2]

program_t& cuda::rtc::program_t< cuda_cpp >::add_registered_global ( const char *  unmangled_name)
inline

Register a pre-mangled name of a global, to make available for use after compilation.

Parameters
unmangled_nameThe text of an expression, e.g. "my_global_func()", "f1", "N1::N2::n2",
Note
The name must continue to exist past the compilation of the program - as it is not copied, only referenced

◆ add_registered_global() [2/2]

program_t& cuda::rtc::program_t< cuda_cpp >::add_registered_global ( const ::std::string &  unmangled_name)
inline

Register a pre-mangled name of a global, to make available for use after compilation.

Parameters
unmangled_nameThe text of an expression, e.g. "my_global_func()", "f1", "N1::N2::n2",
Note
The name must continue to exist past the compilation of the program - as it is not copied, only referenced

◆ add_registered_globals()

template<typename Container >
program_t& cuda::rtc::program_t< cuda_cpp >::add_registered_globals ( const Container &  globals_to_register)
inline

Register multiple pre-mangled names of global, to make available for use after compilation.

Parameters
globals_to_registera container of elements constituting the text of an expression identifying a global, e.g. "my_global_func()", "f1", "N1::N2::n2",
Note
All names in the container must continue to exist past the compilation of the program - as they are not copied, only referenced. Thus, as a safety precaution, we also assume the container continues to exist

◆ compile()

Compiles the program represented by this object (which, until this point, is just a bunch of unrelated sources and options).

Note
Carefully examines the compilation_output_t class to understand what exactly the compilation produces.

◆ header_sources()

const_cstrings_span cuda::rtc::program_t< cuda_cpp >::header_sources ( ) const
inline

Sources of the "memoized"/off-file-system headers made available to the program (and usable as identifiers for #include directives)

Note
each header source string corresponds to the name of the same index accessible via {header_names()}.

◆ num_headers()

size_t cuda::rtc::program_t< cuda_cpp >::num_headers ( ) const
inline
Returns
the number of memoized/off-the-file-system headers made available to the program

◆ set_headers() [1/2]

template<typename RangeOfNames , typename RangeOfSources >
const program_t& cuda::rtc::program_t< cuda_cpp >::set_headers ( RangeOfNames &&  names,
RangeOfSources &&  sources 
)
inline

Replaces the set of "memoized" headers used in the program's compilation.

Parameters
nameNames of the headers, for use in #include directives
sourceThe full source code of each of the header "file", possibly with their own preprocessor directivess.
Note
"names" with path separators can be used, but are discouraged

◆ set_headers() [2/2]

template<typename RangeOfNameAndSourcePairs >
program_t& cuda::rtc::program_t< cuda_cpp >::set_headers ( RangeOfNameAndSourcePairs &&  named_header_pairs)
inline

Replaces the set of "memoized" headers used in the program's compilation.

Parameters
name_and_source_pairsA container of pairs of strings, each being made up of a name for use in #include directives, and the full source code of the header "file", possibly with its own preprocessor directives.
Note
"names" with path separators can be used, but are discouraged

The documentation for this class was generated from the following file: