Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more explicit name for some NumArray methods #1809

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ _executeTest3()
CellGroup own_cells = allCells().own();
Int32 max_local_id = own_cells.itemFamily()->maxLocalId();
NumArray<Int32, MDDim1> checked_local_ids(max_local_id);
checked_local_ids.fill(-1, &queue);
checked_local_ids.fill(-1, queue);
{
// Remplit out_checked_local_ids avec le i-ème localId() du groupe.
auto out_checked_local_ids = ax::viewOut(command, checked_local_ids);
Expand Down
8 changes: 4 additions & 4 deletions arcane/src/arcane/tests/accelerator/MemoryCopyUnitTest.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* MemoryCopyUnitTest.cc (C) 2000-2023 */
/* MemoryCopyUnitTest.cc (C) 2000-2024 */
/* */
/* Service de test des noyaux de recopie mémoire. */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -351,7 +351,7 @@ _executeFill(eMemoryRessource mem_kind, bool use_queue, bool use_index)
info() << "Execute Fill memory_ressource=" << mem_kind
<< " use_queue=" << use_queue << " use_index=" << use_index;

auto queue = makeQueue(m_runner);
RunQueue queue = makeQueue(m_runner);
RunQueue* queue_ptr = &queue;
if (!use_queue)
queue_ptr = nullptr;
Expand Down Expand Up @@ -409,7 +409,7 @@ _executeFill(eMemoryRessource mem_kind, bool use_queue, bool use_index)
if (use_index) {
NumArray<Int16, MDDim1> filter(eMemoryRessource::Host);
filter.resize(n1);
filter.fill(0);
filter.fillHost(0);
for (Int32 i = 0; i < nb_index; ++i)
filter[indexes[i]] = 1;

Expand Down
20 changes: 10 additions & 10 deletions arcane/src/arcane/tests/accelerator/NumArrayUnitTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
// Tableaux 2D
{
NumArray<double, MDDim2> t1(mem_kind);
t1.resize(n1, n2);
t1.resizeDestructive(n1, n2);
_doRank2(queue, t1, expected_sum2);
}
{
Expand All @@ -410,12 +410,12 @@
// Tableaux 3D
{
NumArray<double, MDDim3, LeftLayout> t1(mem_kind);
t1.resize(n1, n2, n3);
t1.resizeDestructive(n1, n2, n3);
_doRank3(queue, t1, expected_sum3);
}
{
NumArray<double, MDDim3, RightLayout> t1(mem_kind);
t1.resize(n1, n2, n3);
t1.resizeDestructive(n1, n2, n3);
_doRank3(queue, t1, expected_sum3);
}
{
Expand Down Expand Up @@ -638,7 +638,7 @@
out_t1[i] = _getValue(i);
};
NumArray<double, MDDim1> host_t1(eMemoryRessource::Host);
host_t1.copy(_toMDSpan(t1), &queue);
host_t1.copy(_toMDSpan(t1), queue);
double s1 = _doSum(host_t1, { n1 }, &queue);
info() << "SUM1 = " << s1;
vc.areEqual(s1, expected_sum1, "SUM1");
Expand All @@ -657,7 +657,7 @@
};

NumArray<double, MDDim1> host_t2(eMemoryRessource::Host);
host_t2.copy(_toMDSpan(t2), &queue);
host_t2.copy(_toMDSpan(t2), queue);
double s2 = _doSum(host_t2, { n1 }, &queue);
info() << "SUM1_2 = " << s2;
vc.areEqual(s2, expected_sum1, "SUM1_2");
Expand Down Expand Up @@ -784,15 +784,15 @@
// Redimensionne t2 avec 6x5 valeurs
t2.resize(6);
// Redimensionne t3 avec 2x7x4 valeurs
t3.resize(2, 4);
t3.resizeDestructive(2, 4);

Check warning on line 787 in arcane/src/arcane/tests/accelerator/NumArrayUnitTest.cc

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/tests/accelerator/NumArrayUnitTest.cc#L787

Added line #L787 was not covered by tests
// Redimensionne a1 avec 12 valeurs
a1.resize(12);
a1.resizeDestructive(12);

Check warning on line 789 in arcane/src/arcane/tests/accelerator/NumArrayUnitTest.cc

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/tests/accelerator/NumArrayUnitTest.cc#L789

Added line #L789 was not covered by tests
// Redimensionne a2 avec 3x4 valeurs
a2.resize(3, 4);
a2.resizeDestructive(3, 4);

Check warning on line 791 in arcane/src/arcane/tests/accelerator/NumArrayUnitTest.cc

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/tests/accelerator/NumArrayUnitTest.cc#L791

Added line #L791 was not covered by tests
// Redimensionne a3 avec 2x7x6 valeurs
a3.resize(2, 7, 6);
a3.resizeDestructive(2, 7, 6);

Check warning on line 793 in arcane/src/arcane/tests/accelerator/NumArrayUnitTest.cc

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/tests/accelerator/NumArrayUnitTest.cc#L793

Added line #L793 was not covered by tests
// Redimensionne a1 avec 2x9x4x6 valeurs
a4.resize(2, 9, 4, 6);
a4.resizeDestructive(2, 9, 4, 6);

Check warning on line 795 in arcane/src/arcane/tests/accelerator/NumArrayUnitTest.cc

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/tests/accelerator/NumArrayUnitTest.cc#L795

Added line #L795 was not covered by tests
//![SampleNumArrayResize]

//![SampleNumArrayDeclarationsMemory]
Expand Down
135 changes: 118 additions & 17 deletions arcane/src/arcane/utils/NumArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,33 +285,73 @@

public:

//! Modifie la taille du tableau en gardant pas les valeurs actuelles
void resize(Int32 dim1_size) requires(Extents::nb_dynamic == 1)

Check warning on line 289 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L289

Added line #L289 was not covered by tests
{
m_span.m_extents = DynamicDimsType(dim1_size);
_resize();

Check warning on line 292 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L291-L292

Added lines #L291 - L292 were not covered by tests
}

// TODO: Rendre obsolète (juin 2025)
//! Modifie la taille du tableau en ne gardant pas les valeurs actuelles
void resize(Int32 dim1_size, Int32 dim2_size, Int32 dim3_size, Int32 dim4_size) requires(Extents::nb_dynamic == 4)

Check warning on line 297 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L297

Added line #L297 was not covered by tests
{
this->resizeDestructive(DynamicDimsType(dim1_size, dim2_size, dim3_size, dim4_size));

Check warning on line 299 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L299

Added line #L299 was not covered by tests
}

// TODO: Rendre obsolète (juin 2025)
//! Modifie la taille du tableau en ne gardant pas les valeurs actuelles
void resize(Int32 dim1_size, Int32 dim2_size, Int32 dim3_size) requires(Extents::nb_dynamic == 3)

Check warning on line 304 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L304

Added line #L304 was not covered by tests
{
this->resizeDestructive(DynamicDimsType(dim1_size, dim2_size, dim3_size));

Check warning on line 306 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L306

Added line #L306 was not covered by tests
}

// TODO: Rendre obsolète (juin 2025)
//! Modifie la taille du tableau en ne gardant pas les valeurs actuelles
void resize(Int32 dim1_size, Int32 dim2_size) requires(Extents::nb_dynamic == 2)

Check warning on line 311 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L311

Added line #L311 was not covered by tests
{
this->resizeDestructive(DynamicDimsType(dim1_size, dim2_size));

Check warning on line 313 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L313

Added line #L313 was not covered by tests
}

/*!
* \brief Modifie la taille du tableau.
* \warning Les valeurs actuelles ne sont pas conservées lors de cette opération
* et les nouvelles valeurs ne sont pas initialisées.
*/
//@{
void resize(Int32 dim1_size, Int32 dim2_size, Int32 dim3_size, Int32 dim4_size) requires(Extents::nb_dynamic == 4)
//! Modifie la taille du tableau en ne gardant pas les valeurs actuelles
void resizeDestructive(Int32 dim1_size, Int32 dim2_size, Int32 dim3_size, Int32 dim4_size) requires(Extents::nb_dynamic == 4)

Check warning on line 323 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L323

Added line #L323 was not covered by tests
{
this->resize(DynamicDimsType(dim1_size, dim2_size, dim3_size, dim4_size));
this->resizeDestructive(DynamicDimsType(dim1_size, dim2_size, dim3_size, dim4_size));

Check warning on line 325 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L325

Added line #L325 was not covered by tests
}

void resize(Int32 dim1_size, Int32 dim2_size, Int32 dim3_size) requires(Extents::nb_dynamic == 3)
//! Modifie la taille du tableau en ne gardant pas les valeurs actuelles
void resizeDestructive(Int32 dim1_size, Int32 dim2_size, Int32 dim3_size) requires(Extents::nb_dynamic == 3)

Check warning on line 329 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L329

Added line #L329 was not covered by tests
{
this->resize(DynamicDimsType(dim1_size, dim2_size, dim3_size));
this->resizeDestructive(DynamicDimsType(dim1_size, dim2_size, dim3_size));

Check warning on line 331 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L331

Added line #L331 was not covered by tests
}

void resize(Int32 dim1_size, Int32 dim2_size) requires(Extents::nb_dynamic == 2)
//! Modifie la taille du tableau en ne gardant pas les valeurs actuelles
void resizeDestructive(Int32 dim1_size, Int32 dim2_size) requires(Extents::nb_dynamic == 2)

Check warning on line 335 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L335

Added line #L335 was not covered by tests
{
this->resize(DynamicDimsType(dim1_size, dim2_size));
this->resizeDestructive(DynamicDimsType(dim1_size, dim2_size));

Check warning on line 337 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L337

Added line #L337 was not covered by tests
}

void resize(Int32 dim1_size) requires(Extents::nb_dynamic == 1)
//! Modifie la taille du tableau en ne gardant pas les valeurs actuelles
void resizeDestructive(Int32 dim1_size) requires(Extents::nb_dynamic == 1)

Check warning on line 341 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L341

Added line #L341 was not covered by tests
{
this->resize(DynamicDimsType(dim1_size));
this->resizeDestructive(DynamicDimsType(dim1_size));

Check warning on line 343 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L343

Added line #L343 was not covered by tests
}

// TODO: Rendre obsolète (juin 2025)
//! Modifie la taille du tableau en ne gardant pas les valeurs actuelles
void resize(const DynamicDimsType& dims)
{
resizeDestructive(dims);

Check warning on line 350 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L350

Added line #L350 was not covered by tests
}

//! Modifie la taille du tableau en ne gardant pas les valeurs actuelles
void resizeDestructive(const DynamicDimsType& dims)
{
m_span.m_extents = dims;
_resize();
Expand All @@ -328,29 +368,64 @@
*/
void fill(const DataType& v)
{
_checkHost(memoryRessource());
m_data.fill(v);
fillHost(v);

Check warning on line 371 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L371

Added line #L371 was not covered by tests
}

/*!
* \brief Remplit via la file \a queue, les valeurs du tableau d'indices
* données par \a indexes par la valeur \a v .
*
* La mémoire associée à l'instance doit être accessible depuis la file \a queue.
* \a queue peut être nulle, auquel cas le remplissage se fait sur l'hôte.
*/
void fill(const DataType& v, SmallSpan<const Int32> indexes, const RunQueue* queue)
{
m_data.fill(v, indexes, queue);
}

/*!
* \brief Remplit les éléments de l'instance la valeur \a v.
* \brief Remplit via la file \a queue, les valeurs du tableau d'indices
* données par \a indexes par la valeur \a v .
*
* La mémoire associée à l'instance doit être accessible depuis la file \a queue.
*/
void fill(const DataType& v, SmallSpan<const Int32> indexes, const RunQueue& queue)

Check warning on line 392 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L392

Added line #L392 was not covered by tests
{
m_data.fill(v, indexes, &queue);

Check warning on line 394 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L394

Added line #L394 was not covered by tests
}

/*!
* \brief Remplit les éléments de l'instance la valeur \a v en utilisant la file \a queue.
*
* \a queue peut être nulle, auquel cas le remplissage se fait sur l'hôte.
*/
void fill(const DataType& v, const RunQueue* queue)
{
m_data.fill(v, queue);
}

/*!
* \brief Remplit les éléments de l'instance la valeur \a v en utilisant la file \a queue.
*
* \a queue peut être nulle, auquel cas le remplissage se fait sur l'hôte.
*/
void fill(const DataType& v, const RunQueue& queue)

Check warning on line 412 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L412

Added line #L412 was not covered by tests
{
m_data.fill(v, &queue);

Check warning on line 414 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L414

Added line #L414 was not covered by tests
}

/*!
* \brief Remplit les valeurs du tableau par \a v.
*
* L'opération se fait sur l'hôte donc la mémoire associée
* à l'instance doit être accessible sur l'hôte.
*/
void fillHost(const DataType& v)
{
_checkHost(memoryRessource());
m_data.fill(v);
}

public:

/*!
Expand All @@ -370,29 +445,55 @@
void copy(const ThatClass& rhs) { copy(rhs, nullptr); }

/*!
* \brief Copie dans l'instance les valeurs de \a rhs via la file \a queue
* \brief Copie dans l'instance les valeurs de \a rhs via la file \a queue.
*
* Cette opération est valide quelle que soit la mêmoire associée
* associée à l'instance.
* \a queue peut être nul. Si la file est asynchrone, il faudra la
* synchroniser avant de pouvoir utiliser l'instance.
*/
void copy(ConstMDSpanType rhs, RunQueue* queue)
void copy(ConstMDSpanType rhs, const RunQueue* queue)

Check warning on line 455 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L455

Added line #L455 was not covered by tests
{
_resizeAndCopy(rhs, eMemoryRessource::Unknown, queue);
}

/*!
* \brief Copie dans l'instance les valeurs de \a rhs via la file \a queue
* \brief Copie dans l'instance les valeurs de \a rhs via la file \a queue.
*
* Cette opération est valide quelle que soit la mêmoire associée
* associée à l'instance.
* \a queue peut être nulle, auquel cas la copie se fait sur l'hôte.
* Si la file est asynchrone, il faudra la synchroniser avant de pouvoir utiliser l'instance.
*/
void copy(ConstMDSpanType rhs, const RunQueue& queue)

Check warning on line 468 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L468

Added line #L468 was not covered by tests
{
_resizeAndCopy(rhs, eMemoryRessource::Unknown, &queue);

Check warning on line 470 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L470

Added line #L470 was not covered by tests
}

/*!
* \brief Copie dans l'instance les valeurs de \a rhs via la file \a queue.
*
* Cette opération est valide quelle que soit la mêmoire associée
* associée à l'instance.
* \a queue peut être nulle, auquel cas la copie se fait sur l'hôte.
* Si la file est asynchrone, il faudra la synchroniser avant de pouvoir utiliser l'instance.
*/
void copy(const ThatClass& rhs, const RunQueue* queue)
{
_resizeAndCopy(rhs.constMDSpan(), rhs.memoryRessource(), queue);
}

/*!
* \brief Copie dans l'instance les valeurs de \a rhs via la file \a queue.
*
* Cette opération est valide quelle que soit la mêmoire associée
* associée à l'instance.
* \a queue peut être nul. Si la file est asynchrone, il faudra la
* synchroniser avant de pouvoir utiliser l'instance.
*/
void copy(const ThatClass& rhs, RunQueue* queue)
void copy(const ThatClass& rhs, const RunQueue& queue)

Check warning on line 494 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L494

Added line #L494 was not covered by tests
{
_resizeAndCopy(rhs.constMDSpan(), rhs.memoryRessource(), queue);
_resizeAndCopy(rhs.constMDSpan(), rhs.memoryRessource(), &queue);

Check warning on line 496 in arcane/src/arcane/utils/NumArray.h

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/utils/NumArray.h#L496

Added line #L496 was not covered by tests
}

public:
Expand Down Expand Up @@ -550,7 +651,7 @@
m_span.m_ptr = m_data.to1DSpan().data();
}

void _resizeAndCopy(ConstMDSpanType rhs, eMemoryRessource input_ressource, RunQueue* queue)
void _resizeAndCopy(ConstMDSpanType rhs, eMemoryRessource input_ressource, const RunQueue* queue)
{
this->resize(rhs.extents().dynamicExtents());
m_data.copyOnly(rhs.to1DSpan(), input_ressource, queue);
Expand Down
Loading