Clean all the mess around KMP_USE_FUTEX and kmp_lock.h

KMP_USE_FUTEX preprocessor definition defined in kmp_lock.h is used
inconsequently throughout LLVM libomp code.

* some .c files that use this define do not include kmp_lock.h file,
  in effect guarded part of code are never compiled
* some places in code use architecture-depending preprocessor
  logic expressions which effectively disable use of Futex for
  AArch64 architecture, all these places should use
  '#if KMP_USE_FUTEX' instead to avoid any further confusions
* some places use KMP_HAS_FUTEX which is nowhere defined,
  KMP_USE_FUTEX should be used instead

Differential Revision: http://reviews.llvm.org/D19629

llvm-svn: 269642
This commit is contained in:
Paul Osmialowski 2016-05-16 09:44:11 +00:00
parent a2bde88e62
commit fb043fdfff
5 changed files with 16 additions and 13 deletions

View File

@ -3132,11 +3132,11 @@ extern void __kmp_balanced_affinity( int tid, int team_size );
extern void __kmp_cleanup_hierarchy();
extern void __kmp_get_hierarchy(kmp_uint32 nproc, kmp_bstate_t *thr_bar);
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64)
#if KMP_USE_FUTEX
extern int __kmp_futex_determine_capable( void );
#endif // KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64)
#endif // KMP_USE_FUTEX
extern void __kmp_gtid_set_specific( int gtid );
extern int __kmp_gtid_get_specific( void );

View File

@ -17,6 +17,7 @@
#include "kmp.h"
#include "kmp_i18n.h"
#include "kmp_itt.h"
#include "kmp_lock.h"
#include "kmp_error.h"
#include "kmp_stats.h"

View File

@ -21,7 +21,7 @@
#include "kmp_lock.h"
#include "kmp_io.h"
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64)
#if KMP_USE_FUTEX
# include <unistd.h>
# include <sys/syscall.h>
// We should really include <futex.h>, but that causes compatibility problems on different
@ -362,7 +362,7 @@ __kmp_destroy_nested_tas_lock_with_checks( kmp_tas_lock_t *lck )
}
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64)
#if KMP_USE_FUTEX
/* ------------------------------------------------------------------------ */
/* futex locks */
@ -710,7 +710,7 @@ __kmp_destroy_nested_futex_lock_with_checks( kmp_futex_lock_t *lck )
__kmp_destroy_nested_futex_lock( lck );
}
#endif // KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
#endif // KMP_USE_FUTEX
/* ------------------------------------------------------------------------ */
@ -3496,7 +3496,7 @@ __kmp_get_user_lock_owner(kmp_user_lock_p lck, kmp_uint32 seq)
case lockseq_tas:
case lockseq_nested_tas:
return __kmp_get_tas_lock_owner((kmp_tas_lock_t *)lck);
#if KMP_HAS_FUTEX
#if KMP_USE_FUTEX
case lockseq_futex:
case lockseq_nested_futex:
return __kmp_get_futex_lock_owner((kmp_futex_lock_t *)lck);
@ -3721,7 +3721,7 @@ void __kmp_set_user_lock_vptrs( kmp_lock_kind_t user_lock_kind )
}
break;
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
#if KMP_USE_FUTEX
case lk_futex: {
__kmp_base_user_lock_size = sizeof( kmp_base_futex_lock_t );
@ -3761,7 +3761,7 @@ void __kmp_set_user_lock_vptrs( kmp_lock_kind_t user_lock_kind )
}
break;
#endif // KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
#endif // KMP_USE_FUTEX
case lk_ticket: {
__kmp_base_user_lock_size = sizeof( kmp_base_ticket_lock_t );

View File

@ -21,6 +21,7 @@
#include "kmp_str.h"
#include "kmp_settings.h"
#include "kmp_i18n.h"
#include "kmp_lock.h"
#include "kmp_io.h"
static int __kmp_env_toPrint( char const * name, int flag );
@ -3924,7 +3925,7 @@ __kmp_stg_parse_lock_kind( char const * name, char const * value, void * data )
__kmp_user_lock_kind = lk_tas;
KMP_STORE_LOCK_SEQ(tas);
}
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
#if KMP_USE_FUTEX
else if ( __kmp_str_match( "futex", 1, value ) ) {
if ( __kmp_futex_determine_capable() ) {
__kmp_user_lock_kind = lk_futex;
@ -3998,7 +3999,7 @@ __kmp_stg_print_lock_kind( kmp_str_buf_t * buffer, char const * name, void * dat
value = "tas";
break;
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
#if KMP_USE_FUTEX
case lk_futex:
value = "futex";
break;

View File

@ -18,6 +18,7 @@
#include "kmp_itt.h"
#include "kmp_str.h"
#include "kmp_i18n.h"
#include "kmp_lock.h"
#include "kmp_io.h"
#include "kmp_stats.h"
#include "kmp_wait_release.h"
@ -34,7 +35,7 @@
#if KMP_OS_LINUX && !KMP_OS_CNK
# include <sys/sysinfo.h>
# if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64)
# if KMP_USE_FUTEX
// We should really include <futex.h>, but that causes compatibility problems on different
// Linux* OS distributions that either require that you include (or break when you try to include)
// <pci/types.h>.
@ -422,7 +423,7 @@ __kmp_affinity_determine_capable(const char *env_var)
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && !KMP_OS_CNK
#if KMP_USE_FUTEX && !KMP_OS_CNK
int
__kmp_futex_determine_capable()
@ -439,7 +440,7 @@ __kmp_futex_determine_capable()
return retval;
}
#endif // KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM) && !KMP_OS_CNK
#endif // KMP_USE_FUTEX && !KMP_OS_CNK
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */