CMS 3D CMS Logo

CMSUnrollLoop.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_interface_CMSUnrollLoop_h
2 #define FWCore_Utilities_interface_CMSUnrollLoop_h
3 
5 
6 #if defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)
7 // CUDA or HIP device compiler
8 
9 #define CMS_UNROLL_LOOP _Pragma(EDM_STRINGIZE(unroll))
10 #define CMS_UNROLL_LOOP_COUNT(N) _Pragma(EDM_STRINGIZE(unroll N))
11 #define CMS_UNROLL_LOOP_DISABLE _Pragma(EDM_STRINGIZE(unroll 1))
12 
13 #define CMS_DEVICE_UNROLL_LOOP _Pragma(EDM_STRINGIZE(unroll))
14 #define CMS_DEVICE_UNROLL_LOOP_COUNT(N) _Pragma(EDM_STRINGIZE(unroll N))
15 #define CMS_DEVICE_UNROLL_LOOP_DISABLE _Pragma(EDM_STRINGIZE(unroll 1))
16 
17 #else // defined (__CUDA_ARCH__) || defined (__HIP_DEVICE_COMPILE__)
18 
19 // any host compiler
20 #define CMS_DEVICE_UNROLL_LOOP
21 #define CMS_DEVICE_UNROLL_LOOP_COUNT(N)
22 #define CMS_DEVICE_UNROLL_LOOP_DISABLE
23 
24 #if defined(__clang__)
25 // clang host compiler
26 
27 #define CMS_UNROLL_LOOP _Pragma(EDM_STRINGIZE(clang loop unroll(enable)))
28 #define CMS_UNROLL_LOOP_COUNT(N) _Pragma(EDM_STRINGIZE(clang loop unroll_count(N)))
29 #define CMS_UNROLL_LOOP_DISABLE _Pragma(EDM_STRINGIZE(clang loop unroll(disable)))
30 
31 #elif defined(__INTEL_COMPILER)
32 // Intel icc compiler
33 #define CMS_UNROLL_LOOP _Pragma(EDM_STRINGIZE(unroll))
34 #define CMS_UNROLL_LOOP_COUNT(N) _Pragma(EDM_STRINGIZE(unroll(N)))
35 #define CMS_UNROLL_LOOP_DISABLE _Pragma(EDM_STRINGIZE(nounroll))
36 
37 #elif defined(__GNUC__)
38 // GCC host compiler
39 
40 #define CMS_UNROLL_LOOP _Pragma(EDM_STRINGIZE(GCC ivdep))
41 #define CMS_UNROLL_LOOP_COUNT(N) _Pragma(EDM_STRINGIZE(GCC unroll N)) _Pragma(EDM_STRINGIZE(GCC ivdep))
42 #define CMS_UNROLL_LOOP_DISABLE _Pragma(EDM_STRINGIZE(GCC unroll 1))
43 
44 #else
45 // unsupported or unknown compiler
46 
47 #define CMS_UNROLL_LOOP
48 #define CMS_UNROLL_LOOP_COUNT(N)
49 #define CMS_UNROLL_LOOP_DISABLE
50 
51 #endif // defined(__clang__) || defined(__GNUC__) || ...
52 
53 #endif // defined (__CUDA_ARCH__) || defined (__HIP_DEVICE_COMPILE__)
54 
55 #endif // FWCore_Utilities_interface_CMSUnrollLoop_h