[Openmp-commits] [openmp] r227199 - Replaces KMP_OS_WINDOWS && KMP_ARCH_X86_64 or any combination of those two options with the feature macro KMP_GROUP_AFFINITY.

Andrey Churbanov Andrey.Churbanov at intel.com
Tue Jan 27 08:52:58 PST 2015


Author: achurbanov
Date: Tue Jan 27 10:52:57 2015
New Revision: 227199

URL: http://llvm.org/viewvc/llvm-project?rev=227199&view=rev
Log:
Replaces KMP_OS_WINDOWS && KMP_ARCH_X86_64 or any combination of those two options with the feature macro KMP_GROUP_AFFINITY.

Modified:
    openmp/trunk/runtime/src/kmp.h
    openmp/trunk/runtime/src/kmp_affinity.cpp
    openmp/trunk/runtime/src/kmp_ftn_entry.h
    openmp/trunk/runtime/src/kmp_global.c
    openmp/trunk/runtime/src/kmp_os.h
    openmp/trunk/runtime/src/kmp_settings.c
    openmp/trunk/runtime/src/z_Windows_NT_util.c

Modified: openmp/trunk/runtime/src/kmp.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp.h?rev=227199&r1=227198&r2=227199&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp.h (original)
+++ openmp/trunk/runtime/src/kmp.h Tue Jan 27 10:52:57 2015
@@ -547,7 +547,7 @@ typedef unsigned char kmp_affin_mask_t;
 // Intel(R) 64 it is 8 bytes times the number of processor groups.
 //
 
-#  if KMP_ARCH_X86_64
+#  if KMP_GROUP_AFFINITY
 
 // GROUP_AFFINITY is already defined for _MSC_VER>=1600 (VS2010 and later).
 #   if _MSC_VER < 1600
@@ -644,7 +644,7 @@ typedef DWORD kmp_affin_mask_t; /* for c
 #   define KMP_CPU_COMPLEMENT(mask) (*(mask) = ~*(mask))
 #   define KMP_CPU_UNION(dest, src) (*(dest) |= *(src))
 
-#  endif /* KMP_ARCH_X86 */
+#  endif /* KMP_GROUP_AFFINITY */
 
 # endif /* KMP_OS_WINDOWS */
 
@@ -690,13 +690,13 @@ enum affinity_gran {
     affinity_gran_core,
     affinity_gran_package,
     affinity_gran_node,
-#if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+#if KMP_GROUP_AFFINITY
     //
     // The "group" granularity isn't necesssarily coarser than all of the
     // other levels, but we put it last in the enum.
     //
     affinity_gran_group,
-#endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+#endif /* KMP_GROUP_AFFINITY */
     affinity_gran_default
 };
 
@@ -707,9 +707,9 @@ enum affinity_top_method {
     affinity_top_method_x2apicid,
 #endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */
     affinity_top_method_cpuinfo, // KMP_CPUINFO_FILE is usable on Windows* OS, too
-#if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+#if KMP_GROUP_AFFINITY
     affinity_top_method_group,
-#endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+#endif /* KMP_GROUP_AFFINITY */
     affinity_top_method_flat,
     affinity_top_method_default
 };

