1
1
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2
2
// -----------------------------------------------------------------------------
3
- // Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3
+ // Copyright 2000-2024 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
- /* NumArrayUnitTest.cc (C) 2000-2023 */
8
+ /* NumArrayUnitTest.cc (C) 2000-2024 */
9
9
/* */
10
10
/* Service de test des 'NumArray'. */
11
11
/* ---------------------------------------------------------------------------*/
31
31
32
32
namespace Arcane
33
33
{
34
- extern " C++" ARCANE_CORE_EXPORT
35
- void _arcaneTestRealArrayVariant ();
34
+ extern " C++" ARCANE_CORE_EXPORT void
35
+ _arcaneTestRealArrayVariant ();
36
36
extern " C++" ARCANE_CORE_EXPORT void
37
37
_arcaneTestRealArray2Variant ();
38
- }
38
+ } // namespace Arcane
39
39
40
40
namespace ArcaneTest
41
41
{
@@ -299,7 +299,7 @@ _executeTest1(eMemoryRessource mem_kind)
299
299
{
300
300
NumArray<double , MDDim1> t1 (mem_kind);
301
301
t1.resize (n1);
302
- _checkPointerAttribute (mem_kind,t1.bytes ().data ());
302
+ _checkPointerAttribute (mem_kind, t1.bytes ().data ());
303
303
304
304
NumArray<double , MDDim1> t2 (mem_kind);
305
305
t2.resize (n1);
@@ -309,30 +309,30 @@ _executeTest1(eMemoryRessource mem_kind)
309
309
310
310
{
311
311
[[maybe_unused]] auto span_value = t1.span ();
312
- using ValueType1 = NumArray<double ,MDDim1>::value_type;
312
+ using ValueType1 = NumArray<double , MDDim1>::value_type;
313
313
using ValueType2 = decltype (span_value)::value_type;
314
- bool is_same_type = std::is_same_v<ValueType1,ValueType2>;
314
+ bool is_same_type = std::is_same_v<ValueType1, ValueType2>;
315
315
std::cout << " IS_SAME: " << is_same_type << " \n " ;
316
316
if (!is_same_type)
317
317
ARCANE_FATAL (" Not same value type" );
318
318
319
- using LayoutType1 = NumArray<double ,MDDim1>::LayoutPolicyType;
319
+ using LayoutType1 = NumArray<double , MDDim1>::LayoutPolicyType;
320
320
using LayoutType2 = decltype (span_value)::LayoutPolicyType;
321
- bool is_same_policy = std::is_same_v<LayoutType1,LayoutType2>;
321
+ bool is_same_policy = std::is_same_v<LayoutType1, LayoutType2>;
322
322
if (!is_same_policy)
323
323
ARCANE_FATAL (" Not same policy" );
324
324
}
325
325
{
326
326
auto command = makeCommand (queue);
327
327
auto out_t1 = viewOut (command, t1);
328
328
command.addNbThreadPerBlock (128 );
329
- if (command.nbThreadPerBlock ()!= 128 )
330
- ARCANE_FATAL (" Bad number of thread per block (v={0} expected=128)" ,command.nbThreadPerBlock ());
329
+ if (command.nbThreadPerBlock () != 128 )
330
+ ARCANE_FATAL (" Bad number of thread per block (v={0} expected=128)" , command.nbThreadPerBlock ());
331
331
332
332
command << RUNCOMMAND_LOOP1 (iter, n1)
333
333
{
334
334
auto [i] = iter ();
335
- if ((i% 2 )== 0 )
335
+ if ((i % 2 ) == 0 )
336
336
out_t1 (i) = _getValue (i);
337
337
else
338
338
out_t1[i] = _getValue (i);
@@ -346,7 +346,7 @@ _executeTest1(eMemoryRessource mem_kind)
346
346
{
347
347
auto command = makeCommand (queue);
348
348
auto in_t1 = t1.constSpan ();
349
- MDSpan<double ,MDDim1> out_t2 = t2.span ();
349
+ MDSpan<double , MDDim1> out_t2 = t2.span ();
350
350
351
351
command << RUNCOMMAND_LOOP1 (iter, n1)
352
352
{
@@ -364,8 +364,8 @@ _executeTest1(eMemoryRessource mem_kind)
364
364
}
365
365
{
366
366
auto command = makeCommand (queue);
367
- auto in_t1 = viewIn (command,t1);
368
- auto out_t3 = viewOut (command,t3);
367
+ ax::NumArrayInView< double , MDDim1> in_t1 = viewIn (command, t1);
368
+ ax::NumArrayOutView< double , MDDim1> out_t3 = viewOut (command, t3);
369
369
370
370
command << RUNCOMMAND_LOOP1 (iter, n1)
371
371
{
@@ -385,68 +385,68 @@ _executeTest1(eMemoryRessource mem_kind)
385
385
{
386
386
NumArray<double , MDDim2> t1 (mem_kind);
387
387
t1.resize (n1, n2);
388
- _doRank2 (queue,t1,expected_sum2);
388
+ _doRank2 (queue, t1, expected_sum2);
389
389
}
390
390
{
391
- NumArray<double , ExtentsV<n1,n2>> t1 (mem_kind);
392
- _doRank2 (queue,t1,expected_sum2);
391
+ NumArray<double , ExtentsV<n1, n2>> t1 (mem_kind);
392
+ _doRank2 (queue, t1, expected_sum2);
393
393
}
394
394
{
395
- NumArray<double , ExtentsV<DynExtent,n2>> t1 (mem_kind);
395
+ NumArray<double , ExtentsV<DynExtent, n2>> t1 (mem_kind);
396
396
t1.resize (n1);
397
- _doRank2 (queue,t1,expected_sum2);
397
+ _doRank2 (queue, t1, expected_sum2);
398
398
}
399
399
{
400
- NumArray<double , ExtentsV<n1,DynExtent>> t1 (mem_kind);
400
+ NumArray<double , ExtentsV<n1, DynExtent>> t1 (mem_kind);
401
401
t1.resize (n2);
402
- _doRank2 (queue,t1,expected_sum2);
402
+ _doRank2 (queue, t1, expected_sum2);
403
403
}
404
404
405
405
// Tableaux 3D
406
406
{
407
407
NumArray<double , MDDim3, LeftLayout> t1 (mem_kind);
408
408
t1.resize (n1, n2, n3);
409
- _doRank3 (queue,t1,expected_sum3);
409
+ _doRank3 (queue, t1, expected_sum3);
410
410
}
411
411
{
412
412
NumArray<double , MDDim3, RightLayout> t1 (mem_kind);
413
413
t1.resize (n1, n2, n3);
414
- _doRank3 (queue,t1,expected_sum3);
414
+ _doRank3 (queue, t1, expected_sum3);
415
415
}
416
416
{
417
- NumArray<double , ExtentsV<DynExtent,n2,n3>, LeftLayout> t1 (mem_kind);
417
+ NumArray<double , ExtentsV<DynExtent, n2, n3>, LeftLayout> t1 (mem_kind);
418
418
t1.resize (n1);
419
- _doRank3 (queue,t1,expected_sum3);
419
+ _doRank3 (queue, t1, expected_sum3);
420
420
}
421
421
{
422
- NumArray<double , ExtentsV<n1,n2,n3>, LeftLayout> t1 (mem_kind);
423
- _doRank3 (queue,t1,expected_sum3);
422
+ NumArray<double , ExtentsV<n1, n2, n3>, LeftLayout> t1 (mem_kind);
423
+ _doRank3 (queue, t1, expected_sum3);
424
424
}
425
425
{
426
- NumArray<double , ExtentsV<DynExtent,n2,DynExtent>, LeftLayout> t1 (mem_kind);
427
- t1.resize (n1,n3);
428
- _doRank3 (queue,t1,expected_sum3);
426
+ NumArray<double , ExtentsV<DynExtent, n2, DynExtent>, LeftLayout> t1 (mem_kind);
427
+ t1.resize (n1, n3);
428
+ _doRank3 (queue, t1, expected_sum3);
429
429
}
430
430
431
431
// Tableaux 4D
432
432
{
433
433
NumArray<double , MDDim4> t1 (mem_kind);
434
434
t1.resize (n1, n2, n3, n4);
435
- _doRank4 (queue,t1,expected_sum4);
435
+ _doRank4 (queue, t1, expected_sum4);
436
436
}
437
437
{
438
- NumArray<double , ExtentsV<n1,DynExtent,DynExtent,n4>> t1 (mem_kind);
439
- t1.resize (n2,n3);
440
- _doRank4 (queue,t1,expected_sum4);
438
+ NumArray<double , ExtentsV<n1, DynExtent, DynExtent, n4>> t1 (mem_kind);
439
+ t1.resize (n2, n3);
440
+ _doRank4 (queue, t1, expected_sum4);
441
441
}
442
442
{
443
- NumArray<double , ExtentsV<DynExtent,DynExtent,n3,n4>, LeftLayout> t1 (mem_kind);
443
+ NumArray<double , ExtentsV<DynExtent, DynExtent, n3, n4>, LeftLayout> t1 (mem_kind);
444
444
t1.resize (n1, n2);
445
- _doRank4 (queue,t1,expected_sum4);
445
+ _doRank4 (queue, t1, expected_sum4);
446
446
}
447
447
{
448
- NumArray<double , ExtentsV<n1,n2,n3,n4>> t1 (mem_kind);
449
- _doRank4 (queue,t1,expected_sum4);
448
+ NumArray<double , ExtentsV<n1, n2, n3, n4>> t1 (mem_kind);
449
+ _doRank4 (queue, t1, expected_sum4);
450
450
}
451
451
452
452
{
@@ -456,7 +456,7 @@ _executeTest1(eMemoryRessource mem_kind)
456
456
t1.resize (n1);
457
457
{
458
458
auto command = makeCommand (queue);
459
- auto out_t1 = viewOut (command,t1);
459
+ ax::NumArrayInOutView< double , MDDim1> out_t1 = viewInOut (command, t1);
460
460
461
461
command << RUNCOMMAND_LOOP1 (iter, n1)
462
462
{
@@ -466,9 +466,9 @@ _executeTest1(eMemoryRessource mem_kind)
466
466
}
467
467
info () << " CHECK ALLOCATOR" ;
468
468
NumArray<double , MDDim1> t2 (t1);
469
- if (t1.memoryRessource ()!= t2.memoryRessource ())
469
+ if (t1.memoryRessource () != t2.memoryRessource ())
470
470
ARCANE_FATAL (" Bad memory ressource 1" );
471
- if (t1.memoryAllocator ()!= t2.memoryAllocator ())
471
+ if (t1.memoryAllocator () != t2.memoryAllocator ())
472
472
ARCANE_FATAL (" Bad allocator 1" );
473
473
474
474
NumArray<double , MDDim1> host_t1 (eMemoryRessource::Host);
@@ -480,9 +480,9 @@ _executeTest1(eMemoryRessource mem_kind)
480
480
NumArray<double , MDDim1> t3;
481
481
t3.resize (25 );
482
482
t3 = t1;
483
- if (t1.memoryRessource ()!= t3.memoryRessource ())
484
- ARCANE_FATAL (" Bad memory ressource 2 t1={0} t3={1}" ,t1.memoryRessource (),t3.memoryRessource ());
485
- if (t1.memoryAllocator ()!= t3.memoryAllocator ())
483
+ if (t1.memoryRessource () != t3.memoryRessource ())
484
+ ARCANE_FATAL (" Bad memory ressource 2 t1={0} t3={1}" , t1.memoryRessource (), t3.memoryRessource ());
485
+ if (t1.memoryAllocator () != t3.memoryAllocator ())
486
486
ARCANE_FATAL (" Bad allocator 2" );
487
487
NumArray<double , MDDim1> host_t3 (eMemoryRessource::Host);
488
488
host_t3.copy (t3);
@@ -656,7 +656,7 @@ _executeTest4(eMemoryRessource mem_kind)
656
656
{
657
657
auto command = makeCommand (queue);
658
658
auto in_t1 = viewIn (command, t1);
659
- auto out_t3 = viewOut (command, t3);
659
+ auto out_t3 = viewInOut (command, t3);
660
660
661
661
command << RUNCOMMAND_LOOP1 (iter, n1)
662
662
{
0 commit comments