Arcane  v4.1.1.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ArcaneGlobal.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/* ArcaneGlobal.cc (C) 2000-2025 */
9/* */
10/* Déclarations générales de Arcane. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/IndexOutOfRangeException.h"
15#include "arcane/utils/ArithmeticException.h"
16#include "arcane/utils/ArgumentException.h"
17#include "arcane/utils/TraceInfo.h"
18#include "arcane/utils/FatalErrorException.h"
19#include "arcane/utils/BadAlignmentException.h"
20#include "arcane/utils/NotImplementedException.h"
21#include "arcane/utils/ArraySimdPadder.h"
22
23#include "arcane/utils/Iostream.h"
24#include "arcane/utils/IMemoryInfo.h"
25
26// Ces includes ne sont pas utilisés par ce fichier
27// mais il faut au moins les lire une fois sous Windows
28// pour que les symboles externes soient créés
29#include "arcane/utils/IFunctor.h"
30#include "arcane/utils/IFunctorWithAddress.h"
31#include "arcane/utils/IRangeFunctor.h"
32#include "arcane/utils/SpinLock.h"
33#include "arcane/utils/IDynamicLibraryLoader.h"
34#include "arcane/utils/IPerformanceCounterService.h"
35#include "arcane/utils/IProfilingService.h"
36#include "arcane/utils/DataTypeContainer.h"
37#include "arcane/utils/ITraceMngPolicy.h"
38#include "arcane/utils/IThreadImplementationService.h"
39#include "arcane/utils/IMessagePassingProfilingService.h"
40#include "arcane/utils/ISymbolizerService.h"
41#include "arcane/utils/IDataCompressor.h"
42
43/*---------------------------------------------------------------------------*/
44/*---------------------------------------------------------------------------*/
58/*---------------------------------------------------------------------------*/
59/*---------------------------------------------------------------------------*/
60
61namespace Arcane
62{
63
64/*---------------------------------------------------------------------------*/
65/*---------------------------------------------------------------------------*/
66
67extern "C++" ARCANE_UTILS_EXPORT void
68arcaneRangeError(Int32 i,Int32 max_size)
69{
70 arcaneDebugPause("arcaneRangeError");
71 throw IndexOutOfRangeException(A_FUNCINFO,String(),i,0,max_size);
72}
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77extern "C++" ARCANE_UTILS_EXPORT void
78arcaneRangeError(Int64 i,Int64 max_size)
79{
80 arcaneDebugPause("arcaneRangeError");
81 throw IndexOutOfRangeException(A_FUNCINFO,String(),i,0,max_size);
82}
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
86
87extern "C++" ARCANE_UTILS_EXPORT void
88_internalArcaneMathError(long double value,const char* funcname)
89{
90 cerr << "** FATAL: Argument error for a mathematical operation:\n";
91 cerr << "** FATAL: Argument: " << value << '\n';
92 if (funcname)
93 cerr << "** FATAL: Operation: " << funcname << '\n';
94 arcaneDebugPause("arcaneMathError");
95 throw ArithmeticException(A_FUNCINFO);
96}
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
100
101extern "C++" ARCANE_UTILS_EXPORT void
102_internalArcaneMathError(long double value1,long double value2,const char* funcname)
103{
104 cerr << "** FATAL: Argument error for a mathematical operation:\n";
105 cerr << "** FATAL: Argument1: " << value1 << '\n';
106 cerr << "** FATAL: Argument2: " << value2 << '\n';
107 if (funcname)
108 cerr << "** FATAL: Operation: " << funcname << '\n';
109 arcaneDebugPause("arcaneMathError");
110 throw ArithmeticException(A_FUNCINFO);
111}
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116extern "C++" ARCANE_UTILS_EXPORT void
117arcaneNotYetImplemented(const char* file,const char* func,
118 unsigned long line,const char* text)
119{
120 cerr << file << ':' << func << ':' << line << '\n';
121 cerr << "sorry, functionality not yet implemented";
122 if (text)
123 cerr << ": " << text;
124 cerr << '\n';
125}
126
127/*---------------------------------------------------------------------------*/
128/*---------------------------------------------------------------------------*/
129
130extern "C++" ARCANE_UTILS_EXPORT void
132{
133 cerr << "** FATAL: null pointer.\n";
134 cerr << "** FATAL: Trying to dereference a null pointer.\n";
135 arcaneDebugPause("arcaneNullPointerPtr");
136 throw FatalErrorException(A_FUNCINFO,"null pointer");
137}
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141
142extern "C++" ARCANE_UTILS_EXPORT void
143arcaneThrowNullPointerError(const char* ptr_name,const char* text)
144{
145 throw FatalErrorException(A_FUNCINFO,text ? text : ptr_name);
146}
147
148/*---------------------------------------------------------------------------*/
149/*---------------------------------------------------------------------------*/
150
151extern "C++" ARCANE_UTILS_EXPORT Integer
152arcaneCheckArraySize(unsigned long long size)
153{
154 ARCANE_THROW_IF((size>=ARCANE_INTEGER_MAX),ArgumentException,"value '{0}' too big for Array size",size);
155 return static_cast<Integer>(size);
156}
157
158extern "C++" ARCANE_UTILS_EXPORT Integer
159arcaneCheckArraySize(long long size)
160{
161 ARCANE_THROW_IF( (size>=ARCANE_INTEGER_MAX),ArgumentException,"value '{0}' too big for Array size",size);
162 ARCANE_THROW_IF((size<0),ArgumentException,"invalid negative value '{0}' for Array size",size);
163 return static_cast<Integer>(size);
164}
165
166extern "C++" ARCANE_UTILS_EXPORT Integer
167arcaneCheckArraySize(unsigned long size)
168{
169 ARCANE_THROW_IF((size>=ARCANE_INTEGER_MAX),ArgumentException,"value '{0}' too big for Array size",size);
170 return static_cast<Integer>(size);
171}
172
173extern "C++" ARCANE_UTILS_EXPORT Integer
175{
176 ARCANE_THROW_IF((size>=ARCANE_INTEGER_MAX),ArgumentException,"value '{0}' too big for Array size",size);
177 ARCANE_THROW_IF((size<0),ArgumentException,"invalid negative value '{0}' for Array size",size);
178 return static_cast<Integer>(size);
179}
180
181extern "C++" ARCANE_UTILS_EXPORT Integer
182arcaneCheckArraySize(unsigned int size)
183{
184 ARCANE_THROW_IF((size>=ARCANE_INTEGER_MAX),ArgumentException,"value '{0}' too big for Array size",size);
185 return static_cast<Integer>(size);
186}
187
188extern "C++" ARCANE_UTILS_EXPORT Integer
190{
191 ARCANE_THROW_IF((size>=ARCANE_INTEGER_MAX),ArgumentException,"value '{0}' too big for Array size",size);
192 ARCANE_THROW_IF((size<0),ArgumentException,"invalid negative value '{0}' for Array size",size);
193 return static_cast<Integer>(size);
194}
195
196/*---------------------------------------------------------------------------*/
197/*---------------------------------------------------------------------------*/
198
199extern "C++" ARCANE_UTILS_EXPORT void
200arcaneCheckAlignment(const void* ptr,Integer alignment)
201{
202 if (alignment<=0)
203 return;
204 Int64 iptr = (intptr_t)ptr;
205 Int64 modulo = iptr % alignment;
206 if (modulo!=0)
207 throw BadAlignmentException(A_FUNCINFO,ptr,alignment);
208}
209
210/*---------------------------------------------------------------------------*/
211/*---------------------------------------------------------------------------*/
212
213extern "C++" ARCANE_UTILS_EXPORT Integer
218
219/*---------------------------------------------------------------------------*/
220/*---------------------------------------------------------------------------*/
221
231
237
243
249
255
261
267
273
279
285
291
292/*---------------------------------------------------------------------------*/
293/*---------------------------------------------------------------------------*/
294
295}
296
297/*---------------------------------------------------------------------------*/
298/*---------------------------------------------------------------------------*/
#define ARCANE_THROW_IF(const, exception_class,...)
Macro pour envoyer une exception avec formattage si cond est vrai.
Exception lorsqu'un argument est invalide.
Exception lorsqu'une erreur arithmétique survient.
__host__ static __device__ SizeType getSizeWithPadding(SizeType size)
Calcule la taille nécessaire pour être un multiple de SIMD_PADDING_SIZE.
Exception lorsqu'une adresse n'est pas correctement alignée.
Exception lorsqu'une erreur fatale est survenue.
Exception lorsqu'une valeur n'est pas dans un intervalle donné.
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Integer arcaneCheckArraySize(unsigned long long size)
Vérifie que size peut être converti dans un 'Integer' pour servir de taille à un tableau....
std::int64_t Int64
Type entier signé sur 64 bits.
void arcaneNullPointerError()
Signalue l'utilisation d'un pointeur nul.
Int32 Integer
Type représentant un entier.
void arcaneNotYetImplemented(const char *file, const char *func, unsigned long line, const char *text)
Signale une fonction non implémentée.
Integer arcaneSizeWithPadding(Integer size)
Retourne la taille avec padding pour une taille size.
void arcaneDebugPause(const char *msg)
Passe en mode pause ou lance une erreur fatale.
Definition Misc.cc:137
void arcaneCheckAlignment(const void *ptr, Integer alignment)
Vérifie que ptr est aligné sur alignment octets. Si ce n'est pas le cas, Sinon, lance une exception d...
std::int32_t Int32
Type entier signé sur 32 bits.
void arcaneThrowNullPointerError(const char *ptr_name, const char *text)
Signalee l'utilisation d'un pointeur nul en envoyant une exception.