Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:11

0001 #ifndef FWCore_Utilities_interface_CMSUnrollLoop_h
0002 #define FWCore_Utilities_interface_CMSUnrollLoop_h
0003 
0004 #include "FWCore/Utilities/interface/stringize.h"
0005 
0006 #if defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)
0007 // CUDA or HIP device compiler
0008 
0009 #define CMS_UNROLL_LOOP _Pragma(EDM_STRINGIZE(unroll))
0010 #define CMS_UNROLL_LOOP_COUNT(N) _Pragma(EDM_STRINGIZE(unroll N))
0011 #define CMS_UNROLL_LOOP_DISABLE _Pragma(EDM_STRINGIZE(unroll 1))
0012 
0013 #define CMS_DEVICE_UNROLL_LOOP _Pragma(EDM_STRINGIZE(unroll))
0014 #define CMS_DEVICE_UNROLL_LOOP_COUNT(N) _Pragma(EDM_STRINGIZE(unroll N))
0015 #define CMS_DEVICE_UNROLL_LOOP_DISABLE _Pragma(EDM_STRINGIZE(unroll 1))
0016 
0017 #else  // defined (__CUDA_ARCH__) || defined (__HIP_DEVICE_COMPILE__)
0018 
0019 // any host compiler
0020 #define CMS_DEVICE_UNROLL_LOOP
0021 #define CMS_DEVICE_UNROLL_LOOP_COUNT(N)
0022 #define CMS_DEVICE_UNROLL_LOOP_DISABLE
0023 
0024 #if defined(__clang__)
0025 // clang host compiler
0026 
0027 #define CMS_UNROLL_LOOP _Pragma(EDM_STRINGIZE(clang loop unroll(enable)))
0028 #define CMS_UNROLL_LOOP_COUNT(N) _Pragma(EDM_STRINGIZE(clang loop unroll_count(N)))
0029 #define CMS_UNROLL_LOOP_DISABLE _Pragma(EDM_STRINGIZE(clang loop unroll(disable)))
0030 
0031 #elif defined(__INTEL_COMPILER)
0032 // Intel icc compiler
0033 #define CMS_UNROLL_LOOP _Pragma(EDM_STRINGIZE(unroll))
0034 #define CMS_UNROLL_LOOP_COUNT(N) _Pragma(EDM_STRINGIZE(unroll(N)))
0035 #define CMS_UNROLL_LOOP_DISABLE _Pragma(EDM_STRINGIZE(nounroll))
0036 
0037 #elif defined(__GNUC__)
0038 // GCC host compiler
0039 
0040 #define CMS_UNROLL_LOOP _Pragma(EDM_STRINGIZE(GCC ivdep))
0041 #define CMS_UNROLL_LOOP_COUNT(N) _Pragma(EDM_STRINGIZE(GCC unroll N)) _Pragma(EDM_STRINGIZE(GCC ivdep))
0042 #define CMS_UNROLL_LOOP_DISABLE _Pragma(EDM_STRINGIZE(GCC unroll 1))
0043 
0044 #else
0045 // unsupported or unknown compiler
0046 
0047 #define CMS_UNROLL_LOOP
0048 #define CMS_UNROLL_LOOP_COUNT(N)
0049 #define CMS_UNROLL_LOOP_DISABLE
0050 
0051 #endif  // defined(__clang__) || defined(__GNUC__) || ...
0052 
0053 #endif  // defined (__CUDA_ARCH__) || defined (__HIP_DEVICE_COMPILE__)
0054 
0055 #endif  // FWCore_Utilities_interface_CMSUnrollLoop_h