Graph Framework
Loading...
Searching...
No Matches
jit::context< T, SAFE_MATH > Class Template Reference

Class for JIT compile of the GPU kernels. More...

#include <jit.hpp>

Public Member Functions

 context (const size_t index)
 Construct a jit context object.
 
void add_kernel (const std::string name, graph::input_nodes< T, SAFE_MATH > inputs, graph::output_nodes< T, SAFE_MATH > outputs, graph::map_nodes< T, SAFE_MATH > setters, graph::shared_random_state< T, SAFE_MATH > state, const size_t size)
 Add a kernel.
 
void add_max_reduction (const size_t size)
 Add max reduction kernel.
 
void print_source ()
 Print the kernel source.
 
void save_source ()
 Save the kernel source code.
 
void compile (const bool add_reduction=false)
 Compile the kernel.
 
std::function< void(void)> create_kernel_call (const std::string kernel_name, graph::input_nodes< T, SAFE_MATH > inputs, graph::output_nodes< T, SAFE_MATH > outputs, graph::shared_random_state< T, SAFE_MATH > state, const size_t num_rays)
 Create a kernel calling function.
 
std::function< T(void)> create_max_call (graph::shared_leaf< T, SAFE_MATH > &argument, std::function< void(void)> run)
 Create a max compute kernel calling function.
 
void print (const size_t index, const graph::output_nodes< T, SAFE_MATH > &nodes)
 Print output.
 
check_value (const size_t index, const graph::shared_leaf< T, SAFE_MATH > &node)
 Check the value.
 
void wait ()
 Wait for kernel to finish.
 
void copy_to_device (graph::shared_leaf< T, SAFE_MATH > &node, T *source)
 Copy contexts of buffer to device.
 
void copy_to_host (graph::shared_leaf< T, SAFE_MATH > &node, T *destination)
 Copy contexts of buffer to host.
 
T * get_buffer (graph::shared_leaf< T, SAFE_MATH > &node)
 Get buffer from the gpu_context.
 

Static Public Member Functions

static size_t max_concurrency ()
 Get the maximum number of concurrent instances.
 

Static Public Attributes

static constexpr size_t random_state_size = gpu_context_type::random_state_size
 Size of random state needed.
 

Detailed Description

template<float_scalar T, bool SAFE_MATH = false>
class jit::context< T, SAFE_MATH >

Class for JIT compile of the GPU kernels.

Template Parameters
TBase type of the calculation.
SAFE_MATHUse Safe Math operations.

Constructor & Destructor Documentation

◆ context()

template<float_scalar T, bool SAFE_MATH = false>
jit::context< T, SAFE_MATH >::context ( const size_t  index)
inline

Construct a jit context object.

Parameters
[in]indexConcurrent index. Not used.

Member Function Documentation

◆ add_kernel()

template<float_scalar T, bool SAFE_MATH = false>
void jit::context< T, SAFE_MATH >::add_kernel ( const std::string  name,
graph::input_nodes< T, SAFE_MATH >  inputs,
graph::output_nodes< T, SAFE_MATH >  outputs,
graph::map_nodes< T, SAFE_MATH >  setters,
graph::shared_random_state< T, SAFE_MATH >  state,
const size_t  size 
)
inline

Add a kernel.

Build the source code for a kernel graph.

Parameters
[in]nameName to call the kernel.
[in]inputsInput variables of the kernel.
[in]outputsOutput nodes of the graph to compute.
[in]settersMap outputs back to input values.
[in]stateRandom state node.
[in]sizeSize of the kernel.

◆ add_max_reduction()

template<float_scalar T, bool SAFE_MATH = false>
void jit::context< T, SAFE_MATH >::add_max_reduction ( const size_t  size)
inline

Add max reduction kernel.

Parameters
[in]sizeSize of the input buffer.

◆ check_value()

template<float_scalar T, bool SAFE_MATH = false>
T jit::context< T, SAFE_MATH >::check_value ( const size_t  index,
const graph::shared_leaf< T, SAFE_MATH > &  node 
)
inline

Check the value.

Parameters
[in]indexRay index to check value for.
[in]nodeNode to check the value for.
Returns
The value at the index.

◆ compile()

template<float_scalar T, bool SAFE_MATH = false>
void jit::context< T, SAFE_MATH >::compile ( const bool  add_reduction = false)
inline

Compile the kernel.

Parameters
[in]add_reductionOptional argument to generate the reduction kernel.

◆ copy_to_device()

template<float_scalar T, bool SAFE_MATH = false>
void jit::context< T, SAFE_MATH >::copy_to_device ( graph::shared_leaf< T, SAFE_MATH > &  node,
T *  source 
)
inline

Copy contexts of buffer to device.

Parameters
[in]nodeNot to copy buffer to.
[in]sourceHost side buffer to copy from.

◆ copy_to_host()

template<float_scalar T, bool SAFE_MATH = false>
void jit::context< T, SAFE_MATH >::copy_to_host ( graph::shared_leaf< T, SAFE_MATH > &  node,
T *  destination 
)
inline

Copy contexts of buffer to host.

Parameters
[in]nodeNode to copy buffer from.
[in,out]destinationHost side buffer to copy to.

◆ create_kernel_call()

template<float_scalar T, bool SAFE_MATH = false>
std::function< void(void)> jit::context< T, SAFE_MATH >::create_kernel_call ( const std::string  kernel_name,
graph::input_nodes< T, SAFE_MATH >  inputs,
graph::output_nodes< T, SAFE_MATH >  outputs,
graph::shared_random_state< T, SAFE_MATH >  state,
const size_t  num_rays 
)
inline

Create a kernel calling function.

Parameters
[in]kernel_nameName of the kernel for later reference.
[in]inputsInput nodes of the kernel.
[in]outputsOutput nodes of the kernel.
[in]stateRandom states.
[in]num_raysNumber of rays to trace.
Returns
A lambda function to run the kernel.

◆ create_max_call()

template<float_scalar T, bool SAFE_MATH = false>
std::function< T(void)> jit::context< T, SAFE_MATH >::create_max_call ( graph::shared_leaf< T, SAFE_MATH > &  argument,
std::function< void(void)>  run 
)
inline

Create a max compute kernel calling function.

Parameters
[in]argumentNode to reduce.
[in]runFunction to run before reduction.
Returns
A lambda function to run the kernel.

◆ get_buffer()

template<float_scalar T, bool SAFE_MATH = false>
T * jit::context< T, SAFE_MATH >::get_buffer ( graph::shared_leaf< T, SAFE_MATH > &  node)
inline

Get buffer from the gpu_context.

Parameters
[in]nodeNode to get the gpu buffer for.

◆ max_concurrency()

template<float_scalar T, bool SAFE_MATH = false>
static size_t jit::context< T, SAFE_MATH >::max_concurrency ( )
inlinestatic

Get the maximum number of concurrent instances.

Returns
The maximum available concurrency.

◆ print()

template<float_scalar T, bool SAFE_MATH = false>
void jit::context< T, SAFE_MATH >::print ( const size_t  index,
const graph::output_nodes< T, SAFE_MATH > &  nodes 
)
inline

Print output.

Parameters
[in]indexParticle index to print.
[in]nodesNodes to output.

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