Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ArcaneGlobal.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* General declarations for 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// These includes are not used by this file
27// but they must at least be read once under Windows
28// for external symbols to be created
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/*---------------------------------------------------------------------------*/
44
45/*!
46 * \file utils/ArcaneGlobal.h
47 *
48 * \brief Arcane configuration file.
49 */
50/*!
51 * \namespace Arcane
52 *
53 * \brief Arcane namespace.
54 *
55 * All classes and types used in \b Arcane are in this
56 * namespace.
57 */
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62namespace Arcane
63{
64
65/*---------------------------------------------------------------------------*/
66/*---------------------------------------------------------------------------*/
67
68extern "C++" ARCANE_UTILS_EXPORT void
69arcaneRangeError(Int32 i, Int32 max_size)
70{
71 arcaneDebugPause("arcaneRangeError");
72 throw IndexOutOfRangeException(A_FUNCINFO, String(), i, 0, max_size);
73}
74
75/*---------------------------------------------------------------------------*/
76/*---------------------------------------------------------------------------*/
77
78extern "C++" ARCANE_UTILS_EXPORT void
79arcaneRangeError(Int64 i, Int64 max_size)
80{
81 arcaneDebugPause("arcaneRangeError");
82 throw IndexOutOfRangeException(A_FUNCINFO, String(), i, 0, max_size);
83}
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
88extern "C++" ARCANE_UTILS_EXPORT void
89_internalArcaneMathError(long double value, const char* funcname)
90{
91 cerr << "** FATAL: Argument error for a mathematical operation:\n";
92 cerr << "** FATAL: Argument: " << value << '\n';
93 if (funcname)
94 cerr << "** FATAL: Operation: " << funcname << '\n';
95 arcaneDebugPause("arcaneMathError");
96 throw ArithmeticException(A_FUNCINFO);
97}
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
102extern "C++" ARCANE_UTILS_EXPORT void
103_internalArcaneMathError(long double value1, long double value2, const char* funcname)
104{
105 cerr << "** FATAL: Argument error for a mathematical operation:\n";
106 cerr << "** FATAL: Argument1: " << value1 << '\n';
107 cerr << "** FATAL: Argument2: " << value2 << '\n';
108 if (funcname)
109 cerr << "** FATAL: Operation: " << funcname << '\n';
110 arcaneDebugPause("arcaneMathError");
111 throw ArithmeticException(A_FUNCINFO);
112}
113
114/*---------------------------------------------------------------------------*/
115/*---------------------------------------------------------------------------*/
116
117extern "C++" ARCANE_UTILS_EXPORT void
118arcaneNotYetImplemented(const char* file, const char* func,
119 unsigned long line, const char* text)
120{
121 cerr << file << ':' << func << ':' << line << '\n';
122 cerr << "sorry, functionality not yet implemented";
123 if (text)
124 cerr << ": " << text;
125 cerr << '\n';
126}
127
128/*---------------------------------------------------------------------------*/
129/*---------------------------------------------------------------------------*/
130
131extern "C++" ARCANE_UTILS_EXPORT void
133{
134 cerr << "** FATAL: null pointer.\n";
135 cerr << "** FATAL: Trying to dereference a null pointer.\n";
136 arcaneDebugPause("arcaneNullPointerPtr");
137 throw FatalErrorException(A_FUNCINFO, "null pointer");
138}
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
143extern "C++" ARCANE_UTILS_EXPORT void
144arcaneThrowNullPointerError(const char* ptr_name, const char* text)
145{
146 throw FatalErrorException(A_FUNCINFO, text ? text : ptr_name);
147}
148
149/*---------------------------------------------------------------------------*/
150/*---------------------------------------------------------------------------*/
151
152extern "C++" ARCANE_UTILS_EXPORT Integer
153arcaneCheckArraySize(unsigned long long size)
154{
155 ARCANE_THROW_IF((size >= ARCANE_INTEGER_MAX), ArgumentException, "value '{0}' too big for Array size", size);
156 return static_cast<Integer>(size);
157}
158
159extern "C++" ARCANE_UTILS_EXPORT Integer
160arcaneCheckArraySize(long long size)
161{
162 ARCANE_THROW_IF((size >= ARCANE_INTEGER_MAX), ArgumentException, "value '{0}' too big for Array size", size);
163 ARCANE_THROW_IF((size < 0), ArgumentException, "invalid negative value '{0}' for Array size", size);
164 return static_cast<Integer>(size);
165}
166
167extern "C++" ARCANE_UTILS_EXPORT Integer
168arcaneCheckArraySize(unsigned long size)
169{
170 ARCANE_THROW_IF((size >= ARCANE_INTEGER_MAX), ArgumentException, "value '{0}' too big for Array size", size);
171 return static_cast<Integer>(size);
172}
173
174extern "C++" ARCANE_UTILS_EXPORT Integer
176{
177 ARCANE_THROW_IF((size >= ARCANE_INTEGER_MAX), ArgumentException, "value '{0}' too big for Array size", size);
178 ARCANE_THROW_IF((size < 0), ArgumentException, "invalid negative value '{0}' for Array size", size);
179 return static_cast<Integer>(size);
180}
181
182extern "C++" ARCANE_UTILS_EXPORT Integer
183arcaneCheckArraySize(unsigned int size)
184{
185 ARCANE_THROW_IF((size >= ARCANE_INTEGER_MAX), ArgumentException, "value '{0}' too big for Array size", size);
186 return static_cast<Integer>(size);
187}
188
189extern "C++" ARCANE_UTILS_EXPORT Integer
191{
192 ARCANE_THROW_IF((size >= ARCANE_INTEGER_MAX), ArgumentException, "value '{0}' too big for Array size", size);
193 ARCANE_THROW_IF((size < 0), ArgumentException, "invalid negative value '{0}' for Array size", size);
194 return static_cast<Integer>(size);
195}
196
197/*---------------------------------------------------------------------------*/
198/*---------------------------------------------------------------------------*/
199
200extern "C++" ARCANE_UTILS_EXPORT void
201arcaneCheckAlignment(const void* ptr, Integer alignment)
202{
203 if (alignment <= 0)
204 return;
205 Int64 iptr = (intptr_t)ptr;
206 Int64 modulo = iptr % alignment;
207 if (modulo != 0)
208 throw BadAlignmentException(A_FUNCINFO, ptr, alignment);
209}
210
211/*---------------------------------------------------------------------------*/
212/*---------------------------------------------------------------------------*/
213
214extern "C++" ARCANE_UTILS_EXPORT Integer
219
220/*---------------------------------------------------------------------------*/
221/*---------------------------------------------------------------------------*/
222
223/*!
224 * \defgroup Collection Collection
225 *
226 * \brief Collection classes.
227 *
228 * Collections are %Arcane classes that manage a set of objects.
229 * Generally, the most used collection is the array. For
230 * more information, refer to the page \ref arcanedoc_core_types_array_usage.
231 */
232
233/*!
234 * \defgroup Module Module
235 *
236 * \brief Module classes
237 */
238
239/*!
240 * \defgroup Core Core
241 *
242 * \brief Core classes
243 */
244
245/*!
246 * \defgroup CaseOption CaseOption
247 *
248 * \brief Data set classes
249 */
250
251/*!
252 * \defgroup Mesh Mesh
253 *
254 * \brief Mesh classes
255 */
256
257/*!
258 * \defgroup Variable Variable
259 *
260 * \brief Variable-related classes
261 */
262
263/*!
264 * \defgroup Parallel Parallel
265 *
266 * \brief Parallelism-related classes
267 */
268
269/*!
270 * \defgroup Xml Xml
271 *
272 * \brief XML-related classes.
273 */
274
275/*!
276 * \defgroup StandardService StandardService
277 *
278 * \brief Standard services
279 */
280
281/*!
282 * \defgroup IO IO
283 *
284 * \brief Input/output management
285 */
286
287/*!
288 * \defgroup Math Math
289 *
290 * \brief Mathematical functions
291 */
292
293/*---------------------------------------------------------------------------*/
294/*---------------------------------------------------------------------------*/
295
296} // namespace Arcane
297
298/*---------------------------------------------------------------------------*/
299/*---------------------------------------------------------------------------*/
#define ARCANE_THROW_IF(const, exception_class,...)
Macro for throwing an exception with formatting if cond is true.
Exception when an arithmetic error occurs.
__host__ static __device__ SizeType getSizeWithPadding(SizeType size)
Calculates the size needed to be a multiple of SIMD_PADDING_SIZE.
Exception when an address is not correctly aligned.
Exception when a value is not within a given range.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Integer arcaneCheckArraySize(unsigned long long size)
Checks that size can be converted into an 'Integer' to serve as the size of an array....
std::int64_t Int64
Signed integer type of 64 bits.
void arcaneNullPointerError()
Signals the use of a null pointer.
Int32 Integer
Type representing an integer.
void arcaneNotYetImplemented(const char *file, const char *func, unsigned long line, const char *text)
Signals an unimplemented function.
Integer arcaneSizeWithPadding(Integer size)
Returns the size with padding for a size size.
void arcaneDebugPause(const char *msg)
Enters pause mode or throws a fatal error.
Definition Misc.cc:122
void arcaneCheckAlignment(const void *ptr, Integer alignment)
Checks that ptr is aligned on alignment bytes. If not, throws a BadAlignmentException.
std::int32_t Int32
Signed integer type of 32 bits.
void arcaneThrowNullPointerError(const char *ptr_name, const char *text)
Signals the use of a null pointer by throwing an exception.