32 #include <vector_types.h>
33 #include <vector_functions.h>
34 #include <thrust/iterator/detail/host_system_tag.h>
35 #include <thrust/iterator/detail/device_system_tag.h>
36 #include <thrust/iterator/detail/any_system_tag.h>
39 #define NVBIO_HOST_DEVICE __host__ __device__
40 #define NVBIO_HOST __host__
41 #define NVBIO_DEVICE __device__
43 #define NVBIO_HOST_DEVICE
49 #define NVBIO_RESTRICT __restrict__
50 #define NVBIO_SHARED __shared__
52 #define NVBIO_RESTRICT
56 #if defined(__CUDA_ARCH__) && __CUDA_ARCH__ > 0
57 #define NVBIO_DEVICE_COMPILATION
64 #define NVBIO_FORCEINLINE __forceinline
66 #define NVBIO_FORCEINLINE __inline__
69 #if defined(NVBIO_CUDA_DEBUG)
70 #define NVBIO_CUDA_DEBUG_STATEMENT(x) x
72 #define NVBIO_CUDA_DEBUG_STATEMENT(x)
75 #if defined(NVBIO_CUDA_ASSERTS)
77 #define NVBIO_CUDA_ASSERT(x) { const bool __yes = true; assert(x && __yes); }
78 #define NVBIO_CUDA_ASSERT_IF(cond, x, ...) if ((cond) && !(x)) {printf(__VA_ARGS__); NVBIO_CUDA_ASSERT(x); }
79 #define NVBIO_CUDA_DEBUG_ASSERT(x,...) if (!(x)) { printf(__VA_ARGS__); NVBIO_CUDA_ASSERT(x); }
80 #elif defined(NVBIO_CUDA_NON_BLOCKING_ASSERTS) // !defined(NVBIO_CUDA_ASSERTS)
81 #define NVBIO_CUDA_ASSERT(x)
82 #define NVBIO_CUDA_ASSERT_IF(cond, x, ...) if ((cond) && !(x)) { printf(__VA_ARGS__); }
83 #define NVBIO_CUDA_DEBUG_ASSERT(x,...) if (!(x)) { printf(__VA_ARGS__); }
84 #else // !defined(NVBIO_NON_BLOCKING_ASSERTS) && !defined(NVBIO_CUDA_ASSERTS)
85 #define NVBIO_CUDA_ASSERT(x)
86 #define NVBIO_CUDA_ASSERT_IF(cond, x, ...)
87 #define NVBIO_CUDA_DEBUG_ASSERT(x,...)
90 #if defined(NVBIO_CUDA_DEBUG)
91 #define NVBIO_CUDA_DEBUG_PRINT(...) printf(__VA_ARGS__)
92 #define NVBIO_CUDA_DEBUG_PRINT_IF(cond,...) if (cond) printf(__VA_ARGS__)
93 #define NVBIO_CUDA_DEBUG_SELECT(debug_val,normal_val) (debug_val)
94 #else // !defined(NVBIO_CUDA_DEBUG)
95 #define NVBIO_CUDA_DEBUG_PRINT(...)
96 #define NVBIO_CUDA_DEBUG_PRINT_IF(cond,...)
97 #define NVBIO_CUDA_DEBUG_SELECT(debug_val,normal_val) (normal_val)
100 #if defined(NVBIO_CUDA_DEBUG)
101 #if defined(NVBIO_CUDA_ASSERTS)
102 #define NVBIO_CUDA_DEBUG_CHECK_IF(cond, check,...) if ((cond) && (!(check))) { printf(__VA_ARGS__); assert(check); }
103 #else // !defined(NVBIO_CUDA_ASSERTS)
104 #define NVBIO_CUDA_DEBUG_CHECK_IF(cond, check,...) if ((cond) && (!(check))) printf(__VA_ARGS__)
106 #else // !defined(NVBIO_CUDA_DEBUG)
107 #define NVBIO_CUDA_DEBUG_CHECK_IF(cond, check,...)
110 #if defined(__CUDACC__)
111 #define NVBIO_HOST_DEVICE_TEMPLATE \
112 #pragma hd_warning_disable
114 #define NVBIO_HOST_DEVICE_TEMPLATE
126 #if defined(__GNUC__)
127 #define NVBIO_VAR_UNUSED __attribute__((unused))
129 #define NVBIO_VAR_UNUSED
153 struct host_tag :
public thrust::host_system_tag {};
224 template <
typename T1,
typename T2>
struct same_type {
static const bool pred =
false; };
225 template <
typename T>
struct same_type<T,T> {
static const bool pred =
true; };
229 template <
typename A,
typename B>
234 template <
bool predicate,
typename T,
typename F>
struct if_true {};
235 template <
typename T,
typename F>
struct if_true<true,T,
F> {
typedef T
type; };
236 template <
typename T,
typename F>
struct if_true<false,T,
F> {
typedef F type; };
240 template <
typename A,
typename B,
typename T,
typename F>
struct if_equal
257 template <
typename Out,
typename In>
266 template <
typename Out,
typename In>
269 #if defined(__CUDA_ARCH__)
270 return reinterpret_cast<const Out&
>(in);
283 I align(
const I a) {
return (N > 1) ?
I(a + N-1) &
I(~(N-1)) : a; }
302 bool operator==(
const uint2 op1,
const uint2 op2) {
return op1.x == op2.x && op1.y == op2.y; }
307 bool operator!=(
const uint2 op1,
const uint2 op2) {
return op1.x != op2.x || op1.y != op2.y; }
312 bool operator==(
const uint3 op1,
const uint3 op2) {
return op1.x == op2.x && op1.y == op2.y && op1.z == op2.z; }
317 bool operator!=(
const uint3 op1,
const uint3 op2) {
return op1.x != op2.x || op1.y != op2.y || op1.z != op2.z; }
322 bool operator==(
const uint4 op1,
const uint4 op2) {
return op1.x == op2.x && op1.y == op2.y && op1.z == op2.z && op1.w == op2.w; }
327 bool operator!=(
const uint4 op1,
const uint4 op2) {
return op1.x != op2.x || op1.y != op2.y || op1.z != op2.z || op1.w != op2.w; }
332 bool operator==(
const int2 op1,
const int2 op2) {
return op1.x == op2.x && op1.y == op2.y; }
337 bool operator!=(
const int2 op1,
const int2 op2) {
return op1.x != op2.x || op1.y != op2.y; }
342 bool operator==(
const int3 op1,
const int3 op2) {
return op1.x == op2.x && op1.y == op2.y && op1.z == op2.z; }
347 bool operator!=(
const int3 op1,
const int3 op2) {
return op1.x != op2.x || op1.y != op2.y || op1.z != op2.z; }
352 bool operator==(
const int4 op1,
const int4 op2) {
return op1.x == op2.x && op1.y == op2.y && op1.z == op2.z && op1.w == op2.w; }
357 bool operator!=(
const int4 op1,
const int4 op2) {
return op1.x != op2.x || op1.y != op2.y || op1.z != op2.z || op1.w != op2.w; }
362 bool operator==(
const float2 op1,
const float2 op2) {
return op1.x == op2.x && op1.y == op2.y; }
367 bool operator!=(
const float2 op1,
const float2 op2) {
return op1.x != op2.x || op1.y != op2.y; }
372 bool operator==(
const float3 op1,
const float3 op2) {
return op1.x == op2.x && op1.y == op2.y && op1.z == op2.z; }
377 bool operator!=(
const float3 op1,
const float3 op2) {
return op1.x != op2.x || op1.y != op2.y || op1.z != op2.z; }
382 bool operator==(
const float4 op1,
const float4 op2) {
return op1.x == op2.x && op1.y == op2.y && op1.z == op2.z && op1.w == op2.w; }
387 bool operator!=(
const float4 op1,
const float4 op2) {
return op1.x != op2.x || op1.y != op2.y || op1.z != op2.z || op1.w != op2.w; }