46 #include <sys/types.h>
47 #include <sys/syscall.h>
50 #if defined(G4MULTITHREADED)
57 G4bool isMTAppType =
false;
63 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
65 pthread_threadid_np(NULL, &tid64);
68 return syscall(SYS_thread_selfid);
71 return GetCurrentThreadId();
73 return syscall(SYS_gettid);
81 GetSystemInfo( &sysinfo );
82 return static_cast<G4int>( sysinfo.dwNumberOfProcessors );
84 return static_cast<G4int>(sysconf( _SC_NPROCESSORS_ONLN ));
93 #if defined(WIN32) // WIN32 stuff needed for MT
94 DWORD G4WaitForSingleObjectInf( __in
G4Mutex m )
95 {
return WaitForSingleObject( m , INFINITE); }
97 {
return ReleaseMutex(m); }
100 #if defined(__linux__) || defined(_AIX)
103 cpu_set_t* aset =
new cpu_set_t;
107 return ( pthread_setaffinity_np(aT,
sizeof(cpu_set_t), aset) == 0 );
109 #else //Not available for Mac, WIN,...
114 "Affinity setting not available for this architecture, ignoring...");
124 std::atomic_int numActThreads(0);
130 #else // Sequential mode
137 return GetCurrentProcessId();
G4bool G4SetPinAffinity(G4int idx, G4Thread &at)
void SetMultithreadedApplication(G4bool value)
G4int GetNumberOfRunningWorkerThreads()
int WorkerThreadLeavesPool()
void G4SetThreadId(G4int aNewValue)
static constexpr double m
const XML_Char int const XML_Char * value
G4int G4GetNumberOfCores()
int WorkerThreadJoinsPool()
G4bool IsMultithreadedApplication()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4int fake_mutex_lock_unlock(G4Mutex *)