[Mesa-dev] [PATCH] build: fixup pthread_setaffinity_np checking
Eric Engestrom
eric.engestrom at intel.com
Thu Sep 20 14:19:45 UTC 2018
On Thursday, 2018-09-20 14:56:03 +0100, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
>
> Use the correct guard name (was missing the _NP) and use the
> AC_CHECK_FUNCS helper instead of opencoding it.
>
> Fixes: 3acc18fcf7c ("move pthread_setaffinity_np check to the build system")
> Cc: Dylan Baker <dylan at pnwbakers.com>
> Cc: Eric Engestrom <eric.engestrom at intel.com>
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
> ---
> configure.ac | 13 +------------
> meson.build | 2 +-
> src/gallium/auxiliary/util/u_helpers.c | 4 ++--
> src/util/u_thread.h | 4 ++--
> 4 files changed, 6 insertions(+), 17 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 7583a375ad7..c2fd762bbf5 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -970,18 +970,7 @@ fi
>
> save_LIBS="$LIBS"
> LIBS="$PTHREAD_LIBS"
> -AC_MSG_CHECKING(whether pthread_setaffinity_np is supported)
> -AC_LINK_IFELSE([AC_LANG_SOURCE([[
> - #define _GNU_SOURCE
> - #include <pthread.h>
> - int main() {
> - void *a = (void*) &pthread_setaffinity_np;
> - long b = (long) a;
> - return (int) b;
> - }]])],
> - [DEFINES="$DEFINES -DHAVE_PTHREAD_SETAFFINITY"];
> - AC_MSG_RESULT([yes]),
> - AC_MSG_RESULT([no]))
> +AC_CHECK_FUNCS([pthread_setaffinity_np])
How does autoconf know to #define _GNU_SOURCE and #include <pthread.h> ?
Are you sure your check is working as previously?
> LIBS="$save_LIBS"
>
> dnl Check for futex for fast inline simple_mtx_t.
> diff --git a/meson.build b/meson.build
> index 0588ebf8e7a..d58d850bb33 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1075,7 +1075,7 @@ if dep_thread.found() and host_machine.system() != 'windows'
> dependencies : dep_thread,
> prefix : '#include <pthread.h>',
> args : '-D_GNU_SOURCE')
> - pre_args += '-DHAVE_PTHREAD_SETAFFINITY'
> + pre_args += '-DHAVE_PTHREAD_SETAFFINITY_NP'
> endif
> endif
> if with_amd_vk or with_gallium_radeonsi or with_gallium_r600 or with_gallium_opencl
> diff --git a/src/gallium/auxiliary/util/u_helpers.c b/src/gallium/auxiliary/util/u_helpers.c
> index b6cebf96329..149bfb10aad 100644
> --- a/src/gallium/auxiliary/util/u_helpers.c
> +++ b/src/gallium/auxiliary/util/u_helpers.c
> @@ -121,7 +121,7 @@ util_upload_index_buffer(struct pipe_context *pipe,
> return *out_buffer != NULL;
> }
>
> -#ifdef HAVE_PTHREAD_SETAFFINITY
> +#ifdef HAVE_PTHREAD_SETAFFINITY_NP
>
> static unsigned L3_cache_number;
> static once_flag thread_pinning_once_flag = ONCE_FLAG_INIT;
> @@ -169,7 +169,7 @@ util_init_thread_pinning(void)
> void
> util_context_thread_changed(struct pipe_context *ctx, thrd_t *upper_thread)
> {
> -#ifdef HAVE_PTHREAD_SETAFFINITY
> +#ifdef HAVE_PTHREAD_SETAFFINITY_NP
> /* If pinning has no effect, don't do anything. */
> if (util_cpu_caps.nr_cpus == util_cpu_caps.cores_per_L3)
> return;
> diff --git a/src/util/u_thread.h b/src/util/u_thread.h
> index 7538d7d634b..84b662bbf94 100644
> --- a/src/util/u_thread.h
> +++ b/src/util/u_thread.h
> @@ -82,7 +82,7 @@ static inline void u_thread_setname( const char *name )
> static inline void
> util_pin_thread_to_L3(thrd_t thread, unsigned L3_index, unsigned cores_per_L3)
> {
> -#if defined(HAVE_PTHREAD_SETAFFINITY)
> +#if defined(HAVE_PTHREAD_SETAFFINITY_NP)
> cpu_set_t cpuset;
>
> CPU_ZERO(&cpuset);
> @@ -102,7 +102,7 @@ util_pin_thread_to_L3(thrd_t thread, unsigned L3_index, unsigned cores_per_L3)
> static inline int
> util_get_L3_for_pinned_thread(thrd_t thread, unsigned cores_per_L3)
> {
> -#if defined(HAVE_PTHREAD_SETAFFINITY)
> +#if defined(HAVE_PTHREAD_SETAFFINITY_NP)
> cpu_set_t cpuset;
>
> if (pthread_getaffinity_np(thread, sizeof(cpuset), &cpuset) == 0) {
> --
> 2.19.0
>
More information about the mesa-dev
mailing list