Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::Platform Namespace Reference

Namespace for platform-dependent functions. More...

Functions

bool isDirectoryExist (const String &dir_name, bool &can_create)
void platformInitialize ()
 Platform-specific initialization.
void platformInitialize (bool enable_fpe)
 Platform-specific initialization.
void platformTerminate ()
 Platform-specific program termination routines.
String getCurrentDate ()
 Current date.
long getCurrentTime ()
 Current time.
Int64 getRealTimeNS ()
 Clock time in nanoseconds.
String getCurrentDateTime ()
 Current date and time in ISO 8601 format.
String getHostName ()
 Name of the machine running the process.
String getCurrentDirectory ()
 Current directory path.
int getProcessId ()
 Process ID.
String getUserName ()
 Username.
String getHomeDirectory ()
 Directory containing user documents.
long unsigned int getFileLength (const String &filename)
 Length of the file filename. If the file is not readable or does not exist, returns 0.
String getEnvironmentVariable (const String &name)
 Environment variable named name.
bool recursiveCreateDirectory (const String &dir_name)
 Create a directory.
bool createDirectory (const String &dir_name)
 Create a directory.
bool removeFile (const String &file_name)
 Delete the file file_name.
bool isFileReadable (const String &file_name)
 Checks if the file file_name is accessible and readable.
String getFileDirName (const String &file_name)
 Returns the directory name of a file.
void stdMemcpy (void *to, const void *from, ::size_t len)
 Memory block copy.
double getMemoryUsed ()
 Memory used in bytes.
Int64 getCPUTime ()
 CPU time used in microseconds.
Real getRealTime ()
 Real time used in seconds.
String timeToHourMinuteSecond (Real t)
 Returns time in hours, minutes, and seconds format.
bool isDenormalized (Real v)
 Returns true if v is denormalized (invalid float).
IStackTraceServicegetStackTraceService ()
 Service used to obtain the call stack.
IStackTraceServicesetStackTraceService (IStackTraceService *service)
 Sets the service used to obtain the call stack.
String getStackTrace ()
 Returns a string containing the call stack.
ISymbolizerServicegetSymbolizerService ()
 Service used to obtain information about source code symbols.
ISymbolizerServicesetSymbolizerService (ISymbolizerService *service)
 Sets the service to obtain information about source code symbols.
void safeStringCopy (char *output, Integer output_len, const char *input)
void sleep (Integer nb_second)
 Puts the process to sleep for nb_second seconds.
void enableFloatingException (bool active)
 Enables or disables exceptions during a floating-point calculation. This operation is not supported on all platforms. If it is not supported, nothing happens.
bool isFloatingExceptionEnabled ()
 Indicates if processor floating exceptions are enabled.
void raiseFloatingException ()
 Raises a floating exception.
bool hasFloatingExceptionSupport ()
 Indicates if the implementation allows modifying the floating exception activation state.
void dumpStackTrace (std::ostream &ostr)
 Dumps the call stack to the stream ostr.
bool getConsoleHasColor ()
 Indicates if the console supports colors.
String getCompilerId ()
 Character string used to identify the compiler used to compile Arccore.
Int64 getPageSize ()
 Host system page size in bytes.
String getLoadedSharedLibraryFullPath (const String &dll_name)
 Returns the full path of a loaded dynamic library.

Variables

IStackTraceServiceglobal_stack_trace_service = nullptr
ISymbolizerServiceglobal_symbolizer_service = nullptr
bool global_has_color_console = false

Detailed Description

Namespace for platform-dependent functions.

This namespace contains all platform-dependent functions.

Function Documentation

◆ createDirectory()

bool Arcane::Platform::createDirectory ( const String & dir_name)

Create a directory.

Creates a directory named dir_name. This function assumes that the parent directory already exists.

Return values
truein case of failure,
falsein case of success or if the directory already exists.

Definition at line 325 of file arccore/src/base/arccore/base/PlatformUtils.cc.

References Arcane::String::localstr().

Here is the call graph for this function:

◆ dumpStackTrace()

