|
MGIS 3.1.0
|
CUDA counterpart of MGIS/Function/Algorithms.hxx. It declares the assign algorithm which evaluates an evaluator on the graphic card using the CUDA programming model and the CUDAExecutionConfiguration type used to configure the launch of the CUDA kernels. More...
#include "MGIS/Config.hxx"#include "MGIS/Context.hxx"#include "MGIS/Function/SpaceConcept.hxx"#include "MGIS/Function/EvaluatorConcept.hxx"#include "MGIS/Function/FunctionConcept.hxx"#include "MGIS/Function/CUDA/Algorithms.ixx"Classes | |
| struct | mgis::function::CUDAExecutionConfiguration |
| execution configuration used to launch CUDA's kernels More... | |
Namespaces | |
| namespace | mgis |
| the namespace mgis encloses all the MGIS project. | |
Functions | |
| template<typename FunctionType, EvaluatorConcept EvaluatorType> requires ( (LinearElementSpaceConcept<evaluator_space<EvaluatorType>>) && std::same_as<function_space<FunctionType>, evaluator_space<EvaluatorType>>) | |
| bool | mgis::function::assign (AbstractErrorHandler &, const CUDAExecutionConfiguration &, FunctionType &, const EvaluatorType) |
| assign the evaluator to a function | |
CUDA counterpart of MGIS/Function/Algorithms.hxx. It declares the assign algorithm which evaluates an evaluator on the graphic card using the CUDA programming model and the CUDAExecutionConfiguration type used to configure the launch of the CUDA kernels.
|
nodiscard |
assign the evaluator to a function
implementation of the CUDA assign algorithm
This is the CUDA counterpart of the assign algorithm declared in MGIS/Function/Algorithms.hxx: the values are computed on the graphic card by a CUDA kernel instead of being computed on the host. The evaluator and the function must therefore be callable from the device, which means in particular that they must be built on data accessible from the device, e.g. thrust::universal_vectors, and that the lambda expressions they rely on must be MGIS_HOST_DEVICE lambda expressions.
The spaces of the function and of the evaluator and their number of components are compared and the evaluator is checked before the kernel is launched; the launch strategy itself is described in MGIS/Function/CUDA/Algorithms.ixx.
Only the function arguments which can be captured by a kernel are supported: if the function is not a lightweight view, a view of it is computed on the host and captured by the kernel.
| FunctionType | type of the function the values are assigned to, which must be defined on the same space as the evaluator |
| EvaluatorType | type of the evaluator, which must satisfy the EvaluatorConcept concept and be defined on a linear element space |
| [in] | ctx | execution context, used to report the errors |
| [in] | c | CUDA execution configuration |
| [in] | f | left hand side, i.e. the function the values are assigned to |
| [in] | e | right hand side, i.e. the evaluator computing the values |
After checking that the spaces of the function and of the evaluator are equivalent, that their numbers of components match and that the evaluator is valid, a device callable lambda expression is built to assign, for a given index, the value computed by the evaluator to that of the function and is applied to every element of the space by cuda::call_kernel.
Two orthogonal choices are made at compile time: