tfel
Loading...
Searching...
No Matches
SYCL.hxx File Reference

This file declares the primitive of the sycl backend of the generic-parallel interfaces. More...

Classes

struct  mfront::generic_parallel::sycl::internals::Atomics
 atomic operations of the statistics More...
struct  mfront::generic_parallel::sycl::internals::Kernel< Statistics, PointFunction >
 kernel applying a function at one point and updating the statistics of the batch. More...

Namespaces

namespace  mfront
 This namespace contains material used to build the MFront code generator.
namespace  mfront::generic_parallel

Functions

template<typename Statistics, typename PointFunction>
auto & mfront::generic_parallel::sycl::internals::getStatisticsBlocks () noexcept
CheckedBackendExecutionPolicy< SyclBackendExecutionPolicy > mfront::generic_parallel::sycl::checkExecutionPolicy (const mfront_gp_AbstractBackendExecutionPolicy *const p, const bool has_statistics) noexcept
const char * mfront::generic_parallel::sycl::checkQueue (const CheckedBackendExecutionPolicy< SyclBackendExecutionPolicy > &p)
template<std::size_t device_stack_size, typename StatisticsHandler, typename PointFunction>
int mfront::generic_parallel::sycl::apply (typename StatisticsHandler::OutputStatus &s, const size_type n, const BatchExecution< typename StatisticsHandler::Statistics > &e, const StatisticsHandler &h, const PointFunction &f)
 apply a function at the points of a batch and report the statistics of the batch.
template<std::size_t device_stack_size = 0>
auto mfront::generic_parallel::sycl::makeApply ()

Detailed Description

This file declares the primitive of the sycl backend of the generic-parallel interfaces.

Date
05/10/2026

Function Documentation

◆ apply()

template<std::size_t device_stack_size, typename StatisticsHandler, typename PointFunction>
int mfront::generic_parallel::sycl::apply ( typename StatisticsHandler::OutputStatus & s,
const size_type n,
const BatchExecution< typename StatisticsHandler::Statistics > & e,
const StatisticsHandler & h,
const PointFunction & f )

apply a function at the points of a batch and report the statistics of the batch.

If the computations are asynchronous, this function returns once they are submitted to the queue. Otherwise, it waits for their completion.

Without statistics given by the calling code, the statistics are held by a block of device memory of a pool of blocks (see StatusBlockPool): no memory is allocated per call. Local statistics are initialized on the host, copied to the block before the computations and copied back once they are completed: the host never accesses the block.

If the function never reports an event (see the hasEvents method of the handler), the statistics are neither combined nor reported, and no block of the pool is used.

Template Parameters
device_stack_sizeminimal stack size, in bytes, of the threads of the device when the computations are performed on an NVIDIA GPU through the CUDA runtime (see setMinimalCUDAStackSize). The stack size is not modified if this value is null. This value is a template argument so that the code setting the stack size, which looks for the CUDA runtime with the functions of the dynamic loader, is only compiled if required.
StatisticsHandlerhandler of the statistics (see MFront/GenericParallel/Batch.hxx)
PointFunctionfunction object taking the index of a point and returning the statistics associated with this point
Parameters
[in,out]soutput status, which must have been initialized
[in]nnumber of points
[in]eexecution of the batch. The policy must be a SyclBackendExecutionPolicy.
[in]hhandler of the statistics
[in]ffunction
Returns
the status

◆ checkExecutionPolicy()

CheckedBackendExecutionPolicy< SyclBackendExecutionPolicy > mfront::generic_parallel::sycl::checkExecutionPolicy ( const mfront_gp_AbstractBackendExecutionPolicy *const p,
const bool has_statistics )
inlinenoexcept
Returns
the policy given by the calling code, checked against the policy of the backend (see mfront::generic_parallel::checkBackendExecutionPolicy). The sycl backend has no default policy: a null policy is refused.
Parameters
[in]ppolicy given by the calling code
[in]has_statisticstrue if the calling code gave statistics

◆ checkQueue()

const char * mfront::generic_parallel::sycl::checkQueue ( const CheckedBackendExecutionPolicy< SyclBackendExecutionPolicy > & p)
inline
Returns
an error message if the computations can't be submitted to the queue of the given policy, a null pointer otherwise

The computations must be executed after the computations already submitted to the queue, which may compute the inputs. This is guaranteed by an in-order queue. With an out-of-order queue, the computations must be synchronous, and the queue is synchronized before them (see apply).

Parameters
[in]ppolicy given by the calling code, checked by checkExecutionPolicy

◆ getStatisticsBlocks()

template<typename Statistics, typename PointFunction>
auto & mfront::generic_parallel::sycl::internals::getStatisticsBlocks ( )
noexcept
Returns
the pool of blocks of device memory holding the statistics of the synchronous computations of a function of the generated library. The blocks are identified by the device and the context of the queue.
Template Parameters
Statisticsstatistics updated by the devices
PointFunctionfunction applied at the points, which is specific to a generated function, so that each generated library has its own pool (see mfront::generic_parallel::gpu::internals)

◆ makeApply()

template<std::size_t device_stack_size = 0>
auto mfront::generic_parallel::sycl::makeApply ( )
Returns
the primitive of the backend, called by the functions of the interfaces (see for instance mfront::gpmp::evaluateBatch)
Template Parameters
device_stack_sizeminimal stack size of the threads of the device (see apply)