void Arcane::Platform::dumpStackTrace ( std::ostream & ostr)

Dumps the call stack to the stream ostr.

Definition at line 652 of file arccore/src/base/arccore/base/PlatformUtils.cc.

References getStackTraceService(), Arcane::IStackTraceService::stackTrace(), and Arcane::StackTrace::toString().

Here is the call graph for this function:

◆ enableFloatingException()

void Arcane::Platform::enableFloatingException ( bool active)

Enables or disables exceptions during a floating-point calculation. This operation is not supported on all platforms. If it is not supported, nothing happens.

Definition at line 680 of file arccore/src/base/arccore/base/PlatformUtils.cc.

Referenced by platformInitialize().

Here is the caller graph for this function:

◆ getCompilerId()

String Arcane::Platform::getCompilerId ( )

Character string used to identify the compiler used to compile Arccore.

Definition at line 889 of file arccore/src/base/arccore/base/PlatformUtils.cc.

References Arcane::StringBuilder::toString().

Here is the call graph for this function:

◆ getConsoleHasColor()

bool Arcane::Platform::getConsoleHasColor ( )

Indicates if the console supports colors.

Definition at line 824 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ getCPUTime()

Int64 Arcane::Platform::getCPUTime ( )

CPU time used in microseconds.

The origin of the CPU time is taken when calling platformInitialize().

Returns
the CPU time used in microseconds.

Definition at line 560 of file arccore/src/base/arccore/base/PlatformUtils.cc.

Referenced by platformInitialize().

Here is the caller graph for this function:

◆ getCurrentDate()

String Arcane::Platform::getCurrentDate ( )

Current date.

The string is returned in the format day/month/year.

Definition at line 101 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ getCurrentDateTime()

String Arcane::Platform::getCurrentDateTime ( )

Current date and time in ISO 8601 format.

The string is returned in the format YYYY-MM-DDTHH:MM:SS.

Definition at line 129 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ getCurrentDirectory()

String Arcane::Platform::getCurrentDirectory ( )

Current directory path.

Definition at line 218 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ getCurrentTime()

long Arcane::Platform::getCurrentTime ( )

Current time.

Returns the current date, expressed in seconds elapsed since January 1, 1970.

Definition at line 118 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ getEnvironmentVariable()

String Arcane::Platform::getEnvironmentVariable ( const String & name)

Environment variable named name.

If no variable named name is defined, an empty string is returned.

Definition at line 255 of file arccore/src/base/arccore/base/PlatformUtils.cc.

References Arcane::String::localstr().

Referenced by Arcane::PropertyImpl::PropertyKeyValues::getValue(), Arcane::Accelerator::Impl::RuntimeLoader::loadRuntime(), Arcane::MessagePassing::Mpi::MpiAdapter::MpiAdapter(), platformInitialize(), and Arcane::Convert::ScalarType< T >::tryParseFromEnvironment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFileDirName()

String Arcane::Platform::getFileDirName ( const String & file_name)

Returns the directory name of a file.

Returns the directory name where the file named file_name is located. For example, if file_name is "/tmp/toto.cc", it returns "/tmp". If the file does not contain directories, it returns ".".

Definition at line 351 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ getFileLength()

long unsigned int Arcane::Platform::getFileLength ( const String & filename)

Length of the file filename. If the file is not readable or does not exist, returns 0.

Definition at line 242 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ getHomeDirectory()

String Arcane::Platform::getHomeDirectory ( )

Directory containing user documents.

This corresponds to the HOME environment variable on Unix, or the 'My Documents' directory under Win32.

Definition at line 191 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ getHostName()

String Arcane::Platform::getHostName ( )

Name of the machine running the process.

Definition at line 147 of file arccore/src/base/arccore/base/PlatformUtils.cc.

Referenced by Arcane::Otf2LibWrapper::_buildOtf2ClockAndStringDefinition(), and Arcane::arccoreDebugPause().

Here is the caller graph for this function:

◆ getLoadedSharedLibraryFullPath()

String Arcane::Platform::getLoadedSharedLibraryFullPath ( const String & dll_name)

