46 #include <sys/types.h> 47 #include <sys/syscall.h> 50 #if defined(G4MULTITHREADED) 55 G4bool isMTAppType =
false;
61 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12 63 pthread_threadid_np(NULL, &tid64);
66 return syscall(SYS_thread_selfid);
69 return GetCurrentThreadId();
71 return syscall(SYS_gettid);
79 GetSystemInfo( &sysinfo );
80 return static_cast<G4int>( sysinfo.dwNumberOfProcessors );
82 return static_cast<G4int>(sysconf( _SC_NPROCESSORS_ONLN ));
91 #if defined(WIN32) // WIN32 stuff needed for MT 92 DWORD G4WaitForSingleObjectInf( __in
G4Mutex m )
93 {
return WaitForSingleObject( m , INFINITE); }
95 {
return ReleaseMutex(m); }
98 #if defined(__linux__) || defined(_AIX) 101 cpu_set_t* aset =
new cpu_set_t;
105 return ( pthread_setaffinity_np(aT,
sizeof(cpu_set_t), aset) == 0 );
107 #else //Not available for Mac, WIN,... 112 "Affinity setting not available for this architecture, ignoring...");
120 #else // Sequential mode 127 return GetCurrentProcessId();
G4bool G4SetPinAffinity(G4int idx, G4Thread &at)
void SetMultithreadedApplication(G4bool value)
void G4SetThreadId(G4int aNewValue)
G4int G4GetNumberOfCores()
G4bool IsMultithreadedApplication()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4int fake_mutex_lock_unlock(G4Mutex *)