2
Copyright 2010-2011, D. E. Shaw Research.
5
Redistribution and use in source and binary forms, with or without
6
modification, are permitted provided that the following conditions are
9
* Redistributions of source code must retain the above copyright
10
notice, this list of conditions, and the following disclaimer.
12
* Redistributions in binary form must reproduce the above copyright
13
notice, this list of conditions, and the following disclaimer in the
14
documentation and/or other materials provided with the distribution.
16
* Neither the name of D. E. Shaw Research nor the names of its
17
contributors may be used to endorse or promote products derived from
18
this software without specific prior written permission.
20
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
#ifndef __r123_nvcc_features_dot_h__
33
#define __r123_nvcc_features_dot_h__
35
#if !defined(CUDART_VERSION)
36
#error "why are we in nvccfeatures.h if CUDART_VERSION is not defined"
39
#if CUDART_VERSION < 4010
40
#error "CUDA versions earlier than 4.1 produce incorrect results for some templated functions in namespaces. Random123 isunsupported. See comments in nvccfeatures.h"
41
// This test was added in Random123-1.08 (August, 2013) because we
42
// discovered that Ftype(maxTvalue<T>()) with Ftype=double and
43
// T=uint64_t in examples/uniform.hpp produces -1 for CUDA4.0 and
44
// earlier. We can't be sure this bug doesn't also affect invocations
45
// of other templated functions, e.g., essentially all of Random123.
46
// Thus, we no longer trust CUDA versions earlier than 4.1 even though
47
// we had previously tested and timed Random123 with CUDA 3.x and 4.0.
48
// If you feel lucky or desperate, you can change #error to #warning, but
49
// please take extra care to be sure that you are getting correct
53
// nvcc falls through to gcc or msvc. So first define
54
// a couple of things and then include either gccfeatures.h
57
#ifndef R123_CUDA_DEVICE
58
#define R123_CUDA_DEVICE __device__
61
#ifndef R123_USE_MULHILO64_CUDA_INTRIN
62
#define R123_USE_MULHILO64_CUDA_INTRIN 1
66
#define R123_ASSERT(x) if((x)) ; else asm("trap;")
69
#ifndef R123_BUILTIN_EXPECT
70
#define R123_BUILTIN_EXPECT(expr,likely) expr
73
#ifndef R123_USE_AES_NI
74
#define R123_USE_AES_NI 0
77
#ifndef R123_USE_SSE4_2
78
#define R123_USE_SSE4_2 0
81
#ifndef R123_USE_SSE4_1
82
#define R123_USE_SSE4_1 0
86
#define R123_USE_SSE 0
89
#ifndef R123_USE_GNU_UINT128
90
#define R123_USE_GNU_UINT128 0
93
#ifndef R123_ULONG_LONG
94
// uint64_t, which is what we'd get without this, is
95
// not the same as unsigned long long
96
#define R123_ULONG_LONG unsigned long long
100
// No exceptions in CUDA, at least upto 4.0
101
#define R123_THROW(x) R123_ASSERT(0)
104
#if defined(__GNUC__)
105
#include "gccfeatures.h"
106
#elif defined(_MSC_FULL_VER)
107
#include "msvcfeatures.h"