Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MeshMaterialSimdUnitTest.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 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/* MeshMaterialSimdUnitTest.cc (C) 2000-2023 */
9/* */
10/* Service de test unitaire de la vectorisation des matériaux/milieux. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ScopedPtr.h"
15#include "arcane/utils/PlatformUtils.h"
16#include "arcane/utils/OStringStream.h"
17#include "arcane/utils/ArithmeticException.h"
18#include "arcane/utils/ValueChecker.h"
19
20#include "arcane/utils/Simd.h"
21#include "arcane/utils/SimdOperation.h"
22
23#include "arcane/core/BasicUnitTest.h"
24#include "arcane/core/ServiceBuilder.h"
25#include "arcane/core/FactoryService.h"
27#include "arcane/core/materials/internal/IMeshComponentInternal.h"
28
30#include "arcane/materials/IMeshMaterialMng.h"
31#include "arcane/materials/IMeshMaterial.h"
32#include "arcane/materials/IMeshEnvironment.h"
33#include "arcane/materials/MeshEnvironmentBuildInfo.h"
34#include "arcane/materials/MeshMaterialModifier.h"
35#include "arcane/materials/MatCellVector.h"
36#include "arcane/materials/EnvCellVector.h"
37#include "arcane/materials/MatItemEnumerator.h"
38#include "arcane/materials/MeshMaterialVariableRef.h"
39#include "arcane/materials/MeshEnvironmentVariableRef.h"
40#include "arcane/materials/EnvItemVector.h"
41
42#include "arcane/tests/ArcaneTestGlobal.h"
43
44// Pour les définitions, il faut finir par GCC car Clang et ICC définissent
45// la macro __GNU__
46// Pour CLANG, il n'y a pas encore d'équivalent au pragma ivdep.
47// Celui qui s'en approche le plus est:
48// #pragma clang loop vectorize(enable)
49// mais il ne force pas la vectorisation.
50#ifdef __clang__
51# define PRAGMA_IVDEP_VALUE "clang loop vectorize(enable)"
52#else
53# ifdef __INTEL_COMPILER
54# define PRAGMA_IVDEP_VALUE "ivdep"
55# else
56# ifdef __GNUC__
57// S'assure qu'on compile avec la vectorisation même en '-O2'
58// NOTE: à partir de GCC 12, le '-O2' implique aussi la vectorisation
59# pragma GCC optimize ("-ftree-vectorize")
60# define PRAGMA_IVDEP_VALUE "GCC ivdep"
61# endif
62# endif
63#endif
64
65//#undef PRAGMA_IVDEP_VALUE
66
67#ifdef PRAGMA_IVDEP_VALUE
68#define PRAGMA_IVDEP _Pragma(PRAGMA_IVDEP_VALUE)
69#else
70#define PRAGMA_IVDEP
71#define PRAGMA_IVDEP_VALUE ""
72#endif
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77ARCANE_BEGIN_NAMESPACE
78MATERIALS_BEGIN_NAMESPACE
79
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
82
83namespace
84{
85String getCompilerInfo()
86{
88 String compiler_name = "Unknown";
91#ifdef __clang__
92 compiler_name = "Clang";
95#else
96#ifdef __INTEL_COMPILER
97 compiler_name = "ICC";
100#else
101#ifdef __GNUC__
102 compiler_name = "GCC";
105#endif // __GNUC__
106#endif // __INTEL_COMPILER
107#endif // __clang__
108 ostr() << compiler_name << " " << version_major << "." << version_minor;
109 return ostr.str();
110}
111}
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116// Normalement pour l'EOS il faut utiliser la racine carrée mais GCC 6
117// ne tente pas de vectorisation (au contraire d'ICC 17) si cette opération est présente.
118// Pour vérifier qu'on vectorise bien, on supprime donc l'appel à la
119// racine carrée. On définit la macro USE_SQRT_IN_EOS à 1 pour utiliser la
120// racine carrée, à 0 sinon.
121#define USE_SQRT_IN_EOS 1
122
123#if USE_SQRT_IN_EOS == 1
124#define DO_SQRT(v) math::sqrt( v )
125#else
126#define DO_SQRT(v) (v)
127#endif
128
129/*---------------------------------------------------------------------------*/
130/*---------------------------------------------------------------------------*/
136{
137 protected:
141 : m_index(0), m_component(component)
142 {
143 m_items_view[0] = pure_view;
144 m_items_view[1] = mixed_view;
145 }
146 public:
148 {
149 return FullComponentPartCellEnumerator(c,c->pureItems(),c->impureItems());
150 }
151 public:
152 void operator++()
153 {
154 ++m_index;
155 }
156 bool hasNext() const { return m_index<2; }
157 ComponentPartItemVectorView operator*() const
158 {
159 return m_items_view[m_index];
160 }
161 protected:
162
163 Integer m_index;
164 ComponentPartItemVectorView m_items_view[2];
165 IMeshComponent* m_component;
166};
167
168/*---------------------------------------------------------------------------*/
169/*---------------------------------------------------------------------------*/
170
171#define ENUMERATE_ENVCELL2(iname,env) \
172 for( FullComponentPartCellEnumerator iname##_part(Arcane::Materials::FullComponentPartCellEnumerator::create(env)); iname##_part . hasNext(); ++ iname##_part ) \
173 PRAGMA_IVDEP \
174 A_ENUMERATE_COMPONENTCELL(ComponentPartCellEnumerator,iname,*(iname##_part))
175
176/*---------------------------------------------------------------------------*/
177/*---------------------------------------------------------------------------*/
178
179MATERIALS_END_NAMESPACE
180ARCANE_END_NAMESPACE
181
182/*---------------------------------------------------------------------------*/
183/*---------------------------------------------------------------------------*/
184
186
187/*---------------------------------------------------------------------------*/
188/*---------------------------------------------------------------------------*/
189
190using namespace Arcane;
191using namespace Materials;
192
193/*---------------------------------------------------------------------------*/
194/*---------------------------------------------------------------------------*/
195
196namespace
197{
198class PerfTimer
199{
200 public:
201 PerfTimer(const char* msg)
202 : m_begin_time(0.0), m_msg(msg), m_has_error(false)
203 {
204 m_begin_time = platform::getRealTime();
205 }
206 ~PerfTimer()
207 {
208 Real end_time = platform::getRealTime();
209 Real true_time_v = end_time - m_begin_time;
210 double true_time = (double)(true_time_v);
211 std::cout << " -- -- Time: ";
212 std::cout.width(60);
213 std::cout << m_msg << " = ";
214 if (m_has_error)
215 std::cout << "ERROR";
216 else
217 std::cout << (true_time);
218 std::cout << '\n';
219 std::cout.flush();
220 }
221 void setError(bool v) { m_has_error = v; }
222 private:
223 Real m_begin_time;
224 const char* m_msg;
225 bool m_has_error;
226};
227}
228
229/*---------------------------------------------------------------------------*/
230/*---------------------------------------------------------------------------*/
235: public BasicUnitTest
236{
237 public:
238
240 ~MeshMaterialSimdUnitTest() override;
241
242 public:
243
244 void initializeTest() override;
245 void executeTest() override;
246
247 private:
248
249 IMeshEnvironment* m_env1 = nullptr;
255
256 MaterialVariableCellReal m_mat_adiabatic_cst;
257 MaterialVariableCellReal m_mat_volume;
258 MaterialVariableCellReal m_mat_density;
259 MaterialVariableCellReal m_mat_old_volume;
260 MaterialVariableCellReal m_mat_internal_energy;
261 MaterialVariableCellReal m_mat_sound_speed;
262 MaterialVariableCellReal m_mat_pressure;
263
264 MaterialVariableCellReal m_mat_ref_internal_energy;
265 MaterialVariableCellReal m_mat_ref_sound_speed;
266 MaterialVariableCellReal m_mat_ref_pressure;
267
268 UniqueArray<Int32> m_env1_pure_value_index;
269 UniqueArray<Int32> m_env1_partial_value_index;
270 EnvCellVector* m_env1_as_vector = nullptr;
271 Int32 m_nb_z;
272
273 void _initializeVariables();
274 Real _executeDirect1(Integer nb_z);
275 void _executeTest1(Integer nb_z);
276 void _executeTest1_bis(Integer nb_z);
277 void _executeTest2(Integer nb_z);
278 void _executeTest2_bis(Integer nb_z);
279 void _executeTest3(Integer nb_z);
280 void _executeTest5(Integer nb_z);
281 void _executeTest6(Integer nb_z);
282 void _executeTest7(Integer nb_z);
283 void _executeTest8(Integer nb_z);
284 void _executeTest9(Integer nb_z);
285 void _executeTest10(Integer nb_z);
286 void _initForEquationOfState();
287 void _compareValues();
288 void _computeEquationOfStateReference();
289 void _computeEquationOfStateDirect1();
290 void _computeEquationOfStateIndirect1();
291 void _computeEquationOfStateV1();
292 void _computeEquationOfStateV1_bis();
293 void _computeEquationOfStateV2();
294 void _computeEquationOfStateV3();
295 void _computeEquationOfStateV4();
296 void _computeEquationOfStateV4_noview();
297
298 template<typename Lambda>
299 bool _apply(const char* message,Lambda&& lambda)
300 {
301 bool has_error = false;
302 {
303 PerfTimer pf(message);
304 try{
305 lambda();
306 }
307 catch(const ArithmeticException& ex){
308 pf.setError(true);
309 has_error = true;
310 info() << "ArithmeticException for '" << message << "'";
311 }
312 }
313 return has_error;
314 }
315
316 template<typename Lambda>
317 void _applyCompare(const char* message,Lambda&& lambda)
318 {
319 _initForEquationOfState();
320 bool has_error = _apply(message,lambda);
321 if (!has_error)
322 _compareValues();
323 }
324};
325
326/*---------------------------------------------------------------------------*/
327/*---------------------------------------------------------------------------*/
328
331
332/*---------------------------------------------------------------------------*/
333/*---------------------------------------------------------------------------*/
334
335MeshMaterialSimdUnitTest::
336MeshMaterialSimdUnitTest(const ServiceBuildInfo& sb)
338, m_env1(nullptr)
339, m_mat_a(VariableBuildInfo(mesh(),"MatA"))
340, m_mat_b(VariableBuildInfo(mesh(),"MatB"))
341, m_mat_c(VariableBuildInfo(mesh(),"MatC"))
342, m_mat_d(VariableBuildInfo(mesh(),"MatD"))
343, m_mat_e(VariableBuildInfo(mesh(),"MatE"))
344, m_mat_adiabatic_cst(VariableBuildInfo(mesh(),"MatAdiabaticCst"))
345, m_mat_volume(VariableBuildInfo(mesh(),"MatVolume"))
346, m_mat_density(VariableBuildInfo(mesh(),"MatDensity"))
347, m_mat_old_volume(VariableBuildInfo(mesh(),"MatOldVolume"))
348, m_mat_internal_energy(VariableBuildInfo(mesh(),"MatInternalEnergy"))
349, m_mat_sound_speed(VariableBuildInfo(mesh(),"MatSoundSpeed"))
350, m_mat_pressure(VariableBuildInfo(mesh(),"MatPressure"))
351, m_mat_ref_internal_energy(VariableBuildInfo(mesh(),"MatRefInternalEnergy"))
352, m_mat_ref_sound_speed(VariableBuildInfo(mesh(),"MatRefSoundSpeed"))
353, m_mat_ref_pressure(VariableBuildInfo(mesh(),"MatRefPressure"))
354, m_nb_z(0)
355{
356}
357
358/*---------------------------------------------------------------------------*/
359/*---------------------------------------------------------------------------*/
360
361MeshMaterialSimdUnitTest::
362~MeshMaterialSimdUnitTest()
363{
364 delete m_env1_as_vector;
365}
366
367/*---------------------------------------------------------------------------*/
368/*---------------------------------------------------------------------------*/
369
372{
374
375 // Lit les infos des matériaux du JDD et les enregistre dans le gestionnaire
376 UniqueArray<String> mat_names = { "MAT1", "MAT2", "MAT3" };
377 for( String v : mat_names ){
378 mm->registerMaterialInfo(v);
379 }
380
381 {
383 env_build.addMaterial("MAT1");
384 env_build.addMaterial("MAT2");
385 mm->createEnvironment(env_build);
386 }
387 {
389 env_build.addMaterial("MAT2");
390 env_build.addMaterial("MAT3");
391 mm->createEnvironment(env_build);
392 }
393
394 mm->endCreate(false);
395
396 IMeshEnvironment* env1 = mm->environments()[0];
397 IMeshEnvironment* env2 = mm->environments()[1];
398
399 m_env1 = env1;
400
401 IMeshMaterial* mat1 = env1->materials()[0];
402 IMeshMaterial* mat2 = env2->materials()[1];
403
404 {
411 Cell cell = *icell;
412 Int64 cell_index = cell.uniqueId();
413 if (cell_index<((2*total_nb_cell)/3)){
414 env1_indexes.add(icell.itemLocalId());
415 }
417 mat2_indexes.add(icell.itemLocalId());
418 }
419 if ((cell_index%2)==0)
420 sub_group_indexes.add(icell.itemLocalId());
421 }
422
423 // Ajoute les mailles du milieu 1
424 {
426 Materials::IMeshEnvironment* env = mat1->environment();
427 // Ajoute les mailles du milieu
428 //modifier.addCells(env,env1_indexes);
432 for( Integer z=0; z<nb_cell; ++z ){
433 bool add_to_mat1 = (z<(nb_cell/2) && z>(nb_cell/4));
434 bool add_to_mat2 = (z>=(nb_cell/2) || z<(nb_cell/3));
435 if (add_to_mat1){
437 }
438 if (add_to_mat2)
440 }
441 // Ajoute les mailles du matériau 1
442 modifier.addCells(mat1,mat1_indexes);
443 Integer nb_mat = env->nbMaterial();
444 if (nb_mat>1)
445 // Ajoute les mailles du matériau 2
446 modifier.addCells(mm->environments()[0]->materials()[1],mat2_indexes);
447 }
448 // Ajoute les mailles du milieu 2
449 if (mat2){
451 //modifier.addCells(m_mat2->environment(),mat2_indexes);
452 modifier.addCells(mat2,mat2_indexes);
453 }
454 }
455
456 for( IMeshEnvironment* env : mm->environments() ){
457 info() << "** ** ENV name=" << env->name() << " nb_item=" << env->view().nbItem();
460 if ( (*ienvcell).allEnvCell().nbEnvironment()==1 )
461 ++nb_pure_env;
462 }
463 info() << "** ** NB_PURE=" << nb_pure_env;
464 }
465}
466
467/*---------------------------------------------------------------------------*/
468/*---------------------------------------------------------------------------*/
469
472{
473 m_env1_pure_value_index.clear();
474 m_env1_partial_value_index.clear();
476 {
479 MatVarIndex mvi = env_cell._varIndex();
480 Integer nb_env = env_cell.allEnvCell().nbEnvironment();
481 if ( nb_env==1 )
482 m_env1_pure_value_index.add(mvi.valueIndex());
483 else if (nb_env>1)
484 m_env1_partial_value_index.add(mvi.valueIndex());
485 else
486 ++nb_unknown;
487 }
488 }
489 m_env1_as_vector = new EnvCellVector(m_env1->cells(),m_env1);
490
491 Integer nb_z = 10000;
492 if (arcaneIsDebug())
493 nb_z /= 100;
494 Integer nb_z2 = nb_z / 5;
495
496 Int32 env_idx = m_env1->_internalApi()->variableIndexerIndex() + 1;
497 info() << "Using vectorisation name=" << SimdInfo::name()
498 << " vector_size=" << SimdReal::Length << " index_size=" << SimdInfo::Int32IndexSize;
499 info() << "Compiler=\"" << getCompilerInfo() << "\""
500 << " machine=" << platform::getHostName();
501 info() << "use_sqrt_in_eos?=" << USE_SQRT_IN_EOS
502 << " PRAGMA_IVDEP=" << PRAGMA_IVDEP_VALUE;
503 info() << "ENV_IDX=" << env_idx
504 << " nb_pure=" << m_env1_pure_value_index.size()
505 << " nb_partial=" << m_env1_partial_value_index.size()
506 << " nb_unknown=" << nb_unknown
507 << " nb_z=" << nb_z << " nb_z2=" << nb_z2;
508
509 _initializeVariables();
510 {
511 PerfTimer pf("executeDirect1");
512 _executeDirect1(nb_z);
513 }
514 {
515 PerfTimer pf("executeTest1 (ENVCELL)");
516 _executeTest1(nb_z);
517 }
518 {
519 PerfTimer pf("executeTest1_bis (ENVCELL2)");
520 _executeTest1_bis(nb_z);
521 }
522 {
523 PerfTimer pf("executeTest2 (ENVCELL,IVDEP,view)");
524 _executeTest2(nb_z);
525 }
526 {
527 PerfTimer pf("executeTest2_bis (ENVCELL2,view)");
528 _executeTest2_bis(nb_z);
529 }
530 {
531 PerfTimer pf("executeTest3 (2 loops)");
532 _executeTest3(nb_z);
533 }
534 {
535 PerfTimer pf("executeTest4 (2 loops, ivdep)");
536 _executeTest3(nb_z);
537 }
538 {
539 PerfTimer pf("executeTest5 (2 loops, functor)");
540 _executeTest5(nb_z);
541 }
542 {
543 PerfTimer pf("executeTest6 (2 loops, functor)");
544 _executeTest6(nb_z);
545 }
546 {
547 PerfTimer pf("executeTest7 (2 loops, loop functor)");
548 _executeTest7(nb_z);
549 }
550 {
551 PerfTimer pf("executeTest8 (simple_env_loop)");
552 _executeTest8(nb_z);
553 }
554 {
555 PerfTimer pf("executeTest9 (SIMD_ENVCELL)");
556 _executeTest9(nb_z);
557 }
558 {
559 PerfTimer pf("executeTest10 (SIMD_ENVCELL, functor)");
560 _executeTest10(nb_z);
561 }
562 m_nb_z = nb_z2;
563 _initForEquationOfState();
564 _computeEquationOfStateReference();
565 _apply("_computeEquationOfStateDirect1",
566 [&](){_computeEquationOfStateDirect1();});
567 _apply("_computeEquationOfStateIndirect1",
568 [&](){_computeEquationOfStateIndirect1();});
569 _applyCompare("_computeEquationOfStateV1 (ENVCELL)",
570 [&](){_computeEquationOfStateV1();});
571 _applyCompare("_computeEquationOfStateV1_bis (ENVCELL2)",
572 [&](){_computeEquationOfStateV1_bis();});
573
574 _applyCompare("_computeEquationOfStateV2 (simple_simd_env_loop)",
575 [&](){_computeEquationOfStateV2();});
576 _applyCompare("_computeEquationOfStateV3 (simple_env_loop)",
577 [&](){_computeEquationOfStateV3();});
578
579 _applyCompare("_computeEquationOfStateV4 (lambda simple_env_loop2)",
580 [&](){_computeEquationOfStateV4();});
581 _applyCompare("_computeEquationOfStateV4_noview (lambda simple_env_loop2)",
582 [&](){_computeEquationOfStateV4_noview();});
583
584}
585
586/*---------------------------------------------------------------------------*/
587/*---------------------------------------------------------------------------*/
588
589void MeshMaterialSimdUnitTest::
590_initializeVariables()
591{
592 MaterialVariableCellReal& a(m_mat_a);
593 MaterialVariableCellReal& b(m_mat_b);
594 MaterialVariableCellReal& c(m_mat_c);
595 MaterialVariableCellReal& d(m_mat_d);
596 MaterialVariableCellReal& e(m_mat_e);
597
598 ENUMERATE_ENVCELL(i,m_env1){
599 Real z = (Real)i.index();
600 b[i] = z*2.3;
601 c[i] = z*3.1;
602 d[i] = z*2.5;
603 e[i] = z*4.2;
604 a[i] = 0;
605 }
606}
607
608/*---------------------------------------------------------------------------*/
609/*---------------------------------------------------------------------------*/
610
611Real MeshMaterialSimdUnitTest::
612_executeDirect1(Integer nb_z)
613{
614 Integer TRUE_SIZE = m_env1->cells().size();
615 Real ARCANE_RESTRICT *a = new Real[TRUE_SIZE];
616 Real *b = new Real[TRUE_SIZE];
617 Real *c = new Real[TRUE_SIZE];
618 Real *d = new Real[TRUE_SIZE];
619 Real *e = new Real[TRUE_SIZE];
620#pragma omp parallel for
621 for( Integer i=0, is=TRUE_SIZE; i<is; ++i ){
622 Real z = (Real)i;
623 a[i] = b[i] = c[i] = d[i] = e[i] = z;
624 }
625 Real s = 0.0;
626 for( Integer z=0, iz=nb_z; z<iz; ++z ){
627 for( Integer i=0, is=TRUE_SIZE; i<is; ++i ){
628 a[i] = b[i] + c[i] * d[i] + e[i];
629 }
630 s += a[z%5];
631 }
632 delete[] a;
633 delete[] b;
634 delete[] c;
635 delete[] d;
636 delete[] e;
637 return s;
638}
639
640/*---------------------------------------------------------------------------*/
641/*---------------------------------------------------------------------------*/
642
643void MeshMaterialSimdUnitTest::
644_executeTest1(Integer nb_z)
645{
646 MaterialVariableCellReal& a(m_mat_a);
647 MaterialVariableCellReal& b(m_mat_b);
648 MaterialVariableCellReal& c(m_mat_c);
649 MaterialVariableCellReal& d(m_mat_d);
650 MaterialVariableCellReal& e(m_mat_e);
651
652 for( Integer z=0, iz=nb_z; z<iz; ++z ){
653 ENUMERATE_ENVCELL(i,m_env1){
654 a[i] = b[i] + c[i] * d[i] + e[i];
655 }
656 }
657}
658
659/*---------------------------------------------------------------------------*/
660/*---------------------------------------------------------------------------*/
661
662void MeshMaterialSimdUnitTest::
663_executeTest1_bis(Integer nb_z)
664{
665 MaterialVariableCellReal& a(m_mat_a);
666 MaterialVariableCellReal& b(m_mat_b);
667 MaterialVariableCellReal& c(m_mat_c);
668 MaterialVariableCellReal& d(m_mat_d);
669 MaterialVariableCellReal& e(m_mat_e);
670
671 for( Integer z=0, iz=nb_z; z<iz; ++z ){
672 ENUMERATE_ENVCELL2(i,m_env1){
673 a[i] = b[i] + c[i] * d[i] + e[i];
674 }
675 }
676}
677
678/*---------------------------------------------------------------------------*/
679/*---------------------------------------------------------------------------*/
680
681void MeshMaterialSimdUnitTest::
682_executeTest2(Integer nb_z)
683{
684 auto a(viewOut(m_mat_a));
685 auto b(viewIn(m_mat_b));
686 auto c(viewIn(m_mat_c));
687 auto d(viewIn(m_mat_d));
688 auto e(viewIn(m_mat_e));
689
690 for( Integer z=0, iz=nb_z; z<iz; ++z ){
691 PRAGMA_IVDEP
692 // Certaines versions du compilateur intel (au moins la version 20.0)
693 // donnent une erreur sur le 'pragma omp simd' car le test de la boucle
694 // est une fonction. Pour éviter une erreur de compilation on supprime
695 // ce pragma avec le compilateur intel. A noter que cela semble fonctionner
696 // avec les versions 2021+ de Intel (icpc, icpx et DPC++).
697#ifndef __INTEL_COMPILER
698#pragma omp simd
699#endif
700 ENUMERATE_ENVCELL(i,m_env1){
701 a[i] = b[i] + c[i] * d[i] + e[i];
702 }
703 }
704}
705
706/*---------------------------------------------------------------------------*/
707/*---------------------------------------------------------------------------*/
708
709void MeshMaterialSimdUnitTest::
710_executeTest2_bis(Integer nb_z)
711{
712 auto a(viewOut(m_mat_a));
713 auto b(viewIn(m_mat_b));
714 auto c(viewIn(m_mat_c));
715 auto d(viewIn(m_mat_d));
716 auto e(viewIn(m_mat_e));
717
718 for( Integer z=0, iz=nb_z; z<iz; ++z ){
719 ENUMERATE_ENVCELL2(i,m_env1){
720 a[i] = b[i] + c[i] * d[i] + e[i];
721 }
722 }
723}
724
725/*---------------------------------------------------------------------------*/
726/*---------------------------------------------------------------------------*/
727
728void MeshMaterialSimdUnitTest::
729_executeTest3(Integer nb_z)
730{
731 auto a(viewOut(m_mat_a));
732 auto b(viewIn(m_mat_b));
733 auto c(viewIn(m_mat_c));
734 auto d(viewIn(m_mat_d));
735 auto e(viewIn(m_mat_e));
736
737 for( Integer z=0, iz=nb_z; z<iz; ++z ){
738 {
739 Int32ConstArrayView indexes = m_env1_pure_value_index;
740 PRAGMA_IVDEP
741 for( Integer i=0, n=indexes.size(); i<n; ++i ){
742 Int32 xi = indexes[i];
743 MatVarIndex mvi(0,xi);
744 a[mvi] = b[mvi] + c[mvi] * d[mvi] + e[mvi];
745 }
746 }
747 {
748 Int32ConstArrayView indexes = m_env1_partial_value_index;
749 Int32 env_idx = m_env1->_internalApi()->variableIndexerIndex() + 1;
750 PRAGMA_IVDEP
751 for( Integer i=0, n=indexes.size(); i<n; ++i ){
752 Int32 xi = indexes[i];
754 a[mvi] = b[mvi] + c[mvi] * d[mvi] + e[mvi];
755 }
756 }
757 }
758}
759
760/*---------------------------------------------------------------------------*/
761/*---------------------------------------------------------------------------*/
762
763void MeshMaterialSimdUnitTest::
764_executeTest5(Integer nb_z)
765{
766 auto a(viewOut(m_mat_a));
767 auto b(viewIn(m_mat_b));
768 auto c(viewIn(m_mat_c));
769 auto d(viewIn(m_mat_d));
770 auto e(viewIn(m_mat_e));
771
772 auto func = [=](Int32 env_idx,Int32ConstArrayView indexes)
773 {
774 for( Integer i=0, n=indexes.size(); i<n; ++i ){
775 Int32 xi = indexes[i];
777 a[mvi] = b[mvi] + c[mvi] * d[mvi] + e[mvi];
778 }
779 };
780
781 for( Integer z=0, iz=nb_z; z<iz; ++z ){
782 Int32 env_idx = m_env1->_internalApi()->variableIndexerIndex() + 1;
783 func(0,m_env1_pure_value_index);
784 func(env_idx,m_env1_partial_value_index);
785 }
786}
787
788/*---------------------------------------------------------------------------*/
789/*---------------------------------------------------------------------------*/
790
791void MeshMaterialSimdUnitTest::
792_executeTest6(Integer nb_z)
793{
794 auto a(viewOut(m_mat_a));
795 auto b(viewIn(m_mat_b));
796 auto c(viewIn(m_mat_c));
797 auto d(viewIn(m_mat_d));
798 auto e(viewIn(m_mat_e));
799
800 auto func = [=](Int32 env_idx,Int32ConstArrayView indexes)
801 {
802 for( Integer i=0, n=indexes.size(); i<n; ++i ){
803 Int32 xi = indexes[i];
805 a[mvi] = b[mvi] + c[mvi] * d[mvi] + e[mvi];
806 }
807 };
808
809 for( Integer z=0, iz=nb_z; z<iz; ++z ){
810 {
811 ComponentPartItemVectorView pv = m_env1_as_vector->pureItems();
812 func(pv.componentPartIndex(),pv.valueIndexes());
813 }
814 {
815 ComponentPartItemVectorView pv = m_env1_as_vector->impureItems();
816 func(pv.componentPartIndex(),pv.valueIndexes());
817 }
818 }
819}
820
821/*---------------------------------------------------------------------------*/
822/*---------------------------------------------------------------------------*/
823
824template<typename Lambda> void
825env_loop(const EnvCellVector& env,const Lambda& lambda)
826{
827 lambda(env.pureItems());
828 lambda(env.impureItems());
829}
830
831void MeshMaterialSimdUnitTest::
832_executeTest7(Integer nb_z)
833{
834 auto a(viewOut(m_mat_a));
835 auto b(viewIn(m_mat_b));
836 auto c(viewIn(m_mat_c));
837 auto d(viewIn(m_mat_d));
838 auto e(viewIn(m_mat_e));
839
840 for( Integer z=0, iz=nb_z; z<iz; ++z ){
841 env_loop(*m_env1_as_vector,[=](ComponentPartItemVectorView view){
843 a[mvi] = b[mvi] + c[mvi] * d[mvi] + e[mvi];
844 }});
845 }
846}
847
848/*---------------------------------------------------------------------------*/
849/*---------------------------------------------------------------------------*/
850
851template<typename Lambda> void
854 const Lambda& lambda)
855{
857 views[0] = pure_items;
858 views[1] = impure_items;
859
860 for( Integer iview=0; iview<2; ++iview ){
861 const auto& xiter = views[iview];
862 Int32 cpi = xiter.componentPartIndex();
863 Int32ConstArrayView item_indexes = xiter.valueIndexes();
864 Integer nb_item = xiter.nbItem();
865 //std::cout << " cpi=" << cpi << " nb_item=" << nb_item << " nb_item2=" << item_indexes.size() << '\n';
866 PRAGMA_IVDEP
867 for( Integer i=0; i<nb_item; ++i ){
869 //std::cout << " cpi=" << cpi << " I=" << i << " IDX=" << item_indexes[i] << '\n';
870 lambda(mvi);
871 }
872 }
873}
874
875template<typename ContainerType,typename Lambda> void
876simple_env_loop(ContainerType& ct,const Lambda& lambda)
877{
878 simple_env_loop(ct.pureItems(),ct.impureItems(),lambda);
879}
880
881template<typename Lambda> void
884 const Lambda& lambda)
885{
887 views[0] = pure_items;
888 views[1] = impure_items;
889
890 {
891 auto view = views[0];
892 Int32ConstArrayView item_indexes = view.valueIndexes();
893 Integer nb_item = view.nbItem();
894 PRAGMA_IVDEP
895 for( Integer i=0; i<nb_item; ++i ){
897 //lambda(PureMatVarIndex(i));
898 }
899 }
900
901 {
902 auto view = views[1];
903 Int32 cpi = view.componentPartIndex();
904 Integer nb_item = view.nbItem();
905 Int32ConstArrayView item_indexes = view.valueIndexes();
906 PRAGMA_IVDEP
907 for( Integer i=0; i<nb_item; ++i ){
908 // On sait pour ce test que les mailles partielles sont contigues
909 // et item_indexes[i] == i.
910 //MatVarIndex mvi(cpi,item_indexes[i]);
912 lambda(mvi);
913 }
914 }
915}
916
917template<typename ContainerType,typename Lambda> void
918simple_env_loop2(const ContainerType& ct,const Lambda& lambda)
919{
920 simple_env_loop2(ct.pureItems(),ct.impureItems(),lambda);
921}
922
923void MeshMaterialSimdUnitTest::
924_executeTest8(Integer nb_z)
925{
926 auto a(viewOut(m_mat_a));
927 auto b(viewIn(m_mat_b));
928 auto c(viewIn(m_mat_c));
929 auto d(viewIn(m_mat_d));
930 auto e(viewIn(m_mat_e));
931
932 for( Integer z=0, iz=nb_z; z<iz; ++z ){
933 simple_env_loop(*m_env1_as_vector,[=](MatVarIndex mvi){
934 a[mvi] = b[mvi] + c[mvi] * d[mvi] + e[mvi];
935 });
936 }
937}
938
939/*---------------------------------------------------------------------------*/
940/*---------------------------------------------------------------------------*/
941
942void MeshMaterialSimdUnitTest::
943_executeTest9(Integer nb_z)
944{
945 auto a(viewOut(m_mat_a));
946 auto b(viewIn(m_mat_b));
947 auto c(viewIn(m_mat_c));
948 auto d(viewIn(m_mat_d));
949 auto e(viewIn(m_mat_e));
950
951 for( Integer z=0, iz=nb_z; z<iz; ++z ){
952 env_loop(*m_env1_as_vector,[=](ComponentPartItemVectorView view){
953 ENUMERATE_SIMD_COMPONENTCELL(mvi,view){
954 a[mvi] = b[mvi] + c[mvi] * d[mvi] + e[mvi];
955 }});
956 }
957
958}
959
960/*---------------------------------------------------------------------------*/
961/*---------------------------------------------------------------------------*/
962
963#define A_ENUMERATE_LAMBDA(iter_type,iter,container,...) \
964 Arcane::Materials:: LoopFunctor ## iter_type ( (container) ) << __VA_ARGS__ ( Arcane::Materials:: LoopFunctor ## iter_type :: IterType iter)
965
966#define A_CAPTURE(a) a
967#define A_ENUMERATE_LAMBDA2(iter_type,iter,container,lambda_capture) \
968 Arcane::Materials:: LoopFunctor ## iter_type ( (container) ) << A_CAPTURE(lambda_capture) ( Arcane::Materials:: LoopFunctor ## iter_type :: IterType iter)
969
970#define A_ENUMERATE_LAMBDA3(iter_type,iter,container) \
971 Arcane::Materials:: LoopFunctor ## iter_type ( (container) ) <<
972
973/*---------------------------------------------------------------------------*/
974/*---------------------------------------------------------------------------*/
975// TODO: mettre dans .h
976template<typename Lambda> void
977simple_simd_env_loop(const EnvCellVector& env,const Lambda& lambda)
978{
979 simple_simd_env_loop(env.pureItems(),env.impureItems(),lambda);
980}
981
982/*---------------------------------------------------------------------------*/
983/*---------------------------------------------------------------------------*/
984
985void MeshMaterialSimdUnitTest::
986_executeTest10(Integer nb_z)
987{
988 auto a(viewOut(m_mat_a));
989 auto b(viewIn(m_mat_b));
990 auto c(viewIn(m_mat_c));
991 auto d(viewIn(m_mat_d));
992 auto e(viewIn(m_mat_e));
993
994 for( Integer z=0, iz=nb_z; z<iz; ++z ){
995 simple_simd_env_loop(*m_env1_as_vector,[=](const SimdMatVarIndex& mvi){
996 a[mvi] = b[mvi] + c[mvi] * d[mvi] + e[mvi];
997 });
998 }
999}
1000
1001/*---------------------------------------------------------------------------*/
1002/*---------------------------------------------------------------------------*/
1003
1004void MeshMaterialSimdUnitTest::
1005_initForEquationOfState()
1006{
1007 ENUMERATE_ENVCELL(icell,m_env1){
1009 m_mat_adiabatic_cst[vi] = 1.4;
1010 m_mat_volume[vi] = 1.2;
1011 m_mat_old_volume[vi] = 1.1;
1012
1013 m_mat_density[vi] = 2.0;
1014 m_mat_pressure[vi] = 1.1;
1015
1016 m_mat_internal_energy[vi] = m_mat_pressure[icell] / ((m_mat_adiabatic_cst[icell]-1.0) * m_mat_density[icell]);
1017 }
1018}
1019
1020/*---------------------------------------------------------------------------*/
1021/*---------------------------------------------------------------------------*/
1022
1023void MeshMaterialSimdUnitTest::
1024_computeEquationOfStateDirect1()
1025{
1026 Int32 nb_z = m_nb_z;
1027 Integer TRUE_SIZE = m_env1->cells().size();
1028
1029 auto in_adiabatic_cst = new Real[TRUE_SIZE];
1030 auto in_volume = new Real[TRUE_SIZE];
1031 auto in_density = new Real[TRUE_SIZE];
1032 auto in_old_volume = new Real[TRUE_SIZE];
1033 auto in_internal_energy = new Real[TRUE_SIZE];
1034
1036 auto out_sound_speed = new Real[TRUE_SIZE];
1037 auto out_pressure = new Real[TRUE_SIZE];
1038
1039 for( Integer i=0, is=TRUE_SIZE; i<is; ++i ){
1040 Integer vi = i;
1041 in_adiabatic_cst[vi] = 1.4;
1042 in_volume[vi] = 1.2;
1043 in_old_volume[vi] = 1.1;
1044
1045 in_density[vi] = 2.0;
1046 Real in_pressure = 1.1;
1047
1049 }
1050 for( Int32 iloop=0; iloop<nb_z; ++iloop){
1051
1052 PRAGMA_IVDEP
1053 for( Integer i=0, n=TRUE_SIZE; i<n; ++i ){
1054 Integer vi = i;
1057 Real x = 0.5 * adiabatic_cst - 1.0;
1058 Real numer_accrois_nrj = 1.0 + x*(1.0-volume_ratio);
1059 Real denom_accrois_nrj = 1.0 + x*(1.0-(1.0/volume_ratio));
1063 Real density = in_density[vi];
1064 Real pressure = (adiabatic_cst - 1.0) * density * internal_energy;
1065 Real sound_speed = DO_SQRT((adiabatic_cst*pressure/density));
1068 }
1069 }
1070 delete[] in_adiabatic_cst;
1071 delete[] in_volume;
1072 delete[] in_density;
1073 delete[] in_old_volume;
1074 delete[] in_internal_energy;
1075 delete[] out_sound_speed;
1076 delete[] out_pressure;
1077}
1078
1079/*---------------------------------------------------------------------------*/
1080/*---------------------------------------------------------------------------*/
1081
1082void MeshMaterialSimdUnitTest::
1083_computeEquationOfStateIndirect1()
1084{
1085 Int32 nb_z = m_nb_z;
1086 Integer TRUE_SIZE = m_env1->cells().size();
1087
1088 auto in_adiabatic_cst = new Real[TRUE_SIZE];
1089 auto in_volume = new Real[TRUE_SIZE];
1090 auto in_density = new Real[TRUE_SIZE];
1091 auto in_old_volume = new Real[TRUE_SIZE];
1092 auto in_internal_energy = new Real[TRUE_SIZE];
1093
1095 auto out_sound_speed = new Real[TRUE_SIZE];
1096 auto out_pressure = new Real[TRUE_SIZE];
1097
1098 ARCANE_RESTRICT Int32* idx = new Int32[TRUE_SIZE];
1099
1100 for( Integer i=0, is=TRUE_SIZE; i<is; ++i ){
1101 idx[i] = i;
1102 Integer vi = idx[i];
1103
1104 in_adiabatic_cst[vi] = 1.4;
1105 in_volume[vi] = 1.2;
1106 in_old_volume[vi] = 1.1;
1107
1108 in_density[vi] = 2.0;
1109 Real in_pressure = 1.1;
1110
1112 }
1113 for( Int32 iloop=0; iloop<nb_z; ++iloop){
1114
1115 PRAGMA_IVDEP
1116 for( Integer i=0, n=TRUE_SIZE; i<n; ++i ){
1117 Integer vi = idx[i];
1120 Real x = 0.5 * adiabatic_cst - 1.0;
1121 Real numer_accrois_nrj = 1.0 + x*(1.0-volume_ratio);
1122 Real denom_accrois_nrj = 1.0 + x*(1.0-(1.0/volume_ratio));
1126 Real density = in_density[vi];
1127 Real pressure = (adiabatic_cst - 1.0) * density * internal_energy;
1128 Real sound_speed = DO_SQRT((adiabatic_cst*pressure/density));
1131 }
1132 }
1133 delete[] idx;
1134 delete[] in_adiabatic_cst;
1135 delete[] in_volume;
1136 delete[] in_density;
1137 delete[] in_old_volume;
1138 delete[] in_internal_energy;
1139 delete[] out_sound_speed;
1140 delete[] out_pressure;
1141}
1142
1143/*---------------------------------------------------------------------------*/
1144/*---------------------------------------------------------------------------*/
1145
1146void MeshMaterialSimdUnitTest::
1147_computeEquationOfStateReference()
1148{
1149 Int32 nb_z = m_nb_z;
1150
1151 auto in_adiabatic_cst = viewIn(m_mat_adiabatic_cst);
1152 auto in_volume = viewIn(m_mat_volume);
1153 auto in_density = viewIn(m_mat_density);
1154 auto in_old_volume = viewIn(m_mat_old_volume);
1155 auto in_internal_energy = viewIn(m_mat_internal_energy);
1156
1157 for( Int32 iloop=0; iloop<nb_z; ++iloop){
1158 ENUMERATE_ENVCELL(icell,m_env1){
1159 auto vi = icell;
1162 Real x = 0.5 * adiabatic_cst - 1.0;
1163 Real numer_accrois_nrj = 1.0 + x*(1.0-volume_ratio);
1164 Real denom_accrois_nrj = 1.0 + x*(1.0-(1.0/volume_ratio));
1167 m_mat_internal_energy[vi] = internal_energy;
1168 Real density = in_density[vi];
1169 Real pressure = (adiabatic_cst - 1.0) * density * internal_energy;
1170 Real sound_speed = DO_SQRT(adiabatic_cst*pressure/density);
1171 m_mat_pressure[vi] = pressure;
1172 m_mat_sound_speed[vi] = sound_speed;
1173 }
1174 }
1175 ENUMERATE_ENVCELL(vi,m_env1){
1176 m_mat_ref_internal_energy[vi] = m_mat_internal_energy[vi];
1177 m_mat_ref_pressure[vi] = m_mat_pressure[vi];
1178 m_mat_ref_sound_speed[vi] = m_mat_sound_speed[vi];
1179 }
1180}
1181
1182/*---------------------------------------------------------------------------*/
1183/*---------------------------------------------------------------------------*/
1184
1185void MeshMaterialSimdUnitTest::
1186_compareValues()
1187{
1188 ValueChecker vc(A_FUNCINFO);
1189 ENUMERATE_ENVCELL(icell,m_env1){
1190 vc.areEqual(m_mat_internal_energy[icell],m_mat_ref_internal_energy[icell],"Energy");
1191 vc.areEqual(m_mat_pressure[icell],m_mat_ref_pressure[icell],"Pressure");
1192 vc.areEqual(m_mat_sound_speed[icell],m_mat_ref_sound_speed[icell],"SoundSpeed");
1193 }
1194}
1195
1196/*----------------------a-----------------------------------------------------*/
1197/*---------------------------------------------------------------------------*/
1198
1199void MeshMaterialSimdUnitTest::
1200_computeEquationOfStateV1()
1201{
1202 Int32 nb_z = m_nb_z;
1203 auto in_adiabatic_cst = viewIn(m_mat_adiabatic_cst);
1204 auto in_volume = viewIn(m_mat_volume);
1205 auto in_density = viewIn(m_mat_density);
1206 auto in_old_volume = viewIn(m_mat_old_volume);
1207 auto in_internal_energy = viewIn(m_mat_internal_energy);
1208
1209 auto out_internal_energy = viewOut(m_mat_internal_energy);
1210 auto out_sound_speed = viewOut(m_mat_sound_speed);
1211 auto out_pressure = viewOut(m_mat_pressure);
1212
1213 for( Int32 iloop=0; iloop<nb_z; ++iloop){
1214
1215 PRAGMA_IVDEP
1216 ENUMERATE_ENVCELL(icell,m_env1){
1217 auto vi = icell;
1220 Real x = 0.5 * adiabatic_cst - 1.0;
1221 Real numer_accrois_nrj = 1.0 + x*(1.0-volume_ratio);
1222 Real denom_accrois_nrj = 1.0 + x*(1.0-(1.0/volume_ratio));
1226 Real density = in_density[vi];
1227 Real pressure = (adiabatic_cst - 1.0) * density * internal_energy;
1228 Real sound_speed = DO_SQRT(adiabatic_cst*pressure/density);
1231 }
1232 }
1233}
1234
1235/*----------------------a-----------------------------------------------------*/
1236/*---------------------------------------------------------------------------*/
1237
1238void MeshMaterialSimdUnitTest::
1239_computeEquationOfStateV1_bis()
1240{
1241 Int32 nb_z = m_nb_z;
1242 auto in_adiabatic_cst = viewIn(m_mat_adiabatic_cst);
1243 auto in_volume = viewIn(m_mat_volume);
1244 auto in_density = viewIn(m_mat_density);
1245 auto in_old_volume = viewIn(m_mat_old_volume);
1246 auto in_internal_energy = viewIn(m_mat_internal_energy);
1247
1248 auto out_internal_energy = viewOut(m_mat_internal_energy);
1249 auto out_sound_speed = viewOut(m_mat_sound_speed);
1250 auto out_pressure = viewOut(m_mat_pressure);
1251
1252 for( Int32 iloop=0; iloop<nb_z; ++iloop){
1253
1254 ENUMERATE_ENVCELL2(icell,m_env1){
1255 auto vi = icell;
1258 Real x = 0.5 * adiabatic_cst - 1.0;
1259 Real numer_accrois_nrj = 1.0 + x*(1.0-volume_ratio);
1260 Real denom_accrois_nrj = 1.0 + x*(1.0-(1.0/volume_ratio));
1264 Real density = in_density[vi];
1265 Real pressure = (adiabatic_cst - 1.0) * density * internal_energy;
1266 Real sound_speed = DO_SQRT((adiabatic_cst*pressure/density));
1269 }
1270 }
1271}
1272
1273/*---------------------------------------------------------------------------*/
1274/*---------------------------------------------------------------------------*/
1275
1276void MeshMaterialSimdUnitTest::
1277_computeEquationOfStateV3()
1278{
1279 Int32 nb_z = m_nb_z;
1280 auto in_adiabatic_cst = viewIn(m_mat_adiabatic_cst);
1281 auto in_volume = viewIn(m_mat_volume);
1282 auto in_density = viewIn(m_mat_density);
1283 auto in_old_volume = viewIn(m_mat_old_volume);
1284 auto in_internal_energy = viewIn(m_mat_internal_energy);
1285
1286 auto out_internal_energy = viewOut(m_mat_internal_energy);
1287 auto out_sound_speed = viewOut(m_mat_sound_speed);
1288 auto out_pressure = viewOut(m_mat_pressure);
1289
1290 for( Int32 iloop=0; iloop<nb_z; ++iloop){
1291
1292 auto func = [=](MatVarIndex vi){
1295 Real x = 0.5 * adiabatic_cst - 1.0;
1296 Real numer_accrois_nrj = 1.0 + x*(1.0-volume_ratio);
1297 Real denom_accrois_nrj = 1.0 + x*(1.0-(1.0/volume_ratio));
1301 Real density = in_density[vi];
1302 Real pressure = (adiabatic_cst - 1.0) * density * internal_energy;
1303 Real sound_speed = DO_SQRT((adiabatic_cst*pressure/density));
1306 };
1307 simple_env_loop(*m_env1,func);
1308 }
1309}
1310
1311/*---------------------------------------------------------------------------*/
1312/*---------------------------------------------------------------------------*/
1313
1314void MeshMaterialSimdUnitTest::
1315_computeEquationOfStateV2()
1316{
1317 Int32 nb_z = m_nb_z;
1318 auto in_adiabatic_cst = viewIn(m_mat_adiabatic_cst);
1319 auto in_volume = viewIn(m_mat_volume);
1320 auto in_density = viewIn(m_mat_density);
1321 auto in_old_volume = viewIn(m_mat_old_volume);
1322 auto in_internal_energy = viewIn(m_mat_internal_energy);
1323
1324 auto out_internal_energy = viewOut(m_mat_internal_energy);
1325 auto out_sound_speed = viewOut(m_mat_sound_speed);
1326 auto out_pressure = viewOut(m_mat_pressure);
1327
1328 for( Int32 iloop=0; iloop<nb_z; ++iloop){
1329
1331 auto vi = mvi;
1334 SimdReal x = 0.5 * adiabatic_cst - 1.0;
1335 SimdReal numer_accrois_nrj = 1.0 + x*(1.0-volume_ratio);
1336 SimdReal denom_accrois_nrj = 1.0 + x*(1.0-(1.0/volume_ratio));
1345 };
1346 }
1347}
1348
1349/*---------------------------------------------------------------------------*/
1350/*---------------------------------------------------------------------------*/
1351
1352void MeshMaterialSimdUnitTest::
1353_computeEquationOfStateV4()
1354{
1355 Int32 nb_z = m_nb_z;
1356 auto in_adiabatic_cst = viewIn(m_mat_adiabatic_cst);
1357 auto in_volume = viewIn(m_mat_volume);
1358 auto in_density = viewIn(m_mat_density);
1359 auto in_old_volume = viewIn(m_mat_old_volume);
1360 auto in_internal_energy = viewIn(m_mat_internal_energy);
1361
1362 auto out_internal_energy = viewOut(m_mat_internal_energy);
1363 auto out_sound_speed = viewOut(m_mat_sound_speed);
1364 auto out_pressure = viewOut(m_mat_pressure);
1365
1366 for( Int32 iloop=0; iloop<nb_z; ++iloop){
1367
1368 auto func = [=](auto vi){
1371 Real x = 0.5 * adiabatic_cst - 1.0;
1372 Real numer_accrois_nrj = 1.0 + x*(1.0-volume_ratio);
1373 Real denom_accrois_nrj = 1.0 + x*(1.0-(1.0/volume_ratio));
1377 Real density = in_density[vi];
1378 Real pressure = (adiabatic_cst - 1.0) * density * internal_energy;
1379 Real sound_speed = DO_SQRT((adiabatic_cst*pressure/density));
1382 };
1383 simple_env_loop2(*m_env1_as_vector,func);
1384 }
1385}
1386
1387/*---------------------------------------------------------------------------*/
1388/*---------------------------------------------------------------------------*/
1389
1390void MeshMaterialSimdUnitTest::
1391_computeEquationOfStateV4_noview()
1392{
1393 Int32 nb_z = m_nb_z;
1394
1395 for( Int32 iloop=0; iloop<nb_z; ++iloop){
1396
1397 auto func = [&](auto vi){
1398 Real adiabatic_cst = m_mat_adiabatic_cst[vi];
1399 Real volume_ratio = m_mat_volume[vi] / m_mat_old_volume[vi];
1400 Real x = 0.5 * adiabatic_cst - 1.0;
1401 Real numer_accrois_nrj = 1.0 + x*(1.0-volume_ratio);
1402 Real denom_accrois_nrj = 1.0 + x*(1.0-(1.0/volume_ratio));
1403 Real internal_energy = m_mat_internal_energy[vi];
1405 m_mat_internal_energy[vi] = internal_energy;
1406 Real density = m_mat_density[vi];
1407 Real pressure = (adiabatic_cst - 1.0) * density * internal_energy;
1408 Real sound_speed = DO_SQRT((adiabatic_cst*pressure/density));
1409 m_mat_pressure[vi] = pressure;
1410 m_mat_sound_speed[vi] = sound_speed;
1411 };
1412 simple_env_loop2(*m_env1_as_vector,func);
1413 }
1414}
1415
1416/*---------------------------------------------------------------------------*/
1417/*---------------------------------------------------------------------------*/
1418
1419/*---------------------------------------------------------------------------*/
1420/*---------------------------------------------------------------------------*/
1421
1423
1424/*---------------------------------------------------------------------------*/
1425/*---------------------------------------------------------------------------*/
#define ENUMERATE_COMPONENTITEM_LAMBDA(iter_type, iter, container)
Macro pour itérer sur les entités d'un composant via une fonction lambda du C++11.
#define ENUMERATE_CELL(name, group)
Enumérateur générique d'un groupe de mailles.
#define ARCANE_REGISTER_CASE_OPTIONS_NOAXL_FACTORY(aclass, ainterface, aname)
Enregistre un service de fabrique pour la classe aclass.
Exception lorsqu'une erreur arithmétique survient.
Service basique de test unitaire.
Maille d'un maillage.
Definition Item.h:1178
Vectorisation des réels par émulation.
Definition SimdEMUL.h:155
Enumérateur sur une sous-partie (pure ou partielle) d'un sous-ensemble des mailles d'un composant (ma...
Interface d'un service de test unitaire.
Definition IUnitTest.h:34
Integer size() const
Nombre d'éléments du groupe.
Definition ItemGroup.h:88
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
Definition Item.h:216
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Index d'un Item matériaux dans une variable.
ComponentPurePartItemVectorView pureItems() const
Liste des entités pures (associées à la maille globale) du composant.
ComponentImpurePartItemVectorView impureItems() const
Liste des entités impures (partielles) du composant.
Vue sur une partie pure ou partielles des entités d'un composant.
Enumérateur sur les mailles d'un milieu.
Vecteur sur les entités d'un milieu.
Maille arcane d'un milieu.
Interface d'un composant (matériau ou milieu) d'un maillage.
virtual CellGroup cells() const =0
Groupe des mailles de ce matériau.
virtual IMeshComponentInternal * _internalApi()=0
API interne.
Interface du gestionnaire des matériaux et des milieux d'un maillage.
static IMeshMaterialMng * getReference(const MeshHandleOrMesh &mesh_handle, bool create=true)
Récupère ou créé la référence associée à mesh.
Interface d'un matériau d'un maillage.
Représente un index sur les variables matériaux et milieux.
Informations pour la création d'un milieu.
Objet permettant de modifier les matériaux ou les milieux.
void addCells(IMeshMaterial *mat, SmallSpan< const Int32 > ids)
Ajoute les mailles d'indices locaux ids au matériau mat.
Index d'un Item matériaux pure dans une variable.
CellGroup allCells() const
Retourne le groupe contenant toutes les mailles.
CellGroup ownCells() const
Retourne le groupe contenant toutes les mailles propres à ce domaine.
Flot de sortie lié à une String.
Structure contenant les informations pour créer un service.
Indexeur SIMD sur un composant.
Vérification de la validité de certaines valeurs.
Paramètres nécessaires à la construction d'une variable.
Integer size() const
Nombre d'éléments du vecteur.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
void clear()
Supprime les éléments du tableau.
Vue constante d'un tableau de type T.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
Chaîne de caractères unicode.
TraceMessage info() const
Flot pour un message d'information.
Vecteur 1D de données avec sémantique par valeur (style STL).
Service de test unitaire de la vectorisation des matériaux/milieux.
void initializeTest() override
Méthode appelée après lecture du jeu de données pour initialiser le test.
void executeTest() override
Méthode appelée pour exécuter le test.
#define ENUMERATE_ENVCELL(iname, env)
Macro pour itérer sur toutes les mailles d'un milieu.
#define ENUMERATE_COMPONENTITEM(enumerator_class_name, iname,...)
Macro générique pour itérer sur les entités d'un matériau ou d'un milieu.
auto viewIn(RunCommand &cmd, const CellMaterialVariableScalarRef< DataType > &var)
Vue en lecture pour les variables materiaux scalaire.
auto viewOut(RunCommand &cmd, CellMaterialVariableScalarRef< DataType > &var)
Vue en écriture pour les variables materiaux scalaire.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
bool arcaneIsDebug()
Vrai si la macro ARCANE_DEBUG est définie.
Definition Misc.cc:163
Int32 Integer
Type représentant un entier.
Ensemble des classes assurant la gestion des matériaux et des milieux.