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
75#if defined(ARCANE_COMPILING_CUDA) || defined(ARCANE_COMPILING_HIP)
76#define ARCANE_COMPILING_CUDA_OR_HIP
84#ifndef ARCANE_NO_USING_FOR_STREAM
91using std::ostringstream;
92using std::istringstream;
99typedef ARCANE_TYPE_INT16 Int16;
100typedef ARCANE_TYPE_INT32 Int32;
101typedef ARCANE_TYPE_INT64 Int64;
104#define ARCANE_BEGIN_NAMESPACE namespace Arcane {
105#define ARCANE_END_NAMESPACE }
106#define NUMERICS_BEGIN_NAMESPACE namespace Numerics {
107#define NUMERICS_END_NAMESPACE }
112#ifdef ARCANE_COMPONENT_FULL
113#define ARCANE_COMPONENT_arcane_utils
114#define ARCANE_COMPONENT_arcane
115#define ARCANE_COMPONENT_arcane_mesh
116#define ARCANE_COMPONENT_arcane_std
117#define ARCANE_COMPONENT_arcane_impl
118#define ARCANE_COMPONENT_arcane_script
121#if defined(ARCANE_COMPONENT_arcane) || defined(ARCANE_COMPONENT_arcane_core)
122#define ARCANE_CORE_EXPORT ARCANE_EXPORT
123#define ARCANE_EXPR_EXPORT ARCANE_EXPORT
124#define ARCANE_DATATYPE_EXPORT ARCANE_EXPORT
125#define ARCANE_CORE_EXTERN_TPL
127#define ARCANE_CORE_EXPORT ARCANE_IMPORT
128#define ARCANE_EXPR_EXPORT ARCANE_IMPORT
129#define ARCANE_DATATYPE_EXPORT ARCANE_IMPORT
130#define ARCANE_CORE_EXTERN_TPL extern
133#ifdef ARCANE_COMPONENT_arcane_utils
134#define ARCANE_UTILS_EXPORT ARCANE_EXPORT
135#define ARCANE_UTILS_EXTERN_TPL
137#define ARCANE_UTILS_EXPORT ARCANE_IMPORT
138#define ARCANE_UTILS_EXTERN_TPL extern
141#ifdef ARCANE_COMPONENT_arcane_impl
142#define ARCANE_IMPL_EXPORT ARCANE_EXPORT
144#define ARCANE_IMPL_EXPORT ARCANE_IMPORT
147#ifdef ARCANE_COMPONENT_arcane_mesh
148#define ARCANE_MESH_EXPORT ARCANE_EXPORT
150#define ARCANE_MESH_EXPORT ARCANE_IMPORT
153#ifdef ARCANE_COMPONENT_arcane_std
154#define ARCANE_STD_EXPORT ARCANE_EXPORT
156#define ARCANE_STD_EXPORT ARCANE_IMPORT
159#ifdef ARCANE_COMPONENT_arcane_script
160#define ARCANE_SCRIPT_EXPORT ARCANE_EXPORT
162#define ARCANE_SCRIPT_EXPORT ARCANE_IMPORT
165#ifdef ARCANE_COMPONENT_arcane_solvers
166#define ARCANE_SOLVERS_EXPORT ARCANE_EXPORT
168#define ARCANE_SOLVERS_EXPORT ARCANE_IMPORT
171#ifdef ARCANE_COMPONENT_arcane_geometry
172#define ARCANE_GEOMETRY_EXPORT ARCANE_EXPORT
174#define ARCANE_GEOMETRY_EXPORT ARCANE_IMPORT
177#ifdef ARCANE_COMPONENT_arcane_thread
178#define ARCANE_THREAD_EXPORT ARCANE_EXPORT
180#define ARCANE_THREAD_EXPORT ARCANE_IMPORT
183#ifdef ARCANE_COMPONENT_arcane_mpi
184#define ARCANE_MPI_EXPORT ARCANE_EXPORT
186#define ARCANE_MPI_EXPORT ARCANE_IMPORT
189#ifdef ARCANE_COMPONENT_arcane_hyoda
190#define ARCANE_HYODA_EXPORT ARCANE_EXPORT
192#define ARCANE_HYODA_EXPORT ARCANE_IMPORT
195#ifdef ARCANE_REAL_USE_APFLOAT
208#define ARCANE_HAS_LONG_LONG
213const double cgrEPSILON_DELTA = 1.0e-2;
214const double cgrPI = 3.14159265358979323846;
219#define ARCANE_REAL(val) ARCCORE_REAL(val)
221#ifdef ARCCORE_REAL_NOT_BUILTIN
222# define ARCANE_REAL_NOT_BUILTIN
225#ifdef ARCCORE_REAL_LONG
226# define ARCANE_REAL_LONG
229#ifdef ARCCORE_REAL_IS_DOUBLE
230# define ARCANE_REAL_IS_DOUBLE
280extern "C++" ARCANE_UTILS_EXPORT
void
296extern "C++" ARCANE_UTILS_EXPORT
void
302extern "C++" ARCANE_UTILS_EXPORT
void
303_internalArcaneMathError(
long double arg_value,
const char* func_name);
305extern "C++" ARCANE_UTILS_EXPORT
void
306_internalArcaneMathError(
long double arg_value1,
long double arg_value2,
const char* func_name);
318ARCCORE_HOST_DEVICE
inline void
321#ifndef ARCCORE_DEVICE_CODE
322 _internalArcaneMathError(arg_value,func_name);
324 ARCANE_UNUSED(arg_value);
325 ARCANE_UNUSED(func_name);
338ARCCORE_HOST_DEVICE
inline void
341#ifndef ARCCORE_DEVICE_CODE
342 _internalArcaneMathError(arg_value1,arg_value2,func_name);
344 ARCANE_UNUSED(arg_value1);
345 ARCANE_UNUSED(arg_value2);
346 ARCANE_UNUSED(func_name);
362extern "C++" ARCANE_UTILS_EXPORT
void
369extern "C++" ARCANE_UTILS_EXPORT
void
384extern "C++" ARCANE_UTILS_EXPORT
void
396extern "C++" ARCANE_UTILS_EXPORT
void
405extern "C++" ARCANE_UTILS_EXPORT
Integer
414extern "C++" ARCANE_UTILS_EXPORT
Integer
423extern "C++" ARCANE_UTILS_EXPORT
Integer
432extern "C++" ARCANE_UTILS_EXPORT
Integer
441extern "C++" ARCANE_UTILS_EXPORT
Integer
450extern "C++" ARCANE_UTILS_EXPORT
Integer
457extern "C++" ARCANE_UTILS_EXPORT
void
466extern "C++" ARCANE_UTILS_EXPORT
476extern "C++" ARCANE_UTILS_EXPORT
482extern "C++" ARCANE_UTILS_EXPORT
488extern "C++" ARCANE_UTILS_EXPORT
500extern "C++" ARCANE_UTILS_EXPORT
508extern "C++" ARCANE_UTILS_EXPORT
515extern "C++" ARCANE_UTILS_EXPORT
bool _checkDebug(
size_t);
516#define ARCANE_DEBUGP(a,b) if (_checkDebug(a)) { arcanePrintf b; }
518#define ARCANE_DEBUGP(a,b)
525# define ARCANE_NOT_YET_IMPLEMENTED(a) \
526{ arcaneNotYetImplemented(__FILE__,__PRETTY_FUNCTION__,__LINE__,(a)); }
528# define ARCANE_NOT_YET_IMPLEMENTED(a) \
529{ arcaneNotYetImplemented(__FILE__,"(NoInfo)",__LINE__,(a)); }
532#define ARCANE_DEPRECATED ARCCORE_DEPRECATED
534#define ARCANE_DEPRECATED_112 ARCANE_DEPRECATED
535#define ARCANE_DEPRECATED_114 ARCANE_DEPRECATED
536#define ARCANE_DEPRECATED_116 ARCANE_DEPRECATED
537#define ARCANE_DEPRECATED_118 ARCANE_DEPRECATED
538#define ARCANE_DEPRECATED_120 ARCANE_DEPRECATED
539#define ARCANE_DEPRECATED_122 ARCANE_DEPRECATED
540#define ARCANE_DEPRECATED_200 ARCANE_DEPRECATED
541#define ARCANE_DEPRECATED_220 ARCANE_DEPRECATED
542#define ARCANE_DEPRECATED_240 ARCANE_DEPRECATED
543#define ARCANE_DEPRECATED_260 ARCANE_DEPRECATED
544#define ARCANE_DEPRECATED_280 ARCANE_DEPRECATED
545#define ARCANE_DEPRECATED_2018 ARCANE_DEPRECATED
546#define ARCANE_DEPRECATED_2018_R(reason) [[deprecated(reason)]]
548#ifndef ARCCORE_DEPRECATED_2021
549#define ARCCORE_DEPRECATED_2021(reason) [[deprecated(reason)]]
552#define ARCANE_DEPRECATED_REASON(reason) [[deprecated(reason)]]
554#ifdef ARCANE_NO_DEPRECATED_LONG_TERM
555#define ARCANE_DEPRECATED_LONG_TERM(reason)
564#define ARCANE_DEPRECATED_LONG_TERM(reason) [[deprecated(reason)]]
569#define ARCANE_NO_DEPRECATED
573#ifdef ARCANE_NO_NOTIFY_DEPRECATED_ARRAY
574#define ARCANE_DEPRECATED_ARRAY
576#define ARCANE_DEPRECATED_ARRAY ARCANE_DEPRECATED
587#define ARCANE_JOIN_HELPER2(a,b) a ## b
588#define ARCANE_JOIN_HELPER(a,b) ARCANE_JOIN_HELPER2(a,b)
589#define ARCANE_JOIN_WITH_LINE(a) ARCANE_JOIN_HELPER(a,__LINE__)
595#define ARCANE_NORETURN ARCCORE_NORETURN
598#define ARCANE_CONSTEXPR ARCCORE_CONSTEXPR
605#define ARCANE_NOEXCEPT ARCCORE_NOEXCEPT
606#define ARCANE_NOEXCEPT_FALSE ARCCORE_NOEXCEPT_FALSE
621# define ARCANE_ALIGNAS(value) __declspec(align(value))
623# define ARCANE_ALIGNAS_PACKED(value) __declspec(align(value))
626# define ARCANE_ALIGNAS_PACKED(value) __attribute__ ((aligned (value),packed))
628# define ARCANE_ALIGNAS(value) __attribute__ ((aligned (value)))
635#ifdef ARCANE_DEPRECATED
636#undef ARCANE_DEPRECATED
643#if defined(ARCANE_CHECK) || defined(ARCANE_DEBUG)
644#ifndef ARCANE_DEBUG_ASSERT
645#define ARCANE_DEBUG_ASSERT
658extern "C++" ARCANE_UTILS_EXPORT
void
674extern "C++" ARCANE_UTILS_EXPORT
void
683arcaneCheckNull(
const void* ptr)
699static const Integer SIMD_PADDING_SIZE = 8;
711extern "C++" ARCANE_UTILS_EXPORT
Integer
720#ifdef ARCANE_DEBUG_ASSERT
721extern "C++" ARCANE_UTILS_EXPORT
void _doAssert(
const char*,
const char*,
const char*,
size_t);
722template<
typename T>
inline T*
723_checkPointer(T* t,
const char* file,
const char* func,
size_t line)
726 _doAssert(
"ARCANE_ASSERT",file,func,line);
732# define ARCANE_D_WHERE(a) Arcane::_doAssert(a,__FILE__,__PRETTY_FUNCTION__,__LINE__)
733# define ARCANE_DCHECK_POINTER(a) Arcane::_checkPointer((a),__FILE__,__PRETTY_FUNCTION__,__LINE__);
735# define ARCANE_D_WHERE(a) Arcane::_doAssert(a,__FILE__,"(NoInfo)",__LINE__)
736# define ARCANE_DCHECK_POINTER(a) Arcane::_checkPointer((a),__FILE__,"(NoInfo"),__LINE__);
738# define ARCANE_CHECK_PTR(a) \
739 {if (!(a)){Arcane::arcanePrintf("Null value");ARCANE_D_WHERE("ARCANE_ASSERT");}}
741# define ARCANE_ASSERT(a,b) \
742 {if (!(a)){ Arcane::arcanePrintf("Assertion '%s' fails:",#a); Arcane::arcanePrintf b; ARCANE_D_WHERE("ARCANE_ASSERT");}}
743# define ARCANE_WARNING(a) \
744 { Arcane::arcanePrintf a; ARCANE_D_WHERE("ARCANE_WARNING"); }
746# define ARCANE_CHECK_PTR(a)
747# define ARCANE_ASSERT(a,b)
748# define ARCANE_WARNING(a)
749# define ARCANE_DCHECK_POINTER(a) (a);
761#define ARCANE_THROW(exception_class,...) \
762 ARCCORE_THROW(exception_class,__VA_ARGS__)
773#define ARCANE_THROW_IF(const, exception_class, ...) \
774 ARCCORE_THROW_IF(const, exception_class, __VA_ARGS__)
784#define ARCANE_FATAL(...) \
785 ARCCORE_FATAL(__VA_ARGS__)
795#define ARCANE_FATAL_IF(const, ...) \
796 ARCCORE_FATAL_IF(const, __VA_ARGS__)
807arcaneThrowIfNull(
void* ptr,
const char* ptr_name,
const char* text)
822static inline const void*
823arcaneThrowIfNull(
const void* ptr,
const char* ptr_name,
const char* text)
838template<
typename T>
inline T*
839arcaneThrowIfNull(T* ptr,
const char* ptr_name,
const char* text)
854#define ARCANE_CHECK_POINTER(ptr) \
855 arcaneThrowIfNull(ptr,#ptr,nullptr)
863#define ARCANE_CHECK_POINTER2(ptr,text)\
864 arcaneThrowIfNull(ptr,#ptr,text)
877extern "C++" ARCANE_UTILS_EXPORT
void
878arcaneRangeError [[noreturn]] (Int64 i,Int64 max_size);
883static inline constexpr ARCCORE_HOST_DEVICE
void
884arcaneCheckAt(Int64 i,Int64 max_size)
886#ifndef ARCCORE_DEVICE_CODE
887 if (i<0 || i>=max_size)
888 arcaneRangeError(i,max_size);
891 ARCANE_UNUSED(max_size);
895#if defined(ARCANE_CHECK) || defined(ARCANE_DEBUG)
896#define ARCANE_CHECK_AT(a,b) ::Arcane::arcaneCheckAt((a),(b))
898#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.