The Linux version of tMPI_Thread_setaffinity_support() did not check
whether pthread_setaffinity_np() would actually work on the system
it's running on. It now checks by running pthread_getaffinity_np()
and checking its return value.
This is relevant for, for example, Bluegene systems which don't
support explicit affinity setting.
Change-Id: I4833e7384067f897013d6fa4d0b35963ae740fcf
enum tMPI_Thread_setaffinity_support tMPI_Thread_setaffinity_support(void)
{
#ifdef HAVE_PTHREAD_SETAFFINITY
- return TMPI_SETAFFINITY_SUPPORT_YES;
+ cpu_set_t set;
+ int ret;
+
+ /* run getaffinity to check whether we get back ENOSYS */
+ ret=pthread_getaffinity_np(pthread_self(), sizeof(set), &set);
+ if (ret == 0)
+ {
+ return TMPI_SETAFFINITY_SUPPORT_YES;
+ }
+ else
+ {
+ return TMPI_SETAFFINITY_SUPPORT_NO;
+ }
#else
return TMPI_SETAFFINITY_SUPPORT_NO;
#endif