kmp_os.h

Go to the documentation of this file.
00001 /*
00002  * kmp_os.h -- KPTS runtime header file.
00003  * $Revision: 42199 $
00004  * $Date: 2013-03-28 10:02:41 -0500 (Thu, 28 Mar 2013) $
00005  */
00006 
00007 /* <copyright>
00008     Copyright (c) 1997-2013 Intel Corporation.  All Rights Reserved.
00009 
00010     Redistribution and use in source and binary forms, with or without
00011     modification, are permitted provided that the following conditions
00012     are met:
00013 
00014       * Redistributions of source code must retain the above copyright
00015         notice, this list of conditions and the following disclaimer.
00016       * Redistributions in binary form must reproduce the above copyright
00017         notice, this list of conditions and the following disclaimer in the
00018         documentation and/or other materials provided with the distribution.
00019       * Neither the name of Intel Corporation nor the names of its
00020         contributors may be used to endorse or promote products derived
00021         from this software without specific prior written permission.
00022 
00023     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00026     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00027     HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00028     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00029     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00030     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00031     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00033     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 
00035 
00036 ------------------------------------------------------------------------
00037 
00038     Portions of this software are protected under the following patents:
00039         U.S. Patent 5,812,852
00040         U.S. Patent 6,792,599
00041         U.S. Patent 7,069,556
00042         U.S. Patent 7,328,433
00043         U.S. Patent 7,500,242
00044 
00045 </copyright> */
00046 
00047 #ifndef KMP_OS_H
00048 #define KMP_OS_H
00049 
00050 #include <stdlib.h>
00051 
00052 #define KMP_FTN_PLAIN   1
00053 #define KMP_FTN_APPEND  2
00054 #define KMP_FTN_UPPER   3
00055 /*
00056 #define KMP_FTN_PREPEND 4
00057 #define KMP_FTN_UAPPEND 5
00058 */
00059 
00060 #define KMP_PTR_SKIP    (sizeof(void*))
00061 
00062 /* -------------------------- Compiler variations ------------------------ */
00063 
00064 #define KMP_OFF             0
00065 #define KMP_ON              1
00066 
00067 #define KMP_MEM_CONS_VOLATILE       0
00068 #define KMP_MEM_CONS_FENCE      1
00069 
00070 #ifndef KMP_MEM_CONS_MODEL
00071 # define KMP_MEM_CONS_MODEL  KMP_MEM_CONS_VOLATILE
00072 #endif
00073 
00074 /* ---------------------- Operating system recognition ------------------- */
00075 
00076 #define KMP_OS_LINUX    0
00077 #define KMP_OS_DARWIN   0
00078 #define KMP_OS_WINDOWS    0
00079 #define KMP_OS_UNIX     0  /* disjunction of KMP_OS_LINUX with KMP_OS_DARWIN */
00080 
00081 #define KMP_ARCH_X86        0
00082 #define KMP_ARCH_X86_64     0
00083 
00084 #ifdef _WIN32
00085 # undef KMP_OS_WINDOWS
00086 # define KMP_OS_WINDOWS 1
00087 #endif
00088 
00089 #if ( defined __APPLE__ && defined __MACH__ )
00090 # undef KMP_OS_DARWIN
00091 # define KMP_OS_DARWIN 1
00092 #endif
00093 
00094 #if ( defined __linux )
00095 # undef KMP_OS_LINUX
00096 # define KMP_OS_LINUX 1
00097 #endif
00098 
00099 #if (1 != KMP_OS_LINUX + KMP_OS_DARWIN + KMP_OS_WINDOWS)
00100 # error Unknown OS
00101 #endif
00102 
00103 #if KMP_OS_LINUX || KMP_OS_DARWIN
00104 # undef KMP_OS_UNIX
00105 # define KMP_OS_UNIX 1
00106 #endif
00107 
00108 #if KMP_OS_WINDOWS
00109 # if defined _M_AMD64
00110 #  undef KMP_ARCH_X86_64
00111 #  define KMP_ARCH_X86_64 1
00112 # else
00113 #  undef KMP_ARCH_X86
00114 #   define KMP_ARCH_X86 1
00115 # endif
00116 #endif
00117 
00118 #if KMP_OS_UNIX
00119 # if defined __x86_64
00120 #  undef KMP_ARCH_X86_64
00121 #  define KMP_ARCH_X86_64 1
00122 # else
00123 #  undef KMP_ARCH_X86
00124 #  define KMP_ARCH_X86 1
00125 # endif
00126 #endif
00127 
00128 #if (1 != KMP_ARCH_X86 + KMP_ARCH_X86_64)
00129 # error Unknown or unsupported architecture
00130 #endif
00131 
00132 #if KMP_OS_WINDOWS
00133 # if defined  KMP_WIN_CDECL ||  !defined GUIDEDLL_EXPORTS
00134 #   define USE_FTN_CDECL      KMP_FTN_UPPER
00135 # endif
00136 
00137 # define KMP_FTN            KMP_FTN_PLAIN
00138 # define USE_FTN_EXTRA      KMP_FTN_PLAIN
00139 # if KMP_ARCH_X86
00140 #  if defined KMP_WIN_STDCALL || !defined GUIDEDLL_EXPORTS
00141 #   define USE_FTN_STDCALL   KMP_FTN_UPPER
00142 #  endif
00143 # endif
00144   typedef char              kmp_int8;
00145   typedef unsigned char     kmp_uint8;
00146   typedef short             kmp_int16;
00147   typedef unsigned short    kmp_uint16;
00148   typedef int               kmp_int32;
00149   typedef unsigned int      kmp_uint32;
00150 # define KMP_INT32_SPEC     "d"
00151 # define KMP_UINT32_SPEC    "u"
00152 # ifndef KMP_STRUCT64
00153    typedef __int64      kmp_int64;
00154    typedef unsigned __int64     kmp_uint64;
00155    #define KMP_INT64_SPEC   "I64d"
00156    #define KMP_UINT64_SPEC  "I64u"
00157 # else
00158    struct kmp_struct64 {
00159     kmp_int32   a,b;
00160    };
00161    typedef struct kmp_struct64 kmp_int64;
00162    typedef struct kmp_struct64 kmp_uint64;
00163    /* Not sure what to use for KMP_[U]INT64_SPEC here */
00164 # endif
00165 # if KMP_ARCH_X86_64
00166 #  define KMP_INTPTR 1
00167    typedef __int64          kmp_intptr_t;
00168    typedef unsigned __int64 kmp_uintptr_t;
00169 #  define KMP_INTPTR_SPEC   "I64d"
00170 #  define KMP_UINTPTR_SPEC  "I64u"
00171 # endif
00172 #endif /* KMP_OS_WINDOWS */
00173 
00174 #if KMP_OS_UNIX
00175 # define KMP_FTN        KMP_FTN_PLAIN
00176 # define USE_FTN_CDECL  KMP_FTN_PLAIN
00177 # define USE_FTN_EXTRA  KMP_FTN_APPEND
00178   typedef char               kmp_int8;
00179   typedef unsigned char      kmp_uint8;
00180   typedef short              kmp_int16;
00181   typedef unsigned short     kmp_uint16;
00182   typedef int                kmp_int32;
00183   typedef unsigned int       kmp_uint32;
00184   typedef long long          kmp_int64;
00185   typedef unsigned long long kmp_uint64;
00186 # define KMP_INT32_SPEC      "d"
00187 # define KMP_UINT32_SPEC     "u"
00188 # define KMP_INT64_SPEC      "lld"
00189 # define KMP_UINT64_SPEC     "llu"
00190 #endif /* KMP_OS_UNIX */
00191 
00192 #if KMP_ARCH_X86
00193 # define KMP_SIZE_T_SPEC KMP_UINT32_SPEC
00194 #elif KMP_ARCH_X86_64
00195 # define KMP_SIZE_T_SPEC KMP_UINT64_SPEC
00196 #else
00197 # error "Can't determine size_t printf format specifier."
00198 #endif
00199 
00200 #if KMP_ARCH_X86
00201 # define KMP_SIZE_T_MAX (0xFFFFFFFF)
00202 #else
00203 # define KMP_SIZE_T_MAX (0xFFFFFFFFFFFFFFFF)
00204 #endif
00205 
00206 typedef size_t  kmp_size_t;
00207 typedef float   kmp_real32;
00208 typedef double  kmp_real64;
00209 
00210 #ifndef KMP_INTPTR
00211 # define KMP_INTPTR 1
00212   typedef long             kmp_intptr_t;
00213   typedef unsigned long    kmp_uintptr_t;
00214 # define KMP_INTPTR_SPEC   "ld"
00215 # define KMP_UINTPTR_SPEC  "lu"
00216 #endif
00217 
00218 #ifdef KMP_I8
00219   typedef kmp_int64      kmp_int;
00220   typedef kmp_uint64     kmp_uint;
00221 # define  KMP_INT_SPEC   KMP_INT64_SPEC
00222 # define  KMP_UINT_SPEC  KMP_UINT64_SPEC
00223 # define  KMP_INT_MAX    ((kmp_int64)0x7FFFFFFFFFFFFFFFLL)
00224 # define  KMP_INT_MIN    ((kmp_int64)0x8000000000000000LL)
00225 #else
00226   typedef kmp_int32      kmp_int;
00227   typedef kmp_uint32     kmp_uint;
00228 # define  KMP_INT_SPEC   KMP_INT32_SPEC
00229 # define  KMP_UINT_SPEC  KMP_UINT32_SPEC
00230 # define  KMP_INT_MAX    ((kmp_int32)0x7FFFFFFF)
00231 # define  KMP_INT_MIN    ((kmp_int64)0x80000000)
00232 #endif /* KMP_I8 */
00233 
00234 #ifdef __cplusplus
00235     //-------------------------------------------------------------------------
00236     // template for debug prints specification ( d, u, lld, llu ), and to obtain
00237     // signed/unsigned flavors of a type
00238     template< typename T >
00239     struct traits_t {
00240         typedef T           signed_t;
00241         typedef T           unsigned_t;
00242         typedef T           floating_t;
00243         static char const * spec;
00244     };
00245     // int
00246     template<>
00247     struct traits_t< signed int > {
00248         typedef signed int    signed_t;
00249         typedef unsigned int  unsigned_t;
00250         typedef double        floating_t;
00251         static char const *   spec;
00252     };
00253     // unsigned int
00254     template<>
00255     struct traits_t< unsigned int > {
00256         typedef signed int    signed_t;
00257         typedef unsigned int  unsigned_t;
00258         typedef double        floating_t;
00259         static char const *   spec;
00260     };
00261     // long long
00262     template<>
00263     struct traits_t< signed long long > {
00264         typedef signed long long    signed_t;
00265         typedef unsigned long long  unsigned_t;
00266         typedef long double         floating_t;
00267         static char const *         spec;
00268     };
00269     // unsigned long long
00270     template<>
00271     struct traits_t< unsigned long long > {
00272         typedef signed long long    signed_t;
00273         typedef unsigned long long  unsigned_t;
00274         typedef long double         floating_t;
00275         static char const *         spec;
00276     };
00277     //-------------------------------------------------------------------------
00278 #endif // __cplusplus
00279 
00280 #if KMP_OS_WINDOWS
00281 # define KMP_STDCALL      __stdcall
00282 #endif
00283 
00284 #ifndef KMP_STDCALL
00285 # define KMP_STDCALL    /* nothing */
00286 #endif
00287 
00288 #define KMP_EXPORT  extern  /* export declaration in guide libraries */
00289 
00290 #if __GNUC__ == 4
00291     #define __forceinline __inline
00292 #endif
00293 
00294 #define PAGE_SIZE                       (0x4000)
00295 #define PAGE_ALIGNED(_addr)     ( ! ((size_t) _addr & \
00296                                      (size_t)(PAGE_SIZE - 1)))
00297 #define ALIGN_TO_PAGE(x)   (void *)(((size_t)(x)) & ~((size_t)(PAGE_SIZE - 1)))
00298 
00299 /* ---------------------- Support for cache alignment, padding, etc. -----------------*/
00300 
00301 #ifdef __cplusplus
00302 extern "C" {
00303 #endif // __cplusplus
00304 
00305 /* Define the default size of the cache line */
00306 #ifndef CACHE_LINE
00307     #define CACHE_LINE                  128         /* cache line size in bytes */
00308 #else
00309     #if ( CACHE_LINE < 64 ) && ! defined( KMP_OS_DARWIN )
00310         // 2006-02-13: This produces too many warnings on OS X*. Disable it for a while...
00311         #warning CACHE_LINE is too small.
00312     #endif
00313 #endif /* CACHE_LINE */
00314 
00315 /* SGI's cache padding improvements using align decl specs (Ver 19) */
00316 #if !defined KMP_PERF_V19
00317 # define KMP_PERF_V19           KMP_ON
00318 #endif
00319 
00320 /* SGI's improvements for inline argv (Ver 106) */
00321 #if !defined KMP_PERF_V106
00322 # define KMP_PERF_V106          KMP_ON
00323 #endif
00324 
00325 #define KMP_CACHE_PREFETCH(ADDR)    /* nothing */
00326 
00327 /* Temporary note: if performance testing of this passes, we can remove
00328    all references to KMP_DO_ALIGN and replace with KMP_ALIGN.  */
00329 #if KMP_OS_UNIX && defined(__GNUC__)
00330 # define KMP_DO_ALIGN(bytes)  __attribute__((aligned(bytes)))
00331 # define KMP_ALIGN_CACHE      __attribute__((aligned(CACHE_LINE)))
00332 # define KMP_ALIGN(bytes)     __attribute__((aligned(bytes)))
00333 #else
00334 # define KMP_DO_ALIGN(bytes)  __declspec( align(bytes) )
00335 # define KMP_ALIGN_CACHE      __declspec( align(CACHE_LINE) )
00336 # define KMP_ALIGN(bytes)     __declspec( align(bytes) )
00337 #endif
00338 
00339 #if defined(__MIC__) || defined(__MIC2__)
00340     #define KMP_MIC  1
00341 // Intel(R) Composer XE (13.0) defines both __MIC__ and __MIC2__ !
00342 # if __MIC2__
00343     #define KMP_MIC1 0
00344 # else
00345     #define KMP_MIC1 1
00346 # endif
00347 #else
00348     #define KMP_MIC  0
00349     #define KMP_MIC1 0
00350 #endif
00351 
00352 /* General purpose fence types for memory operations */
00353 enum kmp_mem_fence_type {
00354     kmp_no_fence,         /* No memory fence */
00355     kmp_acquire_fence,    /* Acquire (read) memory fence */
00356     kmp_release_fence,    /* Release (write) memory fence */
00357     kmp_full_fence        /* Full (read+write) memory fence */
00358 };
00359 
00360 
00361 #if KMP_MIC
00362 /* cast ADDR to correct type so that proper intrinsic will be used */
00363 # define KMP_TEST_THEN_INC32( ADDR )            __sync_fetch_and_add( (kmp_int32*)(ADDR), 1 )
00364 //__atomic_fetch_add_explicit_4((ADDR),1,0)
00365 # define KMP_TEST_THEN_INC_ACQ32( ADDR )    __sync_fetch_and_add( (kmp_int32*)(ADDR), 1 )
00366 //__atomic_fetch_add_explicit_4((ADDR),1,0)
00367 # define KMP_TEST_THEN_INC64( ADDR )        __sync_fetch_and_add( (kmp_int64*)(ADDR), 1LL )
00368 //__atomic_fetch_add_explicit_8((ADDR),1LL,0)
00369 # define KMP_TEST_THEN_INC_ACQ64( ADDR )    __sync_fetch_and_add( (kmp_int64*)(ADDR), 1LL )
00370 //__atomic_fetch_add_explicit_8((ADDR),1LL,0)
00371 # define KMP_TEST_THEN_ADD4_32( ADDR )      __sync_fetch_and_add( (kmp_int32*)(ADDR), 4 )
00372 //__atomic_fetch_add_explicit_4((ADDR),4,0)
00373 # define KMP_TEST_THEN_ADD4_ACQ32( ADDR )   __sync_fetch_and_add( (kmp_int32*)(ADDR), 4 )
00374 //__atomic_fetch_add_explicit_4((ADDR),4,0)
00375 # define KMP_TEST_THEN_ADD4_64( ADDR )      __sync_fetch_and_add( (kmp_int64*)(ADDR), 4LL )
00376 //__atomic_fetch_add_explicit_8((ADDR),4LL,0)
00377 # define KMP_TEST_THEN_ADD4_ACQ64( ADDR )   __sync_fetch_and_add( (kmp_int64*)(ADDR), 4LL )
00378 //__atomic_fetch_add_explicit_8((ADDR),4LL,0)
00379 # define KMP_TEST_THEN_DEC32( ADDR )        __sync_fetch_and_sub( (kmp_int32*)(ADDR), 1 )
00380 //__atomic_fetch_sub_explicit_4((ADDR),1,0)
00381 # define KMP_TEST_THEN_DEC_ACQ32( ADDR )    __sync_fetch_and_sub( (kmp_int32*)(ADDR), 1 )
00382 //__atomic_fetch_sub_explicit_4((ADDR),1,0)
00383 # define KMP_TEST_THEN_DEC64( ADDR )        __sync_fetch_and_sub( (kmp_int64*)(ADDR), 1LL )
00384 //__atomic_fetch_sub_explicit_8((ADDR),1LL,0)
00385 # define KMP_TEST_THEN_DEC_ACQ64( ADDR )    __sync_fetch_and_sub( (kmp_int64*)(ADDR), 1LL )
00386 //__atomic_fetch_sub_explicit_8((ADDR),1LL,0)
00387 # define KMP_TEST_THEN_ADD32( ADDR, INCR )  __sync_fetch_and_add( (kmp_int32*)(ADDR), (INCR) )
00388 //__atomic_fetch_add_explicit_4((ADDR),(INCR),0)
00389 # define KMP_TEST_THEN_ADD64( ADDR, INCR )  __sync_fetch_and_add( (kmp_int64*)(ADDR), (INCR) )
00390 //__atomic_fetch_add_explicit_8((ADDR),(INCR),0)
00391 # define KMP_COMPARE_AND_STORE_ACQ32(p,cv,sv)   __sync_bool_compare_and_swap((volatile kmp_uint32*)(p),(kmp_uint32)(cv),(kmp_uint32)(sv))
00392 # define KMP_COMPARE_AND_STORE_REL32(p,cv,sv)   __sync_bool_compare_and_swap((volatile kmp_uint32*)(p),(kmp_uint32)(cv),(kmp_uint32)(sv))
00393 # define KMP_COMPARE_AND_STORE_ACQ64(p,cv,sv)   __sync_bool_compare_and_swap((volatile kmp_uint64*)(p),(kmp_uint64)(cv),(kmp_uint64)(sv))
00394 # define KMP_COMPARE_AND_STORE_REL64(p,cv,sv)   __sync_bool_compare_and_swap((volatile kmp_uint64*)(p),(kmp_uint64)(cv),(kmp_uint64)(sv))
00395 # define KMP_COMPARE_AND_STORE_PTR(p,cv,sv)     __sync_bool_compare_and_swap((volatile kmp_uint64*)(p),(kmp_uint64)(cv),(kmp_uint64)(sv))
00396 // cannot use low-level CAS intrinsic because it has two pointer parameters (we often use 0 or 1)
00397 #endif
00398 
00399 #if ! defined KMP_TEST_THEN_INC32
00400 # define KMP_TEST_THEN_INC32( ADDR )        ( __kmp_test_then_add32( (ADDR), 1 ) )
00401 #endif
00402 #if ! defined KMP_TEST_THEN_INC_ACQ32
00403 # define KMP_TEST_THEN_INC_ACQ32( ADDR )    ( __kmp_test_then_add32( (ADDR), 1 ) )
00404 #endif
00405 
00406 #if ! defined KMP_TEST_THEN_INC64
00407 # define KMP_TEST_THEN_INC64( ADDR )        ( __kmp_test_then_add64( (ADDR), 1LL ) )
00408 #endif
00409 #if ! defined KMP_TEST_THEN_INC_ACQ64
00410 # define KMP_TEST_THEN_INC_ACQ64( ADDR )    ( __kmp_test_then_add64( (ADDR), 1LL ) )
00411 #endif
00412 
00413 #if ! defined KMP_TEST_THEN_ADD4_32
00414 # define KMP_TEST_THEN_ADD4_32( ADDR )      ( __kmp_test_then_add32( (ADDR), 4 ) )
00415 #endif
00416 #if ! defined KMP_TEST_THEN_ADD4_ACQ32
00417 # define KMP_TEST_THEN_ADD4_ACQ32( ADDR )   ( __kmp_test_then_add32( (ADDR), 4 ) )
00418 #endif
00419 
00420 #if ! defined KMP_TEST_THEN_ADD4_64
00421 # define KMP_TEST_THEN_ADD4_64( ADDR )      ( __kmp_test_then_add64( (ADDR), 4LL ) )
00422 #endif
00423 #if ! defined KMP_TEST_THEN_ADD4_ACQ64
00424 # define KMP_TEST_THEN_ADD4_ACQ64( ADDR )   ( __kmp_test_then_add64( (ADDR), 4LL ) )
00425 #endif
00426 
00427 #if ! defined KMP_TEST_THEN_DEC32
00428 # define KMP_TEST_THEN_DEC32( ADDR )        ( __kmp_test_then_add32( (ADDR), -1 ) )
00429 #endif
00430 #if !defined KMP_TEST_THEN_DEC_ACQ32
00431 # define KMP_TEST_THEN_DEC_ACQ32( ADDR )    ( __kmp_test_then_add32( (ADDR), -1 ) )
00432 #endif
00433 
00434 #if !defined KMP_TEST_THEN_DEC64
00435 # define KMP_TEST_THEN_DEC64( ADDR )        ( __kmp_test_then_add64( (ADDR), -1LL ) )
00436 #endif
00437 #if !defined KMP_TEST_THEN_DEC_ACQ64
00438 # define KMP_TEST_THEN_DEC_ACQ64( ADDR )    ( __kmp_test_then_add64( (ADDR), -1LL ) )
00439 #endif
00440 
00441 #if !defined KMP_TEST_THEN_ADD32
00442 # define KMP_TEST_THEN_ADD32( ADDR, INCR )  ( __kmp_test_then_add32( (ADDR), (INCR) ) )
00443 #endif
00444 
00445 #if !defined KMP_TEST_THEN_ADD64
00446 # define KMP_TEST_THEN_ADD64( ADDR, INCR )  ( __kmp_test_then_add64( (ADDR), (INCR) ) )
00447 #endif
00448 
00449 /* ------------- relaxed consistency memory model stuff ------------------ */
00450 
00451 #if KMP_OS_WINDOWS
00452 #    ifdef __ABSOFT_WIN
00453 #      define KMP_MB()     asm ("nop")
00454 #      define KMP_IMB()    asm ("nop")
00455 #    else
00456 #      define KMP_MB()     /* _asm{ nop } */
00457 #      define KMP_IMB()    /* _asm{ nop } */
00458 #     endif
00459 #endif /* KMP_OS_WINDOWS */
00460 
00461 #ifndef KMP_MB
00462 # define KMP_MB()       /* nothing to do */
00463 #endif
00464 
00465 #ifndef KMP_IMB
00466 # define KMP_IMB()      /* nothing to do */
00467 #endif
00468 
00469 #ifndef KMP_ST4_REL
00470 # define KMP_ST4_REL(A,D)   ( *(A) = (D) )
00471 #endif
00472 
00473 #ifndef KMP_ST8_REL
00474 # define KMP_ST8_REL(A,D)   ( *(A) = (D) )
00475 #endif
00476 
00477 #ifndef KMP_LD4_ACQ
00478 # define KMP_LD4_ACQ(A)     ( *(A) )
00479 #endif
00480 
00481 #ifndef KMP_LD8_ACQ
00482 # define KMP_LD8_ACQ(A)     ( *(A) )
00483 #endif
00484 
00485 /* ------------------------------------------------------------------------ */
00486 
00487     //
00488     // FIXME - maybe this should this be
00489     //
00490     // #define TCR_4(a)    (*(volatile kmp_int32 *)(&a))
00491     // #define TCW_4(a,b)  (a) = (*(volatile kmp_int32 *)&(b))
00492     //
00493     // #define TCR_8(a)    (*(volatile kmp_int64 *)(a))
00494     // #define TCW_8(a,b)  (a) = (*(volatile kmp_int64 *)(&b))
00495     //
00496     // I'm fairly certain this is the correct thing to do, but I'm afraid
00497     // of performance regressions.
00498     //
00499 
00500     #define TCR_4(a)            (a)
00501     #define TCW_4(a,b)          (a) = (b)
00502     #define TCR_8(a)            (a)
00503     #define TCW_8(a,b)          (a) = (b)
00504     #define TCR_SYNC_4(a)       (a)
00505     #define TCW_SYNC_4(a,b)     (a) = (b)
00506     #define TCX_SYNC_4(a,b,c)   KMP_COMPARE_AND_STORE_REL32((volatile kmp_int32 *)(volatile void *)&(a), (kmp_int32)(b), (kmp_int32)(c))
00507     #define TCR_SYNC_8(a)       (a)
00508     #define TCW_SYNC_8(a,b)     (a) = (b)
00509     #define TCX_SYNC_8(a,b,c)   KMP_COMPARE_AND_STORE_REL64((volatile kmp_int64 *)(volatile void *)&(a), (kmp_int64)(b), (kmp_int64)(c))
00510     #define TC_IGNORE(stmt);    stmt;
00511 
00512 #if KMP_ARCH_X86
00513 
00514     #define TCR_PTR(a)          ((void *)TCR_4(a))
00515     #define TCW_PTR(a,b)        TCW_4((a),(b))
00516     #define TCR_SYNC_PTR(a)     ((void *)TCR_SYNC_4(a))
00517     #define TCW_SYNC_PTR(a,b)   TCW_SYNC_4((a),(b))
00518     #define TCX_SYNC_PTR(a,b,c) ((void *)TCX_SYNC_4((a),(b),(c)))
00519 
00520 #else /* 64 bit pointers */
00521 
00522     #define TCR_PTR(a)          ((void *)TCR_8(a))
00523     #define TCW_PTR(a,b)        TCW_8((a),(b))
00524     #define TCR_SYNC_PTR(a)     ((void *)TCR_SYNC_8(a))
00525     #define TCW_SYNC_PTR(a,b)   TCW_SYNC_8((a),(b))
00526     #define TCX_SYNC_PTR(a,b,c) ((void *)TCX_SYNC_8((a),(b),(c)))
00527 
00528 #endif /* KMP_ARCH_X86 */
00529 
00530 /*
00531  * If these FTN_{TRUE,FALSE} values change, may need to
00532  * change several places where they are used to check that
00533  * language is Fortran, not C.
00534  */
00535 
00536 #ifndef FTN_TRUE
00537 # define FTN_TRUE       TRUE
00538 #endif
00539 
00540 #ifndef FTN_FALSE
00541 # define FTN_FALSE      FALSE
00542 #endif
00543 
00544 typedef void    (*microtask_t)( int *gtid, int *npr, ... );
00545 
00546 #ifdef USE_VOLATILE_CAST
00547 # define VOLATILE_CAST(x)        (volatile x)
00548 #else
00549 # define VOLATILE_CAST(x)        (x)
00550 #endif
00551 
00552 #ifdef KMP_I8
00553 # define KMP_WAIT_YIELD           __kmp_wait_yield_8
00554 # define KMP_EQ                   __kmp_eq_8
00555 # define KMP_NEQ                  __kmp_neq_8
00556 # define KMP_LT                   __kmp_lt_8
00557 # define KMP_GE                   __kmp_ge_8
00558 # define KMP_LE                   __kmp_le_8
00559 #else
00560 # define KMP_WAIT_YIELD           __kmp_wait_yield_4
00561 # define KMP_EQ                   __kmp_eq_4
00562 # define KMP_NEQ                  __kmp_neq_4
00563 # define KMP_LT                   __kmp_lt_4
00564 # define KMP_GE                   __kmp_ge_4
00565 # define KMP_LE                   __kmp_le_4
00566 #endif /* KMP_I8 */
00567 
00568 /* Workaround for Intel(R) 64 code gen bug when taking address of static array (Intel(R) 64 Tracker #138) */
00569 #if KMP_ARCH_X86_64 && KMP_OS_LINUX
00570 # define STATIC_EFI2_WORKAROUND
00571 #else
00572 # define STATIC_EFI2_WORKAROUND static
00573 #endif
00574 
00575 // Support of BGET usage
00576 #ifndef KMP_USE_BGET
00577 #define KMP_USE_BGET 1
00578 #endif
00579 
00580 
00581 // Warning levels
00582 enum kmp_warnings_level {
00583     kmp_warnings_off = 0,       /* No warnings */
00584     kmp_warnings_low,           /* Minimal warmings (default) */
00585     kmp_warnings_explicit = 6,      /* Explicitly set to ON - more warnings */
00586     kmp_warnings_verbose        /* reserved */
00587 };
00588 
00589 #ifdef __cplusplus
00590 } // extern "C"
00591 #endif // __cplusplus
00592 
00593 #endif /* KMP_OS_H */

Generated on 25 Aug 2013 for libomp_oss by  doxygen 1.6.1