Arcane  v4.1.2.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/IPerformanceCounterService.h"
34#include "arcane/utils/IProfilingService.h"
35#include "arcane/utils/DataTypeContainer.h"
36#include "arcane/utils/ITraceMngPolicy.h"
37#include "arcane/utils/IThreadImplementationService.h"
38#include "arcane/utils/IMessagePassingProfilingService.h"
39#include "arcane/utils/ISymbolizerService.h"
40#include "arcane/utils/IDataCompressor.h"
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
57/*---------------------------------------------------------------------------*/
58/*---------------------------------------------------------------------------*/
59
60namespace Arcane
61{
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66extern "C++" ARCANE_UTILS_EXPORT void
67arcaneRangeError(Int32 i,Int32 max_size)
68{
69 arcaneDebugPause("arcaneRangeError");
70 throw IndexOutOfRangeException(A_FUNCINFO,String(),i,0,max_size);
71}
72
73/*---------------------------------------------------------------------------*/
74/*---------------------------------------------------------------------------*/
75
76extern "C++" ARCANE_UTILS_EXPORT void
77arcaneRangeError(Int64 i,Int64 max_size)
78{
79 arcaneDebugPause("arcaneRangeError");
80 throw IndexOutOfRangeException(A_FUNCINFO,String(),i,0,max_size);
81}
82
83/*---------------------------------------------------------------------------*/
84/*---------------------------------------------------------------------------*/
85
86extern "C++" ARCANE_UTILS_EXPORT void
87_internalArcaneMathError(long double value,const char* funcname)
88{
89 cerr << "** FATAL: Argument error for a mathematical operation:\n";
90 cerr << "** FATAL: Argument: " << value << '\n';
91 if (funcname)
92 cerr << "** FATAL: Operation: " << funcname << '\n';
93 arcaneDebugPause("arcaneMathError");
94 throw ArithmeticException(A_FUNCINFO);
95}
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
99
100extern "C++" ARCANE_UTILS_EXPORT void
101_internalArcaneMathError(long double value1,long double value2,const char* funcname)
102{
103 cerr << "** FATAL: Argument error for a mathematical operation:\n";
104 cerr << "** FATAL: Argument1: " << value1 << '\n';
105 cerr << "** FATAL: Argument2: " << value2 << '\n';
106 if (funcname)
107 cerr << "** FATAL: Operation: " << funcname << '\n';
108 arcaneDebugPause("arcaneMathError");
109 throw ArithmeticException(A_FUNCINFO);
110}
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114
115extern "C++" ARCANE_UTILS_EXPORT void
116arcaneNotYetImplemented(const char* file,const char* func,
117 unsigned long line,const char* text)
118{
119 cerr << file << ':' << func << ':' << line << '\n';
120 cerr << "sorry, functionality not yet implemented";
121 if (text)
122 cerr << ": " << text;
123 cerr << '\n';
124}
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
129extern "C++" ARCANE_UTILS_EXPORT void
131{
132 cerr << "** FATAL: null pointer.\n";
133 cerr << "** FATAL: Trying to dereference a null pointer.\n";
134 arcaneDebugPause("arcaneNullPointerPtr");
135 throw FatalErrorException(A_FUNCINFO,"null pointer");
136}
137
138/*---------------------------------------------------------------------------*/
139/*---------------------------------------------------------------------------*/
140
141extern "C++" ARCANE_UTILS_EXPORT void
142arcaneThrowNullPointerError(const char* ptr_name,const char* text)
143{
144 throw FatalErrorException(A_FUNCINFO,text ? text : ptr_name);
145}
146
147/*---------------------------------------------------------------------------*/
148/*---------------------------------------------------------------------------*/
149
150extern "C++" ARCANE_UTILS_EXPORT Integer
151arcaneCheckArraySize(unsigned long long size)
152{
153 ARCANE_THROW_IF((size>=ARCANE_INTEGER_MAX),ArgumentException,"value '{0}' too big for Array size",size);
154 return static_cast<Integer>(size);
155}
156
157extern "C++" ARCANE_UTILS_EXPORT Integer
158arcaneCheckArraySize(long long size)
159{
160 ARCANE_THROW_IF( (size>=ARCANE_INTEGER_MAX),ArgumentException,"value '{0}' too big for Array size",size);
161 ARCANE_THROW_IF((size<0),ArgumentException,"invalid negative value '{0}' for Array size",size);
162 return static_cast<Integer>(size);
163}
164
165extern "C++" ARCANE_UTILS_EXPORT Integer
166arcaneCheckArraySize(unsigned long size)
167{
168 ARCANE_THROW_IF((size>=ARCANE_INTEGER_MAX),ArgumentException,"value '{0}' too big for Array size",size);
169 return static_cast<Integer>(size);
170}
171
172extern "C++" ARCANE_UTILS_EXPORT Integer
174{
175 ARCANE_THROW_IF((size>=ARCANE_INTEGER_MAX),ArgumentException,"value '{0}' too big for Array size",size);
176 ARCANE_THROW_IF((size<0),ArgumentException,"invalid negative value '{0}' for Array size",size);
177 return static_cast<Integer>(size);
178}
179
180extern "C++" ARCANE_UTILS_EXPORT Integer
181arcaneCheckArraySize(unsigned int size)
182{
183 ARCANE_THROW_IF((size>=ARCANE_INTEGER_MAX),ArgumentException,"value '{0}' too big for Array size",size);
184 return static_cast<Integer>(size);
185}
186
187extern "C++" ARCANE_UTILS_EXPORT Integer
189{
190 ARCANE_THROW_IF((size>=ARCANE_INTEGER_MAX),ArgumentException,"value '{0}' too big for Array size",size);
191 ARCANE_THROW_IF((size<0),ArgumentException,"invalid negative value '{0}' for Array size",size);
192 return static_cast<Integer>(size);
193}
194
195/*---------------------------------------------------------------------------*/
196/*---------------------------------------------------------------------------*/
197
198extern "C++" ARCANE_UTILS_EXPORT void
199arcaneCheckAlignment(const void* ptr,Integer alignment)
200{
201 if (alignment<=0)
202 return;
203 Int64 iptr = (intptr_t)ptr;
204 Int64 modulo = iptr % alignment;
205 if (modulo!=0)
206 throw BadAlignmentException(A_FUNCINFO,ptr,alignment);
207}
208
209/*---------------------------------------------------------------------------*/
210/*---------------------------------------------------------------------------*/
211
212extern "C++" ARCANE_UTILS_EXPORT Integer
217
218/*---------------------------------------------------------------------------*/
219/*---------------------------------------------------------------------------*/
220
230
236
242
248
254
260
266
272
278
284
290
291/*---------------------------------------------------------------------------*/
292/*---------------------------------------------------------------------------*/
293
294}
295
296/*---------------------------------------------------------------------------*/
297/*---------------------------------------------------------------------------*/
#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:127
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.