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#ifdef ARCCORE_OS_MACOS
33# define ARCANE_OS_MACOS
36#define ARCANE_EXPORT ARCCORE_EXPORT
37#define ARCANE_IMPORT ARCCORE_IMPORT
38#define ARCANE_TEMPLATE_EXPORT ARCCORE_TEMPLATE_EXPORT
39#define ARCANE_RESTRICT ARCCORE_RESTRICT
45#define ARCANE_UNUSED(var) ARCCORE_UNUSED(var)
50#if defined(ARCANE_HAS_CUDA) && defined(__CUDACC__)
55#define ARCANE_COMPILING_CUDA
57#if defined(ARCANE_HAS_HIP) && defined(__HIP__)
62#define ARCANE_COMPILING_HIP
65#if defined(ARCANE_HAS_SYCL)
66# if defined(SYCL_LANGUAGE_VERSION) || defined(__ADAPTIVECPP__)
71# define ARCANE_COMPILING_SYCL
80#ifndef ARCANE_NO_USING_FOR_STREAM
87using std::ostringstream;
88using std::istringstream;
95typedef ARCANE_TYPE_INT16 Int16;
96typedef ARCANE_TYPE_INT32 Int32;
97typedef ARCANE_TYPE_INT64 Int64;
100#define ARCANE_BEGIN_NAMESPACE namespace Arcane {
101#define ARCANE_END_NAMESPACE }
102#define NUMERICS_BEGIN_NAMESPACE namespace Numerics {
103#define NUMERICS_END_NAMESPACE }
108#ifdef ARCANE_COMPONENT_FULL
109#define ARCANE_COMPONENT_arcane_utils
110#define ARCANE_COMPONENT_arcane
111#define ARCANE_COMPONENT_arcane_mesh
112#define ARCANE_COMPONENT_arcane_std
113#define ARCANE_COMPONENT_arcane_impl
114#define ARCANE_COMPONENT_arcane_script
117#if defined(ARCANE_COMPONENT_arcane) || defined(ARCANE_COMPONENT_arcane_core)
118#define ARCANE_CORE_EXPORT ARCANE_EXPORT
119#define ARCANE_EXPR_EXPORT ARCANE_EXPORT
120#define ARCANE_DATATYPE_EXPORT ARCANE_EXPORT
121#define ARCANE_CORE_EXTERN_TPL
123#define ARCANE_CORE_EXPORT ARCANE_IMPORT
124#define ARCANE_EXPR_EXPORT ARCANE_IMPORT
125#define ARCANE_DATATYPE_EXPORT ARCANE_IMPORT
126#define ARCANE_CORE_EXTERN_TPL extern
129#ifdef ARCANE_COMPONENT_arcane_utils
130#define ARCANE_UTILS_EXPORT ARCANE_EXPORT
131#define ARCANE_UTILS_EXTERN_TPL
133#define ARCANE_UTILS_EXPORT ARCANE_IMPORT
134#define ARCANE_UTILS_EXTERN_TPL extern
137#ifdef ARCANE_COMPONENT_arcane_impl
138#define ARCANE_IMPL_EXPORT ARCANE_EXPORT
140#define ARCANE_IMPL_EXPORT ARCANE_IMPORT
143#ifdef ARCANE_COMPONENT_arcane_mesh
144#define ARCANE_MESH_EXPORT ARCANE_EXPORT
146#define ARCANE_MESH_EXPORT ARCANE_IMPORT
149#ifdef ARCANE_COMPONENT_arcane_std
150#define ARCANE_STD_EXPORT ARCANE_EXPORT
152#define ARCANE_STD_EXPORT ARCANE_IMPORT
155#ifdef ARCANE_COMPONENT_arcane_script
156#define ARCANE_SCRIPT_EXPORT ARCANE_EXPORT
158#define ARCANE_SCRIPT_EXPORT ARCANE_IMPORT
161#ifdef ARCANE_COMPONENT_arcane_solvers
162#define ARCANE_SOLVERS_EXPORT ARCANE_EXPORT
164#define ARCANE_SOLVERS_EXPORT ARCANE_IMPORT
167#ifdef ARCANE_COMPONENT_arcane_geometry
168#define ARCANE_GEOMETRY_EXPORT ARCANE_EXPORT
170#define ARCANE_GEOMETRY_EXPORT ARCANE_IMPORT
173#ifdef ARCANE_COMPONENT_arcane_thread
174#define ARCANE_THREAD_EXPORT ARCANE_EXPORT
176#define ARCANE_THREAD_EXPORT ARCANE_IMPORT
179#ifdef ARCANE_COMPONENT_arcane_mpi
180#define ARCANE_MPI_EXPORT ARCANE_EXPORT
182#define ARCANE_MPI_EXPORT ARCANE_IMPORT
185#ifdef ARCANE_COMPONENT_arcane_hyoda
186#define ARCANE_HYODA_EXPORT ARCANE_EXPORT
188#define ARCANE_HYODA_EXPORT ARCANE_IMPORT
191#ifdef ARCANE_REAL_USE_APFLOAT
204#define ARCANE_HAS_LONG_LONG
209const double cgrEPSILON_DELTA = 1.0e-2;
210const double cgrPI = 3.14159265358979323846;
215#define ARCANE_REAL(val) ARCCORE_REAL(val)
217#ifdef ARCCORE_REAL_NOT_BUILTIN
218# define ARCANE_REAL_NOT_BUILTIN
221#ifdef ARCCORE_REAL_LONG
222# define ARCANE_REAL_LONG
225#ifdef ARCCORE_REAL_IS_DOUBLE
226# define ARCANE_REAL_IS_DOUBLE
276extern "C++" ARCANE_UTILS_EXPORT
void
292extern "C++" ARCANE_UTILS_EXPORT
void
298extern "C++" ARCANE_UTILS_EXPORT
void
299_internalArcaneMathError(
long double arg_value,
const char* func_name);
301extern "C++" ARCANE_UTILS_EXPORT
void
302_internalArcaneMathError(
long double arg_value1,
long double arg_value2,
const char* func_name);
314ARCCORE_HOST_DEVICE
inline void
317#ifndef ARCCORE_DEVICE_CODE
318 _internalArcaneMathError(arg_value,func_name);
320 ARCANE_UNUSED(arg_value);
321 ARCANE_UNUSED(func_name);
334ARCCORE_HOST_DEVICE
inline void
337#ifndef ARCCORE_DEVICE_CODE
338 _internalArcaneMathError(arg_value1,arg_value2,func_name);
340 ARCANE_UNUSED(arg_value1);
341 ARCANE_UNUSED(arg_value2);
342 ARCANE_UNUSED(func_name);
358extern "C++" ARCANE_UTILS_EXPORT
void
365extern "C++" ARCANE_UTILS_EXPORT
void
380extern "C++" ARCANE_UTILS_EXPORT
void
392extern "C++" ARCANE_UTILS_EXPORT
void
401extern "C++" ARCANE_UTILS_EXPORT
Integer
410extern "C++" ARCANE_UTILS_EXPORT
Integer
419extern "C++" ARCANE_UTILS_EXPORT
Integer
428extern "C++" ARCANE_UTILS_EXPORT
Integer
437extern "C++" ARCANE_UTILS_EXPORT
Integer
446extern "C++" ARCANE_UTILS_EXPORT
Integer
453extern "C++" ARCANE_UTILS_EXPORT
void
462extern "C++" ARCANE_UTILS_EXPORT
472extern "C++" ARCANE_UTILS_EXPORT
478extern "C++" ARCANE_UTILS_EXPORT
484extern "C++" ARCANE_UTILS_EXPORT
496extern "C++" ARCANE_UTILS_EXPORT
504extern "C++" ARCANE_UTILS_EXPORT
511extern "C++" ARCANE_UTILS_EXPORT
bool _checkDebug(
size_t);
512#define ARCANE_DEBUGP(a,b) if (_checkDebug(a)) { arcanePrintf b; }
514#define ARCANE_DEBUGP(a,b)
521# define ARCANE_NOT_YET_IMPLEMENTED(a) \
522{ arcaneNotYetImplemented(__FILE__,__PRETTY_FUNCTION__,__LINE__,(a)); }
524# define ARCANE_NOT_YET_IMPLEMENTED(a) \
525{ arcaneNotYetImplemented(__FILE__,"(NoInfo)",__LINE__,(a)); }
528#define ARCANE_DEPRECATED ARCCORE_DEPRECATED
530#define ARCANE_DEPRECATED_112 ARCANE_DEPRECATED
531#define ARCANE_DEPRECATED_114 ARCANE_DEPRECATED
532#define ARCANE_DEPRECATED_116 ARCANE_DEPRECATED
533#define ARCANE_DEPRECATED_118 ARCANE_DEPRECATED
534#define ARCANE_DEPRECATED_120 ARCANE_DEPRECATED
535#define ARCANE_DEPRECATED_122 ARCANE_DEPRECATED
536#define ARCANE_DEPRECATED_200 ARCANE_DEPRECATED
537#define ARCANE_DEPRECATED_220 ARCANE_DEPRECATED
538#define ARCANE_DEPRECATED_240 ARCANE_DEPRECATED
539#define ARCANE_DEPRECATED_260 ARCANE_DEPRECATED
540#define ARCANE_DEPRECATED_280 ARCANE_DEPRECATED
541#define ARCANE_DEPRECATED_2018 ARCANE_DEPRECATED
542#define ARCANE_DEPRECATED_2018_R(reason) [[deprecated(reason)]]
544#ifndef ARCCORE_DEPRECATED_2021
545#define ARCCORE_DEPRECATED_2021(reason) [[deprecated(reason)]]
548#define ARCANE_DEPRECATED_REASON(reason) [[deprecated(reason)]]
550#ifdef ARCANE_NO_DEPRECATED_LONG_TERM
551#define ARCANE_DEPRECATED_LONG_TERM(reason)
560#define ARCANE_DEPRECATED_LONG_TERM(reason) [[deprecated(reason)]]
565#define ARCANE_NO_DEPRECATED
569#ifdef ARCANE_NO_NOTIFY_DEPRECATED_ARRAY
570#define ARCANE_DEPRECATED_ARRAY
572#define ARCANE_DEPRECATED_ARRAY ARCANE_DEPRECATED
583#define ARCANE_JOIN_HELPER2(a,b) a ## b
584#define ARCANE_JOIN_HELPER(a,b) ARCANE_JOIN_HELPER2(a,b)
585#define ARCANE_JOIN_WITH_LINE(a) ARCANE_JOIN_HELPER(a,__LINE__)
591#define ARCANE_NORETURN ARCCORE_NORETURN
594#define ARCANE_CONSTEXPR ARCCORE_CONSTEXPR
601#define ARCANE_NOEXCEPT ARCCORE_NOEXCEPT
602#define ARCANE_NOEXCEPT_FALSE ARCCORE_NOEXCEPT_FALSE
617# define ARCANE_ALIGNAS(value) __declspec(align(value))
619# define ARCANE_ALIGNAS_PACKED(value) __declspec(align(value))
622# define ARCANE_ALIGNAS_PACKED(value) __attribute__ ((aligned (value),packed))
624# define ARCANE_ALIGNAS(value) __attribute__ ((aligned (value)))
631#ifdef ARCANE_DEPRECATED
632#undef ARCANE_DEPRECATED
639#if defined(ARCANE_CHECK) || defined(ARCANE_DEBUG)
640#ifndef ARCANE_DEBUG_ASSERT
641#define ARCANE_DEBUG_ASSERT
654extern "C++" ARCANE_UTILS_EXPORT
void
670extern "C++" ARCANE_UTILS_EXPORT
void
679arcaneCheckNull(
const void* ptr)
695static const Integer SIMD_PADDING_SIZE = 8;
707extern "C++" ARCANE_UTILS_EXPORT
Integer
716#ifdef ARCANE_DEBUG_ASSERT
717extern "C++" ARCANE_UTILS_EXPORT
void _doAssert(
const char*,
const char*,
const char*,
size_t);
718template<
typename T>
inline T*
719_checkPointer(T* t,
const char* file,
const char* func,
size_t line)
722 _doAssert(
"ARCANE_ASSERT",file,func,line);
728# define ARCANE_D_WHERE(a) Arcane::_doAssert(a,__FILE__,__PRETTY_FUNCTION__,__LINE__)
729# define ARCANE_DCHECK_POINTER(a) Arcane::_checkPointer((a),__FILE__,__PRETTY_FUNCTION__,__LINE__);
731# define ARCANE_D_WHERE(a) Arcane::_doAssert(a,__FILE__,"(NoInfo)",__LINE__)
732# define ARCANE_DCHECK_POINTER(a) Arcane::_checkPointer((a),__FILE__,"(NoInfo"),__LINE__);
734# define ARCANE_CHECK_PTR(a) \
735 {if (!(a)){Arcane::arcanePrintf("Null value");ARCANE_D_WHERE("ARCANE_ASSERT");}}
737# define ARCANE_ASSERT(a,b) \
738 {if (!(a)){ Arcane::arcanePrintf("Assertion '%s' fails:",#a); Arcane::arcanePrintf b; ARCANE_D_WHERE("ARCANE_ASSERT");}}
739# define ARCANE_WARNING(a) \
740 { Arcane::arcanePrintf a; ARCANE_D_WHERE("ARCANE_WARNING"); }
742# define ARCANE_CHECK_PTR(a)
743# define ARCANE_ASSERT(a,b)
744# define ARCANE_WARNING(a)
745# define ARCANE_DCHECK_POINTER(a) (a);
757#define ARCANE_THROW(exception_class,...) \
758 throw exception_class (A_FUNCINFO,Arcane::String::format(__VA_ARGS__))
768#define ARCANE_FATAL(...)\
769 throw Arcane::FatalErrorException(A_FUNCINFO,Arcane::String::format(__VA_ARGS__))
780arcaneThrowIfNull(
void* ptr,
const char* ptr_name,
const char* text)
795static inline const void*
796arcaneThrowIfNull(
const void* ptr,
const char* ptr_name,
const char* text)
811template<
typename T>
inline T*
812arcaneThrowIfNull(T* ptr,
const char* ptr_name,
const char* text)
827#define ARCANE_CHECK_POINTER(ptr) \
828 arcaneThrowIfNull(ptr,#ptr,nullptr)
836#define ARCANE_CHECK_POINTER2(ptr,text)\
837 arcaneThrowIfNull(ptr,#ptr,text)
850extern "C++" ARCANE_UTILS_EXPORT
void
851arcaneRangeError [[noreturn]] (Int64 i,Int64 max_size);
856static inline constexpr ARCCORE_HOST_DEVICE
void
857arcaneCheckAt(Int64 i,Int64 max_size)
859#ifndef ARCCORE_DEVICE_CODE
860 if (i<0 || i>=max_size)
861 arcaneRangeError(i,max_size);
864 ARCANE_UNUSED(max_size);
868#if defined(ARCANE_CHECK) || defined(ARCANE_DEBUG)
869#define ARCANE_CHECK_AT(a,b) ::Arcane::arcaneCheckAt((a),(b))
871#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.