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

This file declares the primitive of the stlpar backend of the generic-parallel interfaces, based on the parallel algorithms of the C++ standard library. More...

#include <cstddef>
#include <algorithm>
#include <iterator>
#include <numeric>
#include <execution>
#include "MFront/GenericParallel/CountingIterator.hxx"
#include "MFront/GenericParallel/DeviceStackSize.hxx"
#include "MFront/GenericParallel/ParallelSTLBackendExecutionPolicy.hxx"
#include "MFront/GenericParallel/Batch.hxx"

Namespaces

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

Typedefs

using mfront::generic_parallel::stlpar::CountingIterator = generic_parallel::CountingIterator<size_type>
 a simple alias

Functions

template<std::size_t device_stack_size, typename StatisticsHandler, typename PointFunction, typename ExecutionPolicy>
int mfront::generic_parallel::stlpar::apply (typename StatisticsHandler::OutputStatus &s, const size_type n, const BatchExecution< typename StatisticsHandler::Statistics > &e, const StatisticsHandler &h, const PointFunction &f, ExecutionPolicy &&policy)
 apply a function at the points of a batch and report the statistics of the batch. This function waits for the completion of the computations. The statistics given by the calling code, if any, are accumulated on the host. If the function never reports an event (see the hasEvents method of the handler), the statistics are neither combined nor reported.
template<std::size_t device_stack_size = 0, typename ExecutionPolicy>
auto mfront::generic_parallel::stlpar::makeApply (const ExecutionPolicy policy)

Detailed Description

This file declares the primitive of the stlpar backend of the generic-parallel interfaces, based on the parallel algorithms of the C++ standard library.

Date
05/10/2026

Function Documentation

◆ apply()

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

apply a function at the points of a batch and report the statistics of the batch. This function waits for the completion of the computations. The statistics given by the calling code, if any, are accumulated on the host. If the function never reports an event (see the hasEvents method of the handler), the statistics are neither combined nor reported.

Template Parameters
device_stack_sizeminimal stack size, in bytes, of the threads of the device when the parallel algorithms are offloaded to an NVIDIA GPU by nvc++ -stdpar=gpu (see mfront::generic_parallel::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
ExecutionPolicyexecution policy
Parameters
[in,out]soutput status, which must have been initialized
[in]nnumber of points
[in]eexecution of the batch. The policy is a ParallelSTLBackendExecutionPolicy, or null for the default policy: only its common options are used, the computations being synchronous.
[in]hhandler of the statistics
[in]ffunction
[in]policyexecution policy
Returns
the status

◆ makeApply()

template<std::size_t device_stack_size = 0, typename ExecutionPolicy>
auto mfront::generic_parallel::stlpar::makeApply ( const ExecutionPolicy policy)
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)
Parameters
[in]policyexecution policy