Returns the full path of a loaded dynamic library.

Returns the full path of the dynamic library named dll_name. dll_name must only contain the library name without platform-specific extensions. For example, on Linux, do not use 'libtoto.so' but just 'toto'.

Returns a null string if the full path cannot be determined.

Definition at line 833 of file arccore/src/base/arccore/base/PlatformUtils.cc.

References Arcane::String::endsWith(), Arcane::String::localstr(), Arcane::String::null(), and Arcane::SpanImpl< T, SizeType, Extent >::size().

Here is the call graph for this function:

◆ getMemoryUsed()

double Arcane::Platform::getMemoryUsed ( )

Memory used in bytes.

Returns
the memory used or a negative number if unknown

Definition at line 542 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ getPageSize()

Int64 Arcane::Platform::getPageSize ( )

Host system page size in bytes.

Definition at line 736 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ getProcessId()

int Arcane::Platform::getProcessId ( )

Process ID.

Definition at line 233 of file arccore/src/base/arccore/base/PlatformUtils.cc.

Referenced by Arcane::arccoreDebugPause().

Here is the caller graph for this function:

◆ getRealTime()

Real Arcane::Platform::getRealTime ( )

Real time used in seconds.

Returns
the time used in seconds.

Definition at line 597 of file arccore/src/base/arccore/base/PlatformUtils.cc.

Referenced by Arcane::Alina::Profiler::tic(), and Arcane::Alina::Profiler::toc().

Here is the caller graph for this function:

◆ getRealTimeNS()

Int64 Arcane::Platform::getRealTimeNS ( )

Clock time in nanoseconds.

Definition at line 723 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ getStackTrace()

String Arcane::Platform::getStackTrace ( )

Returns a string containing the call stack.

If no call stack management service is present (getStackTraceService()==0), the returned string is null.

Definition at line 448 of file arccore/src/base/arccore/base/PlatformUtils.cc.

References getStackTraceService(), Arcane::IStackTraceService::stackTrace(), and Arcane::StackTrace::toString().

Referenced by Arcane::MessagePassing::Mpi::MpiAdapter::RequestSet::_addRequest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStackTraceService()

IStackTraceService * Arcane::Platform::getStackTraceService ( )

Service used to obtain the call stack.

May return null if no service is available.

Definition at line 428 of file arccore/src/base/arccore/base/PlatformUtils.cc.

Referenced by dumpStackTrace(), and getStackTrace().

Here is the caller graph for this function:

◆ getSymbolizerService()

ISymbolizerService * Arcane::Platform::getSymbolizerService ( )

Service used to obtain information about source code symbols.

May return null if no service is available.

Definition at line 462 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ getUserName()

String Arcane::Platform::getUserName ( )

Username.

Definition at line 167 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ hasFloatingExceptionSupport()

bool Arcane::Platform::hasFloatingExceptionSupport ( )

Indicates if the implementation allows modifying the floating exception activation state.

If this method returns false, then the methods enableFloatingException() and isFloatingExceptionEnabled() have no effect.

Definition at line 670 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ isDenormalized()

bool Arcane::Platform::isDenormalized ( Real v)

Returns true if v is denormalized (invalid float).

If the platform does not support this concept, it always returns false.

Definition at line 418 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ isDirectoryExist()

bool Arcane::Platform::isDirectoryExist ( const String & dir_name,
bool & can_create )

◆ isFileReadable()

bool Arcane::Platform::isFileReadable ( const String & file_name)

Checks if the file file_name is accessible and readable.

Return values
trueif the file is readable,
falseotherwise.

Definition at line 397 of file arccore/src/base/arccore/base/PlatformUtils.cc.

References Arcane::String::localstr().

Here is the call graph for this function:

◆ isFloatingExceptionEnabled()

bool Arcane::Platform::isFloatingExceptionEnabled ( )

Indicates if processor floating exceptions are enabled.

Definition at line 697 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ platformInitialize() [1/2]

void Arcane::Platform::platformInitialize ( )

Platform-specific initialization.

