random123

Counter-based Random Number Generators
git clone git://git.meso-star.com/random123.git
Log | Files | Refs | README | LICENSE

xlcfeatures.h (6406B)


      1 /* This derivative file contributed via email by Gabriel Rockefeller on 8/5/2013 */
      2 /*
      3 Copyright 2010-2011, D. E. Shaw Research.
      4 All rights reserved.
      5 
      6 Redistribution and use in source and binary forms, with or without
      7 modification, are permitted provided that the following conditions are
      8 met:
      9 
     10 * Redistributions of source code must retain the above copyright
     11   notice, this list of conditions, and the following disclaimer.
     12 
     13 * Redistributions in binary form must reproduce the above copyright
     14   notice, this list of conditions, and the following disclaimer in the
     15   documentation and/or other materials provided with the distribution.
     16 
     17 * Neither the name of D. E. Shaw Research nor the names of its
     18   contributors may be used to endorse or promote products derived from
     19   this software without specific prior written permission.
     20 
     21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     24 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     25 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     27 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     31 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32 
     33 Copyright (c) 2013, Los Alamos National Security, LLC
     34 All rights reserved.
     35 
     36 Copyright 2013. Los Alamos National Security, LLC. This software was produced
     37 under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
     38 Laboratory (LANL), which is operated by Los Alamos National Security, LLC for
     39 the U.S. Department of Energy. The U.S. Government has rights to use,
     40 reproduce, and distribute this software.  NEITHER THE GOVERNMENT NOR LOS
     41 ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
     42 ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE.  If software is modified
     43 to produce derivative works, such modified software should be clearly marked,
     44 so as not to confuse it with the version available from LANL.
     45 */
     46 #ifndef __xlcfeatures_dot_hpp
     47 #define __xlcfeatures_dot_hpp
     48 
     49 #if !defined(__x86_64__) && !defined(__i386__) && !defined(__powerpc__)
     50 #  error "This code has only been tested on x86 and PowerPC platforms."
     51 #include <including_a_nonexistent_file_will_stop_some_compilers_from_continuing_with_a_hopeless_task>
     52 { /* maybe an unbalanced brace will terminate the compilation */
     53  /* Feel free to try the Random123 library on other architectures by changing
     54  the conditions that reach this error, but you should consider it a
     55  porting exercise and expect to encounter bugs and deficiencies.
     56  Please let the authors know of any successes (or failures). */
     57 #endif
     58 
     59 #ifdef __cplusplus
     60 /* builtins are automatically available to xlc.  To use them with xlc++,
     61    one must include builtins.h.   c.f
     62    http://publib.boulder.ibm.com/infocenter/cellcomp/v101v121/index.jsp?topic=/com.ibm.xlcpp101.cell.doc/compiler_ref/compiler_builtins.html
     63 */
     64 #include <builtins.h>
     65 #endif
     66 
     67 #ifndef R123_STATIC_INLINE
     68 #define R123_STATIC_INLINE static inline
     69 #endif
     70 
     71 #ifndef R123_FORCE_INLINE
     72 #define R123_FORCE_INLINE(decl) decl __attribute__((__always_inline__))
     73 #endif
     74 
     75 #ifndef R123_CUDA_DEVICE
     76 #define R123_CUDA_DEVICE
     77 #endif
     78 
     79 #ifndef R123_ASSERT
     80 #include <assert.h>
     81 #define R123_ASSERT(x) assert(x)
     82 #endif
     83 
     84 #ifndef R123_BUILTIN_EXPECT
     85 #define R123_BUILTIN_EXPECT(expr,likely) __builtin_expect(expr,likely)
     86 #endif
     87 
     88 #ifndef R123_USE_AES_NI
     89 #define R123_USE_AES_NI 0
     90 #endif
     91 
     92 #ifndef R123_USE_SSE4_2
     93 #define R123_USE_SSE4_2 0
     94 #endif
     95 
     96 #ifndef R123_USE_SSE4_1
     97 #define R123_USE_SSE4_1 0
     98 #endif
     99 
    100 #ifndef R123_USE_SSE
    101 #define R123_USE_SSE 0
    102 #endif
    103 
    104 #ifndef R123_USE_AES_OPENSSL
    105 /* There isn't really a good way to tell at compile time whether
    106    openssl is available.  Without a pre-compilation configure-like
    107    tool, it's less error-prone to guess that it isn't available.  Add
    108    -DR123_USE_AES_OPENSSL=1 and any necessary LDFLAGS or LDLIBS to
    109    play with openssl */
    110 #define R123_USE_AES_OPENSSL 0
    111 #endif
    112 
    113 #ifndef R123_USE_GNU_UINT128
    114 #define R123_USE_GNU_UINT128 0
    115 #endif
    116 
    117 #ifndef R123_USE_ASM_GNU
    118 #define R123_USE_ASM_GNU 1
    119 #endif
    120 
    121 #ifndef R123_USE_CPUID_MSVC
    122 #define R123_USE_CPUID_MSVC 0
    123 #endif
    124 
    125 #ifndef R123_USE_X86INTRIN_H
    126 #define R123_USE_X86INTRIN_H 0
    127 #endif
    128 
    129 #ifndef R123_USE_IA32INTRIN_H
    130 #define R123_USE_IA32INTRIN_H 0
    131 #endif
    132 
    133 #ifndef R123_USE_XMMINTRIN_H
    134 #define R123_USE_XMMINTRIN_H 0
    135 #endif
    136 
    137 #ifndef R123_USE_EMMINTRIN_H
    138 #define R123_USE_EMMINTRIN_H 0
    139 #endif
    140 
    141 #ifndef R123_USE_SMMINTRIN_H
    142 #define R123_USE_SMMINTRIN_H 0
    143 #endif
    144 
    145 #ifndef R123_USE_WMMINTRIN_H
    146 #define R123_USE_WMMINTRIN_H 0
    147 #endif
    148 
    149 #ifndef R123_USE_INTRIN_H
    150 #ifdef __ABM__
    151 #define R123_USE_INTRIN_H 1
    152 #else
    153 #define R123_USE_INTRIN_H 0
    154 #endif
    155 #endif
    156 
    157 #ifndef R123_USE_MULHILO32_ASM
    158 #define R123_USE_MULHILO32_ASM 0
    159 #endif
    160 
    161 #ifndef R123_USE_MULHILO64_MULHI_INTRIN
    162 #if (defined(__powerpc64__))
    163 #define R123_USE_MULHILO64_MULHI_INTRIN 1
    164 #else
    165 #define R123_USE_MULHILO64_MULHI_INTRIN 0
    166 #endif
    167 #endif
    168 
    169 #ifndef R123_MULHILO64_MULHI_INTRIN
    170 #define R123_MULHILO64_MULHI_INTRIN __mulhdu
    171 #endif
    172 
    173 #ifndef R123_USE_MULHILO32_MULHI_INTRIN
    174 #define R123_USE_MULHILO32_MULHI_INTRIN 0
    175 #endif
    176 
    177 #ifndef R123_MULHILO32_MULHI_INTRIN
    178 #define R123_MULHILO32_MULHI_INTRIN __mulhwu
    179 #endif
    180 
    181 #ifndef R123_USE_MULHILO64_ASM
    182 #if defined(__powerpc64__)
    183 #define R123_USE_MULHILO64_ASM (1 /*defined(__powerpc64__)*/ && !(R123_USE_MULHILO64_MULHI_INTRIN))
    184 #else
    185 #define R123_USE_MULHILO64_ASM (0 /*defined(__powerpc64__)*/ && !(R123_USE_MULHILO64_MULHI_INTRIN))
    186 #endif
    187 #endif
    188 
    189 #ifndef R123_USE_MULHILO64_MSVC_INTRIN
    190 #define R123_USE_MULHILO64_MSVC_INTRIN 0
    191 #endif
    192 
    193 #ifndef R123_USE_MULHILO64_CUDA_INTRIN
    194 #define R123_USE_MULHILO64_CUDA_INTRIN 0
    195 #endif
    196 
    197 #ifndef R123_USE_MULHILO64_OPENCL_INTRIN
    198 #define R123_USE_MULHILO64_OPENCL_INTRIN 0
    199 #endif
    200 
    201 #ifndef __STDC_CONSTANT_MACROS
    202 #define __STDC_CONSTANT_MACROS
    203 #endif
    204 #include <stdint.h>
    205 #ifndef UINT64_C
    206 #error UINT64_C not defined.  You must define __STDC_CONSTANT_MACROS before you #include <stdint.h>
    207 #endif
    208 
    209 /* If you add something, it must go in all the other XXfeatures.hpp
    210    and in ../ut_features.cpp */
    211 #endif