Skip to content

Commit acd3eb4

Browse files
Merge pull request #1770 from arcaneframework/dev/gg-add-alephint-for-aleph
Add typedef 'AlephInt' to handle indexing of matrix and vectors in Aleph
2 parents 65535b4 + 826f923 commit acd3eb4

14 files changed

+270
-207
lines changed

arcane/src/arcane/aleph/AlephGlobal.h

+8-2
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-
/* AlephGlobal.h (C) 2000-2023 */
8+
/* AlephGlobal.h (C) 2000-2024 */
99
/* */
1010
/* Déclarations générales de la composante 'arcane_aleph'. */
1111
/*---------------------------------------------------------------------------*/
@@ -36,13 +36,19 @@ namespace Arcane
3636

3737
class IAlephFactory;
3838
class IAlephTopology;
39+
class IAlephMatrix;
40+
class IAlephVector;
41+
class AlephKernel;
3942
class AlephTopology;
4043
class AlephMatrix;
4144
class AlephOrdering;
4245
class AlephIndexing;
4346
class AlephVector;
4447
class AlephParams;
4548

49+
//! Type par défaut pour indexer les lignes et les colonnes des matrices et vecteurs
50+
using AlephInt = int;
51+
4652
/*---------------------------------------------------------------------------*/
4753
/*---------------------------------------------------------------------------*/
4854

arcane/src/arcane/aleph/AlephInterface.h

+33-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 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-
/* AlephInterface.h (C) 2000-2011 */
8+
/* AlephInterface.h (C) 2000-2024 */
99
/* */
1010
/* */
1111
/*---------------------------------------------------------------------------*/
12-
#ifndef ARCANE_ALEPH_ALEPHINTERFACE_H_
13-
#define ARCANE_ALEPH_ALEPHINTERFACE_H_
12+
#ifndef ARCANE_ALEPH_ALEPHINTERFACE_H
13+
#define ARCANE_ALEPH_ALEPHINTERFACE_H
1414
/*---------------------------------------------------------------------------*/
1515
/*---------------------------------------------------------------------------*/
1616

@@ -20,7 +20,8 @@
2020
/*---------------------------------------------------------------------------*/
2121
/*---------------------------------------------------------------------------*/
2222