This routine is called when the architecture is initialized. It allows certain operations that depend on the platform to be performed.

Activates floating exceptions if they are available.

Definition at line 807 of file arccore/src/base/arccore/base/PlatformUtils.cc.

References platformInitialize().

Referenced by platformInitialize(), and Arcane::platform::platformInitialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ platformInitialize() [2/2]

void Arcane::Platform::platformInitialize ( bool enable_fpe)

Platform-specific initialization.

This routine is called when the architecture is initialized. It allows certain operations that depend on the platform to be performed.

If enable_fpe is true, floating exceptions are enabled if they are available (via the call to enableFloatingException().

Definition at line 784 of file arccore/src/base/arccore/base/PlatformUtils.cc.

References enableFloatingException(), getCPUTime(), and getEnvironmentVariable().

Here is the call graph for this function:

◆ platformTerminate()

void Arcane::Platform::platformTerminate ( )

Platform-specific program termination routines.

Cette routine is called just before exiting the program.

Definition at line 816 of file arccore/src/base/arccore/base/PlatformUtils.cc.

Referenced by Arcane::platform::platformTerminate().

Here is the caller graph for this function:

◆ raiseFloatingException()

void Arcane::Platform::raiseFloatingException ( )

Raises a floating exception.

This method does nothing if hasFloatingExceptionSupport()==false. Generally under Linux, this translates to sending a signal of type SIGFPE. By default, Arccore catches this signal and raises an 'ArithmeticException'.

Definition at line 710 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ recursiveCreateDirectory()

bool Arcane::Platform::recursiveCreateDirectory ( const String & dir_name)

Create a directory.

Creates the directory named dir_name. If necessary, creates the required parent directories.

Return values
truein case of failure,
falsein case of success or if the directory already exists.

Definition at line 290 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ removeFile()

bool Arcane::Platform::removeFile ( const String & file_name)

Delete the file file_name.

Return values
truein case of failure,
falsein case of success or if the file does not exist.

Definition at line 384 of file arccore/src/base/arccore/base/PlatformUtils.cc.

Referenced by Arcane::TraceMng::finishInitialize().

Here is the caller graph for this function:

◆ safeStringCopy()

void Arcane::Platform::safeStringCopy ( char * output,
Integer output_len,
const char * input )

◆ setStackTraceService()

IStackTraceService * Arcane::Platform::setStackTraceService ( IStackTraceService * service)

Sets the service used to obtain the call stack.

Returns the previously used service.

Definition at line 437 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ setSymbolizerService()

ISymbolizerService * Arcane::Platform::setSymbolizerService ( ISymbolizerService * service)

Sets the service to obtain information about source code symbols.

Returns the previously used service.

Definition at line 471 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ sleep()

void Arcane::Platform::sleep ( Integer nb_second)

Puts the process to sleep for nb_second seconds.

Definition at line 636 of file arccore/src/base/arccore/base/PlatformUtils.cc.

References sleep().

Referenced by sleep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stdMemcpy()

void Arcane::Platform::stdMemcpy ( void * to,
const void * from,
::size_t len )

Memory block copy.

Copies len bytes from address from to address to.

Definition at line 409 of file arccore/src/base/arccore/base/PlatformUtils.cc.

◆ timeToHourMinuteSecond()

String Arcane::Platform::timeToHourMinuteSecond ( Real t)

Returns time in hours, minutes, and seconds format.

Converts t, expressed in seconds, into the format AhBmCs where A is hours, B is minutes, and C is seconds. For example, 3732 becomes 1h2m12s.

Definition at line 610 of file arccore/src/base/arccore/base/PlatformUtils.cc.

References Arcane::StringBuilder::toString().

Here is the call graph for this function:

Variable Documentation

◆ global_has_color_console

bool Arcane::Platform::global_has_color_console = false

◆ global_stack_trace_service

IStackTraceService* Arcane::Platform::global_stack_trace_service = nullptr

◆ global_symbolizer_service

ISymbolizerService* Arcane::Platform::global_symbolizer_service = nullptr