8#include <gtest/gtest.h>
10#include "arccore/base/MDIndex.h"
12#include "arccore/common/accelerator/RunQueue.h"
13#include "arccore/common/NumArray.h"
26template<
typename Extents>
void
29 using ExtentIndexType = Extents::ExtentIndexType;
30 ExtentIndexType nb_value = num_array.
extent0();
31 for (ExtentIndexType i = 0; i < nb_value; ++i) {
32 num_array(i) = (i + base_value);
39 Int32 nb_value = 50000;
41 std::cout <<
"Using accelerator policy name=" << queue.
executionPolicy() <<
"\n";
42 std::cout <<
" nb_value=" << nb_value <<
"\n";
53 auto lambda1 = [=] ARCCORE_HOST_DEVICE(Int32 index) {
54 b_view[index] = a_view[index];
58 std::cout <<
"Test lambda direct\n";
61 Arcane::Accelerator::run(command, range, lambda1);
64 for (Int32 k = 0; k < nb_value; ++k) {
65 ASSERT_EQ(a_view[k], b_view[k]) <<
" Index1=" << k;
75 auto mutable_lambda1 = [=] ARCCORE_HOST_DEVICE(Int32 index)
mutable {
76 b_view[index] = a_view[index];
80 std::cout <<
"Test mutable lambda direct\n";
86 for (Int32 k = 0; k < nb_value; ++k) {
87 ASSERT_EQ(a_view[k], b_view[k]) <<
" Index2=" << k;
96 Int32 nb_value = 50000;
98 std::cout <<
"Using accelerator policy name=" << queue.
executionPolicy() <<
"\n";
99 std::cout <<
" nb_value=" << nb_value <<
"\n";
110 auto lambda1 = [=] ARCCORE_HOST_DEVICE(Int64 index) {
111 b_view[index] = a_view[index];
115 std::cout <<
"Test lambda direct\n";
121 for (Int32 k = 0; k < nb_value; ++k) {
122 ASSERT_EQ(a_view[k], b_view[k]) <<
" Index1=" << k;
134 _doTestLambda1(queue);
135 _doTestLambda2(queue);
Types and macros for managing loops on accelerators.
Management of an accelerator command.
Execution queue for an accelerator.
eExecutionPolicy executionPolicy() const
Execution policy of the queue.
Modifiable view of an array of type T.
Constant view of an array of type T.
Multi-dimensional arrays for numerical types accessible on accelerators.
constexpr ExtentIndexType extent0() const
Value of the first dimension.
View of an array of elements of type T.
View of an array of elements of type T.
Namespace for accelerator usage.
RunCommand makeCommand(const RunQueue &run_queue)
Creates a command associated with the queue run_queue.
void launchRunCommand(RunCommand &command, SimpleForLoopRanges< N, IndexType_ > bounds, Lambda func)
Applies the lambda func on the iteration range given by bounds.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
SimpleForLoopRanges< 1 > makeLoopRanges(Int32 n1)
Creates an iteration range [0,n1[, [0,n2[.