|
1 | 1 | // -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
|
2 | 2 | //-----------------------------------------------------------------------------
|
3 |
| -// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com) |
| 3 | +// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com) |
4 | 4 | // See the top-level COPYRIGHT file for details.
|
5 | 5 | // SPDX-License-Identifier: Apache-2.0
|
6 | 6 | //-----------------------------------------------------------------------------
|
7 | 7 | /*---------------------------------------------------------------------------*/
|
8 |
| -/* AcceleratorViewsUnitTest.cc (C) 2000-2024 */ |
| 8 | +/* AcceleratorViewsUnitTest.cc (C) 2000-2025 */ |
9 | 9 | /* */
|
10 | 10 | /* Service de test des vues pour les accelerateurs. */
|
11 | 11 | /*---------------------------------------------------------------------------*/
|
12 | 12 | /*---------------------------------------------------------------------------*/
|
13 | 13 |
|
14 | 14 | #include "arcane/utils/ValueChecker.h"
|
| 15 | +#include "arcane/utils/MemoryUtils.h" |
| 16 | +#include "arcane/utils/MultiArray2.h" |
15 | 17 |
|
16 | 18 | #include "arcane/core/BasicUnitTest.h"
|
17 | 19 | #include "arcane/core/ServiceFactory.h"
|
@@ -91,6 +93,7 @@ class AcceleratorViewsUnitTest
|
91 | 93 | void _checkResultReal2x2(Real to_add);
|
92 | 94 | void _checkResultReal3x3(Real to_add);
|
93 | 95 | void _executeTestGroupIndexTable();
|
| 96 | + void _executeTestMultiArray(); |
94 | 97 | };
|
95 | 98 |
|
96 | 99 | /*---------------------------------------------------------------------------*/
|
@@ -209,6 +212,7 @@ executeTest()
|
209 | 212 | _executeTestMemoryCopy();
|
210 | 213 | _executeTestVariableCopy();
|
211 | 214 | _executeTestVariableFill();
|
| 215 | + _executeTestMultiArray(); |
212 | 216 | }
|
213 | 217 |
|
214 | 218 | /*---------------------------------------------------------------------------*/
|
@@ -871,6 +875,53 @@ _executeTestGroupIndexTable()
|
871 | 875 | /*---------------------------------------------------------------------------*/
|
872 | 876 | /*---------------------------------------------------------------------------*/
|
873 | 877 |
|
| 878 | +void AcceleratorViewsUnitTest:: |
| 879 | +_executeTestMultiArray() |
| 880 | +{ |
| 881 | + info() << "Execute test TestMultiArray"; |
| 882 | + ValueChecker vc(A_FUNCINFO); |
| 883 | + auto queue = makeQueue(m_runner); |
| 884 | + UniqueMultiArray2<Int32> values(MemoryUtils::getDefaultDataAllocator()); |
| 885 | + const Int32 dim1_size = 5; |
| 886 | + NumArray<Int32, MDDim1> result_values(dim1_size); |
| 887 | + NumArray<Int32, MDDim1> expected_result_values(dim1_size); |
| 888 | + UniqueArray<Int32> sizes(dim1_size); |
| 889 | + for (Int32 i = 0; i < dim1_size; ++i) |
| 890 | + sizes[i] = i + 1; |
| 891 | + values.resize(sizes); |
| 892 | + MultiArray2SmallSpan<Int32> inout_values = values.span(); |
| 893 | + for (Int32 i = 0; i < dim1_size; ++i) { |
| 894 | + const Int32 dim2_size = inout_values[i].size(); |
| 895 | + Int32 total = 0; |
| 896 | + info() << "I=" << i << " dim2_size=" << dim2_size; |
| 897 | + for (Int32 j = 0; j < dim2_size; ++j) { |
| 898 | + Int32 v = i + j + 1; |
| 899 | + inout_values[i][j] = v; |
| 900 | + total += v; |
| 901 | + } |
| 902 | + expected_result_values[i] = total; |
| 903 | + } |
| 904 | + |
| 905 | + { |
| 906 | + auto command = makeCommand(queue); |
| 907 | + auto out_values_view = viewOut(command, result_values); |
| 908 | + |
| 909 | + command << RUNCOMMAND_LOOP1(iter, dim1_size) |
| 910 | + { |
| 911 | + auto [i] = iter(); |
| 912 | + const Int32 dim2_size = inout_values[i].size(); |
| 913 | + Int32 total = 0; |
| 914 | + for (Int32 j = 0; j < dim2_size; ++j) |
| 915 | + total += inout_values[i][j]; |
| 916 | + out_values_view[i] = total; |
| 917 | + }; |
| 918 | + } |
| 919 | + vc.areEqualArray(result_values.to1DSpan(), expected_result_values.to1DSpan(), "Result"); |
| 920 | +} |
| 921 | + |
| 922 | +/*---------------------------------------------------------------------------*/ |
| 923 | +/*---------------------------------------------------------------------------*/ |
| 924 | + |
874 | 925 | } // namespace ArcaneTest
|
875 | 926 |
|
876 | 927 | /*---------------------------------------------------------------------------*/
|
|
0 commit comments