Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
TestCooperativeLaunch_GridSync.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7
8#include <gtest/gtest.h>
9
10#include "arccore/base/PlatformUtils.h"
11
12#include "arccore/common/accelerator/Runner.h"
13#include "arccore/common/accelerator/RunQueue.h"
14
16
17/*---------------------------------------------------------------------------*/
18/*---------------------------------------------------------------------------*/
19
20using namespace Arcane;
21using namespace Arcane::Accelerator;
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26// Test grid synchronization performance
27extern "C++" void
28_testCooperativeLaunch_GridSync(RunQueue queue, Int32 nb_value, Int32 nb_loop, Int32 nb_loop2)
29{
30 double x = Platform::getRealTime();
31 {
32 for (int j = 0; j < nb_loop; ++j) {
33 auto command = makeCommand(queue);
34 CooperativeWorkGroupLoopRange loop_range(nb_value);
35 command << RUNCOMMAND_LAUNCH(iter, loop_range)
36 {
37 auto grid = iter.grid();
38 for (Int32 j = 0; j < nb_loop2; ++j) {
39 grid.barrier();
40 }
41 };
42 }
43 }
44 double y = Platform::getRealTime();
45 Real diff = (y - x) * 1000.0;
46 std::cout << "** TotalCooperativeLaunch_GridSync nb_value=" << nb_value
47 << " nb_loop2=" << nb_loop2 << " time(ms)=" << diff << "\n";
48}
49
50/*---------------------------------------------------------------------------*/
51/*---------------------------------------------------------------------------*/
Types and macros for managing hierarchical parallelism on accelerators.
#define RUNCOMMAND_LAUNCH(iter_name, bounds,...)
Macro to launch a command using hierarchical, possibly cooperative, parallelism.
Iteration range of a loop using cooperative hierarchical parallelism.
RunCommand makeCommand(const RunQueue &run_queue)
Creates a command associated with the queue run_queue.
Real getRealTime()
Real time used in seconds.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --