Skip to content

Commit d356b1e

Browse files
Merge pull request #1184 from arcaneframework/dev/gg-add-runcommand-for-material
Add support for 'RUNCOMMAND_MAT_ENUMERATE' for 'MatCell'
2 parents 0724167 + b64c812 commit d356b1e

File tree

7 files changed

+394
-36
lines changed

7 files changed

+394
-36
lines changed

arcane/ceapart/src/arcane/tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
if (ARCANE_HAS_ACCELERATOR_API)
44
list(APPEND ARCANE_SOURCES
55
AdiProjectionModule.cc
6+
MaterialHeatTestModule.cc
67
)
78
set(ARCANE_ACCELERATOR_SOURCES
89
AdiProjectionModule.cc
910
CartesianMeshTestUtils.cc
1011
MeshMaterialSyncUnitTest.cc
12+
MaterialHeatTestModule.cc
1113
)
1214
arcane_accelerator_add_source_files(${ARCANE_ACCELERATOR_SOURCES})
1315
endif()

arcane/ceapart/src/arcane/tests/MaterialHeatTestModule.cc

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* MaterialHeatTestModule.cc (C) 2000-2023 */
8+
/* MaterialHeatTestModule.cc (C) 2000-2024 */
99
/* */
1010
/* Module de test des matériaux. */
1111
/*---------------------------------------------------------------------------*/
@@ -29,6 +29,13 @@
2929
#include "arcane/materials/MeshMaterialModifier.h"
3030
#include "arcane/materials/ComponentItemVectorView.h"
3131

32+
#include "arcane/accelerator/core/IAcceleratorMng.h"
33+
#include "arcane/accelerator/core/RunCommand.h"
34+
#include "arcane/accelerator/core/RunQueue.h"
35+
#include "arcane/accelerator/VariableViews.h"
36+
#include "arcane/accelerator/MaterialVariableViews.h"
37+
#include "arcane/accelerator/RunCommandMaterialEnumerate.h"
38+
3239
#include "arcane/tests/ArcaneTestGlobal.h"
3340
#include "arcane/tests/MaterialHeatTest_axl.h"
3441

@@ -49,7 +56,7 @@ using namespace Arcane::Materials;
4956
class MaterialHeatTestModule
5057
: public ArcaneMaterialHeatTestObject
5158
{
52-
private:
59+
public:
5360

5461
//! Caractéristiques de l'objet qui chauffe (disque ou sphère)
5562
struct HeatObject
@@ -120,7 +127,9 @@ class MaterialHeatTestModule
120127
void _computeGlobalTemperature();
121128
void _computeCellsToAdd(const HeatObject& heat_object, MaterialWorkArray& wa);
122129
void _computeCellsToRemove(const HeatObject& heat_object, MaterialWorkArray& wa);
130+
public:
123131
void _addHeat(const HeatObject& heat_object);
132+
private:
124133
void _addCold(const HeatObject& heat_object);
125134
void _initNewCells(const HeatObject& heat_object, MaterialWorkArray& wa);
126135
void _compute();
@@ -157,9 +166,11 @@ MaterialHeatTestModule::
157166
void MaterialHeatTestModule::
158167
buildInit()
159168
{
169+
ProfilingRegistry::setProfilingLevel(2);
170+
160171
// La création des milieux et des matériaux doit se faire dans un point
161172
// d'entrée de type 'build' pour que la liste des variables créés par les
162-
// milieux et les matériaux soit accessible dans le post-traitement.
173+
// milieux et les matériaux soit accessibles dans le post-traitement.
163174
info() << "MaterialHeatTestModule::buildInit()";
164175

165176
Materials::IMeshMaterialMng* mm = IMeshMaterialMng::getReference(defaultMesh());
@@ -378,18 +389,23 @@ _addHeat(const HeatObject& heat_object)
378389
const Real heat_radius_norm = heat_object.radius * heat_object.radius;
379390

380391
IMeshMaterial* current_mat = heat_object.material;
392+
RunQueue* queue = this->acceleratorMng()->defaultQueue();
393+
auto command = makeCommand(queue);
394+
395+
auto in_cell_center = viewIn(command, m_cell_center);
396+
auto inout_mat_temperature = viewInOut(command, m_mat_temperature);
381397

382398
//! Chauffe les mailles déjà présentes dans le matériau
383-
ENUMERATE_MATCELL (imatcell, current_mat) {
384-
MatCell mc = *imatcell;
385-
Cell cell = mc.globalCell();
386-
Real3 center = m_cell_center[cell];
399+
command << RUNCOMMAND_MAT_ENUMERATE(MatAndGlobalCell, iter, current_mat)
400+
{
401+
auto [matcell, cell] = iter();
402+
Real3 center = in_cell_center[cell];
387403
Real distance2 = (center - heat_center).squareNormL2();
388404
if (distance2 < heat_radius_norm) {
389405
Real to_add = heat_value / (1.0 + distance2);
390-
m_mat_temperature[mc] += to_add;
406+
inout_mat_temperature[matcell] += to_add;
391407
}
392-
}
408+
};
393409
}
394410

395411
/*---------------------------------------------------------------------------*/

arcane/ceapart/src/arcane/tests/srcs.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
set(ARCANE_SOURCES
22
RayMeshIntersectionUnitTest.cc
3-
MaterialHeatTestModule.cc
43
MeshMaterialTesterModule.cc
54
CartesianMeshTesterModule.cc
65
HyodaMixedCellsUnitTest.cc

arcane/ceapart/tests/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,21 @@ foreach(test_index 1 2 3)
303303
set(TEST_ACTIVE_LOAD_BALANCE "false")
304304
set(_TEST_FILENAME "${ARCANE_TEST_PATH}/testMaterialHeat-${test_index}-opt${opt_level}.arc")
305305
configure_file("testMaterialHeat-${test_index}.arc.in" "${_TEST_FILENAME}")
306-
arcane_add_test(material_heat_opt${opt_level}_${test_index} ${_TEST_FILENAME})
307306

308307
# Test avec équilibrage
309308
set(TEST_ACTIVE_LOAD_BALANCE "true")
310309
set(_TEST_FILENAME "${ARCANE_TEST_PATH}/testMaterialHeat-${test_index}-opt${opt_level}-lb.arc")
311310
configure_file("testMaterialHeat-${test_index}.arc.in" "${_TEST_FILENAME}")
312-
arcane_add_test(material_heat_lb_opt${opt_level}_${test_index} ${_TEST_FILENAME})
311+
if (ARCANE_HAS_ACCELERATOR_API)
312+
arcane_add_test(material_heat_opt${opt_level}_${test_index} ${_TEST_FILENAME})
313+
arcane_add_test(material_heat_lb_opt${opt_level}_${test_index} ${_TEST_FILENAME})
314+
endif()
313315
endforeach()
314316
endforeach()
315-
arcane_add_test_sequential(material_heat_opt15_2small testMaterialHeat-2-small-opt15.arc "-We,ARCANE_DEBUG_MATERIAL_MODIFIER,2")
317+
if (ARCANE_HAS_ACCELERATOR_API)
318+
arcane_add_test_sequential(material_heat_opt15_2small testMaterialHeat-2-small-opt15.arc "-We,ARCANE_DEBUG_MATERIAL_MODIFIER,2")
319+
arcane_add_accelerator_test_sequential(material_heat_accelerator "${ARCANE_TEST_PATH}/testMaterialHeat-2-opt15.arc" "-m 20")
320+
endif()
316321

317322
###################
318323
# WRAPPING '.Net' #

0 commit comments

Comments
 (0)