-
Notifications
You must be signed in to change notification settings - Fork 100
/
config.hpp.in
591 lines (507 loc) · 17.2 KB
/
config.hpp.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
/*!
******************************************************************************
*
* \file
*
* \brief Header file for basic RAJA configuration options.
*
* This file contains platform-specific parameters that control
* aspects of compilation of application code using RAJA. These
* parameters specify: SIMD unit width, data alignment information,
* inline directives, etc.
*
* IMPORTANT: These options are set by CMake and depend on the options
* passed to it.
*
* IMPORTANT: Exactly one e RAJA_COMPILER_* option must be defined to
* ensure correct behavior.
*
* Definitions in this file will propagate to all RAJA header files.
*
******************************************************************************
*/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC
// and RAJA project contributors. See the RAJA/LICENSE file for details.
//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
#ifndef RAJA_config_HPP
#define RAJA_config_HPP
#include <utility>
#include <cstddef>
#include <type_traits>
#if defined(_MSVC_LANG)
#define RAJA_CXX_VER _MSVC_LANG
#else
#define RAJA_CXX_VER __cplusplus
#endif
#if RAJA_CXX_VER >= 201402L
#define RAJA_HAS_SOME_CXX14 1
#elif __cpp_generic_lambdas >= 201304 && \
__cpp_constexpr >= 201304 && \
__cpp_decltype_auto >= 201304 && \
__cpp_return_type_deduction >= 201304 && \
__cpp_aggregate_nsdmi >= 201304 && \
__cpp_variable_templates >= 201304
#define RAJA_HAS_SOME_CXX14 1
#else
#define RAJA_HAS_SOME_CXX14 0
static_assert(__cpp_generic_lambdas >= 201304,
"RAJA requires C++14 __cpp_generic_lambdas to operate.");
static_assert(__cpp_constexpr >= 201304,
"RAJA requires C++14 __cpp_constexpr to operate.");
static_assert(__cpp_decltype_auto >= 201304 ,
"RAJA requires C++14 __cpp_decltype_auto to operate");
static_assert(__cpp_return_type_deduction >= 201304,
"RAJA requires C++14 __cpp_return_type_deduction to operate");
static_assert(__cpp_aggregate_nsdmi >= 201304,
"RAJA requires C++14 __cpp_aggregate_nsdmi to operate");
#endif
/* NOTE: we want this one __cpp_init_captures >= 201304 */
/* NOTE: we want this too __cpp_lib_transformation_trait_aliases >= 201304 */
// __has_cpp_attribute(deprecated) >= 201309
// __cpp_lib_exchange_function >= 201304
// __cpp_lib_make_unique >= 201304
// __cpp_lib_integer_sequence >= 201304
// __cpp_lib_tuples_by_type >= 201304
// __cpp_lib_tuple_element_t >= 201402
// __cpp_lib_transparent_operators >= 201210
// __cpp_lib_integral_constant_callable >= 201304
// __cpp_lib_result_of_sfinae >= 201210
// __cpp_binary_literals 201304
// __cpp_sized_deallocation 201309
// __cpp_lib_is_final 201402
// __cpp_lib_is_null_pointer 201309
// __cpp_lib_chrono_udls 201304
// __cpp_lib_string_udls 201304
// __cpp_lib_generic_associative_lookup 201304
// __cpp_lib_null_iterators 201304
// __cpp_lib_make_reverse_iterator 201402
// __cpp_lib_robust_nonmodifying_seq_ops 201304
// __cpp_lib_complex_udls 201309
// __cpp_lib_quoted_string_io 201304
// __has_include(<shared_mutex>) 1
// __cpp_lib_shared_timed_mutex 201402
static_assert(RAJA_HAS_SOME_CXX14,
"RAJA requires at least basic C++14 to operate correctly, your "
"compiler and/or standard library does not claim support for "
"C++14 features we need");
#if defined(__cpp_lib_is_invocable) && (__cpp_lib_is_invocable >= 201703L)
#define RAJA_HAS_CXX17_IS_INVOCABLE 1
#else
#define RAJA_HAS_CXX17_IS_INVOCABLE 0
#endif
/*!
******************************************************************************
*
* \brief Enable/disable exploratory fault tolerance mechanism.
*
******************************************************************************
*/
#cmakedefine RAJA_ENABLE_FT
#cmakedefine RAJA_ENABLE_ITERATOR_OVERFLOW_DEBUG
/*!
******************************************************************************
*
* \brief Default RAJA floating point scalar and pointer options.
*
******************************************************************************
*/
#define @RAJA_FP@
#define @RAJA_PTR@
/*!
******************************************************************************
*
* \brief Deprecated tests
*
******************************************************************************
*/
#cmakedefine RAJA_DEPRECATED_TESTS
/*!
******************************************************************************
*
* \brief Add forceinline recursive directive to Kernel and Forall (Intel only)
*
******************************************************************************
*/
#cmakedefine RAJA_ENABLE_FORCEINLINE_RECURSIVE
/*!
******************************************************************************
*
* \brief Add bounds check to views and layouts
*
******************************************************************************
*/
#cmakedefine RAJA_ENABLE_BOUNDS_CHECK
/*
******************************************************************************
*
* \brief Exhaustive index types for tests
*
******************************************************************************
*/
#cmakedefine RAJA_TEST_EXHAUSTIVE
/*!
******************************************************************************
*
* \brief Programming model back-ends.
*
******************************************************************************
*/
#cmakedefine RAJA_ENABLE_OPENMP
#cmakedefine RAJA_ENABLE_TARGET_OPENMP
#cmakedefine RAJA_ENABLE_TBB
#cmakedefine RAJA_ENABLE_CUDA
#cmakedefine RAJA_ENABLE_CLANG_CUDA
#cmakedefine RAJA_ENABLE_HIP
#cmakedefine RAJA_ENABLE_SYCL
#cmakedefine RAJA_ENABLE_OMP_TASK
#cmakedefine RAJA_ENABLE_VECTORIZATION
#cmakedefine RAJA_ENABLE_NV_TOOLS_EXT
#cmakedefine RAJA_ENABLE_ROCTX
/*!
******************************************************************************
*
* \brief Timer options.
*
******************************************************************************
*/
#cmakedefine RAJA_USE_CHRONO
#cmakedefine RAJA_USE_GETTIME
#cmakedefine RAJA_USE_CLOCK
#cmakedefine RAJA_USE_CYCLE
/*!
******************************************************************************
*
* \brief Runtime plugins.
*
******************************************************************************
*/
#cmakedefine RAJA_ENABLE_RUNTIME_PLUGINS
/*!
******************************************************************************
*
* \brief Desul atomics.
*
******************************************************************************
*/
#cmakedefine RAJA_ENABLE_DESUL_ATOMICS
/*!
******************************************************************************
*
* \brief Detect the host C++ compiler we are using.
*
******************************************************************************
*/
#if defined(_WIN32)
#define RAJA_COMPILER_MSVC // This must be defined for all windows builds (even if using compilers other than MSVC)
#elif defined(__INTEL_COMPILER)
#define RAJA_COMPILER_INTEL
#elif defined(__ibmxl__)
#define RAJA_COMPILER_XLC
#elif defined(__clang__)
#define RAJA_COMPILER_CLANG
#elif defined(__PGI)
#define RAJA_COMPILER_PGI
#elif defined(__GNUC__)
#define RAJA_COMPILER_GNU
#endif
#define RAJA_STRINGIFY(x) RAJA_DO_STRINGIFY(x)
#define RAJA_DO_STRINGIFY(x) #x
#ifdef _WIN32
#define RAJA_PRAGMA(x) __pragma(x)
#else
#define RAJA_PRAGMA(x) _Pragma(RAJA_STRINGIFY(x))
#endif
/* NOTE: Below we define RAJA_MAX_ALIGN for each compiler, currently it is set as 16 bytes
for all cases, except MSVC. Previously this was set by alignof(std::max_align_t) which, in Clang,
is based on the sizeof(long double). This causes an in inconsistency as CUDA/HIP long doubles
are demoted to doubles causing alignof(std::max_align_t) to return 8 bytes on the device and
16 bytes on the host. We therefore set a standard size and ensure validity through a
static_assert.
*/
namespace RAJA {
#if defined(RAJA_ENABLE_OPENMP) && !defined(__HIP_DEVICE_COMPILE__)
#if defined(_OPENMP)
#if (_OPENMP >= 200805)
#if defined(RAJA_ENABLE_OPENMP_TASK)
#define RAJA_ENABLE_OPENMP_TASK_INTERNAL
#endif
#endif // _OPENMP >= 200805
#else
#error RAJA configured with RAJA_ENABLE_OPENMP, but _OPENMP is not defined in this code section
#endif // else
#endif // RAJA_ENABLE_OPENMP && !__HIP_DEVICE_COMPILE__
#if defined(RAJA_ENABLE_CUDA) && defined(__CUDACC__)
#define RAJA_CUDA_ACTIVE
#endif // RAJA_ENABLE_CUDA && __CUDACC__
#if defined(RAJA_ENABLE_HIP) && defined(__HIPCC__)
#define RAJA_HIP_ACTIVE
#include <hip/hip_version.h>
#if (HIP_VERSION_MAJOR > 5) || \
(HIP_VERSION_MAJOR == 5 && HIP_VERSION_MINOR >= 1)
// enable device function pointers with rocm version >= 5.1
// this used to be set to 4.3, but tests start passing with 5.1
#define RAJA_ENABLE_HIP_INDIRECT_FUNCTION_CALL
#define RAJA_ENABLE_HIP_DOUBLE_ATOMICADD
#endif
#if (HIP_VERSION_MAJOR > 4) || \
(HIP_VERSION_MAJOR == 4 && HIP_VERSION_MINOR >= 2)
// enable occupancy calculator with rocm version >= 4.2
// can't test older versions thought they may work
#define RAJA_ENABLE_HIP_OCCUPANCY_CALCULATOR
#endif
#endif // RAJA_ENABLE_HIP && __HIPCC__
#if defined(RAJA_ENABLE_SYCL)
#if defined(SYCL_LANGUAGE_VERSION)
#define RAJA_SYCL_ACTIVE
#endif
#endif
#if defined(RAJA_CUDA_ACTIVE) || \
defined(RAJA_HIP_ACTIVE) || \
defined(RAJA_SYCL_ACTIVE)
#define RAJA_GPU_ACTIVE
#endif
/*!
******************************************************************************
*
* \brief RAJA software version number.
*
******************************************************************************
*/
#define RAJA_VERSION_MAJOR @RAJA_VERSION_MAJOR@
#define RAJA_VERSION_MINOR @RAJA_VERSION_MINOR@
#define RAJA_VERSION_PATCHLEVEL @RAJA_VERSION_PATCHLEVEL@
/*!
******************************************************************************
*
* \brief Useful macros.
*
******************************************************************************
*/
//
// Platform-specific constants for data alignment:
//
// DATA_ALIGN - used in compiler-specific intrinsics and type aliases
// to specify alignment of data, loop bounds, etc.;
// units of "bytes"
const int DATA_ALIGN = @RAJA_DATA_ALIGN@;
#if defined (_WIN32)
#define RAJA_RESTRICT __restrict
#else
#define RAJA_RESTRICT __restrict__
#endif
#if !defined(RAJA_COMPILER_MSVC)
#define RAJA_COLLAPSE(X) collapse(X)
#else
#define RAJA_COLLAPSE(X)
#endif
//
// Runtime bounds checking for Views
//
#if defined(RAJA_ENABLE_BOUNDS_CHECK)
#define RAJA_BOUNDS_CHECK_INTERNAL
#define RAJA_BOUNDS_CHECK_constexpr
#else
#define RAJA_BOUNDS_CHECK_constexpr constexpr
#endif
//
// Compiler-specific definitions for inline directives, data alignment
// intrinsics, and SIMD vector pragmas
//
// Variables for compiler instrinsics, directives, type aliases
//
// RAJA_INLINE - macro to enforce method inlining
//
// RAJA_ALIGN_DATA(<variable>) - macro to express alignment of data,
// loop bounds, etc.
//
// RAJA_SIMD - macro to express SIMD vectorization pragma to force
// loop vectorization
//
// RAJA_ALIGNED_ATTR(<alignment>) - macro to express type or variable alignments
//
#if (defined(_WIN32) || defined(_WIN64)) && !defined(RAJA_WIN_STATIC_BUILD)
#ifdef RAJA_EXPORTS
#define RAJASHAREDDLL_API __declspec(dllexport)
#else
#define RAJASHAREDDLL_API __declspec(dllimport)
#endif
#else
#define RAJASHAREDDLL_API
#endif
#if defined(RAJA_COMPILER_GNU)
#define RAJA_ALIGNED_ATTR(N) __attribute__((aligned(N)))
#else
#define RAJA_ALIGNED_ATTR(N) alignas(N)
#endif
#if defined(RAJA_COMPILER_INTEL)
//
// Configuration options for Intel compilers
//
#define RAJA_MAX_ALIGN 16
#if defined (RAJA_ENABLE_FORCEINLINE_RECURSIVE)
#define RAJA_FORCEINLINE_RECURSIVE RAJA_PRAGMA(forceinline recursive)
#else
#define RAJA_FORCEINLINE_RECURSIVE
#endif
#if defined (_WIN32)
#define RAJA_INLINE inline
#else
#define RAJA_INLINE inline __attribute__((always_inline))
#endif
#define RAJA_UNROLL RAJA_PRAGMA(unroll)
#define RAJA_UNROLL_COUNT(N) RAJA_PRAGMA(unroll(N))
#if defined(RAJA_ENABLE_CUDA) || defined(RAJA_ENABLE_HIP)
#define RAJA_ALIGN_DATA(d) d
#else
#define RAJA_ALIGN_DATA(d) __assume_aligned(d, RAJA::DATA_ALIGN)
#endif
#if defined(_OPENMP) && (_OPENMP >= 201307) && (__INTEL_COMPILER >= 1700)
#define RAJA_SIMD RAJA_PRAGMA(omp simd)
#elif defined(_OPENMP) && (_OPENMP >= 201307) && (__INTEL_COMPILER < 1700)
#define RAJA_SIMD
#else
#define RAJA_SIMD RAJA_PRAGMA(simd)
#endif
#elif defined(RAJA_COMPILER_GNU)
//
// Configuration options for GNU compilers
//
#define RAJA_MAX_ALIGN 16
#define RAJA_FORCEINLINE_RECURSIVE
#define RAJA_INLINE inline __attribute__((always_inline))
#if !defined(__NVCC__)
#define RAJA_UNROLL RAJA_PRAGMA(GCC unroll 10000)
#define RAJA_UNROLL_COUNT(N) RAJA_PRAGMA(GCC unroll N)
#else
#define RAJA_UNROLL RAJA_PRAGMA(unroll)
#define RAJA_UNROLL_COUNT(N) RAJA_PRAGMA(unroll N)
#endif
#if defined(RAJA_ENABLE_CUDA) || defined(RAJA_ENABLE_HIP)
#define RAJA_ALIGN_DATA(d) d
#else
#define RAJA_ALIGN_DATA(d) __builtin_assume_aligned(d, RAJA::DATA_ALIGN)
#endif
#if defined(_OPENMP) && (_OPENMP >= 201307)
#define RAJA_SIMD RAJA_PRAGMA(omp simd)
#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && \
( ( (__GNUC__ == 4) && (__GNUC_MINOR__ == 9) ) || (__GNUC__ >= 5) )
#define RAJA_SIMD RAJA_PRAGMA(GCC ivdep)
#else
#define RAJA_SIMD
#endif
#elif defined(RAJA_COMPILER_XLC)
//
// Configuration options for xlc compiler (i.e., bgq/sequoia).
//
#define RAJA_MAX_ALIGN 16
#define RAJA_FORCEINLINE_RECURSIVE
#define RAJA_INLINE inline __attribute__((always_inline))
#define RAJA_UNROLL
#define RAJA_UNROLL_COUNT(N)
// FIXME: alignx is breaking CUDA+xlc
#if defined(RAJA_ENABLE_CUDA)
#define RAJA_ALIGN_DATA(d) d
#else
#define RAJA_ALIGN_DATA(d) __alignx(RAJA::DATA_ALIGN, d)
#endif
#if defined(_OPENMP) && (_OPENMP >= 201307)
#define RAJA_SIMD RAJA_PRAGMA(omp simd)
#else
#define RAJA_SIMD RAJA_PRAGMA(simd_level(10))
#endif
// Detect altivec, but disable if NVCC is being used due to some bad interactions
#if defined(__ALTIVEC__) && (__ALTIVEC__ == 1) && !defined(__NVCC__)
#define RAJA_ALTIVEC
#endif
#elif defined(RAJA_COMPILER_CLANG)
//
// Configuration options for clang compilers
//
#define RAJA_MAX_ALIGN 16
#define RAJA_FORCEINLINE_RECURSIVE
#define RAJA_INLINE inline __attribute__((always_inline))
#define RAJA_UNROLL RAJA_PRAGMA(clang loop unroll(enable))
#define RAJA_UNROLL_COUNT(N) RAJA_PRAGMA(clang loop unroll_count(N))
// note that neither nvcc nor Apple Clang compiler currently doesn't support
// the __builtin_assume_aligned attribute
#if defined(RAJA_ENABLE_CUDA) || defined(__APPLE__)
#define RAJA_ALIGN_DATA(d) d
#else
#define RAJA_ALIGN_DATA(d) __builtin_assume_aligned(d, RAJA::DATA_ALIGN)
#endif
#if defined(_OPENMP) && (_OPENMP >= 201307) && (__clang_major__ >= 4 )
#define RAJA_SIMD RAJA_PRAGMA(omp simd)
#else
// Clang 3.7 and later changed the "pragma clang loop vectorize" options
// Apple Clang compiler supports older options
#if ( ( (__clang_major__ >= 4 ) || (__clang_major__ >= 3 && __clang_minor__ > 7) ) && !defined(__APPLE__) )
#define RAJA_SIMD RAJA_PRAGMA(clang loop vectorize(assume_safety))
#else
#define RAJA_SIMD RAJA_PRAGMA(clang loop vectorize(enable))
#endif
#endif
// Detect altivec, but only seems to work since Clang 9
#if defined(__ALTIVEC__) && (__clang_major__ >= 9 ) && (__ALTIVEC__ == 1)
#define RAJA_ALTIVEC
#endif
// This is the same as undefined compiler, but squelches the warning message
#elif defined(RAJA_COMPILER_MSVC)
#define RAJA_MAX_ALIGN alignof(std::max_align_t)
#define RAJA_FORCEINLINE_RECURSIVE
#define RAJA_INLINE inline
#define RAJA_ALIGN_DATA(d) d
#define RAJA_SIMD
#define RAJA_UNROLL
#define RAJA_UNROLL_COUNT(N)
#else
#pragma message("RAJA_COMPILER unknown, using default empty macros.")
#define RAJA_MAX_ALIGN 16
#define RAJA_FORCEINLINE_RECURSIVE
#define RAJA_INLINE inline
#define RAJA_ALIGN_DATA(d) d
#define RAJA_SIMD
#define RAJA_UNROLL
#define RAJA_UNROLL_COUNT(N)
#endif
static_assert(RAJA_MAX_ALIGN >= alignof(std::max_align_t) && (RAJA_MAX_ALIGN/alignof(std::max_align_t))*alignof(std::max_align_t) == RAJA_MAX_ALIGN,
"Inconsistent RAJA_MAX_ALIGN size");
#cmakedefine RAJA_HAVE_POSIX_MEMALIGN
#cmakedefine RAJA_HAVE_ALIGNED_ALLOC
#cmakedefine RAJA_HAVE_MM_MALLOC
//
//Creates a general framework for compiler alignment hints
//
// Example usage:
// double *a = RAJA::allocate_aligned_type<double>(RAJA::DATA_ALIGN,10*sizeof(double));
// double *y = RAJA::align_hint
template<typename T>
RAJA_INLINE
T * align_hint(T * x)
{
#if defined(RAJA_COMPILER_XLC) && defined(RAJA_ENABLE_CUDA)
return x;
#elif defined(RAJA_COMPILER_INTEL) || defined(RAJA_COMPILER_XLC)
RAJA_ALIGN_DATA(x);
return x;
#else
return static_cast<T *>(RAJA_ALIGN_DATA(x));
#endif
}
} // closing brace for RAJA namespace
#ifndef RAJA_UNROLL
#define RAJA_UNROLL
#endif
#ifndef RAJA_UNROLL_COUNT
#define RAJA_UNROLL_COUNT(N)
#endif
// If we're in CUDA or HIP device code, we can use the unroll pragma
#if (defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)) && defined(RAJA_GPU_ACTIVE)
#undef RAJA_UNROLL
#undef RAJA_UNROLL_COUNT
#define RAJA_UNROLL RAJA_PRAGMA(unroll)
#define RAJA_UNROLL_COUNT(N) RAJA_PRAGMA(unroll N)
#endif
#endif // closing endif for header file include guard