diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 2f7bbdfebc1f1..45d391ad175d1 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -3754,13 +3754,13 @@ class __SYCL_EXPORT handler { /// According to section 4.7.6.11. of the SYCL specification, a local accessor /// must not be used in a SYCL kernel function that is invoked via single_task /// or via the simple form of parallel_for that takes a range parameter. - template - void throwOnKernelParameterMisuse() const { - using NameT = - typename detail::get_kernel_name_t::name; - for (unsigned I = 0; I < detail::getKernelNumParams(); ++I) { - const detail::kernel_param_desc_t ParamDesc = - detail::getKernelParamDesc(I); + // + // Exception handling generates lots of code, outline it out of template + // method to improve compilation times. + void throwOnKernelParameterMisuseHelper( + int N, detail::kernel_param_desc_t (*f)(int)) const { + for (int I = 0; I < N; ++I) { + detail::kernel_param_desc_t ParamDesc = (*f)(I); const detail::kernel_param_kind_t &Kind = ParamDesc.kind; const access::target AccTarget = static_cast(ParamDesc.info & AccessTargetMask); @@ -3779,6 +3779,13 @@ class __SYCL_EXPORT handler { "of parallel_for that takes a range parameter."); } } + template + void throwOnKernelParameterMisuse() const { + using NameT = + typename detail::get_kernel_name_t::name; + throwOnKernelParameterMisuseHelper(detail::getKernelNumParams(), + &detail::getKernelParamDesc); + } template