Kokkos Core Kernels Package
Version of the Day
core
src
Kokkos_Macros.hpp
1
/*
2
//@HEADER
3
// ************************************************************************
4
//
5
// Kokkos v. 2.0
6
// Copyright (2014) Sandia Corporation
7
//
8
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9
// the U.S. Government retains certain rights in this software.
10
//
11
// Redistribution and use in source and binary forms, with or without
12
// modification, are permitted provided that the following conditions are
13
// met:
14
//
15
// 1. Redistributions of source code must retain the above copyright
16
// notice, this list of conditions and the following disclaimer.
17
//
18
// 2. Redistributions in binary form must reproduce the above copyright
19
// notice, this list of conditions and the following disclaimer in the
20
// documentation and/or other materials provided with the distribution.
21
//
22
// 3. Neither the name of the Corporation nor the names of the
23
// contributors may be used to endorse or promote products derived from
24
// this software without specific prior written permission.
25
//
26
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
//
38
// Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
39
//
40
// ************************************************************************
41
//@HEADER
42
*/
43
44
#ifndef KOKKOS_MACROS_HPP
45
#define KOKKOS_MACROS_HPP
46
47
//----------------------------------------------------------------------------
63
#ifndef KOKKOS_DONT_INCLUDE_CORE_CONFIG_H
64
#include <KokkosCore_config.h>
65
#endif
66
67
//----------------------------------------------------------------------------
97
//----------------------------------------------------------------------------
98
99
#if defined( KOKKOS_HAVE_CUDA ) && defined( __CUDACC__ )
100
101
/* Compiling with a CUDA compiler.
102
*
103
* Include <cuda.h> to pick up the CUDA_VERSION macro defined as:
104
* CUDA_VERSION = ( MAJOR_VERSION * 1000 ) + ( MINOR_VERSION * 10 )
105
*
106
* When generating device code the __CUDA_ARCH__ macro is defined as:
107
* __CUDA_ARCH__ = ( MAJOR_CAPABILITY * 100 ) + ( MINOR_CAPABILITY * 10 )
108
*/
109
110
#include <cuda_runtime.h>
111
#include <cuda.h>
112
113
#if ! defined( CUDA_VERSION )
114
#error "#include <cuda.h> did not define CUDA_VERSION"
115
#endif
116
117
#if ( CUDA_VERSION < 7000 )
118
// CUDA supports C++11 in device code starting with
119
// version 7.0. This includes auto type and device code internal
120
// lambdas.
121
#error "Cuda version 7.0 or greater required"
122
#endif
123
124
#if defined( __CUDA_ARCH__ ) && ( __CUDA_ARCH__ < 300 )
125
/* Compiling with CUDA compiler for device code. */
126
#error "Cuda device capability >= 3.0 is required"
127
#endif
128
129
#ifdef KOKKOS_CUDA_USE_LAMBDA
130
#if ( CUDA_VERSION < 7050 )
131
// CUDA supports C++11 lambdas generated in host code to be given
132
// to the device starting with version 7.5. But the release candidate (7.5.6)
133
// still identifies as 7.0
134
#error "Cuda version 7.5 or greater required for host-to-device Lambda support"
135
#endif
136
#if ( CUDA_VERSION < 8000 ) && defined(__NVCC__)
137
#define KOKKOS_LAMBDA [=]__device__
138
#else
139
#define KOKKOS_LAMBDA [=]__host__ __device__
140
#if defined( KOKKOS_HAVE_CXX1Z )
141
#define KOKKOS_CLASS_LAMBDA [=,*this] __host__ __device__
142
#endif
143
#endif
144
#define KOKKOS_HAVE_CXX11_DISPATCH_LAMBDA 1
145
#endif
146
#endif
/* #if defined( KOKKOS_HAVE_CUDA ) && defined( __CUDACC__ ) */
147
148
149
#if defined(KOKKOS_HAVE_CXX11_DISPATCH_LAMBDA)
150
// Cuda version 8.0 still needs the functor wrapper
151
#if (KOKKOS_HAVE_CXX11_DISPATCH_LAMBDA
/* && (CUDA_VERSION < 8000) */
) && defined(__NVCC__)
152
#define KOKKOS_IMPL_NEED_FUNCTOR_WRAPPER
153
#endif
154
#endif
155
156
/*--------------------------------------------------------------------------*/
157
/* Language info: C++, CUDA, OPENMP */
158
159
#if defined( KOKKOS_HAVE_CUDA )
160
// Compiling Cuda code to 'ptx'
161
162
#define KOKKOS_FORCEINLINE_FUNCTION __device__ __host__ __forceinline__
163
#define KOKKOS_INLINE_FUNCTION __device__ __host__ inline
164
#define KOKKOS_FUNCTION __device__ __host__
165
#endif
/* #if defined( __CUDA_ARCH__ ) */
166
167
#if defined( _OPENMP )
168
169
/* Compiling with OpenMP.
170
* The value of _OPENMP is an integer value YYYYMM
171
* where YYYY and MM are the year and month designation
172
* of the supported OpenMP API version.
173
*/
174
175
#endif
/* #if defined( _OPENMP ) */
176
177
/*--------------------------------------------------------------------------*/
178
/* Mapping compiler built-ins to KOKKOS_COMPILER_*** macros */
179
180
#if defined( __NVCC__ )
181
// NVIDIA compiler is being used.
182
// Code is parsed and separated into host and device code.
183
// Host code is compiled again with another compiler.
184
// Device code is compile to 'ptx'.
185
#define KOKKOS_COMPILER_NVCC __NVCC__
186
187
#else
188
#if defined( KOKKOS_HAVE_CXX11 ) && ! defined( KOKKOS_HAVE_CXX11_DISPATCH_LAMBDA )
189
#if !defined (KOKKOS_HAVE_CUDA) // Compiling with clang for Cuda does not work with LAMBDAs either
190
// CUDA (including version 6.5) does not support giving lambdas as
191
// arguments to global functions. Thus its not currently possible
192
// to dispatch lambdas from the host.
193
#define KOKKOS_HAVE_CXX11_DISPATCH_LAMBDA 1
194
#endif
195
#endif
196
#endif
/* #if defined( __NVCC__ ) */
197
198
#if defined( KOKKOS_HAVE_CXX11 ) && !defined (KOKKOS_LAMBDA)
199
#define KOKKOS_LAMBDA [=]
200
#endif
201
202
#if defined( KOKKOS_HAVE_CXX1Z ) && !defined (KOKKOS_CLASS_LAMBDA)
203
#define KOKKOS_CLASS_LAMBDA [=,*this]
204
#endif
205
206
//#if ! defined( __CUDA_ARCH__ ) /* Not compiling Cuda code to 'ptx'. */
207
208
/* Intel compiler for host code */
209
210
#if defined( __INTEL_COMPILER )
211
#define KOKKOS_COMPILER_INTEL __INTEL_COMPILER
212
#elif defined( __ICC )
213
// Old define
214
#define KOKKOS_COMPILER_INTEL __ICC
215
#elif defined( __ECC )
216
// Very old define
217
#define KOKKOS_COMPILER_INTEL __ECC
218
#endif
219
220
/* CRAY compiler for host code */
221
#if defined( _CRAYC )
222
#define KOKKOS_COMPILER_CRAYC _CRAYC
223
#endif
224
225
#if defined( __IBMCPP__ )
226
// IBM C++
227
#define KOKKOS_COMPILER_IBM __IBMCPP__
228
#elif defined( __IBMC__ )
229
#define KOKKOS_COMPILER_IBM __IBMC__
230
#endif
231
232
#if defined( __APPLE_CC__ )
233
#define KOKKOS_COMPILER_APPLECC __APPLE_CC__
234
#endif
235
236
#if defined (__clang__) && !defined (KOKKOS_COMPILER_INTEL)
237
#define KOKKOS_COMPILER_CLANG __clang_major__*100+__clang_minor__*10+__clang_patchlevel__
238
#endif
239
240
#if ! defined( __clang__ ) && ! defined( KOKKOS_COMPILER_INTEL ) &&defined( __GNUC__ )
241
#define KOKKOS_COMPILER_GNU __GNUC__*100+__GNUC_MINOR__*10+__GNUC_PATCHLEVEL__
242
#if ( 472 > KOKKOS_COMPILER_GNU )
243
#error "Compiling with GCC version earlier than 4.7.2 is not supported."
244
#endif
245
#endif
246
247
#if defined( __PGIC__ ) && ! defined( __GNUC__ )
248
#define KOKKOS_COMPILER_PGI __PGIC__*100+__PGIC_MINOR__*10+__PGIC_PATCHLEVEL__
249
#if ( 1540 > KOKKOS_COMPILER_PGI )
250
#error "Compiling with PGI version earlier than 15.4 is not supported."
251
#endif
252
#endif
253
254
//#endif /* #if ! defined( __CUDA_ARCH__ ) */
255
256
/*--------------------------------------------------------------------------*/
257
/*--------------------------------------------------------------------------*/
258
/* Intel compiler macros */
259
260
#if defined( KOKKOS_COMPILER_INTEL )
261
262
#define KOKKOS_HAVE_PRAGMA_UNROLL 1
263
#define KOKKOS_HAVE_PRAGMA_IVDEP 1
264
#define KOKKOS_HAVE_PRAGMA_LOOPCOUNT 1
265
#define KOKKOS_HAVE_PRAGMA_VECTOR 1
266
#define KOKKOS_HAVE_PRAGMA_SIMD 1
267
268
#if ( 1400 > KOKKOS_COMPILER_INTEL )
269
#if ( 1300 > KOKKOS_COMPILER_INTEL )
270
#error "Compiling with Intel version earlier than 13.0 is not supported. Official minimal version is 14.0."
271
#else
272
#warning "Compiling with Intel version 13.x probably works but is not officially supported. Official minimal version is 14.0."
273
#endif
274
#endif
275
#if ( 1200 <= KOKKOS_COMPILER_INTEL ) && ! defined( KOKKOS_ENABLE_ASM ) && ! defined( _WIN32 )
276
#define KOKKOS_ENABLE_ASM 1
277
#endif
278
279
#if ( 1200 <= KOKKOS_COMPILER_INTEL ) && ! defined( KOKKOS_FORCEINLINE_FUNCTION )
280
#if !defined (_WIN32)
281
#define KOKKOS_FORCEINLINE_FUNCTION inline __attribute__((always_inline))
282
#else
283
#define KOKKOS_FORCEINLINE_FUNCTION inline
284
#endif
285
#endif
286
287
#if defined( __MIC__ )
288
// Compiling for Xeon Phi
289
#endif
290
291
#endif
292
293
/*--------------------------------------------------------------------------*/
294
/* Cray compiler macros */
295
296
#if defined( KOKKOS_COMPILER_CRAYC )
297
298
299
#endif
300
301
/*--------------------------------------------------------------------------*/
302
/* IBM Compiler macros */
303
304
#if defined( KOKKOS_COMPILER_IBM )
305
306
#define KOKKOS_HAVE_PRAGMA_UNROLL 1
307
//#define KOKKOS_HAVE_PRAGMA_IVDEP 1
308
//#define KOKKOS_HAVE_PRAGMA_LOOPCOUNT 1
309
//#define KOKKOS_HAVE_PRAGMA_VECTOR 1
310
//#define KOKKOS_HAVE_PRAGMA_SIMD 1
311
312
#endif
313
314
/*--------------------------------------------------------------------------*/
315
/* CLANG compiler macros */
316
317
#if defined( KOKKOS_COMPILER_CLANG )
318
319
//#define KOKKOS_HAVE_PRAGMA_UNROLL 1
320
//#define KOKKOS_HAVE_PRAGMA_IVDEP 1
321
//#define KOKKOS_HAVE_PRAGMA_LOOPCOUNT 1
322
//#define KOKKOS_HAVE_PRAGMA_VECTOR 1
323
//#define KOKKOS_HAVE_PRAGMA_SIMD 1
324
325
#if ! defined( KOKKOS_FORCEINLINE_FUNCTION )
326
#define KOKKOS_FORCEINLINE_FUNCTION inline __attribute__((always_inline))
327
#endif
328
329
#endif
330
331
/*--------------------------------------------------------------------------*/
332
/* GNU Compiler macros */
333
334
#if defined( KOKKOS_COMPILER_GNU )
335
336
//#define KOKKOS_HAVE_PRAGMA_UNROLL 1
337
//#define KOKKOS_HAVE_PRAGMA_IVDEP 1
338
//#define KOKKOS_HAVE_PRAGMA_LOOPCOUNT 1
339
//#define KOKKOS_HAVE_PRAGMA_VECTOR 1
340
//#define KOKKOS_HAVE_PRAGMA_SIMD 1
341
342
#if ! defined( KOKKOS_FORCEINLINE_FUNCTION )
343
#define KOKKOS_FORCEINLINE_FUNCTION inline __attribute__((always_inline))
344
#endif
345
346
#if ! defined( KOKKOS_ENABLE_ASM ) && ! defined( __PGIC__ ) && \
347
( defined( __amd64 ) || \
348
defined( __amd64__ ) || \
349
defined( __x86_64 ) || \
350
defined( __x86_64__ ) )
351
#define KOKKOS_ENABLE_ASM 1
352
#endif
353
354
#endif
355
356
/*--------------------------------------------------------------------------*/
357
358
#if defined( KOKKOS_COMPILER_PGI )
359
360
#define KOKKOS_HAVE_PRAGMA_UNROLL 1
361
#define KOKKOS_HAVE_PRAGMA_IVDEP 1
362
//#define KOKKOS_HAVE_PRAGMA_LOOPCOUNT 1
363
#define KOKKOS_HAVE_PRAGMA_VECTOR 1
364
//#define KOKKOS_HAVE_PRAGMA_SIMD 1
365
366
#endif
367
368
/*--------------------------------------------------------------------------*/
369
370
#if defined( KOKKOS_COMPILER_NVCC )
371
372
#if defined(__CUDA_ARCH__ )
373
#define KOKKOS_HAVE_PRAGMA_UNROLL 1
374
#endif
375
376
#endif
377
378
//----------------------------------------------------------------------------
381
#if ! defined( KOKKOS_FORCEINLINE_FUNCTION )
382
#define KOKKOS_FORCEINLINE_FUNCTION inline
383
#endif
384
385
#if ! defined( KOKKOS_INLINE_FUNCTION )
386
#define KOKKOS_INLINE_FUNCTION inline
387
#endif
388
389
#if ! defined( KOKKOS_FUNCTION )
390
#define KOKKOS_FUNCTION
391
#endif
392
393
//----------------------------------------------------------------------------
395
#if ! defined(KOKKOS_ALIGN_16)
396
#define KOKKOS_ALIGN_16 __attribute__((aligned(16)))
397
#endif
398
399
//----------------------------------------------------------------------------
404
#if 1 < ( ( defined ( KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_CUDA ) ? 1 : 0 ) + \
405
( defined ( KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_OPENMP ) ? 1 : 0 ) + \
406
( defined ( KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_THREADS ) ? 1 : 0 ) + \
407
( defined ( KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_SERIAL ) ? 1 : 0 ) )
408
409
#error "More than one KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_* specified" ;
410
411
#endif
412
416
#if defined ( KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_CUDA )
417
#elif defined ( KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_OPENMP )
418
#elif defined ( KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_THREADS )
419
#elif defined ( KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_SERIAL )
420
#elif defined ( KOKKOS_HAVE_CUDA )
421
#define KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_CUDA
422
#elif defined ( KOKKOS_HAVE_OPENMP )
423
#define KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_OPENMP
424
#elif defined ( KOKKOS_HAVE_PTHREAD )
425
#define KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_THREADS
426
#else
427
#define KOKKOS_HAVE_DEFAULT_DEVICE_TYPE_SERIAL
428
#endif
429
430
//----------------------------------------------------------------------------
433
#if defined( __CUDACC__ ) && defined( __CUDA_ARCH__ ) && defined (KOKKOS_HAVE_CUDA)
434
#define KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_CUDA
435
#else
436
#define KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
437
#endif
438
439
//----------------------------------------------------------------------------
440
//----------------------------------------------------------------------------
441
442
#if ( defined( _POSIX_C_SOURCE ) && _POSIX_C_SOURCE >= 200112L ) || \
443
( defined( _XOPEN_SOURCE ) && _XOPEN_SOURCE >= 600 )
444
#if defined(KOKKOS_ENABLE_PERFORMANCE_POSIX_MEMALIGN)
445
#define KOKKOS_POSIX_MEMALIGN_AVAILABLE 1
446
#endif
447
#endif
448
449
//----------------------------------------------------------------------------
450
//----------------------------------------------------------------------------
451
454
#ifndef KOKKOS_ENABLE_PROFILING
455
#define KOKKOS_ENABLE_PROFILING 1
456
#endif
457
458
//----------------------------------------------------------------------------
459
//----------------------------------------------------------------------------
460
/* Transitional macro to change between old and new View
461
* are no longer supported.
462
*/
463
464
#define KOKKOS_USING_EXP_VIEW 1
465
#define KOKKOS_USING_EXPERIMENTAL_VIEW
466
467
//----------------------------------------------------------------------------
468
//----------------------------------------------------------------------------
469
470
#endif
/* #ifndef KOKKOS_MACROS_HPP */
471
Generated by
1.8.13