OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
util_macro.cuh
1/******************************************************************************
2 * Copyright (c) 2011, Duane Merrill. All rights reserved.
3 * Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the NVIDIA CORPORATION nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 ******************************************************************************/
28
29/******************************************************************************
30 * Common C/C++ macro utilities
31 ******************************************************************************/
32
33#pragma once
34
35#include "util_namespace.cuh"
36
38CUB_NS_PREFIX
39
41namespace cub {
42
43
49#ifndef CUB_ALIGN
50 #if defined(_WIN32) || defined(_WIN64)
52 #define CUB_ALIGN(bytes) __declspec(align(32))
53 #else
55 #define CUB_ALIGN(bytes) __attribute__((aligned(bytes)))
56 #endif
57#endif
58
59#ifndef CUB_MAX
61 #define CUB_MAX(a, b) (((b) > (a)) ? (b) : (a))
62#endif
63
64#ifndef CUB_MIN
66 #define CUB_MIN(a, b) (((b) < (a)) ? (b) : (a))
67#endif
68
69#ifndef CUB_QUOTIENT_FLOOR
71 #define CUB_QUOTIENT_FLOOR(x, y) ((x) / (y))
72#endif
73
74#ifndef CUB_QUOTIENT_CEILING
76 #define CUB_QUOTIENT_CEILING(x, y) (((x) + (y) - 1) / (y))
77#endif
78
79#ifndef CUB_ROUND_UP_NEAREST
81 #define CUB_ROUND_UP_NEAREST(x, y) ((((x) + (y) - 1) / (y)) * y)
82#endif
83
84#ifndef CUB_ROUND_DOWN_NEAREST
86 #define CUB_ROUND_DOWN_NEAREST(x, y) (((x) / (y)) * y)
87#endif
88
89
90#ifndef CUB_STATIC_ASSERT
91 #ifndef DOXYGEN_SHOULD_SKIP_THIS // Do not document
92 #define CUB_CAT_(a, b) a ## b
93 #define CUB_CAT(a, b) CUB_CAT_(a, b)
94 #endif // DOXYGEN_SHOULD_SKIP_THIS
95
97 #define CUB_STATIC_ASSERT(cond, msg) typedef int CUB_CAT(cub_static_assert, __LINE__)[(cond) ? 1 : -1]
98#endif
99 // end group UtilModule
101
102} // CUB namespace
103CUB_NS_POSTFIX // Optional outer namespace(s)
Optional outer namespace(s)