[Mesa-dev] [PATCH 1/2] util: try to fix the Android build

Tapani Pälli tapani.palli at intel.com
Mon Sep 10 05:07:05 UTC 2018



On 09/10/2018 08:02 AM, Tapani Pälli wrote:
> Thanks Marek, this fixes the build.

(and reason for breakage was that bionic does not have 
pthread_setaffinity_np)

> Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
> 
> On 09/09/2018 04:02 AM, Marek Olšák wrote:
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> ---
>>   src/util/u_thread.h | 7 +++++--
>>   1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/util/u_thread.h b/src/util/u_thread.h
>> index ec0d9a7..0c20ebb 100644
>> --- a/src/util/u_thread.h
>> +++ b/src/util/u_thread.h
>> @@ -29,20 +29,23 @@
>>   #include <stdint.h>
>>   #include <stdbool.h>
>>   #include "c11/threads.h"
>>   #ifdef HAVE_PTHREAD
>>   #include <signal.h>
>>   #endif
>> +#if defined(HAVE_PTHREAD) && !defined(ANDROID)
>> +#define HAVE_PTHREAD_SETAFFINITY
>> +#endif
>>   static inline thrd_t u_thread_create(int (*routine)(void *), void 
>> *param)
>>   {
>>      thrd_t thread;
>>   #ifdef HAVE_PTHREAD
>>      sigset_t saved_set, new_set;
>>      int ret;
>>      sigfillset(&new_set);
>>      pthread_sigmask(SIG_SETMASK, &new_set, &saved_set);
>> @@ -76,41 +79,41 @@ static inline void u_thread_setname( const char 
>> *name )
>>    * is very expensive. It's desirable to pin a group of closely 
>> cooperating
>>    * threads to one group of cores sharing L3.
>>    *
>>    * \param thread        thread
>>    * \param L3_index      index of the L3 cache
>>    * \param cores_per_L3  number of CPU cores shared by one L3
>>    */
>>   static inline void
>>   util_pin_thread_to_L3(thrd_t thread, unsigned L3_index, unsigned 
>> cores_per_L3)
>>   {
>> -#if defined(HAVE_PTHREAD)
>> +#if defined(HAVE_PTHREAD_SETAFFINITY)
>>      cpu_set_t cpuset;
>>      CPU_ZERO(&cpuset);
>>      for (unsigned i = 0; i < cores_per_L3; i++)
>>         CPU_SET(L3_index * cores_per_L3 + i, &cpuset);
>>      pthread_setaffinity_np(thread, sizeof(cpuset), &cpuset);
>>   #endif
>>   }
>>   /**
>>    * Return the index of L3 that the thread is pinned to. If the 
>> thread is
>>    * pinned to multiple L3 caches, return -1.
>>    *
>>    * \param thread        thread
>>    * \param cores_per_L3  number of CPU cores shared by one L3
>>    */
>>   static inline int
>>   util_get_L3_for_pinned_thread(thrd_t thread, unsigned cores_per_L3)
>>   {
>> -#if defined(HAVE_PTHREAD)
>> +#if defined(HAVE_PTHREAD_SETAFFINITY)
>>      cpu_set_t cpuset;
>>      if (pthread_getaffinity_np(thread, sizeof(cpuset), &cpuset) == 0) {
>>         int L3_index = -1;
>>         for (unsigned i = 0; i < CPU_SETSIZE; i++) {
>>            if (CPU_ISSET(i, &cpuset)) {
>>               int x = i / cores_per_L3;
>>               if (L3_index != x) {
>>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list