Arcane  v4.1.1.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
SpecificMemoryCopy.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* SpecificMemoryCopy.cc (C) 2000-2025 */
9/* */
10/* Classes pour gérer des fonctions spécialisées de copie mémoire. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/common/internal/SpecificMemoryCopyList.h"
15#include "arccore/common/internal/HostSpecificMemoryCopy.h"
16
17/*---------------------------------------------------------------------------*/
18/*---------------------------------------------------------------------------*/
19
20namespace Arcane::impl
21{
22
23ISpecificMemoryCopyList* GlobalMemoryCopyList::default_global_copy_list = nullptr;
24ISpecificMemoryCopyList* GlobalMemoryCopyList::accelerator_global_copy_list = nullptr;
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
30{
31 public:
32
33 using InterfaceType = ISpecificMemoryCopy;
34 template <typename DataType, typename Extent> using SpecificType = HostSpecificMemoryCopy<DataType, Extent>;
35 using RefType = SpecificMemoryCopyRef<HostIndexedCopyTraits>;
36};
37
38//! Copieur spécifique lorsqu'aucun runtime accélérateur n'est initialisé
40: public SpecificMemoryCopyList<impl::HostIndexedCopyTraits>
41{
42 public:
43
45 {
46 //! Ajoute des implémentations spécifiques pour les tailles courantes
47 addCopier<SpecificType<std::byte, ExtentValue<1>>>(); // 1
48 addCopier<SpecificType<Int16, ExtentValue<1>>>(); // 2
49 addCopier<SpecificType<std::byte, ExtentValue<3>>>(); // 3
50 addCopier<SpecificType<Int32, ExtentValue<1>>>(); // 4
51 addCopier<SpecificType<std::byte, ExtentValue<5>>>(); // 5
52 addCopier<SpecificType<Int16, ExtentValue<3>>>(); // 6
53 addCopier<SpecificType<std::byte, ExtentValue<7>>>(); // 7
54 addCopier<SpecificType<Int64, ExtentValue<1>>>(); // 8
55 addCopier<SpecificType<std::byte, ExtentValue<9>>>(); // 9
56 addCopier<SpecificType<Int16, ExtentValue<5>>>(); // 10
57 addCopier<SpecificType<Int32, ExtentValue<3>>>(); // 12
58
59 addCopier<SpecificType<Int64, ExtentValue<2>>>(); // 16
60 addCopier<SpecificType<Int64, ExtentValue<3>>>(); // 24
61 addCopier<SpecificType<Int64, ExtentValue<4>>>(); // 32
62 addCopier<SpecificType<Int64, ExtentValue<5>>>(); // 40
63 addCopier<SpecificType<Int64, ExtentValue<6>>>(); // 48
64 addCopier<SpecificType<Int64, ExtentValue<7>>>(); // 56
65 addCopier<SpecificType<Int64, ExtentValue<8>>>(); // 64
66 addCopier<SpecificType<Int64, ExtentValue<9>>>(); // 72
67 }
68};
69
70namespace
71{
72 // Copieur spécifique lorsqu'aucun runtime accélérateur n'est initialisé
73 HostSpecificMemoryCopyList global_host_copy_list;
74} // namespace
75
76/*---------------------------------------------------------------------------*/
77/*---------------------------------------------------------------------------*/
78
79void GlobalMemoryCopyList::
80setAcceleratorInstance(ISpecificMemoryCopyList* ptr)
81{
82 if (!default_global_copy_list) {
83 default_global_copy_list = ptr;
84 }
85 accelerator_global_copy_list = ptr;
86}
87
88/*---------------------------------------------------------------------------*/
89/*---------------------------------------------------------------------------*/
90
91ISpecificMemoryCopyList* GlobalMemoryCopyList::
92getDefault(const RunQueue* queue)
93{
94 if (queue && !default_global_copy_list)
95 ARCCORE_FATAL("No instance of copier is available for RunQueue");
96 if (default_global_copy_list && queue)
97 return default_global_copy_list;
98 return &global_host_copy_list;
99}
100
101/*---------------------------------------------------------------------------*/
102/*---------------------------------------------------------------------------*/
103
104} // namespace Arcane::impl
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/