8#include <gtest/gtest.h>
10#include "arccore/base/PlatformUtils.h"
12#include "arccore/trace/ITraceMng.h"
14#include "arccore/common/accelerator/Runner.h"
15#include "arccore/common/accelerator/RunQueue.h"
16#include "arccore/common/NumArray.h"
17#include "arccore/common/accelerator/Memory.h"
22#include "arccore/accelerator/AcceleratorInitializer.h"
24#include "./TestCommon.h"
36_testCooperativeLaunch_GridSync(
RunQueue queue, Int32 nb_value,
37 Int32 nb_loop1, Int32 nb_loop2);
41 Int32 nb_value, Int32 nb_loop);
44 Int32 nb_value, Int32 nb_loop);
46void _doTestCooperativeLaunch(
bool use_accelerator, Int32 max_allowed_thread)
49 Runner runner(x.executionPolicy());
51 if (queue.isAcceleratorPolicy())
54 Int32 nb_value = 1000000;
55 Int64 expected_value = 1000004000000;
58 expected_value = 100000040000000;
65 if (!queue.isAcceleratorPolicy()) {
76 tm->
info() <<
"Using accelerator policy name=" << queue.executionPolicy() <<
" nb_loop=" << nb_loop;
80 host_c.resize(nb_value);
82 for (Int32 i = 0; i < nb_value; ++i) {
83 host_c(i) = (i + 2) + (i + 3);
90 for (Int32 k = 1; k < 5; ++k) {
91 Int32 nb_loop1 = 10000;
93 _testCooperativeLaunch_GridSync(queue, nb_value, nb_loop1, nb_loop2);
95 for (Int32 k = 1; k < 5; ++k) {
96 Int32 nb_loop1 = 1000;
98 _testCooperativeLaunch_GridSync(queue, nb_value, nb_loop1, nb_loop2);
100 for (Int32 k = 1; k < 5; ++k) {
101 Int32 nb_loop1 = 100;
103 _testCooperativeLaunch_GridSync(queue, nb_value, nb_loop1, nb_loop2);
105 for (Int32 k = 1; k < 5; ++k) {
107 Int32 nb_loop2 = 999;
108 _testCooperativeLaunch_GridSync(queue, nb_value, nb_loop1, nb_loop2);
111 for (Int32 k = 1; k < 5; ++k) {
113 Int64 v = _testCooperativeLaunch(queue, c, nb_value, nb_loop);
114 Int64 v2 = v / nb_loop;
115 ASSERT_EQ(v2, expected_value);
119 for (Int32 k = 1; k < 5; ++k) {
121 Int64 v = _testCooperativeLaunch2(queue, c, nb_value, nb_loop);
122 Int64 v2 = v / nb_loop;
123 ASSERT_EQ(v2, expected_value);
128ARCCORE_TEST_DO_TEST_ACCELERATOR(ArccoreAccelerator, TestCooperativeLaunch, _doTestCooperativeLaunch);
Types and functions for managing synchronizations on accelerators.
Types and macros for managing loops on accelerators.
Class to initialize a runtime for the accelerator API.
Execution queue for an accelerator.
Execution manager for accelerator.
virtual TraceMessage info()=0
Stream for an information message.
Multi-dimensional arrays for numerical types accessible on accelerators.
View of an array of elements of type T.
Namespace for accelerator usage.
RunQueue makeQueue(const Runner &runner)
Creates a queue associated with runner.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
bool arccoreIsDebug()
True if the ARCCORE_DEBUG macro is defined.
eMemoryResource
List of available memory resources.
@ Host
Allocates on the host.
@ Device
Allocates on the device.