23-
ARCANE_BEGIN_NAMESPACE
23+
namespace Arcane
24+
{
2425

2526
/*---------------------------------------------------------------------------*/
2627
/*---------------------------------------------------------------------------*/
@@ -32,9 +33,11 @@ class AlephVector;
3233
/******************************************************************************
3334
* IAlephTopology
3435
*****************************************************************************/
35-
class IAlephTopology : public TraceAccessor
36+
class IAlephTopology
37+
: public TraceAccessor
3638
{
3739
public:
40+
3841
IAlephTopology(ITraceMng* tm,
3942
AlephKernel* kernel,
4043
Integer index,
@@ -57,10 +60,12 @@ class IAlephTopology : public TraceAccessor
5760
}
5861

5962
public:
63+
6064
virtual void backupAndInitialize() = 0;
6165
virtual void restore() = 0;
6266

6367
protected:
68+
6469
Integer m_index;
6570
AlephKernel* m_kernel;
6671
bool m_participating_in_solver;
@@ -69,9 +74,11 @@ class IAlephTopology : public TraceAccessor
6974
/******************************************************************************
7075
* IAlephVector
7176
*****************************************************************************/
72-
class IAlephVector : public TraceAccessor
77+
class IAlephVector
78+
: public TraceAccessor
7379
{
7480
public:
81+
7582
IAlephVector(ITraceMng* tm,
7683
AlephKernel* kernel,
7784
Integer index)
@@ -89,23 +96,27 @@ class IAlephVector : public TraceAccessor
8996
}
9097

9198
public:
99+
92100
virtual void AlephVectorCreate(void) = 0;
93-
virtual void AlephVectorSet(const double*, const int*, Integer) = 0;
101+
virtual void AlephVectorSet(const double*, const AlephInt*, Integer) = 0;
94102
virtual int AlephVectorAssemble(void) = 0;
95-
virtual void AlephVectorGet(double*, const int*, Integer) = 0;
103+
virtual void AlephVectorGet(double*, const AlephInt*, Integer) = 0;
96104
virtual void writeToFile(const String) = 0;
97105

98106
protected:
107+
99108
Integer m_index;
100109
AlephKernel* m_kernel;
101110
};
102111

103112
/******************************************************************************
104113
* IAlephMatrix
105114
*****************************************************************************/
106-
class IAlephMatrix : public TraceAccessor
115+
class IAlephMatrix
116+
: public TraceAccessor
107117
{
108118
public:
119+
109120
IAlephMatrix(ITraceMng* tm,
110121
AlephKernel* kernel,
111122
Integer index)
@@ -123,10 +134,11 @@ class IAlephMatrix : public TraceAccessor
123134
}
124135

125136
public:
137+
126138
virtual void AlephMatrixCreate(void) = 0;
127139
virtual void AlephMatrixSetFilled(bool) = 0;
128140
virtual int AlephMatrixAssemble(void) = 0;
129-
virtual void AlephMatrixFill(int, int*, int*, double*) = 0;
141+
virtual void AlephMatrixFill(int, AlephInt*, AlephInt*, double*) = 0;
130142
virtual int AlephMatrixSolve(AlephVector*,
131143
AlephVector*,
132144
AlephVector*,
@@ -136,14 +148,20 @@ class IAlephMatrix : public TraceAccessor
136148
virtual void writeToFile(const String) = 0;
137149

138150
protected:
151+
139152
Integer m_index;
140153
AlephKernel* m_kernel;
141154
};
142155

143-
class IAlephFactory : public TraceAccessor
156+
/*---------------------------------------------------------------------------*/
157+
/*---------------------------------------------------------------------------*/
158+
159+
class IAlephFactory
160+
: public TraceAccessor
144161
{
145162
public:
146-
IAlephFactory(ITraceMng* tm)
163+
164+
explicit IAlephFactory(ITraceMng* tm)
147165
: TraceAccessor(tm)
148166
{
149167
debug() << "\33[1;34m[IAlephFactory] NEW IAlephFactory"
@@ -170,6 +188,7 @@ class IAlephFactory : public TraceAccessor
170188
class IAlephFactoryImpl
171189
{
172190
public:
191+
173192
virtual ~IAlephFactoryImpl() {}
174193
virtual void initialize() = 0;
175194
virtual IAlephTopology* createTopology(ITraceMng*, AlephKernel*, Integer, Integer) = 0;
@@ -180,7 +199,7 @@ class IAlephFactoryImpl
180199
/*---------------------------------------------------------------------------*/
181200
/*---------------------------------------------------------------------------*/
182201

183-
ARCANE_END_NAMESPACE
202+
} // namespace Arcane
184203

185204
/*---------------------------------------------------------------------------*/
186205
/*---------------------------------------------------------------------------*/

arcane/src/arcane/aleph/AlephMatrix.cc

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 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-
/* AlephMatrix.cc (C) 2010 */
8+
/* AlephMatrix.cc (C) 2000-2024 */
99
/* */
1010
/*---------------------------------------------------------------------------*/
1111
/*---------------------------------------------------------------------------*/
12-
#include "AlephArcane.h"
12+
13+
#include "arcane/aleph/AlephArcane.h"
1314
#include "arcane/MeshVariableScalarRef.h"
1415

1516
/*---------------------------------------------------------------------------*/
1617
/*---------------------------------------------------------------------------*/
1718

18-
ARCANE_BEGIN_NAMESPACE
19+
namespace Arcane
20+
{
1921

2022
/*---------------------------------------------------------------------------*/
2123
/*---------------------------------------------------------------------------*/
@@ -124,10 +126,10 @@ void AlephMatrix::addValue(const VariableRef& rowVar, const Item& rowItm,
124126
const VariableRef& colVar, const Item& colItm,
125127
const Real val)
126128
{
127-
Integer row = m_kernel->indexing()->get(rowVar, rowItm);
128-
Integer col = m_kernel->indexing()->get(colVar, colItm);
129+
AlephInt row = m_kernel->indexing()->get(rowVar, rowItm);
130+
AlephInt col = m_kernel->indexing()->get(colVar, colItm);
129131
if (m_kernel->isInitialized()) {
130-
const Integer row_offset = m_kernel->topology()->part()[m_kernel->rank()];
132+
const AlephInt row_offset = m_kernel->topology()->part()[m_kernel->rank()];
131133
row += row_offset;
132134
col += row_offset;
133135
}
@@ -496,25 +498,25 @@ assemble_waitAndFill(void)
496498
m_implementation->AlephMatrixSetFilled(false); // Activation de la protection de remplissage
497499
debug() << "\33[1;32m[AlephMatrix::assemble_waitAndFill] " << m_index << " fill"
498500
<< "\33[0m";
499-
int* bfr_row_implem;
500-
int* bfr_col_implem;
501+
AlephInt* bfr_row_implem;
502+
AlephInt* bfr_col_implem;
501503
double* bfr_val_implem;
502504
for (int iCpu = 0; iCpu < m_kernel->size(); ++iCpu) {
503505
if (m_kernel->rank() != m_ranks[iCpu])
504506
continue;
505507
if (iCpu == m_kernel->rank()) {
506-
bfr_row_implem = reinterpret_cast<int*>(m_setValue_row.unguardedBasePointer());
507-
bfr_col_implem = reinterpret_cast<int*>(m_setValue_col.unguardedBasePointer());
508-
bfr_val_implem = reinterpret_cast<double*>(m_setValue_val.unguardedBasePointer());
508+
bfr_row_implem = m_setValue_row.data();
509+
bfr_col_implem = m_setValue_col.data();
510+
bfr_val_implem = m_setValue_val.data();
509511
m_implementation->AlephMatrixFill(m_setValue_val.size(),
510512
bfr_row_implem,
511513
bfr_col_implem,
512514
bfr_val_implem);
513515
}
514516
else {
515-
bfr_row_implem = reinterpret_cast<int*>(m_aleph_matrix_buffer_rows[iCpu].unguardedBasePointer());
516-
bfr_col_implem = reinterpret_cast<int*>(m_aleph_matrix_buffer_cols[iCpu].unguardedBasePointer());
517-
bfr_val_implem = reinterpret_cast<double*>(m_aleph_matrix_buffer_vals[iCpu].unguardedBasePointer());
517+
bfr_row_implem = m_aleph_matrix_buffer_rows[iCpu].data();
518+
bfr_col_implem = m_aleph_matrix_buffer_cols[iCpu].data();
519+
bfr_val_implem = m_aleph_matrix_buffer_vals[iCpu].data();
518520
m_implementation->AlephMatrixFill(m_aleph_matrix_buffer_vals[iCpu].size(),
519521
bfr_row_implem,
520522
bfr_col_implem,
@@ -719,7 +721,7 @@ writeToFile(const String file_name)
719721
/*---------------------------------------------------------------------------*/
720722
/*---------------------------------------------------------------------------*/
721723

722-
ARCANE_END_NAMESPACE
724+
} // namespace Arcane
723725

724726
/*---------------------------------------------------------------------------*/
725727
/*---------------------------------------------------------------------------*/

arcane/src/arcane/aleph/AlephMatrix.h

+10-9
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-2022 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-
/* AlephMatrix.h (C) 2000-2022 */
8+
/* AlephMatrix.h (C) 2000-2024 */
99
/* */
1010
/*---------------------------------------------------------------------------*/
1111
#ifndef ARCANE_ALEPH_MATRIX_H
@@ -23,8 +23,6 @@
2323
namespace Arcane
2424
{
2525

26-
class IAlephMatrix;
27-
2826
/*---------------------------------------------------------------------------*/
2927
/*---------------------------------------------------------------------------*/
3028
/*!
@@ -34,7 +32,8 @@ class ARCANE_ALEPH_EXPORT AlephMatrix
3432
: public TraceAccessor
3533
{
3634
public:
37-
AlephMatrix(AlephKernel*);
35+
36+
explicit AlephMatrix(AlephKernel*);
3837
~AlephMatrix();
3938

4039
public:
@@ -67,21 +66,23 @@ class ARCANE_ALEPH_EXPORT AlephMatrix
6766
void solveNow(AlephVector*, AlephVector*, AlephVector*, Integer&, Real*, AlephParams*);
6867

6968
private:
69+
7070
AlephKernel* m_kernel = nullptr;
7171
Integer m_index;
7272
ArrayView<Integer> m_ranks;
7373
bool m_participating_in_solver = false;
7474
IAlephMatrix* m_implementation = nullptr;
7575

7676
private:
77+
7778
// Matrice utilisée dans le cas où nous sommes le solveur
78-
MultiArray2<Int32> m_aleph_matrix_buffer_rows;
79-
MultiArray2<Int32> m_aleph_matrix_buffer_cols;
79+
MultiArray2<AlephInt> m_aleph_matrix_buffer_rows;
80+
MultiArray2<AlephInt> m_aleph_matrix_buffer_cols;
8081
MultiArray2<Real> m_aleph_matrix_buffer_vals;
8182
// Tableaux tampons des setValues
8283
Integer m_setValue_idx;
83-
UniqueArray<Int32> m_setValue_row;
84-
UniqueArray<Int32> m_setValue_col;
84+
UniqueArray<AlephInt> m_setValue_row;
85+
UniqueArray<AlephInt> m_setValue_col;
8586
UniqueArray<Real> m_setValue_val;
8687

8788
private: // Tableaux tampons des addValues

arcane/src/arcane/aleph/AlephOrdering.cc

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 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-
/* AlephOrdering.cc (C) 2012 */
8+
/* AlephOrdering.cc (C) 2000-2024 */
99
/* */
1010
/*---------------------------------------------------------------------------*/
1111
/*---------------------------------------------------------------------------*/
12-
#include "AlephArcane.h"
13-
#include "arcane/IMesh.h"
12+
13+
#include "arcane/aleph/AlephArcane.h"
14+
#include "arcane/core/IMesh.h"
1415

1516
/*---------------------------------------------------------------------------*/
1617
/*---------------------------------------------------------------------------*/
1718

18-
ARCANE_BEGIN_NAMESPACE
19+
namespace Arcane
20+
{
1921

2022
/*---------------------------------------------------------------------------*/
2123
/*---------------------------------------------------------------------------*/
@@ -289,15 +291,15 @@ initCellNodeOrder(void)
289291
m_swap.resize(m_swap_cell.size() + m_swap_node.size());
290292
Integer iCell = 0;
291293
for (Integer i = 0; i < m_kernel->size(); ++i) {
292-
Integer offset = m_kernel->topology()->gathered_nb_row(i);
294+
AlephInt offset = m_kernel->topology()->gathered_nb_row(i);
293295
for (Integer j = 0; j < gathered_nb_cells.at(i); ++j) {
294296
m_swap[offset + j] = m_swap_cell.at(iCell);
295297
iCell += 1;
296298
}
297299
}
298300
Integer iNode = 0;
299301
for (Integer i = 0; i < m_kernel->size(); ++i) {
300-
Integer offset = 0;
302+
AlephInt offset = 0;
301303
if (i > 0)
302304
offset = m_kernel->topology()->gathered_nb_row(i);
303305
offset += gathered_nb_cells.at(i);
@@ -365,7 +367,7 @@ initTwiceCellNodeOrder(void)
365367
/*---------------------------------------------------------------------------*/
366368
/*---------------------------------------------------------------------------*/
367369

368-
ARCANE_END_NAMESPACE
370+
} // namespace Arcane
369371

370372
/*---------------------------------------------------------------------------*/
371373
/*---------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)