00001 00029 #ifndef GALOIS_RUNTIME_LL_HWTOPO_H 00030 #define GALOIS_RUNTIME_LL_HWTOPO_H 00031 00032 namespace Galois { 00033 namespace Runtime { 00034 namespace LL { 00035 00037 bool bindThreadToProcessor(int galois_thread_id); 00039 unsigned getProcessorForThread(int galois_thread_id); 00041 unsigned getMaxThreads(); 00043 unsigned getMaxCores(); 00045 unsigned getMaxPackages(); 00047 unsigned getPackageForThread(int galois_thread_id); 00049 unsigned getMaxPackageForThread(int galois_thread_id); 00051 bool isPackageLeader(int galois_thread_id); 00052 00053 unsigned getLeaderForThread(int galois_thread_id); 00054 unsigned getLeaderForPackage(int galois_pkg_id); 00055 00056 extern __thread unsigned PACKAGE_ID; 00057 00058 static inline unsigned fillPackageID(int galois_thread_id) { 00059 unsigned x = getPackageForThread(galois_thread_id); 00060 bool y = isPackageLeader(galois_thread_id); 00061 x = (x << 2) | ((y ? 1 : 0) << 1) | 1; 00062 PACKAGE_ID = x; 00063 return x; 00064 } 00065 00067 static inline unsigned getPackageForSelf(int galois_thread_id) { 00068 unsigned x = PACKAGE_ID; 00069 if (x & 1) 00070 return x >> 2; 00071 x = fillPackageID(galois_thread_id); 00072 return x >> 2; 00073 } 00074 00076 static inline bool isPackageLeaderForSelf(int galois_thread_id) { 00077 unsigned x = PACKAGE_ID; 00078 if (x & 1) 00079 return (x >> 1) & 1; 00080 x = fillPackageID(galois_thread_id); 00081 return (x >> 1) & 1; 00082 } 00083 00084 } 00085 } 00086 } // end namespace Galois 00087 00088 #endif //_HWTOPO_H