Modified: openmp/trunk/runtime/src/kmp_affinity.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_affinity.cpp?rev=227199&r1=227198&r2=227199&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_affinity.cpp (original)
+++ openmp/trunk/runtime/src/kmp_affinity.cpp Tue Jan 27 10:52:57 2015
@@ -85,7 +85,7 @@ __kmp_affinity_entire_machine_mask(kmp_a
 {
     KMP_CPU_ZERO(mask);
 
-# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+# if KMP_GROUP_AFFINITY
 
     if (__kmp_num_proc_groups > 1) {
         int group;
@@ -100,7 +100,7 @@ __kmp_affinity_entire_machine_mask(kmp_a
     }
     else
 
-# endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+# endif /* KMP_GROUP_AFFINITY */
 
     {
         int proc;
@@ -641,7 +641,7 @@ __kmp_affinity_create_flat_map(AddrUnsPa
 }
 
 
-# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+# if KMP_GROUP_AFFINITY
 
 //
 // If multiple Windows* OS processor groups exist, we can create a 2-level
@@ -723,7 +723,7 @@ __kmp_affinity_create_proc_group_map(Add
     return 2;
 }
 
-# endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+# endif /* KMP_GROUP_AFFINITY */
 
 
 # if KMP_ARCH_X86 || KMP_ARCH_X86_64
@@ -3541,7 +3541,7 @@ __kmp_aux_affinity_initialize(void)
 
 # endif /* KMP_OS_LINUX */
 
-# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+# if KMP_GROUP_AFFINITY
 
         if ((depth < 0) && (__kmp_num_proc_groups > 1)) {
             if (__kmp_affinity_verbose) {
@@ -3552,7 +3552,7 @@ __kmp_aux_affinity_initialize(void)
             KMP_ASSERT(depth != 0);
         }
 
-# endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+# endif /* KMP_GROUP_AFFINITY */
 
         if (depth < 0) {
             if (__kmp_affinity_verbose && (msg_id != kmp_i18n_null)) {
@@ -3678,7 +3678,7 @@ __kmp_aux_affinity_initialize(void)
         }
     }
 
-# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+# if KMP_GROUP_AFFINITY
 
     else if (__kmp_affinity_top_method == affinity_top_method_group) {
         if (__kmp_affinity_verbose) {
@@ -3693,7 +3693,7 @@ __kmp_aux_affinity_initialize(void)
         }
     }
 
-# endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+# endif /* KMP_GROUP_AFFINITY */
 
     else if (__kmp_affinity_top_method == affinity_top_method_flat) {
         if (__kmp_affinity_verbose) {
@@ -4019,7 +4019,7 @@ __kmp_affinity_set_init_mask(int gtid, i
     {
         if ((__kmp_affinity_type == affinity_none) || (__kmp_affinity_type == affinity_balanced)
           ) {
-# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+# if KMP_GROUP_AFFINITY
             if (__kmp_num_proc_groups > 1) {
                 return;
             }
@@ -4038,7 +4038,7 @@ __kmp_affinity_set_init_mask(int gtid, i
     else {
         if ((! isa_root)
           || (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
-#  if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+#  if KMP_GROUP_AFFINITY
             if (__kmp_num_proc_groups > 1) {
                 return;
             }
@@ -4206,11 +4206,11 @@ __kmp_aux_set_affinity(void **mask)
                 KMP_FATAL(AffinityInvalidMask, "kmp_set_affinity");
             }
 
-# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+# if KMP_GROUP_AFFINITY
             if (__kmp_get_proc_group((kmp_affin_mask_t *)(*mask)) < 0) {
                 KMP_FATAL(AffinityInvalidMask, "kmp_set_affinity");
             }
-# endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+# endif /* KMP_GROUP_AFFINITY */
 
         }
     }

Modified: openmp/trunk/runtime/src/kmp_ftn_entry.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_ftn_entry.h?rev=227199&r1=227198&r2=227199&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_ftn_entry.h (original)
+++ openmp/trunk/runtime/src/kmp_ftn_entry.h Tue Jan 27 10:52:57 2015
@@ -259,11 +259,11 @@ FTN_GET_AFFINITY_MAX_PROC( void )
             return 0;
         }
 
-    #if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+    #if KMP_GROUP_AFFINITY
         if ( __kmp_num_proc_groups <= 1 ) {
             return (int)KMP_CPU_SETSIZE;
         }
-    #endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+    #endif /* KMP_GROUP_AFFINITY */
         return __kmp_xproc;
     #endif
 }

Modified: openmp/trunk/runtime/src/kmp_global.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_global.c?rev=227199&r1=227198&r2=227199&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_global.c (original)
+++ openmp/trunk/runtime/src/kmp_global.c Tue Jan 27 10:52:57 2015
@@ -217,7 +217,7 @@ int __kmp_clock_function_param;
 
 #if KMP_AFFINITY_SUPPORTED
 
-# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+# if KMP_GROUP_AFFINITY
 
 int __kmp_num_proc_groups = 1;
 
@@ -226,7 +226,7 @@ kmp_GetActiveProcessorGroupCount_t __kmp
 kmp_GetThreadGroupAffinity_t __kmp_GetThreadGroupAffinity = NULL;
 kmp_SetThreadGroupAffinity_t __kmp_SetThreadGroupAffinity = NULL;
 
-# endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+# endif /* KMP_GROUP_AFFINITY */
 
 size_t   __kmp_affin_mask_size = 0;
 enum affinity_type __kmp_affinity_type = affinity_default;

Modified: openmp/trunk/runtime/src/kmp_os.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_os.h?rev=227199&r1=227198&r2=227199&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_os.h (original)
+++ openmp/trunk/runtime/src/kmp_os.h Tue Jan 27 10:52:57 2015
@@ -121,12 +121,6 @@
 # define KMP_OS_UNIX 1
 #endif
 
-#if (KMP_OS_LINUX || KMP_OS_WINDOWS) && !KMP_OS_CNK && !KMP_ARCH_PPC64
-# define KMP_AFFINITY_SUPPORTED 1
-#else
-# define KMP_AFFINITY_SUPPORTED 0
-#endif
-
 #if KMP_OS_WINDOWS
 # if defined _M_AMD64
 #  undef KMP_ARCH_X86_64
@@ -199,6 +193,18 @@
 # error Unknown or unsupported architecture
 #endif
 
+#if (KMP_OS_LINUX || KMP_OS_WINDOWS) && !KMP_OS_CNK && !KMP_ARCH_PPC64
+# define KMP_AFFINITY_SUPPORTED 1
+# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+#  define KMP_GROUP_AFFINITY    1
+# else
+#  define KMP_GROUP_AFFINITY    0
+# endif
+#else
+# define KMP_AFFINITY_SUPPORTED 0
+# define KMP_GROUP_AFFINITY     0
+#endif
+
 /* Check for quad-precision extension. */
 #define KMP_HAVE_QUAD 0
 #if KMP_ARCH_X86 || KMP_ARCH_X86_64

Modified: openmp/trunk/runtime/src/kmp_settings.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_settings.c?rev=227199&r1=227198&r2=227199&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_settings.c (original)
+++ openmp/trunk/runtime/src/kmp_settings.c Tue Jan 27 10:52:57 2015
@@ -2192,11 +2192,11 @@ __kmp_parse_affinity_env( char const * n
             } else if (__kmp_match_str("node", buf, (const char **)&next)) {
                 set_gran( affinity_gran_node, -1 );
                 buf = next;
-# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+# if KMP_GROUP_AFFINITY
             } else if (__kmp_match_str("group", buf, (const char **)&next)) {
                 set_gran( affinity_gran_group, -1 );
                 buf = next;
-# endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+# endif /* KMP_GROUP AFFINITY */
             } else if ((*buf >= '0') && (*buf <= '9')) {
                 int n;
                 next = buf;
@@ -2430,11 +2430,11 @@ __kmp_stg_print_affinity( kmp_str_buf_t
             case affinity_gran_node:
                 __kmp_str_buf_print( buffer, "%s", "granularity=node,");
                 break;
-# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+# if KMP_GROUP_AFFINITY
             case affinity_gran_group:
                 __kmp_str_buf_print( buffer, "%s", "granularity=group,");
                 break;
-# endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+# endif /* KMP_GROUP_AFFINITY */
         }
         if ( __kmp_affinity_dups ) {
             __kmp_str_buf_print( buffer, "%s,", "duplicates");
@@ -3103,11 +3103,11 @@ __kmp_stg_parse_topology_method( char co
       || __kmp_str_match( "cpuinfo", 5, value )) {
         __kmp_affinity_top_method = affinity_top_method_cpuinfo;
     }
-# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+# if KMP_GROUP_AFFINITY
     else if ( __kmp_str_match( "group", 1, value ) ) {
         __kmp_affinity_top_method = affinity_top_method_group;
     }
-# endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+# endif /* KMP_GROUP_AFFINITY */
     else if ( __kmp_str_match( "flat", 1, value ) ) {
         __kmp_affinity_top_method = affinity_top_method_flat;
     }
@@ -3145,11 +3145,11 @@ __kmp_stg_print_topology_method( kmp_str
         value = "cpuinfo";
         break;
 
-#  if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+#  if KMP_GROUP_AFFINITY
         case affinity_top_method_group:
         value = "group";
         break;
-#  endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+#  endif /* KMP_GROUP_AFFINITY */
 
         case affinity_top_method_flat:
         value = "flat";
@@ -5106,7 +5106,7 @@ __kmp_env_initialize( char const * strin
 
         if ( KMP_AFFINITY_CAPABLE() ) {
 
-# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+# if KMP_GROUP_AFFINITY
 
             //
             // Handle the Win 64 group affinity stuff if there are multiple
@@ -5180,16 +5180,16 @@ __kmp_env_initialize( char const * strin
             }
             else
 
-# endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+# endif /* KMP_GROUP_AFFINITY */
 
             {
                 if ( __kmp_affinity_respect_mask == affinity_respect_mask_default ) {
-# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
+# if KMP_GROUP_AFFINITY
                     if ( __kmp_num_proc_groups > 1 ) {
                         __kmp_affinity_respect_mask = FALSE;
                     }
                     else
-# endif /* KMP_OS_WINDOWS && KMP_ARCH_X86_64 */
+# endif /* KMP_GROUP_AFFINITY */
                     {
                         __kmp_affinity_respect_mask = TRUE;
                     }

Modified: openmp/trunk/runtime/src/z_Windows_NT_util.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/z_Windows_NT_util.c?rev=227199&r1=227198&r2=227199&view=diff
==============================================================================
--- openmp/trunk/runtime/src/z_Windows_NT_util.c (original)
+++ openmp/trunk/runtime/src/z_Windows_NT_util.c Tue Jan 27 10:52:57 2015
@@ -134,9 +134,9 @@ HMODULE ntdll = NULL;
 
 /* End of NtQuerySystemInformation()-related code */
 
-#if KMP_ARCH_X86_64
+#if KMP_GROUP_AFFINITY
 static HMODULE kernel32 = NULL;
-#endif /* KMP_ARCH_X86_64 */
+#endif /* KMP_GROUP_AFFINITY */
 
 /* ----------------------------------------------------------------------------------- */
 /* ----------------------------------------------------------------------------------- */
@@ -547,7 +547,7 @@ __kmp_gtid_get_specific()
 /* ------------------------------------------------------------------------ */
 /* ------------------------------------------------------------------------ */
 
-#if KMP_ARCH_X86_64
+#if KMP_GROUP_AFFINITY
 
 //
 // Only 1 DWORD in the mask should have any procs set.
@@ -570,13 +570,13 @@ __kmp_get_proc_group( kmp_affin_mask_t c
     return group;
 }
 
-#endif /* KMP_ARCH_X86_64 */
+#endif /* KMP_GROUP_AFFINITY */
 
 int
 __kmp_set_system_affinity( kmp_affin_mask_t const *mask, int abort_on_error )
 {
 
-#if KMP_ARCH_X86_64
+#if KMP_GROUP_AFFINITY
 
     if (__kmp_num_proc_groups > 1) {
         //
@@ -615,7 +615,7 @@ __kmp_set_system_affinity( kmp_affin_mas
     }
     else
 
-#endif /* KMP_ARCH_X86_64 */
+#endif /* KMP_GROUP_AFFINITY */
 
     {
         if (!SetThreadAffinityMask( GetCurrentThread(), *mask )) {
@@ -638,7 +638,7 @@ int
 __kmp_get_system_affinity( kmp_affin_mask_t *mask, int abort_on_error )
 {
 
-#if KMP_ARCH_X86_64
+#if KMP_GROUP_AFFINITY
 
     if (__kmp_num_proc_groups > 1) {
         KMP_CPU_ZERO(mask);
@@ -667,7 +667,7 @@ __kmp_get_system_affinity( kmp_affin_mas
     }
     else
 
-#endif /* KMP_ARCH_X86_64 */
+#endif /* KMP_GROUP_AFFINITY */
 
     {
         kmp_affin_mask_t newMask, sysMask, retval;
@@ -718,7 +718,7 @@ void
 __kmp_affinity_bind_thread( int proc )
 {
 
-#if KMP_ARCH_X86_64
+#if KMP_GROUP_AFFINITY
 
     if (__kmp_num_proc_groups > 1) {
         //
@@ -747,7 +747,7 @@ __kmp_affinity_bind_thread( int proc )
     }
     else
 
-#endif /* KMP_ARCH_X86_64 */
+#endif /* KMP_GROUP_AFFINITY */
 
     {
         kmp_affin_mask_t mask;
@@ -764,7 +764,7 @@ __kmp_affinity_determine_capable( const
     // All versions of Windows* OS (since Win '95) support SetThreadAffinityMask().
     //
 
-#if KMP_ARCH_X86_64
+#if KMP_GROUP_AFFINITY
     __kmp_affin_mask_size = __kmp_num_proc_groups * sizeof(kmp_affin_mask_t);
 #else
     __kmp_affin_mask_size = sizeof(kmp_affin_mask_t);
@@ -920,7 +920,7 @@ __kmp_runtime_initialize( void )
     }
     KMP_DEBUG_ASSERT( NtQuerySystemInformation != NULL );
 
-#if KMP_ARCH_X86_64
+#if KMP_GROUP_AFFINITY
     //
     // Load kernel32.dll.
     // Same caveat - must use full system path name.
@@ -985,7 +985,7 @@ __kmp_runtime_initialize( void )
 #else
     GetSystemInfo( & info );
     __kmp_xproc = info.dwNumberOfProcessors;
-#endif // KMP_ARCH_X86_64
+#endif /* KMP_GROUP_AFFINITY */
 
     //
     // If the OS said there were 0 procs, take a guess and use a value of 2.





More information about the Openmp-commits mailing list