53 typename Operator,
typename DataType>
63#if defined(ARCANE_COMPILING_CUDA)
66 cudaStream_t stream = impl::CudaUtils::toNativeStream(&m_queue);
83#if defined(ARCANE_COMPILING_HIP)
87 hipStream_t stream = impl::HipUtils::toNativeStream(&m_queue);
103#if defined(ARCANE_COMPILING_SYCL)
105#if defined(ARCANE_USE_SCAN_ONEDPL) && defined(__INTEL_LLVM_COMPILER)
106 sycl::queue queue = impl::SyclUtils::toNativeStream(&m_queue);
107 auto policy = oneapi::dpl::execution::make_device_policy(queue);
261 template <
typename DataType,
typename SetterLambda>
275 ARCCORE_HOST_DEVICE
void operator=(
const DataType& value)
277 m_lambda(m_index, value);
286 using value_type = DataType;
287 using iterator_category = std::random_access_iterator_tag;
305 ARCCORE_HOST_DEVICE ThatClass& operator++()
310 ARCCORE_HOST_DEVICE
friend ThatClass operator+(
const ThatClass& iter, Int32 x)
312 return ThatClass(iter.m_lambda, iter.m_index + x);
314 ARCCORE_HOST_DEVICE
friend ThatClass operator+(
Int32 x,
const ThatClass& iter)
316 return ThatClass(iter.m_lambda, iter.m_index + x);
318 ARCCORE_HOST_DEVICE
friend bool operator<(
const ThatClass& iter1,
const ThatClass& iter2)
320 return iter1.m_index < iter2.m_index;
322 ARCCORE_HOST_DEVICE ThatClass operator-(
Int32 x)
324 return ThatClass(m_lambda, m_index - x);
326 ARCCORE_HOST_DEVICE
Int32 operator-(
const ThatClass& x)
const
328 return m_index - x.m_index;
330 ARCCORE_HOST_DEVICE reference operator*()
const
332 return Setter(m_lambda, m_index);
334 ARCCORE_HOST_DEVICE reference operator[](
Int32 x)
const {
return Setter(m_lambda, m_index + x); }
335 ARCCORE_HOST_DEVICE
friend bool operator!=(
const ThatClass& a,
const ThatClass& b)
337 return a.m_index != b.m_index;
343 SetterLambda m_lambda;
348 explicit GenericScanner(
const RunQueue& queue)
354 template <
typename DataType,
typename GetterLambda,
typename SetterLambda,
typename Operator>
355 void applyWithIndexExclusive(
Int32 nb_value,
const DataType& initial_value,
356 const GetterLambda& getter_lambda,
357 const SetterLambda& setter_lambda,
358 const Operator& op_lambda,
359 const TraceInfo& trace_info = TraceInfo())
361 _applyWithIndex<true>(nb_value, initial_value, getter_lambda, setter_lambda, op_lambda, trace_info);
364 template <
typename DataType,
typename GetterLambda,
typename SetterLambda,
typename Operator>
365 void applyWithIndexInclusive(
Int32 nb_value,
const DataType& initial_value,
366 const GetterLambda& getter_lambda,
367 const SetterLambda& setter_lambda,
368 const Operator& op_lambda,
369 const TraceInfo& trace_info = TraceInfo())
371 _applyWithIndex<false>(nb_value, initial_value, getter_lambda, setter_lambda, op_lambda, trace_info);
374 template <
typename InputDataType,
typename OutputDataType,
typename Operator>
375 void applyExclusive(
const OutputDataType& initial_value,
376 SmallSpan<const InputDataType> input,
377 SmallSpan<OutputDataType> output,
378 const Operator& op_lambda,
379 const TraceInfo& trace_info = TraceInfo())
381 _apply<true>(initial_value, input, output, op_lambda, trace_info);
384 template <
typename InputDataType,
typename OutputDataType,
typename Operator>
385 void applyInclusive(
const OutputDataType& initial_value,
386 SmallSpan<const InputDataType> input,
387 SmallSpan<OutputDataType> output,
388 const Operator& op_lambda,
389 const TraceInfo& trace_info = TraceInfo())
391 _apply<false>(initial_value, input, output, op_lambda, trace_info);
396 template <
bool IsExclusive,
typename DataType,
typename GetterLambda,
typename SetterLambda,
typename Operator>
397 void _applyWithIndex(
Int32 nb_value,
const DataType& initial_value,
398 const GetterLambda& getter_lambda,
399 const SetterLambda& setter_lambda,
400 const Operator& op_lambda,
401 const TraceInfo& trace_info)
403 impl::GetterLambdaIterator<DataType, GetterLambda> input_iter(getter_lambda);
404 SetterLambdaIterator<DataType, SetterLambda> output_iter(setter_lambda);
405 impl::ScannerImpl scanner(m_queue);
406 scanner.apply<IsExclusive>(nb_value, input_iter, output_iter, initial_value, op_lambda, trace_info);
409 template <
bool IsExclusive,
typename InputDataType,
typename OutputDataType,
typename Operator>
410 void _apply(
const OutputDataType& initial_value,
411 SmallSpan<const InputDataType> input,
412 SmallSpan<OutputDataType> output,
414 const TraceInfo& trace_info = TraceInfo())
416 const Int32 nb_item = input.size();
417 if (output.size() != nb_item)
418 ARCANE_FATAL(
"Sizes are not equals: input={0} output={1}", nb_item, output.size());
419 auto* input_data = input.data();
420 auto* output_data = output.data();
421 impl::ScannerImpl scanner(m_queue);
422 scanner.apply<IsExclusive>(nb_item, input_data, output_data, initial_value, op, trace_info);