12#ifndef ARCANE_UTILS_ARCANEGLOBAL_H
13#define ARCANE_UTILS_ARCANEGLOBAL_H
17#include "arccore/base/ArccoreGlobal.h"
21#include "arcane_core_config.h"
23#ifdef ARCCORE_OS_LINUX
24# define ARCANE_OS_LINUX
28#ifdef ARCCORE_OS_WIN32
29# define ARCANE_OS_WIN32
32#define ARCANE_EXPORT ARCCORE_EXPORT
33#define ARCANE_IMPORT ARCCORE_IMPORT
34#define ARCANE_TEMPLATE_EXPORT ARCCORE_TEMPLATE_EXPORT
35#define ARCANE_RESTRICT ARCCORE_RESTRICT
41#define ARCANE_UNUSED(var) ARCCORE_UNUSED(var)
46#if defined(ARCANE_HAS_CUDA) && defined(__CUDACC__)
51#define ARCANE_COMPILING_CUDA
53#if defined(ARCANE_HAS_HIP) && defined(__HIP__)
58#define ARCANE_COMPILING_HIP
61#if defined(ARCANE_HAS_SYCL)
62# if defined(SYCL_LANGUAGE_VERSION) || defined(__ADAPTIVECPP__)
67# define ARCANE_COMPILING_SYCL
76#ifndef ARCANE_NO_USING_FOR_STREAM
83using std::ostringstream;
84using std::istringstream;
91typedef ARCANE_TYPE_INT16 Int16;
92typedef ARCANE_TYPE_INT32 Int32;
93typedef ARCANE_TYPE_INT64 Int64;
96#define ARCANE_BEGIN_NAMESPACE namespace Arcane {
97#define ARCANE_END_NAMESPACE }
98#define NUMERICS_BEGIN_NAMESPACE namespace Numerics {
99#define NUMERICS_END_NAMESPACE }
104#ifdef ARCANE_COMPONENT_FULL
105#define ARCANE_COMPONENT_arcane_utils
106#define ARCANE_COMPONENT_arcane
107#define ARCANE_COMPONENT_arcane_mesh
108#define ARCANE_COMPONENT_arcane_std
109#define ARCANE_COMPONENT_arcane_impl
110#define ARCANE_COMPONENT_arcane_script
113#if defined(ARCANE_COMPONENT_arcane) || defined(ARCANE_COMPONENT_arcane_core)
114#define ARCANE_CORE_EXPORT ARCANE_EXPORT
115#define ARCANE_EXPR_EXPORT ARCANE_EXPORT
116#define ARCANE_DATATYPE_EXPORT ARCANE_EXPORT
117#define ARCANE_CORE_EXTERN_TPL
119#define ARCANE_CORE_EXPORT ARCANE_IMPORT
120#define ARCANE_EXPR_EXPORT ARCANE_IMPORT
121#define ARCANE_DATATYPE_EXPORT ARCANE_IMPORT
122#define ARCANE_CORE_EXTERN_TPL extern
125#ifdef ARCANE_COMPONENT_arcane_utils
126#define ARCANE_UTILS_EXPORT ARCANE_EXPORT
127#define ARCANE_UTILS_EXTERN_TPL
129#define ARCANE_UTILS_EXPORT ARCANE_IMPORT
130#define ARCANE_UTILS_EXTERN_TPL extern
133#ifdef ARCANE_COMPONENT_arcane_impl
134#define ARCANE_IMPL_EXPORT ARCANE_EXPORT
136#define ARCANE_IMPL_EXPORT ARCANE_IMPORT
139#ifdef ARCANE_COMPONENT_arcane_mesh
140#define ARCANE_MESH_EXPORT ARCANE_EXPORT
142#define ARCANE_MESH_EXPORT ARCANE_IMPORT
145#ifdef ARCANE_COMPONENT_arcane_std
146#define ARCANE_STD_EXPORT ARCANE_EXPORT
148#define ARCANE_STD_EXPORT ARCANE_IMPORT
151#ifdef ARCANE_COMPONENT_arcane_script
152#define ARCANE_SCRIPT_EXPORT ARCANE_EXPORT
154#define ARCANE_SCRIPT_EXPORT ARCANE_IMPORT
157#ifdef ARCANE_COMPONENT_arcane_solvers
158#define ARCANE_SOLVERS_EXPORT ARCANE_EXPORT
160#define ARCANE_SOLVERS_EXPORT ARCANE_IMPORT
163#ifdef ARCANE_COMPONENT_arcane_geometry
164#define ARCANE_GEOMETRY_EXPORT ARCANE_EXPORT
166#define ARCANE_GEOMETRY_EXPORT ARCANE_IMPORT
169#ifdef ARCANE_COMPONENT_arcane_thread
170#define ARCANE_THREAD_EXPORT ARCANE_EXPORT
172#define ARCANE_THREAD_EXPORT ARCANE_IMPORT
175#ifdef ARCANE_COMPONENT_arcane_mpi
176#define ARCANE_MPI_EXPORT ARCANE_EXPORT
178#define ARCANE_MPI_EXPORT ARCANE_IMPORT
181#ifdef ARCANE_COMPONENT_arcane_hyoda
182#define ARCANE_HYODA_EXPORT ARCANE_EXPORT
184#define ARCANE_HYODA_EXPORT ARCANE_IMPORT
187#ifdef ARCANE_REAL_USE_APFLOAT
200#define ARCANE_HAS_LONG_LONG
205const double cgrEPSILON_DELTA = 1.0e-2;
206const double cgrPI = 3.14159265358979323846;
211#define ARCANE_REAL(val) ARCCORE_REAL(val)
213#ifdef ARCCORE_REAL_NOT_BUILTIN
214# define ARCANE_REAL_NOT_BUILTIN
217#ifdef ARCCORE_REAL_LONG
218# define ARCANE_REAL_LONG
221#ifdef ARCCORE_REAL_IS_DOUBLE
222# define ARCANE_REAL_IS_DOUBLE
272extern "C++" ARCANE_UTILS_EXPORT
void
288extern "C++" ARCANE_UTILS_EXPORT
void
294extern "C++" ARCANE_UTILS_EXPORT
void
295_internalArcaneMathError(
long double arg_value,
const char* func_name);
297extern "C++" ARCANE_UTILS_EXPORT
void
298_internalArcaneMathError(
long double arg_value1,
long double arg_value2,
const char* func_name);
310ARCCORE_HOST_DEVICE
inline void
313#ifndef ARCCORE_DEVICE_CODE
314 _internalArcaneMathError(arg_value,func_name);
316 ARCANE_UNUSED(arg_value);
317 ARCANE_UNUSED(func_name);
330ARCCORE_HOST_DEVICE
inline void
333#ifndef ARCCORE_DEVICE_CODE
334 _internalArcaneMathError(arg_value1,arg_value2,func_name);
336 ARCANE_UNUSED(arg_value1);
337 ARCANE_UNUSED(arg_value2);
338 ARCANE_UNUSED(func_name);
354extern "C++" ARCANE_UTILS_EXPORT
void
361extern "C++" ARCANE_UTILS_EXPORT
void
376extern "C++" ARCANE_UTILS_EXPORT
void
388extern "C++" ARCANE_UTILS_EXPORT
void
397extern "C++" ARCANE_UTILS_EXPORT
Integer
406extern "C++" ARCANE_UTILS_EXPORT
Integer
415extern "C++" ARCANE_UTILS_EXPORT
Integer
424extern "C++" ARCANE_UTILS_EXPORT
Integer
433extern "C++" ARCANE_UTILS_EXPORT
Integer
442extern "C++" ARCANE_UTILS_EXPORT
Integer
449extern "C++" ARCANE_UTILS_EXPORT
void
458extern "C++" ARCANE_UTILS_EXPORT
468extern "C++" ARCANE_UTILS_EXPORT
474extern "C++" ARCANE_UTILS_EXPORT
480extern "C++" ARCANE_UTILS_EXPORT
492extern "C++" ARCANE_UTILS_EXPORT
500extern "C++" ARCANE_UTILS_EXPORT
507extern "C++" ARCANE_UTILS_EXPORT
bool _checkDebug(
size_t);
508#define ARCANE_DEBUGP(a,b) if (_checkDebug(a)) { arcanePrintf b; }
510#define ARCANE_DEBUGP(a,b)
517# define ARCANE_NOT_YET_IMPLEMENTED(a) \
518{ arcaneNotYetImplemented(__FILE__,__PRETTY_FUNCTION__,__LINE__,(a)); }
520# define ARCANE_NOT_YET_IMPLEMENTED(a) \
521{ arcaneNotYetImplemented(__FILE__,"(NoInfo)",__LINE__,(a)); }
524#define ARCANE_DEPRECATED ARCCORE_DEPRECATED
526#define ARCANE_DEPRECATED_112 ARCANE_DEPRECATED
527#define ARCANE_DEPRECATED_114 ARCANE_DEPRECATED
528#define ARCANE_DEPRECATED_116 ARCANE_DEPRECATED
529#define ARCANE_DEPRECATED_118 ARCANE_DEPRECATED
530#define ARCANE_DEPRECATED_120 ARCANE_DEPRECATED
531#define ARCANE_DEPRECATED_122 ARCANE_DEPRECATED
532#define ARCANE_DEPRECATED_200 ARCANE_DEPRECATED
533#define ARCANE_DEPRECATED_220 ARCANE_DEPRECATED
534#define ARCANE_DEPRECATED_240 ARCANE_DEPRECATED
535#define ARCANE_DEPRECATED_260 ARCANE_DEPRECATED
536#define ARCANE_DEPRECATED_280 ARCANE_DEPRECATED
537#define ARCANE_DEPRECATED_2018 ARCANE_DEPRECATED
538#define ARCANE_DEPRECATED_2018_R(reason) [[deprecated(reason)]]
540#ifndef ARCCORE_DEPRECATED_2021
541#define ARCCORE_DEPRECATED_2021(reason) [[deprecated(reason)]]
544#define ARCANE_DEPRECATED_REASON(reason) [[deprecated(reason)]]
546#ifdef ARCANE_NO_DEPRECATED_LONG_TERM
547#define ARCANE_DEPRECATED_LONG_TERM(reason)
556#define ARCANE_DEPRECATED_LONG_TERM(reason) [[deprecated(reason)]]
561#define ARCANE_NO_DEPRECATED
565#ifdef ARCANE_NO_NOTIFY_DEPRECATED_ARRAY
566#define ARCANE_DEPRECATED_ARRAY
568#define ARCANE_DEPRECATED_ARRAY ARCANE_DEPRECATED
579#define ARCANE_JOIN_HELPER2(a,b) a ## b
580#define ARCANE_JOIN_HELPER(a,b) ARCANE_JOIN_HELPER2(a,b)
581#define ARCANE_JOIN_WITH_LINE(a) ARCANE_JOIN_HELPER(a,__LINE__)
587#define ARCANE_NORETURN ARCCORE_NORETURN
590#define ARCANE_CONSTEXPR ARCCORE_CONSTEXPR
597#define ARCANE_NOEXCEPT ARCCORE_NOEXCEPT
598#define ARCANE_NOEXCEPT_FALSE ARCCORE_NOEXCEPT_FALSE
613# define ARCANE_ALIGNAS(value) __declspec(align(value))
615# define ARCANE_ALIGNAS_PACKED(value) __declspec(align(value))
618# define ARCANE_ALIGNAS_PACKED(value) __attribute__ ((aligned (value),packed))
620# define ARCANE_ALIGNAS(value) __attribute__ ((aligned (value)))
627#ifdef ARCANE_DEPRECATED
628#undef ARCANE_DEPRECATED
635#if defined(ARCANE_CHECK) || defined(ARCANE_DEBUG)
636#ifndef ARCANE_DEBUG_ASSERT
637#define ARCANE_DEBUG_ASSERT
650extern "C++" ARCANE_UTILS_EXPORT
void
666extern "C++" ARCANE_UTILS_EXPORT
void
675arcaneCheckNull(
const void* ptr)
691static const Integer SIMD_PADDING_SIZE = 8;
703extern "C++" ARCANE_UTILS_EXPORT
Integer
712#ifdef ARCANE_DEBUG_ASSERT
713extern "C++" ARCANE_UTILS_EXPORT
void _doAssert(
const char*,
const char*,
const char*,
size_t);
714template<
typename T>
inline T*
715_checkPointer(T* t,
const char* file,
const char* func,
size_t line)
718 _doAssert(
"ARCANE_ASSERT",file,func,line);
724# define ARCANE_D_WHERE(a) Arcane::_doAssert(a,__FILE__,__PRETTY_FUNCTION__,__LINE__)
725# define ARCANE_DCHECK_POINTER(a) Arcane::_checkPointer((a),__FILE__,__PRETTY_FUNCTION__,__LINE__);
727# define ARCANE_D_WHERE(a) Arcane::_doAssert(a,__FILE__,"(NoInfo)",__LINE__)
728# define ARCANE_DCHECK_POINTER(a) Arcane::_checkPointer((a),__FILE__,"(NoInfo"),__LINE__);
730# define ARCANE_CHECK_PTR(a) \
731 {if (!(a)){Arcane::arcanePrintf("Null value");ARCANE_D_WHERE("ARCANE_ASSERT");}}
733# define ARCANE_ASSERT(a,b) \
734 {if (!(a)){ Arcane::arcanePrintf("Assertion '%s' fails:",#a); Arcane::arcanePrintf b; ARCANE_D_WHERE("ARCANE_ASSERT");}}
735# define ARCANE_WARNING(a) \
736 { Arcane::arcanePrintf a; ARCANE_D_WHERE("ARCANE_WARNING"); }
738# define ARCANE_CHECK_PTR(a)
739# define ARCANE_ASSERT(a,b)
740# define ARCANE_WARNING(a)
741# define ARCANE_DCHECK_POINTER(a) (a);
753#define ARCANE_THROW(exception_class,...) \
754 throw exception_class (A_FUNCINFO,Arcane::String::format(__VA_ARGS__))
764#define ARCANE_FATAL(...)\
765 throw Arcane::FatalErrorException(A_FUNCINFO,Arcane::String::format(__VA_ARGS__))
776arcaneThrowIfNull(
void* ptr,
const char* ptr_name,
const char* text)
791static inline const void*
792arcaneThrowIfNull(
const void* ptr,
const char* ptr_name,
const char* text)
807template<
typename T>
inline T*
808arcaneThrowIfNull(T* ptr,
const char* ptr_name,
const char* text)
823#define ARCANE_CHECK_POINTER(ptr) \
824 arcaneThrowIfNull(ptr,#ptr,nullptr)
832#define ARCANE_CHECK_POINTER2(ptr,text)\
833 arcaneThrowIfNull(ptr,#ptr,text)
846extern "C++" ARCANE_UTILS_EXPORT
void
847arcaneRangeError [[noreturn]] (Int64 i,Int64 max_size);
852static inline constexpr ARCCORE_HOST_DEVICE
void
853arcaneCheckAt(Int64 i,Int64 max_size)
855#ifndef ARCCORE_DEVICE_CODE
856 if (i<0 || i>=max_size)
857 arcaneRangeError(i,max_size);
860 ARCANE_UNUSED(max_size);
864#if defined(ARCANE_CHECK) || defined(ARCANE_DEBUG)
865#define ARCANE_CHECK_AT(a,b) ::Arcane::arcaneCheckAt((a),(b))
867#define ARCANE_CHECK_AT(a,b)
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
void arcaneNoReferenceErrorCallTerminate(const void *ptr)
Utilisation d'un objet non référencé.
Int64 arcaneCurrentThread()
Retourne l'identifiant du thread courant.
Integer arcaneCheckArraySize(unsigned long long size)
Vérifie que size peut être converti dans un 'Integer' pour servir de taille à un tableau....
bool arcaneIsCheck()
Vrai si on est en mode vérification.
bool arcaneHasThread()
Vrai si arcane est compilé avec le support des threads ET qu'ils sont actifs.
Int64 UniqueIdType
Type des entiers utilisés pour stocker les identifiants uniques (globaux) des entités.
std::int64_t Int64
Type entier signé sur 64 bits.
void arcaneSetHasThread(bool v)
Active ou désactive le support des threads.
void arcaneNullPointerError()
Signalue l'utilisation d'un pointeur nul.
Int32 Integer
Type représentant un entier.
void arcanePrintf(const char *,...)
Encapsulation de la fonction C printf.
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 arcaneDeprecated(const char *file, const char *func, unsigned long line, const char *text)
Signale l'utilisation d'une fonction obsolète.
bool arcaneIsDebug()
Vrai si la macro ARCANE_DEBUG est définie.
void arcaneSetCheck(bool v)
Active ou désactive le mode vérification.
void arcaneNoReferenceError(const void *ptr)
Utilisation d'un objet non référencé.
bool _checkDebug(unsigned int val)
__host__ __device__ void arcaneMathError(long double arg_value, const char *func_name)
Signale un argument invalide d'une fonction mathématique.
void _doAssert(const char *text, const char *file, const char *func, size_t line)
void arcaneDebugPause(const char *msg)
Passe en mode pause ou lance une erreur fatale.
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.