Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
NumArray.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* NumArray.cc (C) 2000-2024 */
9/* */
10/* Tableaux multi-dimensionnel pour les types numériques sur accélérateur. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/NumArray.h"
15
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/MemoryView.h"
18#include "arcane/utils/MemoryUtils.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane::impl
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29MemoryAllocationOptions NumArrayBaseCommon::
30_getDefaultAllocator()
31{
32 return _getDefaultAllocator(eMemoryRessource::UnifiedMemory);
33}
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38MemoryAllocationOptions NumArrayBaseCommon::
39_getDefaultAllocator(eMemoryRessource r)
40{
41 return MemoryUtils::getAllocationOptions(r);
42}
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
47void NumArrayBaseCommon::
48_checkHost(eMemoryRessource r)
49{
51 return;
52 ARCANE_FATAL("Invalid access from '{0}' ressource memory to host memory", (int)r);
53}
54
55/*---------------------------------------------------------------------------*/
56/*---------------------------------------------------------------------------*/
57
58void NumArrayBaseCommon::
59_memoryAwareCopy(Span<const std::byte> from, eMemoryRessource from_mem,
60 Span<std::byte> to, eMemoryRessource to_mem, RunQueue* queue)
61{
62 MemoryUtils::copy(MutableMemoryView(to), to_mem, ConstMemoryView(from), from_mem, queue);
63}
64
65/*---------------------------------------------------------------------------*/
66/*---------------------------------------------------------------------------*/
67
68void NumArrayBaseCommon::
69_memoryAwareFill(Span<std::byte> to, Int64 nb_element, const void* fill_address,
70 Int32 datatype_size, SmallSpan<const Int32> indexes, RunQueue* queue)
71{
72 ConstMemoryView fill_value_view(makeConstMemoryView(fill_address, datatype_size, 1));
73 MutableMemoryView destination(makeMutableMemoryView(to.data(), datatype_size, nb_element));
74 destination.fillIndexes(fill_value_view, indexes, queue);
75}
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
79
80void NumArrayBaseCommon::
81_memoryAwareFill(Span<std::byte> to, Int64 nb_element, const void* fill_address,
82 Int32 datatype_size, RunQueue* queue)
83{
84 ConstMemoryView fill_value_view(makeConstMemoryView(fill_address, datatype_size, 1));
85 MutableMemoryView destination(makeMutableMemoryView(to.data(), datatype_size, nb_element));
86 destination.fill(fill_value_view, queue);
87}
88
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
92} // namespace Arcane::impl
93
94namespace Arcane
95{
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
99
100template class NumArray<Real, MDDim4>;
101template class NumArray<Real, MDDim3>;
102template class NumArray<Real, MDDim2>;
103template class NumArray<Real, MDDim1>;
104
105template class ArrayStridesBase<1>;
106template class ArrayStridesBase<2>;
107template class ArrayStridesBase<3>;
108template class ArrayStridesBase<4>;
109
110namespace impl
111{
112 template class NumArrayContainer<Real>;
113}
114
115/*---------------------------------------------------------------------------*/
116/*---------------------------------------------------------------------------*/
117
118} // End namespace Arcane
119
120/*---------------------------------------------------------------------------*/
121/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
eMemoryRessource
Liste des ressources mémoire disponibles.
@ Host
Alloue sur l'hôte.
@ UnifiedMemory
Alloue en utilisant la mémoire unifiée.