From f26371ae30c8d4bff9684e9a774908f02867d09f Mon Sep 17 00:00:00 2001 From: vasilito Date: Sat, 25 Jul 2026 14:29:34 +0900 Subject: [PATCH] recipes: add libclc as a local Red Bear OS project (Cat 1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libclc was vendored at recipes/dev/llvm21/source/libclc/ as a build artifact of the llvm21 fork. This promoted it from an implicit Mesa dependency (the CLC bitcode Mesa consumes) to a first-class local project, mirroring how tlc, redbear-*, cub, etc. are organized per local/AGENTS.md. Local layout follows the existing in-house pattern: recipes/dev/libclc -> ../../local/recipes/dev/libclc local/recipes/dev/libclc/recipe.toml local/recipes/dev/libclc/source/ (vendored from llvm-project) The recipe builds libclc as a host-side CMake project using the cookbook-sysroot clang21 binary (not the cross-compiler) to compile OpenCL kernels to .bc bitcode. Output targets are amdgcn, amdgcn-amdhsa, r600, generic, and spirv — the union that Mesa's clc tool consumes for the iris/radeonsi/llvmpipe drivers. ptx-nvidiacl and clspv are excluded because they don't map onto any Mesa hardware driver. The recipe also wires the cookbook's native-cmake generation with an override that points CMAKE_C_COMPILER etc. at the cookbook sysroot's clang-21 binary. This is needed because libclc must run on the build host (output is bitcode, not a Redox binary), and the cookbook's default cross-toolchain would link the build against relibc instead of host glibc. libclc.pc is installed at usr/lib/pkgconfig/, satisfying Mesa's dependency('libclc') lookup. The .bc files are installed under usr/share/clc/, which is what the libclc.pc libexecdir pointer (libexecdir=/share/clc) expects. This is the prerequisite for re-enabling iris, radeonsi, and the Intel Vulkan driver in the Mesa recipe (Phase 4-6 of local/docs/3D-DRIVER-PLAN.md). With libclc available in the cross-sysroot, mesa's meson '-Dwith_clc -> dependency(libclc)' resolves and the gallium drivers compile. --- local/recipes/dev/libclc/recipe.toml | 124 ++ .../recipes/dev/libclc/source/CMakeLists.txt | 486 +++++ local/recipes/dev/libclc/source/CREDITS.TXT | 2 + local/recipes/dev/libclc/source/LICENSE.TXT | 299 +++ .../recipes/dev/libclc/source/Maintainers.md | 17 + local/recipes/dev/libclc/source/README.md | 67 + .../dev/libclc/source/check_external_calls.sh | 30 + .../clc/include/clc/async/clc_prefetch.h | 18 + .../clc/include/clc/async/clc_prefetch.inc | 10 + .../source/clc/include/clc/clc_as_type.h | 90 + .../source/clc/include/clc/clc_convert.h | 108 ++ .../libclc/source/clc/include/clc/clcfunc.h | 40 + .../libclc/source/clc/include/clc/clcmacro.h | 69 + .../libclc/source/clc/include/clc/clctypes.h | 108 ++ .../clc/include/clc/common/clc_degrees.h | 19 + .../clc/include/clc/common/clc_radians.h | 19 + .../source/clc/include/clc/common/clc_sign.h | 19 + .../clc/include/clc/common/clc_smoothstep.h | 18 + .../clc/include/clc/common/clc_smoothstep.inc | 11 + .../source/clc/include/clc/common/clc_step.h | 19 + .../clc/include/clc/float/definitions.h | 96 + .../clc/include/clc/geometric/binary_decl.inc | 16 + .../clc/include/clc/geometric/binary_def.inc | 24 + .../clc/include/clc/geometric/clc_cross.h | 33 + .../clc/include/clc/geometric/clc_distance.h | 19 + .../clc/include/clc/geometric/clc_dot.h | 19 + .../include/clc/geometric/clc_fast_distance.h | 20 + .../include/clc/geometric/clc_fast_length.h | 20 + .../clc/geometric/clc_fast_normalize.h | 21 + .../clc/include/clc/geometric/clc_length.h | 19 + .../clc/include/clc/geometric/clc_normalize.h | 20 + .../clc/include/clc/geometric/unary_decl.inc | 21 + .../clc/include/clc/geometric/unary_def.inc | 29 + .../source/clc/include/clc/integer/clc_abs.h | 15 + .../clc/include/clc/integer/clc_abs.inc | 9 + .../clc/include/clc/integer/clc_abs_diff.h | 15 + .../clc/include/clc/integer/clc_abs_diff.inc | 10 + .../clc/include/clc/integer/clc_add_sat.h | 19 + .../source/clc/include/clc/integer/clc_clz.h | 19 + .../source/clc/include/clc/integer/clc_ctz.h | 19 + .../source/clc/include/clc/integer/clc_hadd.h | 19 + .../clc/include/clc/integer/clc_mad24.h | 19 + .../clc/include/clc/integer/clc_mad_hi.h | 16 + .../clc/include/clc/integer/clc_mad_sat.h | 19 + .../clc/include/clc/integer/clc_mul24.h | 19 + .../clc/include/clc/integer/clc_mul_hi.h | 19 + .../clc/include/clc/integer/clc_popcount.h | 20 + .../clc/include/clc/integer/clc_rhadd.h | 19 + .../clc/include/clc/integer/clc_rotate.h | 19 + .../clc/include/clc/integer/clc_sub_sat.h | 19 + .../clc/include/clc/integer/clc_upsample.h | 40 + .../clc/include/clc/integer/definitions.h | 32 + .../clc/include/clc/integer/gentype.inc | 602 ++++++ .../clc/include/clc/integer/gentype24.inc | 145 ++ .../source/clc/include/clc/internal/clc.h | 37 + .../include/clc/internal/math/clc_sw_fma.h | 19 + .../binary_decl_with_scalar_second_arg.inc | 12 + .../include/clc/math/binary_def_via_fp32.inc | 13 + .../source/clc/include/clc/math/clc_acos.h | 19 + .../source/clc/include/clc/math/clc_acosh.h | 19 + .../source/clc/include/clc/math/clc_acospi.h | 19 + .../source/clc/include/clc/math/clc_asin.h | 19 + .../source/clc/include/clc/math/clc_asinh.h | 19 + .../source/clc/include/clc/math/clc_asinpi.h | 19 + .../source/clc/include/clc/math/clc_atan.h | 19 + .../source/clc/include/clc/math/clc_atan2.h | 19 + .../source/clc/include/clc/math/clc_atan2pi.h | 19 + .../source/clc/include/clc/math/clc_atanh.h | 19 + .../source/clc/include/clc/math/clc_atanpi.h | 19 + .../source/clc/include/clc/math/clc_cbrt.inc | 19 + .../source/clc/include/clc/math/clc_ceil.h | 19 + .../clc/include/clc/math/clc_copysign.h | 19 + .../source/clc/include/clc/math/clc_cos.h | 19 + .../source/clc/include/clc/math/clc_cosh.h | 19 + .../source/clc/include/clc/math/clc_cospi.h | 19 + .../source/clc/include/clc/math/clc_ep_log.h | 15 + .../clc/include/clc/math/clc_ep_log.inc | 16 + .../source/clc/include/clc/math/clc_erf.h | 19 + .../source/clc/include/clc/math/clc_erfc.h | 19 + .../source/clc/include/clc/math/clc_exp.h | 19 + .../source/clc/include/clc/math/clc_exp10.h | 19 + .../source/clc/include/clc/math/clc_exp2.h | 19 + .../clc/include/clc/math/clc_exp_helper.h | 17 + .../clc/include/clc/math/clc_exp_helper.inc | 13 + .../source/clc/include/clc/math/clc_expm1.h | 19 + .../source/clc/include/clc/math/clc_fabs.h | 19 + .../source/clc/include/clc/math/clc_fdim.h | 19 + .../source/clc/include/clc/math/clc_floor.h | 19 + .../source/clc/include/clc/math/clc_fma.h | 19 + .../source/clc/include/clc/math/clc_fmax.h | 19 + .../source/clc/include/clc/math/clc_fmin.h | 19 + .../source/clc/include/clc/math/clc_fmod.h | 19 + .../source/clc/include/clc/math/clc_fract.h | 19 + .../source/clc/include/clc/math/clc_frexp.h | 18 + .../clc/include/clc/math/clc_half_cos.h | 20 + .../clc/include/clc/math/clc_half_divide.h | 20 + .../clc/include/clc/math/clc_half_exp.h | 20 + .../clc/include/clc/math/clc_half_exp10.h | 20 + .../clc/include/clc/math/clc_half_exp2.h | 20 + .../clc/include/clc/math/clc_half_log.h | 20 + .../clc/include/clc/math/clc_half_log10.h | 20 + .../clc/include/clc/math/clc_half_log2.h | 20 + .../clc/include/clc/math/clc_half_powr.h | 20 + .../clc/include/clc/math/clc_half_recip.h | 20 + .../clc/include/clc/math/clc_half_rsqrt.h | 20 + .../clc/include/clc/math/clc_half_sin.h | 20 + .../clc/include/clc/math/clc_half_sqrt.h | 20 + .../clc/include/clc/math/clc_half_tan.h | 20 + .../source/clc/include/clc/math/clc_hypot.h | 19 + .../source/clc/include/clc/math/clc_ilogb.h | 18 + .../source/clc/include/clc/math/clc_ldexp.h | 15 + .../source/clc/include/clc/math/clc_ldexp.inc | 9 + .../source/clc/include/clc/math/clc_lgamma.h | 19 + .../clc/include/clc/math/clc_lgamma_r.h | 19 + .../source/clc/include/clc/math/clc_log.h | 19 + .../source/clc/include/clc/math/clc_log10.h | 19 + .../source/clc/include/clc/math/clc_log1p.h | 19 + .../source/clc/include/clc/math/clc_log2.h | 19 + .../source/clc/include/clc/math/clc_logb.h | 18 + .../source/clc/include/clc/math/clc_mad.h | 19 + .../source/clc/include/clc/math/clc_maxmag.h | 19 + .../source/clc/include/clc/math/clc_minmag.h | 19 + .../source/clc/include/clc/math/clc_modf.h | 18 + .../source/clc/include/clc/math/clc_nan.h | 19 + .../source/clc/include/clc/math/clc_nan.inc | 10 + .../clc/include/clc/math/clc_native_cos.h | 20 + .../clc/include/clc/math/clc_native_divide.h | 20 + .../clc/include/clc/math/clc_native_exp.h | 20 + .../clc/include/clc/math/clc_native_exp10.h | 20 + .../clc/include/clc/math/clc_native_exp2.h | 20 + .../clc/include/clc/math/clc_native_log.h | 20 + .../clc/include/clc/math/clc_native_log10.h | 20 + .../clc/include/clc/math/clc_native_log2.h | 20 + .../clc/include/clc/math/clc_native_powr.h | 20 + .../clc/include/clc/math/clc_native_recip.h | 20 + .../clc/include/clc/math/clc_native_rsqrt.h | 20 + .../clc/include/clc/math/clc_native_sin.h | 20 + .../clc/include/clc/math/clc_native_sqrt.h | 20 + .../clc/include/clc/math/clc_native_tan.h | 20 + .../clc/include/clc/math/clc_nextafter.h | 19 + .../source/clc/include/clc/math/clc_pow.h | 19 + .../source/clc/include/clc/math/clc_pown.h | 19 + .../source/clc/include/clc/math/clc_powr.h | 19 + .../clc/include/clc/math/clc_remainder.h | 19 + .../source/clc/include/clc/math/clc_remquo.h | 19 + .../source/clc/include/clc/math/clc_rint.h | 19 + .../source/clc/include/clc/math/clc_rootn.h | 19 + .../source/clc/include/clc/math/clc_round.h | 19 + .../source/clc/include/clc/math/clc_rsqrt.h | 19 + .../source/clc/include/clc/math/clc_sin.h | 19 + .../source/clc/include/clc/math/clc_sincos.h | 19 + .../clc/include/clc/math/clc_sincos_helpers.h | 22 + .../include/clc/math/clc_sincos_helpers.inc | 18 + .../clc/math/clc_sincos_helpers_fp64.inc | 17 + .../clc/include/clc/math/clc_sincos_piby4.h | 14 + .../clc/include/clc/math/clc_sincos_piby4.inc | 174 ++ .../source/clc/include/clc/math/clc_sinh.h | 19 + .../source/clc/include/clc/math/clc_sinpi.h | 19 + .../source/clc/include/clc/math/clc_sqrt.h | 19 + .../include/clc/math/clc_subnormal_config.h | 18 + .../source/clc/include/clc/math/clc_tan.h | 19 + .../source/clc/include/clc/math/clc_tanh.h | 19 + .../source/clc/include/clc/math/clc_tanpi.h | 19 + .../source/clc/include/clc/math/clc_tgamma.h | 19 + .../source/clc/include/clc/math/clc_trunc.h | 19 + .../source/clc/include/clc/math/gentype.inc | 355 ++++ .../libclc/source/clc/include/clc/math/math.h | 125 ++ .../clc/include/clc/math/remquo_decl.inc | 20 + .../source/clc/include/clc/math/tables.h | 105 + .../clc/include/clc/math/unary_decl.inc | 9 + .../clc/math/unary_decl_with_int_ptr.inc | 18 + .../clc/math/unary_decl_with_int_return.inc | 9 + .../include/clc/math/unary_decl_with_ptr.inc | 19 + .../include/clc/math/unary_def_via_fp32.inc | 11 + .../clc/math/unary_def_with_int_ptr.inc | 35 + .../clc/math/unary_def_with_int_return.inc | 17 + .../include/clc/math/unary_def_with_ptr.inc | 35 + .../source/clc/include/clc/misc/clc_shuffle.h | 24 + .../clc/include/clc/misc/clc_shuffle2.h | 24 + .../clc/include/clc/misc/shuffle2_decl.inc | 28 + .../clc/include/clc/misc/shuffle2_def.inc | 42 + .../clc/include/clc/misc/shuffle_decl.inc | 24 + .../clc/include/clc/misc/shuffle_def.inc | 38 + .../include/clc/relational/binary_decl.inc | 9 + .../clc/include/clc/relational/clc_all.h | 33 + .../clc/include/clc/relational/clc_any.h | 33 + .../include/clc/relational/clc_bitselect.h | 17 + .../include/clc/relational/clc_bitselect.inc | 11 + .../clc/include/clc/relational/clc_isequal.h | 43 + .../clc/include/clc/relational/clc_isfinite.h | 19 + .../include/clc/relational/clc_isgreater.h | 19 + .../clc/relational/clc_isgreaterequal.h | 19 + .../clc/include/clc/relational/clc_isinf.h | 43 + .../clc/include/clc/relational/clc_isless.h | 19 + .../include/clc/relational/clc_islessequal.h | 19 + .../clc/relational/clc_islessgreater.h | 19 + .../clc/include/clc/relational/clc_isnan.h | 43 + .../clc/include/clc/relational/clc_isnormal.h | 19 + .../include/clc/relational/clc_isnotequal.h | 19 + .../include/clc/relational/clc_isordered.h | 19 + .../include/clc/relational/clc_isunordered.h | 19 + .../clc/include/clc/relational/clc_select.h | 23 + .../clc/relational/clc_select_decl.inc | 14 + .../clc/relational/clc_select_impl.inc | 19 + .../clc/include/clc/relational/clc_signbit.h | 19 + .../clc/include/clc/relational/floatn.inc | 132 ++ .../clc/include/clc/relational/relational.h | 68 + .../clc/include/clc/relational/unary_decl.inc | 9 + .../clc/include/clc/shared/binary_decl.inc | 10 + .../binary_decl_with_int_second_arg.inc | 11 + .../binary_decl_with_scalar_second_arg.inc | 15 + .../clc/include/clc/shared/binary_def.inc | 18 + .../clc/shared/binary_def_scalarize.inc | 131 ++ .../shared/binary_def_with_int_second_arg.inc | 17 + .../binary_def_with_scalar_second_arg.inc | 25 + .../source/clc/include/clc/shared/clc_clamp.h | 18 + .../clc/include/clc/shared/clc_clamp.inc | 17 + .../clc/shared/clc_less_aligned_types.h | 23 + .../clc/shared/clc_less_aligned_types.inc | 23 + .../source/clc/include/clc/shared/clc_max.h | 18 + .../source/clc/include/clc/shared/clc_max.inc | 15 + .../source/clc/include/clc/shared/clc_min.h | 18 + .../source/clc/include/clc/shared/clc_min.inc | 15 + .../source/clc/include/clc/shared/clc_vload.h | 20 + .../clc/include/clc/shared/clc_vload.inc | 64 + .../clc/include/clc/shared/clc_vstore.h | 20 + .../clc/include/clc/shared/clc_vstore.inc | 70 + .../clc/include/clc/shared/ternary_decl.inc | 10 + .../clc/include/clc/shared/ternary_def.inc | 18 + .../clc/shared/ternary_def_scalarize.inc | 153 ++ .../clc/include/clc/shared/unary_decl.inc | 9 + .../clc/include/clc/shared/unary_def.inc | 17 + .../clc/shared/unary_def_scalarize.inc | 97 + .../dev/libclc/source/clc/include/clc/utils.h | 18 + .../include/clc/workitem/clc_get_global_id.h | 16 + .../clc/workitem/clc_get_global_offset.h | 16 + .../clc/workitem/clc_get_global_size.h | 16 + .../include/clc/workitem/clc_get_group_id.h | 16 + .../include/clc/workitem/clc_get_local_id.h | 16 + .../clc/workitem/clc_get_local_linear_id.h | 16 + .../include/clc/workitem/clc_get_local_size.h | 16 + .../clc/workitem/clc_get_max_sub_group_size.h | 16 + .../include/clc/workitem/clc_get_num_groups.h | 16 + .../clc/workitem/clc_get_num_sub_groups.h | 16 + .../clc/workitem/clc_get_sub_group_id.h | 16 + .../clc/workitem/clc_get_sub_group_local_id.h | 16 + .../clc/workitem/clc_get_sub_group_size.h | 16 + .../include/clc/workitem/clc_get_work_dim.h | 16 + .../dev/libclc/source/clc/lib/amdgcn/SOURCES | 8 + .../source/clc/lib/amdgcn/math/clc_fmax.cl | 49 + .../source/clc/lib/amdgcn/math/clc_fmin.cl | 50 + .../clc/lib/amdgcn/math/clc_ldexp_override.cl | 34 + .../amdgcn/workitem/clc_get_global_offset.cl | 24 + .../amdgcn/workitem/clc_get_global_size.cl | 22 + .../lib/amdgcn/workitem/clc_get_group_id.cl | 22 + .../lib/amdgcn/workitem/clc_get_local_id.cl | 22 + .../lib/amdgcn/workitem/clc_get_work_dim.cl | 22 + .../dev/libclc/source/clc/lib/amdgpu/SOURCES | 13 + .../clc/lib/amdgpu/math/clc_half_exp.cl | 14 + .../clc/lib/amdgpu/math/clc_half_exp10.cl | 14 + .../clc/lib/amdgpu/math/clc_half_exp2.cl | 15 + .../clc/lib/amdgpu/math/clc_half_log.cl | 14 + .../clc/lib/amdgpu/math/clc_half_log10.cl | 14 + .../clc/lib/amdgpu/math/clc_half_log2.cl | 14 + .../lib/amdgpu/math/clc_half_native_unary.inc | 20 + .../clc/lib/amdgpu/math/clc_half_recip.cl | 14 + .../clc/lib/amdgpu/math/clc_half_rsqrt.cl | 14 + .../clc/lib/amdgpu/math/clc_half_sqrt.cl | 14 + .../clc/lib/amdgpu/math/clc_native_exp.cl | 15 + .../clc/lib/amdgpu/math/clc_native_exp.inc | 11 + .../clc/lib/amdgpu/math/clc_native_exp2.cl | 17 + .../clc/lib/amdgpu/math/clc_native_log10.cl | 15 + .../clc/lib/amdgpu/math/clc_native_log10.inc | 11 + .../clc/lib/amdgpu/math/clc_sqrt_fp64.cl | 51 + .../dev/libclc/source/clc/lib/clspv/SOURCES | 2 + .../clc/lib/clspv/integer/clc_mul_hi.cl | 12 + .../source/clc/lib/clspv/math/clc_sw_fma.cl | 275 +++ .../dev/libclc/source/clc/lib/generic/SOURCES | 158 ++ .../clc/lib/generic/async/clc_prefetch.cl | 16 + .../clc/lib/generic/async/clc_prefetch.inc | 10 + .../clc/lib/generic/common/clc_degrees.cl | 42 + .../clc/lib/generic/common/clc_radians.cl | 42 + .../source/clc/lib/generic/common/clc_sign.cl | 14 + .../clc/lib/generic/common/clc_sign.inc | 14 + .../clc/lib/generic/common/clc_smoothstep.cl | 38 + .../source/clc/lib/generic/common/clc_step.cl | 12 + .../clc/lib/generic/common/clc_step.inc | 12 + .../clc/lib/generic/geometric/clc_cross.cl | 12 + .../clc/lib/generic/geometric/clc_cross.inc | 25 + .../clc/lib/generic/geometric/clc_distance.cl | 13 + .../lib/generic/geometric/clc_distance.inc | 17 + .../clc/lib/generic/geometric/clc_dot.cl | 13 + .../clc/lib/generic/geometric/clc_dot.inc | 25 + .../generic/geometric/clc_fast_distance.cl | 14 + .../generic/geometric/clc_fast_distance.inc | 17 + .../lib/generic/geometric/clc_fast_length.cl | 28 + .../generic/geometric/clc_fast_normalize.cl | 15 + .../generic/geometric/clc_fast_normalize.inc | 23 + .../clc/lib/generic/geometric/clc_length.cl | 16 + .../clc/lib/generic/geometric/clc_length.inc | 62 + .../lib/generic/geometric/clc_normalize.cl | 22 + .../lib/generic/geometric/clc_normalize.inc | 84 + .../source/clc/lib/generic/integer/clc_abs.cl | 12 + .../clc/lib/generic/integer/clc_abs.inc | 12 + .../clc/lib/generic/integer/clc_abs_diff.cl | 12 + .../clc/lib/generic/integer/clc_abs_diff.inc | 14 + .../clc/lib/generic/integer/clc_add_sat.cl | 15 + .../source/clc/lib/generic/integer/clc_clz.cl | 47 + .../source/clc/lib/generic/integer/clc_ctz.cl | 43 + .../clc/lib/generic/integer/clc_hadd.cl | 12 + .../clc/lib/generic/integer/clc_hadd.inc | 16 + .../clc/lib/generic/integer/clc_mad24.cl | 13 + .../clc/lib/generic/integer/clc_mad24.inc | 13 + .../clc/lib/generic/integer/clc_mad_sat.cl | 110 ++ .../clc/lib/generic/integer/clc_mul24.cl | 12 + .../clc/lib/generic/integer/clc_mul24.inc | 19 + .../clc/lib/generic/integer/clc_mul_hi.cl | 131 ++ .../clc/lib/generic/integer/clc_popcount.cl | 15 + .../clc/lib/generic/integer/clc_rhadd.cl | 12 + .../clc/lib/generic/integer/clc_rhadd.inc | 16 + .../clc/lib/generic/integer/clc_rotate.cl | 13 + .../clc/lib/generic/integer/clc_rotate.inc | 27 + .../clc/lib/generic/integer/clc_sub_sat.cl | 15 + .../clc/lib/generic/integer/clc_upsample.cl | 39 + .../source/clc/lib/generic/math/clc_acos.cl | 20 + .../source/clc/lib/generic/math/clc_acos.inc | 158 ++ .../source/clc/lib/generic/math/clc_acosh.cl | 24 + .../source/clc/lib/generic/math/clc_acosh.inc | 111 ++ .../source/clc/lib/generic/math/clc_acospi.cl | 19 + .../clc/lib/generic/math/clc_acospi.inc | 156 ++ .../source/clc/lib/generic/math/clc_asin.cl | 19 + .../source/clc/lib/generic/math/clc_asin.inc | 154 ++ .../source/clc/lib/generic/math/clc_asinh.cl | 24 + .../source/clc/lib/generic/math/clc_asinh.inc | 310 +++ .../source/clc/lib/generic/math/clc_asinpi.cl | 19 + .../clc/lib/generic/math/clc_asinpi.inc | 156 ++ .../source/clc/lib/generic/math/clc_atan.cl | 19 + .../source/clc/lib/generic/math/clc_atan.inc | 168 ++ .../source/clc/lib/generic/math/clc_atan2.cl | 26 + .../source/clc/lib/generic/math/clc_atan2.inc | 248 +++ .../clc/lib/generic/math/clc_atan2pi.cl | 26 + .../clc/lib/generic/math/clc_atan2pi.inc | 227 +++ .../source/clc/lib/generic/math/clc_atanh.cl | 19 + .../source/clc/lib/generic/math/clc_atanh.inc | 105 + .../source/clc/lib/generic/math/clc_atanpi.cl | 19 + .../clc/lib/generic/math/clc_atanpi.inc | 172 ++ .../source/clc/lib/generic/math/clc_cbrt.cl | 22 + .../source/clc/lib/generic/math/clc_cbrt.inc | 135 ++ .../source/clc/lib/generic/math/clc_ceil.cl | 15 + .../clc/lib/generic/math/clc_copysign.cl | 15 + .../source/clc/lib/generic/math/clc_cos.cl | 21 + .../source/clc/lib/generic/math/clc_cos.inc | 63 + .../source/clc/lib/generic/math/clc_cosh.cl | 24 + .../source/clc/lib/generic/math/clc_cosh.inc | 199 ++ .../source/clc/lib/generic/math/clc_cospi.cl | 18 + .../source/clc/lib/generic/math/clc_cospi.inc | 116 ++ .../source/clc/lib/generic/math/clc_ep_log.cl | 23 + .../clc/lib/generic/math/clc_ep_log.inc | 81 + .../source/clc/lib/generic/math/clc_erf.cl | 523 +++++ .../source/clc/lib/generic/math/clc_erfc.cl | 532 +++++ .../source/clc/lib/generic/math/clc_exp.cl | 19 + .../source/clc/lib/generic/math/clc_exp.inc | 76 + .../source/clc/lib/generic/math/clc_exp10.cl | 21 + .../source/clc/lib/generic/math/clc_exp10.inc | 155 ++ .../source/clc/lib/generic/math/clc_exp2.cl | 20 + .../source/clc/lib/generic/math/clc_exp2.inc | 68 + .../clc/lib/generic/math/clc_exp_helper.cl | 20 + .../clc/lib/generic/math/clc_exp_helper.inc | 54 + .../source/clc/lib/generic/math/clc_expm1.cl | 20 + .../source/clc/lib/generic/math/clc_expm1.inc | 169 ++ .../source/clc/lib/generic/math/clc_fabs.cl | 15 + .../source/clc/lib/generic/math/clc_fdim.cl | 18 + .../source/clc/lib/generic/math/clc_fdim.inc | 14 + .../source/clc/lib/generic/math/clc_floor.cl | 15 + .../source/clc/lib/generic/math/clc_fma.cl | 14 + .../source/clc/lib/generic/math/clc_fma.inc | 16 + .../source/clc/lib/generic/math/clc_fmax.cl | 58 + .../source/clc/lib/generic/math/clc_fmin.cl | 57 + .../source/clc/lib/generic/math/clc_fmod.cl | 197 ++ .../source/clc/lib/generic/math/clc_fract.cl | 17 + .../source/clc/lib/generic/math/clc_fract.inc | 41 + .../source/clc/lib/generic/math/clc_frexp.cl | 38 + .../source/clc/lib/generic/math/clc_frexp.inc | 67 + .../clc/lib/generic/math/clc_half_cos.cl | 16 + .../clc/lib/generic/math/clc_half_divide.cl | 14 + .../clc/lib/generic/math/clc_half_divide.inc | 12 + .../clc/lib/generic/math/clc_half_exp.cl | 16 + .../clc/lib/generic/math/clc_half_exp10.cl | 16 + .../clc/lib/generic/math/clc_half_exp2.cl | 16 + .../clc/lib/generic/math/clc_half_log.cl | 16 + .../clc/lib/generic/math/clc_half_log10.cl | 16 + .../clc/lib/generic/math/clc_half_log2.cl | 16 + .../clc/lib/generic/math/clc_half_powr.cl | 16 + .../clc/lib/generic/math/clc_half_recip.cl | 12 + .../clc/lib/generic/math/clc_half_recip.inc | 11 + .../clc/lib/generic/math/clc_half_rsqrt.cl | 16 + .../clc/lib/generic/math/clc_half_sin.cl | 16 + .../clc/lib/generic/math/clc_half_sqrt.cl | 16 + .../clc/lib/generic/math/clc_half_tan.cl | 16 + .../source/clc/lib/generic/math/clc_hypot.cl | 22 + .../source/clc/lib/generic/math/clc_hypot.inc | 94 + .../source/clc/lib/generic/math/clc_ilogb.cl | 17 + .../source/clc/lib/generic/math/clc_ilogb.inc | 81 + .../source/clc/lib/generic/math/clc_ldexp.cl | 138 ++ .../source/clc/lib/generic/math/clc_lgamma.cl | 13 + .../clc/lib/generic/math/clc_lgamma.inc | 12 + .../clc/lib/generic/math/clc_lgamma_r.cl | 620 ++++++ .../clc/lib/generic/math/clc_lgamma_r.inc | 15 + .../source/clc/lib/generic/math/clc_log.cl | 44 + .../source/clc/lib/generic/math/clc_log10.cl | 27 + .../source/clc/lib/generic/math/clc_log1p.cl | 19 + .../source/clc/lib/generic/math/clc_log1p.inc | 170 ++ .../source/clc/lib/generic/math/clc_log2.cl | 27 + .../clc/lib/generic/math/clc_log_base.h | 324 ++++ .../source/clc/lib/generic/math/clc_logb.cl | 17 + .../source/clc/lib/generic/math/clc_logb.inc | 54 + .../source/clc/lib/generic/math/clc_mad.cl | 12 + .../source/clc/lib/generic/math/clc_mad.inc | 13 + .../source/clc/lib/generic/math/clc_maxmag.cl | 19 + .../clc/lib/generic/math/clc_maxmag.inc | 18 + .../source/clc/lib/generic/math/clc_minmag.cl | 19 + .../clc/lib/generic/math/clc_minmag.inc | 17 + .../source/clc/lib/generic/math/clc_modf.cl | 16 + .../source/clc/lib/generic/math/clc_modf.inc | 30 + .../source/clc/lib/generic/math/clc_nan.cl | 13 + .../source/clc/lib/generic/math/clc_nan.inc | 27 + .../clc/lib/generic/math/clc_native_cos.cl | 16 + .../clc/lib/generic/math/clc_native_divide.cl | 14 + .../lib/generic/math/clc_native_divide.inc | 12 + .../clc/lib/generic/math/clc_native_exp.cl | 16 + .../clc/lib/generic/math/clc_native_exp10.cl | 16 + .../clc/lib/generic/math/clc_native_exp10.inc | 11 + .../clc/lib/generic/math/clc_native_exp2.cl | 16 + .../clc/lib/generic/math/clc_native_log.cl | 16 + .../clc/lib/generic/math/clc_native_log10.cl | 16 + .../clc/lib/generic/math/clc_native_log2.cl | 16 + .../clc/lib/generic/math/clc_native_powr.cl | 16 + .../clc/lib/generic/math/clc_native_powr.inc | 14 + .../clc/lib/generic/math/clc_native_recip.cl | 14 + .../clc/lib/generic/math/clc_native_recip.inc | 11 + .../clc/lib/generic/math/clc_native_rsqrt.cl | 14 + .../clc/lib/generic/math/clc_native_rsqrt.inc | 11 + .../clc/lib/generic/math/clc_native_sin.cl | 16 + .../clc/lib/generic/math/clc_native_sqrt.cl | 16 + .../clc/lib/generic/math/clc_native_tan.cl | 16 + .../clc/lib/generic/math/clc_native_tan.inc | 11 + .../clc/lib/generic/math/clc_nextafter.cl | 80 + .../source/clc/lib/generic/math/clc_pow.cl | 22 + .../source/clc/lib/generic/math/clc_pow.inc | 438 +++++ .../source/clc/lib/generic/math/clc_pown.cl | 22 + .../source/clc/lib/generic/math/clc_pown.inc | 402 ++++ .../source/clc/lib/generic/math/clc_powr.cl | 22 + .../source/clc/lib/generic/math/clc_powr.inc | 414 ++++ .../clc/lib/generic/math/clc_remainder.cl | 233 +++ .../source/clc/lib/generic/math/clc_remquo.cl | 37 + .../clc/lib/generic/math/clc_remquo.inc | 271 +++ .../source/clc/lib/generic/math/clc_rint.cl | 15 + .../source/clc/lib/generic/math/clc_rootn.cl | 21 + .../source/clc/lib/generic/math/clc_rootn.inc | 404 ++++ .../source/clc/lib/generic/math/clc_round.cl | 15 + .../source/clc/lib/generic/math/clc_rsqrt.cl | 12 + .../source/clc/lib/generic/math/clc_rsqrt.inc | 13 + .../source/clc/lib/generic/math/clc_sin.cl | 25 + .../source/clc/lib/generic/math/clc_sin.inc | 68 + .../source/clc/lib/generic/math/clc_sincos.cl | 14 + .../clc/lib/generic/math/clc_sincos.inc | 22 + .../lib/generic/math/clc_sincos_helpers.cl | 53 + .../lib/generic/math/clc_sincos_helpers.inc | 323 ++++ .../generic/math/clc_sincos_helpers_fp64.inc | 235 +++ .../source/clc/lib/generic/math/clc_sinh.cl | 23 + .../source/clc/lib/generic/math/clc_sinh.inc | 201 ++ .../source/clc/lib/generic/math/clc_sinpi.cl | 18 + .../source/clc/lib/generic/math/clc_sinpi.inc | 114 ++ .../source/clc/lib/generic/math/clc_sqrt.cl | 13 + .../source/clc/lib/generic/math/clc_sqrt.inc | 12 + .../source/clc/lib/generic/math/clc_sw_fma.cl | 166 ++ .../source/clc/lib/generic/math/clc_tables.cl | 1711 +++++++++++++++++ .../source/clc/lib/generic/math/clc_tan.cl | 22 + .../source/clc/lib/generic/math/clc_tan.inc | 61 + .../source/clc/lib/generic/math/clc_tanh.cl | 21 + .../source/clc/lib/generic/math/clc_tanh.inc | 137 ++ .../source/clc/lib/generic/math/clc_tanpi.cl | 19 + .../source/clc/lib/generic/math/clc_tanpi.inc | 132 ++ .../source/clc/lib/generic/math/clc_tgamma.cl | 82 + .../source/clc/lib/generic/math/clc_trunc.cl | 15 + .../clc/lib/generic/misc/clc_shuffle.cl | 173 ++ .../clc/lib/generic/misc/clc_shuffle2.cl | 173 ++ .../clc/lib/generic/relational/clc_all.cl | 29 + .../clc/lib/generic/relational/clc_any.cl | 29 + .../lib/generic/relational/clc_bitselect.cl | 52 + .../lib/generic/relational/clc_bitselect.inc | 13 + .../clc/lib/generic/relational/clc_isequal.cl | 36 + .../lib/generic/relational/clc_isfinite.cl | 32 + .../lib/generic/relational/clc_isgreater.cl | 36 + .../generic/relational/clc_isgreaterequal.cl | 39 + .../clc/lib/generic/relational/clc_isinf.cl | 32 + .../clc/lib/generic/relational/clc_isless.cl | 36 + .../lib/generic/relational/clc_islessequal.cl | 37 + .../generic/relational/clc_islessgreater.cl | 39 + .../clc/lib/generic/relational/clc_isnan.cl | 32 + .../lib/generic/relational/clc_isnormal.cl | 32 + .../lib/generic/relational/clc_isnotequal.cl | 36 + .../lib/generic/relational/clc_isordered.cl | 38 + .../lib/generic/relational/clc_isunordered.cl | 38 + .../clc/lib/generic/relational/clc_select.cl | 18 + .../clc/lib/generic/relational/clc_signbit.cl | 90 + .../clc/lib/generic/shared/clc_clamp.cl | 15 + .../clc/lib/generic/shared/clc_clamp.inc | 22 + .../source/clc/lib/generic/shared/clc_max.cl | 15 + .../source/clc/lib/generic/shared/clc_max.inc | 19 + .../source/clc/lib/generic/shared/clc_min.cl | 15 + .../source/clc/lib/generic/shared/clc_min.inc | 19 + .../clc/lib/generic/shared/clc_vload.cl | 130 ++ .../clc/lib/generic/shared/clc_vload_half.inc | 37 + .../clc/lib/generic/shared/clc_vstore.cl | 268 +++ .../lib/generic/shared/clc_vstore_half.inc | 51 + .../workitem/clc_get_local_linear_id.cl | 18 + .../workitem/clc_get_num_sub_groups.cl | 18 + .../generic/workitem/clc_get_sub_group_id.cl | 25 + .../workitem/clc_get_sub_group_size.cl | 26 + .../source/clc/lib/ptx-nvidiacl/SOURCES | 7 + .../workitem/clc_get_global_id.cl | 17 + .../ptx-nvidiacl/workitem/clc_get_group_id.cl | 22 + .../ptx-nvidiacl/workitem/clc_get_local_id.cl | 22 + .../workitem/clc_get_local_size.cl | 22 + .../workitem/clc_get_max_sub_group_size.cl | 13 + .../workitem/clc_get_num_groups.cl | 22 + .../workitem/clc_get_sub_group_local_id.cl | 13 + .../dev/libclc/source/clc/lib/r600/SOURCES | 4 + .../source/clc/lib/r600/math/clc_fmax.cl | 41 + .../source/clc/lib/r600/math/clc_fmin.cl | 42 + .../clc/lib/r600/math/clc_native_rsqrt.cl | 19 + .../clc/lib/r600/math/clc_rsqrt_override.cl | 36 + .../dev/libclc/source/clc/lib/spirv/SOURCES | 1 + .../spirv/math/clc_runtime_has_hw_fma32.cl | 9 + .../source/cmake/modules/AddLibclc.cmake | 485 +++++ .../recipes/dev/libclc/source/compile-test.sh | 3 + local/recipes/dev/libclc/source/libclc.pc.in | 6 + .../opencl/include/clc/opencl/as_type.h | 92 + .../clc/opencl/async/async_work_group_copy.h | 30 + .../opencl/async/async_work_group_copy.inc | 12 + .../async/async_work_group_strided_copy.h | 30 + .../async/async_work_group_strided_copy.inc | 12 + .../include/clc/opencl/async/prefetch.h | 18 + .../include/clc/opencl/async/prefetch.inc | 10 + .../clc/opencl/async/wait_group_events.h | 17 + .../include/clc/opencl/atomic/atom_add.h | 31 + .../include/clc/opencl/atomic/atom_and.h | 31 + .../include/clc/opencl/atomic/atom_cmpxchg.h | 46 + .../include/clc/opencl/atomic/atom_dec.h | 35 + .../clc/opencl/atomic/atom_decl_int32.inc | 21 + .../clc/opencl/atomic/atom_decl_int64.inc | 22 + .../include/clc/opencl/atomic/atom_inc.h | 35 + .../include/clc/opencl/atomic/atom_max.h | 31 + .../include/clc/opencl/atomic/atom_min.h | 31 + .../include/clc/opencl/atomic/atom_or.h | 31 + .../include/clc/opencl/atomic/atom_sub.h | 31 + .../include/clc/opencl/atomic/atom_xchg.h | 31 + .../include/clc/opencl/atomic/atom_xor.h | 31 + .../include/clc/opencl/atomic/atomic_add.h | 17 + .../include/clc/opencl/atomic/atomic_and.h | 17 + .../clc/opencl/atomic/atomic_cmpxchg.h | 19 + .../include/clc/opencl/atomic/atomic_dec.h | 19 + .../include/clc/opencl/atomic/atomic_decl.inc | 22 + .../include/clc/opencl/atomic/atomic_inc.h | 19 + .../include/clc/opencl/atomic/atomic_max.h | 17 + .../include/clc/opencl/atomic/atomic_min.h | 17 + .../include/clc/opencl/atomic/atomic_or.h | 17 + .../include/clc/opencl/atomic/atomic_sub.h | 17 + .../include/clc/opencl/atomic/atomic_xchg.h | 20 + .../include/clc/opencl/atomic/atomic_xor.h | 17 + .../include/clc/opencl/common/degrees.h | 19 + .../opencl/include/clc/opencl/common/mix.h | 15 + .../opencl/include/clc/opencl/common/mix.inc | 15 + .../include/clc/opencl/common/radians.h | 19 + .../opencl/include/clc/opencl/common/sign.h | 17 + .../include/clc/opencl/common/smoothstep.h | 15 + .../include/clc/opencl/common/smoothstep.inc | 18 + .../opencl/include/clc/opencl/common/step.h | 15 + .../opencl/include/clc/opencl/common/step.inc | 14 + .../opencl/include/clc/opencl/convert.h | 108 ++ .../explicit_fence/explicit_memory_fence.h | 19 + .../include/clc/opencl/geometric/cross.h | 20 + .../include/clc/opencl/geometric/distance.h | 19 + .../opencl/include/clc/opencl/geometric/dot.h | 19 + .../clc/opencl/geometric/fast_distance.h | 20 + .../clc/opencl/geometric/fast_length.h | 20 + .../clc/opencl/geometric/fast_normalize.h | 22 + .../include/clc/opencl/geometric/length.h | 19 + .../include/clc/opencl/geometric/normalize.h | 21 + .../opencl/include/clc/opencl/image/image.h | 55 + .../include/clc/opencl/image/image_defines.h | 62 + .../opencl/include/clc/opencl/integer/abs.h | 17 + .../opencl/include/clc/opencl/integer/abs.inc | 9 + .../include/clc/opencl/integer/abs_diff.h | 17 + .../include/clc/opencl/integer/abs_diff.inc | 10 + .../include/clc/opencl/integer/add_sat.h | 21 + .../opencl/include/clc/opencl/integer/clz.h | 21 + .../opencl/include/clc/opencl/integer/ctz.h | 25 + .../opencl/include/clc/opencl/integer/hadd.h | 21 + .../opencl/include/clc/opencl/integer/mad24.h | 21 + .../include/clc/opencl/integer/mad_hi.h | 21 + .../include/clc/opencl/integer/mad_sat.h | 21 + .../opencl/include/clc/opencl/integer/mul24.h | 21 + .../include/clc/opencl/integer/mul_hi.h | 21 + .../include/clc/opencl/integer/popcount.h | 21 + .../opencl/include/clc/opencl/integer/rhadd.h | 19 + .../include/clc/opencl/integer/rotate.h | 21 + .../include/clc/opencl/integer/sub_sat.h | 19 + .../include/clc/opencl/integer/upsample.h | 39 + .../opencl/include/clc/opencl/math/acos.h | 19 + .../opencl/include/clc/opencl/math/acosh.h | 19 + .../opencl/include/clc/opencl/math/acospi.h | 19 + .../opencl/include/clc/opencl/math/asin.h | 19 + .../opencl/include/clc/opencl/math/asinh.h | 19 + .../opencl/include/clc/opencl/math/asinpi.h | 19 + .../opencl/include/clc/opencl/math/atan.h | 19 + .../opencl/include/clc/opencl/math/atan2.h | 19 + .../opencl/include/clc/opencl/math/atan2pi.h | 19 + .../opencl/include/clc/opencl/math/atanh.h | 19 + .../opencl/include/clc/opencl/math/atanpi.h | 19 + .../opencl/include/clc/opencl/math/cbrt.h | 19 + .../opencl/include/clc/opencl/math/ceil.h | 19 + .../opencl/include/clc/opencl/math/copysign.h | 19 + .../opencl/include/clc/opencl/math/cos.h | 19 + .../opencl/include/clc/opencl/math/cosh.h | 19 + .../opencl/include/clc/opencl/math/cospi.h | 19 + .../opencl/include/clc/opencl/math/erf.h | 21 + .../opencl/include/clc/opencl/math/erfc.h | 21 + .../opencl/include/clc/opencl/math/exp.h | 21 + .../opencl/include/clc/opencl/math/exp10.h | 21 + .../opencl/include/clc/opencl/math/exp2.h | 19 + .../opencl/include/clc/opencl/math/expm1.h | 21 + .../opencl/include/clc/opencl/math/fabs.h | 19 + .../opencl/include/clc/opencl/math/fdim.h | 19 + .../opencl/include/clc/opencl/math/floor.h | 19 + .../opencl/include/clc/opencl/math/fma.h | 19 + .../opencl/include/clc/opencl/math/fmax.h | 19 + .../opencl/include/clc/opencl/math/fmin.h | 19 + .../opencl/include/clc/opencl/math/fmod.h | 17 + .../opencl/include/clc/opencl/math/fract.h | 17 + .../opencl/include/clc/opencl/math/frexp.h | 18 + .../opencl/include/clc/opencl/math/half_cos.h | 20 + .../include/clc/opencl/math/half_divide.h | 19 + .../opencl/include/clc/opencl/math/half_exp.h | 20 + .../include/clc/opencl/math/half_exp10.h | 20 + .../include/clc/opencl/math/half_exp2.h | 20 + .../opencl/include/clc/opencl/math/half_log.h | 20 + .../include/clc/opencl/math/half_log10.h | 20 + .../include/clc/opencl/math/half_log2.h | 20 + .../include/clc/opencl/math/half_powr.h | 19 + .../include/clc/opencl/math/half_recip.h | 20 + .../include/clc/opencl/math/half_rsqrt.h | 18 + .../opencl/include/clc/opencl/math/half_sin.h | 20 + .../include/clc/opencl/math/half_sqrt.h | 18 + .../opencl/include/clc/opencl/math/half_tan.h | 20 + .../opencl/include/clc/opencl/math/hypot.h | 19 + .../opencl/include/clc/opencl/math/ilogb.h | 19 + .../opencl/include/clc/opencl/math/ldexp.h | 20 + .../opencl/include/clc/opencl/math/ldexp.inc | 13 + .../opencl/include/clc/opencl/math/lgamma.h | 19 + .../opencl/include/clc/opencl/math/lgamma_r.h | 19 + .../opencl/include/clc/opencl/math/log.h | 19 + .../opencl/include/clc/opencl/math/log10.h | 19 + .../opencl/include/clc/opencl/math/log1p.h | 19 + .../opencl/include/clc/opencl/math/log2.h | 19 + .../opencl/include/clc/opencl/math/logb.h | 19 + .../opencl/include/clc/opencl/math/mad.h | 19 + .../opencl/include/clc/opencl/math/maxmag.h | 19 + .../opencl/include/clc/opencl/math/minmag.h | 19 + .../opencl/include/clc/opencl/math/modf.h | 18 + .../opencl/include/clc/opencl/math/nan.h | 15 + .../opencl/include/clc/opencl/math/nan.inc | 9 + .../include/clc/opencl/math/native_cos.h | 20 + .../include/clc/opencl/math/native_divide.h | 19 + .../include/clc/opencl/math/native_exp.h | 20 + .../include/clc/opencl/math/native_exp10.h | 20 + .../include/clc/opencl/math/native_exp2.h | 20 + .../include/clc/opencl/math/native_log.h | 20 + .../include/clc/opencl/math/native_log10.h | 20 + .../include/clc/opencl/math/native_log2.h | 20 + .../include/clc/opencl/math/native_powr.h | 19 + .../include/clc/opencl/math/native_recip.h | 20 + .../include/clc/opencl/math/native_rsqrt.h | 20 + .../include/clc/opencl/math/native_sin.h | 20 + .../include/clc/opencl/math/native_sqrt.h | 20 + .../include/clc/opencl/math/native_tan.h | 20 + .../include/clc/opencl/math/nextafter.h | 19 + .../opencl/include/clc/opencl/math/pow.h | 17 + .../opencl/include/clc/opencl/math/pown.h | 19 + .../opencl/include/clc/opencl/math/powr.h | 17 + .../include/clc/opencl/math/remainder.h | 17 + .../opencl/include/clc/opencl/math/remquo.h | 26 + .../opencl/include/clc/opencl/math/rint.h | 19 + .../opencl/include/clc/opencl/math/rootn.h | 19 + .../opencl/include/clc/opencl/math/round.h | 19 + .../opencl/include/clc/opencl/math/rsqrt.h | 19 + .../opencl/include/clc/opencl/math/sin.h | 19 + .../opencl/include/clc/opencl/math/sincos.h | 17 + .../opencl/include/clc/opencl/math/sinh.h | 19 + .../opencl/include/clc/opencl/math/sinpi.h | 19 + .../opencl/include/clc/opencl/math/sqrt.h | 19 + .../opencl/include/clc/opencl/math/tan.h | 19 + .../opencl/include/clc/opencl/math/tanh.h | 19 + .../opencl/include/clc/opencl/math/tanpi.h | 19 + .../opencl/include/clc/opencl/math/tgamma.h | 19 + .../opencl/include/clc/opencl/math/trunc.h | 19 + .../opencl/include/clc/opencl/misc/shuffle.h | 24 + .../opencl/include/clc/opencl/misc/shuffle2.h | 24 + .../opencl/include/clc/opencl/opencl-base.h | 26 + .../include/clc/opencl/relational/all.h | 32 + .../include/clc/opencl/relational/any.h | 32 + .../include/clc/opencl/relational/bitselect.h | 19 + .../clc/opencl/relational/bitselect.inc | 11 + .../include/clc/opencl/relational/isequal.h | 39 + .../include/clc/opencl/relational/isfinite.h | 21 + .../include/clc/opencl/relational/isgreater.h | 21 + .../clc/opencl/relational/isgreaterequal.h | 21 + .../include/clc/opencl/relational/isinf.h | 40 + .../include/clc/opencl/relational/isless.h | 21 + .../clc/opencl/relational/islessequal.h | 21 + .../clc/opencl/relational/islessgreater.h | 21 + .../include/clc/opencl/relational/isnan.h | 40 + .../include/clc/opencl/relational/isnormal.h | 21 + .../clc/opencl/relational/isnotequal.h | 21 + .../include/clc/opencl/relational/isordered.h | 21 + .../clc/opencl/relational/isunordered.h | 21 + .../include/clc/opencl/relational/select.h | 23 + .../include/clc/opencl/relational/signbit.h | 21 + .../opencl/include/clc/opencl/shared/clamp.h | 18 + .../include/clc/opencl/shared/clamp.inc | 16 + .../opencl/include/clc/opencl/shared/max.h | 18 + .../opencl/include/clc/opencl/shared/max.inc | 14 + .../opencl/include/clc/opencl/shared/min.h | 18 + .../opencl/include/clc/opencl/shared/min.inc | 14 + .../opencl/include/clc/opencl/shared/vload.h | 88 + .../opencl/include/clc/opencl/shared/vstore.h | 91 + .../clc/opencl/synchronization/barrier.h | 17 + .../synchronization/cl_mem_fence_flags.h | 17 + .../clc/opencl/workitem/get_global_id.h | 16 + .../clc/opencl/workitem/get_global_offset.h | 16 + .../clc/opencl/workitem/get_global_size.h | 16 + .../clc/opencl/workitem/get_group_id.h | 16 + .../clc/opencl/workitem/get_local_id.h | 16 + .../clc/opencl/workitem/get_local_linear_id.h | 16 + .../clc/opencl/workitem/get_local_size.h | 16 + .../opencl/workitem/get_max_sub_group_size.h | 16 + .../clc/opencl/workitem/get_num_groups.h | 16 + .../clc/opencl/workitem/get_num_sub_groups.h | 16 + .../clc/opencl/workitem/get_sub_group_id.h | 16 + .../opencl/workitem/get_sub_group_local_id.h | 16 + .../clc/opencl/workitem/get_sub_group_size.h | 16 + .../clc/opencl/workitem/get_work_dim.h | 16 + .../source/opencl/lib/amdgcn-amdhsa/SOURCES | 3 + .../amdgcn-amdhsa/workitem/get_global_size.cl | 32 + .../amdgcn-amdhsa/workitem/get_local_size.cl | 38 + .../amdgcn-amdhsa/workitem/get_num_groups.cl | 21 + .../libclc/source/opencl/lib/amdgcn/SOURCES | 10 + .../minmax_helpers.ll | 55 + .../opencl/lib/amdgcn/mem_fence/fence.cl | 45 + .../lib/amdgcn/synchronization/barrier.cl | 15 + .../lib/amdgcn/workitem/get_global_offset.cl | 14 + .../lib/amdgcn/workitem/get_global_size.cl | 14 + .../lib/amdgcn/workitem/get_group_id.cl | 14 + .../lib/amdgcn/workitem/get_local_id.cl | 14 + .../lib/amdgcn/workitem/get_local_size.cl | 26 + .../lib/amdgcn/workitem/get_num_groups.cl | 26 + .../lib/amdgcn/workitem/get_work_dim.cl | 12 + .../libclc/source/opencl/lib/clspv/SOURCES | 73 + .../source/opencl/lib/clspv/math/fma.cl | 17 + .../opencl/lib/clspv/shared/vstore_half.cl | 150 ++ .../opencl/lib/clspv/shared/vstore_half.inc | 29 + .../opencl/lib/clspv/subnormal_config.cl | 16 + .../libclc/source/opencl/lib/generic/SOURCES | 180 ++ .../generic/async/async_work_group_copy.cl | 16 + .../generic/async/async_work_group_copy.inc | 21 + .../async/async_work_group_strided_copy.cl | 17 + .../async/async_work_group_strided_copy.inc | 33 + .../opencl/lib/generic/async/prefetch.cl | 16 + .../opencl/lib/generic/async/prefetch.inc | 12 + .../lib/generic/async/wait_group_events.cl | 15 + .../opencl/lib/generic/atomic/atom_add.cl | 37 + .../opencl/lib/generic/atomic/atom_and.cl | 37 + .../opencl/lib/generic/atomic/atom_cmpxchg.cl | 43 + .../opencl/lib/generic/atomic/atom_dec.cl | 42 + .../opencl/lib/generic/atomic/atom_inc.cl | 42 + .../lib/generic/atomic/atom_int32_binary.inc | 23 + .../opencl/lib/generic/atomic/atom_max.cl | 45 + .../opencl/lib/generic/atomic/atom_min.cl | 45 + .../opencl/lib/generic/atomic/atom_or.cl | 37 + .../opencl/lib/generic/atomic/atom_sub.cl | 37 + .../opencl/lib/generic/atomic/atom_xchg.cl | 37 + .../opencl/lib/generic/atomic/atom_xor.cl | 37 + .../opencl/lib/generic/atomic/atomic_add.cl | 20 + .../opencl/lib/generic/atomic/atomic_and.cl | 20 + .../lib/generic/atomic/atomic_cmpxchg.cl | 21 + .../opencl/lib/generic/atomic/atomic_dec.cl | 20 + .../opencl/lib/generic/atomic/atomic_inc.cl | 20 + .../opencl/lib/generic/atomic/atomic_max.cl | 20 + .../opencl/lib/generic/atomic/atomic_min.cl | 20 + .../opencl/lib/generic/atomic/atomic_or.cl | 20 + .../opencl/lib/generic/atomic/atomic_sub.cl | 20 + .../opencl/lib/generic/atomic/atomic_xchg.cl | 29 + .../opencl/lib/generic/atomic/atomic_xor.cl | 20 + .../opencl/lib/generic/common/degrees.cl | 15 + .../source/opencl/lib/generic/common/mix.cl | 13 + .../source/opencl/lib/generic/common/mix.inc | 19 + .../opencl/lib/generic/common/radians.cl | 15 + .../source/opencl/lib/generic/common/sign.cl | 16 + .../opencl/lib/generic/common/smoothstep.cl | 68 + .../source/opencl/lib/generic/common/step.cl | 13 + .../source/opencl/lib/generic/common/step.inc | 20 + .../opencl/lib/generic/geometric/cross.cl | 44 + .../opencl/lib/generic/geometric/distance.cl | 14 + .../opencl/lib/generic/geometric/dot.cl | 14 + .../lib/generic/geometric/fast_distance.cl | 15 + .../lib/generic/geometric/fast_length.cl | 15 + .../lib/generic/geometric/fast_normalize.cl | 17 + .../opencl/lib/generic/geometric/length.cl | 14 + .../opencl/lib/generic/geometric/normalize.cl | 16 + .../source/opencl/lib/generic/integer/abs.cl | 13 + .../source/opencl/lib/generic/integer/abs.inc | 11 + .../opencl/lib/generic/integer/abs_diff.cl | 13 + .../opencl/lib/generic/integer/abs_diff.inc | 12 + .../opencl/lib/generic/integer/add_sat.cl | 15 + .../source/opencl/lib/generic/integer/clz.cl | 15 + .../source/opencl/lib/generic/integer/ctz.cl | 19 + .../source/opencl/lib/generic/integer/hadd.cl | 15 + .../opencl/lib/generic/integer/mad24.cl | 15 + .../opencl/lib/generic/integer/mad_hi.cl | 15 + .../opencl/lib/generic/integer/mad_sat.cl | 15 + .../opencl/lib/generic/integer/mul24.cl | 15 + .../opencl/lib/generic/integer/mul_hi.cl | 15 + .../opencl/lib/generic/integer/popcount.cl | 15 + .../opencl/lib/generic/integer/rhadd.cl | 15 + .../opencl/lib/generic/integer/rotate.cl | 15 + .../opencl/lib/generic/integer/sub_sat.cl | 15 + .../opencl/lib/generic/integer/upsample.cl | 44 + .../source/opencl/lib/generic/math/acos.cl | 15 + .../source/opencl/lib/generic/math/acosh.cl | 15 + .../source/opencl/lib/generic/math/acospi.cl | 15 + .../source/opencl/lib/generic/math/asin.cl | 15 + .../source/opencl/lib/generic/math/asinh.cl | 15 + .../source/opencl/lib/generic/math/asinpi.cl | 15 + .../source/opencl/lib/generic/math/atan.cl | 15 + .../source/opencl/lib/generic/math/atan2.cl | 16 + .../source/opencl/lib/generic/math/atan2pi.cl | 16 + .../source/opencl/lib/generic/math/atanh.cl | 15 + .../source/opencl/lib/generic/math/atanpi.cl | 15 + .../source/opencl/lib/generic/math/cbrt.cl | 15 + .../source/opencl/lib/generic/math/ceil.cl | 15 + .../opencl/lib/generic/math/copysign.cl | 15 + .../source/opencl/lib/generic/math/cos.cl | 14 + .../source/opencl/lib/generic/math/cosh.cl | 14 + .../source/opencl/lib/generic/math/cospi.cl | 15 + .../source/opencl/lib/generic/math/erf.cl | 14 + .../source/opencl/lib/generic/math/erfc.cl | 14 + .../source/opencl/lib/generic/math/exp.cl | 14 + .../source/opencl/lib/generic/math/exp10.cl | 14 + .../source/opencl/lib/generic/math/exp2.cl | 14 + .../source/opencl/lib/generic/math/expm1.cl | 14 + .../source/opencl/lib/generic/math/fabs.cl | 15 + .../source/opencl/lib/generic/math/fdim.cl | 14 + .../source/opencl/lib/generic/math/floor.cl | 15 + .../source/opencl/lib/generic/math/fma.cl | 16 + .../source/opencl/lib/generic/math/fmax.cl | 14 + .../source/opencl/lib/generic/math/fmax.inc | 35 + .../source/opencl/lib/generic/math/fmin.cl | 14 + .../source/opencl/lib/generic/math/fmin.inc | 35 + .../source/opencl/lib/generic/math/fmod.cl | 14 + .../source/opencl/lib/generic/math/fract.cl | 14 + .../source/opencl/lib/generic/math/frexp.cl | 14 + .../opencl/lib/generic/math/half_cos.cl | 16 + .../opencl/lib/generic/math/half_divide.cl | 16 + .../opencl/lib/generic/math/half_exp.cl | 16 + .../opencl/lib/generic/math/half_exp10.cl | 16 + .../opencl/lib/generic/math/half_exp2.cl | 16 + .../opencl/lib/generic/math/half_log.cl | 16 + .../opencl/lib/generic/math/half_log10.cl | 16 + .../opencl/lib/generic/math/half_log2.cl | 16 + .../opencl/lib/generic/math/half_powr.cl | 16 + .../opencl/lib/generic/math/half_recip.cl | 16 + .../opencl/lib/generic/math/half_rsqrt.cl | 16 + .../opencl/lib/generic/math/half_sin.cl | 16 + .../opencl/lib/generic/math/half_sqrt.cl | 16 + .../opencl/lib/generic/math/half_tan.cl | 16 + .../source/opencl/lib/generic/math/hypot.cl | 14 + .../source/opencl/lib/generic/math/ilogb.cl | 14 + .../source/opencl/lib/generic/math/ldexp.cl | 20 + .../source/opencl/lib/generic/math/ldexp.inc | 15 + .../source/opencl/lib/generic/math/lgamma.cl | 14 + .../opencl/lib/generic/math/lgamma_r.cl | 14 + .../source/opencl/lib/generic/math/log.cl | 16 + .../source/opencl/lib/generic/math/log10.cl | 16 + .../source/opencl/lib/generic/math/log1p.cl | 15 + .../source/opencl/lib/generic/math/log2.cl | 16 + .../source/opencl/lib/generic/math/logb.cl | 14 + .../source/opencl/lib/generic/math/mad.cl | 15 + .../source/opencl/lib/generic/math/maxmag.cl | 14 + .../source/opencl/lib/generic/math/minmag.cl | 14 + .../source/opencl/lib/generic/math/modf.cl | 14 + .../source/opencl/lib/generic/math/nan.cl | 13 + .../source/opencl/lib/generic/math/nan.inc | 11 + .../opencl/lib/generic/math/native_cos.cl | 16 + .../opencl/lib/generic/math/native_divide.cl | 16 + .../opencl/lib/generic/math/native_exp.cl | 16 + .../opencl/lib/generic/math/native_exp10.cl | 16 + .../opencl/lib/generic/math/native_exp2.cl | 16 + .../opencl/lib/generic/math/native_log.cl | 16 + .../opencl/lib/generic/math/native_log10.cl | 16 + .../opencl/lib/generic/math/native_log2.cl | 16 + .../opencl/lib/generic/math/native_powr.cl | 16 + .../opencl/lib/generic/math/native_recip.cl | 16 + .../opencl/lib/generic/math/native_rsqrt.cl | 16 + .../opencl/lib/generic/math/native_sin.cl | 16 + .../opencl/lib/generic/math/native_sqrt.cl | 16 + .../opencl/lib/generic/math/native_tan.cl | 16 + .../opencl/lib/generic/math/nextafter.cl | 16 + .../source/opencl/lib/generic/math/pow.cl | 14 + .../source/opencl/lib/generic/math/pown.cl | 14 + .../source/opencl/lib/generic/math/powr.cl | 14 + .../opencl/lib/generic/math/remainder.cl | 14 + .../source/opencl/lib/generic/math/remquo.cl | 13 + .../source/opencl/lib/generic/math/remquo.inc | 29 + .../source/opencl/lib/generic/math/rint.cl | 15 + .../source/opencl/lib/generic/math/rootn.cl | 14 + .../source/opencl/lib/generic/math/round.cl | 15 + .../source/opencl/lib/generic/math/rsqrt.cl | 15 + .../source/opencl/lib/generic/math/sin.cl | 14 + .../source/opencl/lib/generic/math/sincos.cl | 14 + .../source/opencl/lib/generic/math/sinh.cl | 14 + .../source/opencl/lib/generic/math/sinpi.cl | 15 + .../source/opencl/lib/generic/math/sqrt.cl | 15 + .../source/opencl/lib/generic/math/tan.cl | 14 + .../source/opencl/lib/generic/math/tanh.cl | 14 + .../source/opencl/lib/generic/math/tanpi.cl | 15 + .../source/opencl/lib/generic/math/tgamma.cl | 14 + .../source/opencl/lib/generic/math/trunc.cl | 15 + .../source/opencl/lib/generic/misc/shuffle.cl | 18 + .../opencl/lib/generic/misc/shuffle2.cl | 18 + .../opencl/lib/generic/relational/all.cl | 25 + .../opencl/lib/generic/relational/any.cl | 25 + .../lib/generic/relational/binary_def.inc | 15 + .../lib/generic/relational/bitselect.cl | 16 + .../lib/generic/relational/bitselect.inc | 12 + .../opencl/lib/generic/relational/isequal.cl | 15 + .../opencl/lib/generic/relational/isfinite.cl | 15 + .../lib/generic/relational/isgreater.cl | 15 + .../lib/generic/relational/isgreaterequal.cl | 15 + .../opencl/lib/generic/relational/isinf.cl | 15 + .../opencl/lib/generic/relational/isless.cl | 15 + .../lib/generic/relational/islessequal.cl | 15 + .../lib/generic/relational/islessgreater.cl | 15 + .../opencl/lib/generic/relational/isnan.cl | 15 + .../opencl/lib/generic/relational/isnormal.cl | 15 + .../lib/generic/relational/isnotequal.cl | 15 + .../lib/generic/relational/isordered.cl | 15 + .../lib/generic/relational/isunordered.cl | 15 + .../opencl/lib/generic/relational/select.cl | 19 + .../opencl/lib/generic/relational/signbit.cl | 15 + .../lib/generic/relational/unary_def.inc | 15 + .../source/opencl/lib/generic/shared/clamp.cl | 16 + .../opencl/lib/generic/shared/clamp.inc | 20 + .../source/opencl/lib/generic/shared/max.cl | 16 + .../source/opencl/lib/generic/shared/max.inc | 18 + .../source/opencl/lib/generic/shared/min.cl | 16 + .../source/opencl/lib/generic/shared/min.inc | 18 + .../source/opencl/lib/generic/shared/vload.cl | 16 + .../opencl/lib/generic/shared/vload.inc | 71 + .../opencl/lib/generic/shared/vstore.cl | 16 + .../opencl/lib/generic/shared/vstore.inc | 77 + .../opencl/lib/generic/subnormal_config.cl | 18 + .../opencl/lib/generic/subnormal_disable.ll | 9 + .../lib/generic/subnormal_helper_func.ll | 16 + .../lib/generic/subnormal_use_default.ll | 9 + .../lib/generic/workitem/get_global_id.cl | 18 + .../lib/generic/workitem/get_global_size.cl | 15 + .../source/opencl/lib/ptx-nvidiacl/SOURCES | 13 + .../lib/ptx-nvidiacl/mem_fence/fence.cl | 23 + .../ptx-nvidiacl/synchronization/barrier.cl | 13 + .../ptx-nvidiacl/workitem/get_global_id.cl | 14 + .../lib/ptx-nvidiacl/workitem/get_group_id.cl | 14 + .../lib/ptx-nvidiacl/workitem/get_local_id.cl | 14 + .../workitem/get_local_linear_id.cl | 14 + .../ptx-nvidiacl/workitem/get_local_size.cl | 14 + .../workitem/get_max_sub_group_size.cl | 14 + .../ptx-nvidiacl/workitem/get_num_groups.cl | 14 + .../workitem/get_num_sub_groups.cl | 14 + .../ptx-nvidiacl/workitem/get_sub_group_id.cl | 14 + .../workitem/get_sub_group_local_id.cl | 14 + .../workitem/get_sub_group_size.cl | 14 + .../dev/libclc/source/opencl/lib/r600/SOURCES | 8 + .../libclc/source/opencl/lib/r600/SOURCES_3.9 | 15 + .../r600/image/get_image_attributes_impl.ll | 95 + .../r600/image/get_image_channel_data_type.cl | 19 + .../lib/r600/image/get_image_channel_order.cl | 19 + .../opencl/lib/r600/image/get_image_depth.cl | 15 + .../opencl/lib/r600/image/get_image_dim.cl | 17 + .../opencl/lib/r600/image/get_image_height.cl | 19 + .../opencl/lib/r600/image/get_image_width.cl | 19 + .../opencl/lib/r600/image/read_image_impl.ll | 54 + .../opencl/lib/r600/image/read_imagef.cl | 22 + .../opencl/lib/r600/image/read_imagei.cl | 31 + .../opencl/lib/r600/image/read_imageui.cl | 31 + .../opencl/lib/r600/image/write_image_impl.ll | 60 + .../opencl/lib/r600/image/write_imagef.cl | 16 + .../opencl/lib/r600/image/write_imagei.cl | 16 + .../opencl/lib/r600/image/write_imageui.cl | 16 + .../lib/r600/synchronization/barrier.cl | 16 + .../lib/r600/workitem/get_global_offset.cl | 18 + .../lib/r600/workitem/get_global_size.cl | 26 + .../opencl/lib/r600/workitem/get_group_id.cl | 22 + .../opencl/lib/r600/workitem/get_local_id.cl | 22 + .../lib/r600/workitem/get_local_size.cl | 26 + .../lib/r600/workitem/get_num_groups.cl | 26 + .../opencl/lib/r600/workitem/get_work_dim.cl | 16 + .../libclc/source/opencl/lib/spirv/SOURCES | 73 + .../source/opencl/lib/spirv/math/fma.cl | 17 + .../opencl/lib/spirv/subnormal_config.cl | 16 + .../recipes/dev/libclc/source/test/add_sat.cl | 11 + .../recipes/dev/libclc/source/test/as_type.cl | 11 + .../recipes/dev/libclc/source/test/convert.cl | 11 + local/recipes/dev/libclc/source/test/cos.cl | 11 + local/recipes/dev/libclc/source/test/cross.cl | 11 + local/recipes/dev/libclc/source/test/fabs.cl | 11 + .../dev/libclc/source/test/get_group_id.cl | 11 + local/recipes/dev/libclc/source/test/rsqrt.cl | 14 + .../recipes/dev/libclc/source/test/subsat.cl | 27 + .../dev/libclc/source/utils/gen_convert.py | 550 ++++++ .../libclc/source/utils/prepare-builtins.cpp | 133 ++ .../recipes/dev/libclc/source/www/index.html | 53 + recipes/dev/libclc | 1 + 1032 files changed, 37240 insertions(+) create mode 100644 local/recipes/dev/libclc/recipe.toml create mode 100644 local/recipes/dev/libclc/source/CMakeLists.txt create mode 100644 local/recipes/dev/libclc/source/CREDITS.TXT create mode 100644 local/recipes/dev/libclc/source/LICENSE.TXT create mode 100644 local/recipes/dev/libclc/source/Maintainers.md create mode 100644 local/recipes/dev/libclc/source/README.md create mode 100755 local/recipes/dev/libclc/source/check_external_calls.sh create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/async/clc_prefetch.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/async/clc_prefetch.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/clc_as_type.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/clc_convert.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/clcfunc.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/clcmacro.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/clctypes.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/common/clc_degrees.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/common/clc_radians.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/common/clc_sign.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/common/clc_smoothstep.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/common/clc_smoothstep.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/common/clc_step.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/float/definitions.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/geometric/binary_decl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/geometric/binary_def.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_cross.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_distance.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_dot.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_fast_distance.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_fast_length.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_fast_normalize.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_length.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_normalize.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/geometric/unary_decl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/geometric/unary_def.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs_diff.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs_diff.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_add_sat.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_clz.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_ctz.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_hadd.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mad24.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mad_hi.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mad_sat.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mul24.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mul_hi.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_popcount.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_rhadd.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_rotate.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_sub_sat.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/clc_upsample.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/definitions.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/gentype.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/integer/gentype24.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/internal/clc.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/internal/math/clc_sw_fma.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/binary_decl_with_scalar_second_arg.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/binary_def_via_fp32.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_acos.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_acosh.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_acospi.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_asin.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_asinh.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_asinpi.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_atan.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_atan2.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_atan2pi.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_atanh.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_atanpi.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_cbrt.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_ceil.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_copysign.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_cos.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_cosh.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_cospi.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_ep_log.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_ep_log.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_erf.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_erfc.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp10.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp2.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp_helper.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp_helper.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_expm1.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_fabs.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_fdim.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_floor.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_fma.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_fmax.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_fmin.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_fmod.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_fract.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_frexp.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_cos.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_divide.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_exp.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_exp10.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_exp2.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_log.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_log10.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_log2.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_powr.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_recip.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_rsqrt.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_sin.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_sqrt.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_tan.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_hypot.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_ilogb.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_ldexp.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_ldexp.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_lgamma.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_lgamma_r.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_log.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_log10.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_log1p.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_log2.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_logb.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_mad.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_maxmag.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_minmag.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_modf.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_nan.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_nan.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_cos.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_divide.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_exp.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_exp10.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_exp2.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_log.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_log10.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_log2.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_powr.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_recip.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_rsqrt.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_sin.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_sqrt.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_tan.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_nextafter.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_pow.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_pown.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_powr.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_remainder.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_remquo.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_rint.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_rootn.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_round.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_rsqrt.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_sin.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_helpers.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_helpers.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_helpers_fp64.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_piby4.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_piby4.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_sinh.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_sinpi.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_sqrt.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_subnormal_config.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_tan.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_tanh.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_tanpi.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_tgamma.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/clc_trunc.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/gentype.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/math.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/remquo_decl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/tables.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl_with_int_ptr.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl_with_int_return.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl_with_ptr.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_via_fp32.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_with_int_ptr.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_with_int_return.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_with_ptr.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/misc/clc_shuffle.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/misc/clc_shuffle2.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle2_decl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle2_def.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle_decl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle_def.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/binary_decl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_all.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_any.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_bitselect.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_bitselect.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isequal.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isfinite.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isgreater.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isgreaterequal.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isinf.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isless.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_islessequal.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_islessgreater.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isnan.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isnormal.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isnotequal.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isordered.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isunordered.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_select.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_select_decl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_select_impl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/clc_signbit.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/floatn.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/relational.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/relational/unary_decl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/binary_decl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/binary_decl_with_int_second_arg.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/binary_decl_with_scalar_second_arg.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def_scalarize.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def_with_int_second_arg.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def_with_scalar_second_arg.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/clc_clamp.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/clc_clamp.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/clc_less_aligned_types.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/clc_less_aligned_types.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/clc_max.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/clc_max.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/clc_min.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/clc_min.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vload.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vload.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vstore.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vstore.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/ternary_decl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/ternary_def.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/ternary_def_scalarize.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/unary_decl.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/unary_def.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/shared/unary_def_scalarize.inc create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/utils.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_global_id.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_global_offset.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_global_size.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_group_id.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_local_id.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_local_linear_id.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_local_size.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_max_sub_group_size.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_num_groups.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_num_sub_groups.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_sub_group_id.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_sub_group_local_id.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_sub_group_size.h create mode 100644 local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_work_dim.h create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgcn/SOURCES create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgcn/math/clc_fmax.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgcn/math/clc_fmin.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgcn/math/clc_ldexp_override.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_global_offset.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_global_size.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_group_id.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_local_id.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_work_dim.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/SOURCES create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_exp.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_exp10.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_exp2.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_log.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_log10.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_log2.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_native_unary.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_recip.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_rsqrt.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_sqrt.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_exp.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_exp.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_exp2.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_log10.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_log10.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_sqrt_fp64.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/clspv/SOURCES create mode 100644 local/recipes/dev/libclc/source/clc/lib/clspv/integer/clc_mul_hi.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/clspv/math/clc_sw_fma.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/SOURCES create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/async/clc_prefetch.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/async/clc_prefetch.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/common/clc_degrees.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/common/clc_radians.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/common/clc_sign.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/common/clc_sign.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/common/clc_smoothstep.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/common/clc_step.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/common/clc_step.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_cross.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_cross.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_distance.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_distance.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_dot.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_dot.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_distance.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_distance.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_length.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_normalize.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_normalize.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_length.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_length.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_normalize.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_normalize.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs_diff.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs_diff.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_add_sat.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_clz.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_ctz.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_hadd.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_hadd.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mad24.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mad24.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mad_sat.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mul24.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mul24.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mul_hi.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_popcount.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rhadd.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rhadd.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rotate.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rotate.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_sub_sat.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_upsample.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acos.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acos.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acosh.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acosh.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acospi.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acospi.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asin.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asin.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinh.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinh.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinpi.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinpi.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2pi.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2pi.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanh.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanh.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanpi.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanpi.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cbrt.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cbrt.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ceil.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_copysign.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cos.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cos.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cosh.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cosh.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cospi.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cospi.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ep_log.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ep_log.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_erf.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_erfc.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp10.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp10.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp2.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp2.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp_helper.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp_helper.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_expm1.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_expm1.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fabs.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fdim.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fdim.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_floor.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fma.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fma.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fmax.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fmin.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fmod.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fract.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fract.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_frexp.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_frexp.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_cos.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_divide.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_divide.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_exp.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_exp10.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_exp2.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_log.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_log10.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_log2.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_powr.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_recip.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_recip.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_rsqrt.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_sin.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_sqrt.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_tan.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_hypot.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_hypot.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ilogb.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ilogb.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ldexp.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma_r.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma_r.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log10.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log1p.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log1p.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log2.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log_base.h create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_logb.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_logb.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_mad.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_mad.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_maxmag.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_maxmag.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_minmag.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_minmag.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_modf.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_modf.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_nan.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_nan.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_cos.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_divide.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_divide.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp10.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp10.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp2.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_log.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_log10.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_log2.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_powr.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_powr.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_recip.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_recip.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_rsqrt.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_rsqrt.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_sin.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_sqrt.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_tan.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_tan.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_nextafter.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pow.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pow.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pown.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pown.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_powr.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_powr.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_remainder.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_remquo.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_remquo.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rint.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rootn.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rootn.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_round.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rsqrt.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rsqrt.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sin.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sin.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos_helpers.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos_helpers.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos_helpers_fp64.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinh.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinh.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinpi.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinpi.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sqrt.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sqrt.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sw_fma.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tables.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tan.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tan.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanh.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanh.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanpi.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanpi.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tgamma.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/math/clc_trunc.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/misc/clc_shuffle.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/misc/clc_shuffle2.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_all.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_any.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_bitselect.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_bitselect.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isequal.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isfinite.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isgreater.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isgreaterequal.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isinf.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isless.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_islessequal.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_islessgreater.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isnan.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isnormal.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isnotequal.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isordered.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isunordered.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_select.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_signbit.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_clamp.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_clamp.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_max.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_max.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_min.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_min.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vload.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vload_half.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vstore.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vstore_half.inc create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_local_linear_id.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_num_sub_groups.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_sub_group_id.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_sub_group_size.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/SOURCES create mode 100644 local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_global_id.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_group_id.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_local_id.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_local_size.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_max_sub_group_size.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_num_groups.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_sub_group_local_id.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/r600/SOURCES create mode 100644 local/recipes/dev/libclc/source/clc/lib/r600/math/clc_fmax.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/r600/math/clc_fmin.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/r600/math/clc_native_rsqrt.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/r600/math/clc_rsqrt_override.cl create mode 100644 local/recipes/dev/libclc/source/clc/lib/spirv/SOURCES create mode 100644 local/recipes/dev/libclc/source/clc/lib/spirv/math/clc_runtime_has_hw_fma32.cl create mode 100644 local/recipes/dev/libclc/source/cmake/modules/AddLibclc.cmake create mode 100755 local/recipes/dev/libclc/source/compile-test.sh create mode 100644 local/recipes/dev/libclc/source/libclc.pc.in create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/as_type.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_copy.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_copy.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_strided_copy.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_strided_copy.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/prefetch.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/prefetch.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/wait_group_events.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_add.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_and.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_cmpxchg.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_dec.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_decl_int32.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_decl_int64.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_inc.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_max.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_min.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_or.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_sub.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_xchg.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_xor.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_add.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_and.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_cmpxchg.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_dec.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_decl.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_inc.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_max.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_min.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_or.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_sub.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_xchg.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_xor.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/degrees.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/mix.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/mix.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/radians.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/sign.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/smoothstep.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/smoothstep.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/step.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/step.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/convert.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/explicit_fence/explicit_memory_fence.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/cross.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/distance.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/dot.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/fast_distance.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/fast_length.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/fast_normalize.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/length.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/normalize.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/image/image.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/image/image_defines.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs_diff.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs_diff.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/add_sat.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/clz.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/ctz.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/hadd.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mad24.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mad_hi.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mad_sat.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mul24.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mul_hi.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/popcount.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/rhadd.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/rotate.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/sub_sat.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/upsample.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/acos.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/acosh.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/acospi.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/asin.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/asinh.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/asinpi.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atan.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atan2.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atan2pi.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atanh.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atanpi.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cbrt.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ceil.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/copysign.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cos.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cosh.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cospi.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/erf.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/erfc.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/exp.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/exp10.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/exp2.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/expm1.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fabs.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fdim.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/floor.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fma.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fmax.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fmin.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fmod.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fract.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/frexp.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_cos.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_divide.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_exp.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_exp10.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_exp2.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_log.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_log10.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_log2.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_powr.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_recip.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_rsqrt.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_sin.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_sqrt.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_tan.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/hypot.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ilogb.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ldexp.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ldexp.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/lgamma.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/lgamma_r.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log10.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log1p.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log2.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/logb.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/mad.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/maxmag.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/minmag.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/modf.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/nan.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/nan.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_cos.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_divide.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_exp.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_exp10.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_exp2.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_log.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_log10.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_log2.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_powr.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_recip.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_rsqrt.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_sin.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_sqrt.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_tan.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/nextafter.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/pow.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/pown.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/powr.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/remainder.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/remquo.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/rint.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/rootn.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/round.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/rsqrt.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sin.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sincos.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sinh.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sinpi.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sqrt.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tan.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tanh.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tanpi.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tgamma.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/trunc.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/misc/shuffle.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/misc/shuffle2.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/opencl-base.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/all.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/any.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/bitselect.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/bitselect.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isequal.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isfinite.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isgreater.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isgreaterequal.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isinf.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isless.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/islessequal.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/islessgreater.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isnan.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isnormal.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isnotequal.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isordered.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isunordered.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/select.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/signbit.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/clamp.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/clamp.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/max.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/max.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/min.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/min.inc create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/vload.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/vstore.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/synchronization/barrier.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/synchronization/cl_mem_fence_flags.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_global_id.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_global_offset.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_global_size.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_group_id.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_local_id.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_local_linear_id.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_local_size.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_max_sub_group_size.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_num_groups.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_num_sub_groups.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_sub_group_id.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_sub_group_local_id.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_sub_group_size.h create mode 100644 local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_work_dim.h create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/SOURCES create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/workitem/get_global_size.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/workitem/get_local_size.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/workitem/get_num_groups.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn/SOURCES create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn/cl_khr_int64_extended_atomics/minmax_helpers.ll create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn/mem_fence/fence.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn/synchronization/barrier.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_global_offset.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_global_size.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_group_id.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_local_id.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_local_size.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_num_groups.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_work_dim.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/clspv/SOURCES create mode 100644 local/recipes/dev/libclc/source/opencl/lib/clspv/math/fma.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/clspv/shared/vstore_half.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/clspv/shared/vstore_half.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/clspv/subnormal_config.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/SOURCES create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_copy.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_copy.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_strided_copy.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_strided_copy.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/async/prefetch.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/async/prefetch.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/async/wait_group_events.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_add.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_and.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_cmpxchg.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_dec.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_inc.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_int32_binary.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_max.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_min.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_or.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_sub.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_xchg.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_xor.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_add.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_and.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_cmpxchg.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_dec.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_inc.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_max.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_min.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_or.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_sub.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_xchg.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_xor.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/common/degrees.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/common/mix.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/common/mix.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/common/radians.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/common/sign.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/common/smoothstep.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/common/step.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/common/step.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/geometric/cross.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/geometric/distance.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/geometric/dot.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/geometric/fast_distance.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/geometric/fast_length.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/geometric/fast_normalize.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/geometric/length.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/geometric/normalize.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs_diff.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs_diff.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/add_sat.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/clz.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/ctz.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/hadd.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/mad24.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/mad_hi.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/mad_sat.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/mul24.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/mul_hi.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/popcount.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/rhadd.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/rotate.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/sub_sat.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/integer/upsample.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/acos.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/acosh.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/acospi.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/asin.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/asinh.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/asinpi.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/atan.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/atan2.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/atan2pi.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/atanh.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/atanpi.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/cbrt.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/ceil.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/copysign.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/cos.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/cosh.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/cospi.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/erf.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/erfc.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/exp.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/exp10.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/exp2.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/expm1.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/fabs.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/fdim.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/floor.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/fma.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/fmax.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/fmax.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/fmin.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/fmin.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/fmod.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/fract.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/frexp.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_cos.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_divide.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_exp.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_exp10.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_exp2.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_log.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_log10.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_log2.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_powr.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_recip.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_rsqrt.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_sin.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_sqrt.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/half_tan.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/hypot.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/ilogb.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/ldexp.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/ldexp.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/lgamma.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/lgamma_r.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/log.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/log10.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/log1p.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/log2.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/logb.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/mad.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/maxmag.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/minmag.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/modf.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/nan.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/nan.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_cos.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_divide.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_exp.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_exp10.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_exp2.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_log.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_log10.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_log2.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_powr.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_recip.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_rsqrt.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_sin.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_sqrt.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/native_tan.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/nextafter.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/pow.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/pown.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/powr.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/remainder.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/remquo.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/remquo.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/rint.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/rootn.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/round.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/rsqrt.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/sin.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/sincos.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/sinh.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/sinpi.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/sqrt.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/tan.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/tanh.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/tanpi.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/tgamma.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/math/trunc.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/misc/shuffle.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/misc/shuffle2.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/all.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/any.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/binary_def.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/bitselect.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/bitselect.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/isequal.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/isfinite.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/isgreater.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/isgreaterequal.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/isinf.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/isless.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/islessequal.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/islessgreater.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/isnan.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/isnormal.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/isnotequal.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/isordered.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/isunordered.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/select.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/signbit.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/relational/unary_def.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/shared/clamp.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/shared/clamp.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/shared/max.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/shared/max.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/shared/min.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/shared/min.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/shared/vload.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/shared/vload.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/shared/vstore.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/shared/vstore.inc create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_config.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_disable.ll create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_helper_func.ll create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_use_default.ll create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/workitem/get_global_id.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/generic/workitem/get_global_size.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/SOURCES create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/mem_fence/fence.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/synchronization/barrier.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_global_id.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_group_id.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_local_id.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_local_linear_id.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_local_size.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_max_sub_group_size.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_num_groups.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_num_sub_groups.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_sub_group_id.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_sub_group_local_id.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_sub_group_size.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/SOURCES create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/SOURCES_3.9 create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_attributes_impl.ll create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_channel_data_type.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_channel_order.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_depth.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_dim.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_height.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_width.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/read_image_impl.ll create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/read_imagef.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/read_imagei.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/read_imageui.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/write_image_impl.ll create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/write_imagef.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/write_imagei.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/image/write_imageui.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/synchronization/barrier.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_global_offset.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_global_size.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_group_id.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_local_id.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_local_size.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_num_groups.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_work_dim.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/spirv/SOURCES create mode 100644 local/recipes/dev/libclc/source/opencl/lib/spirv/math/fma.cl create mode 100644 local/recipes/dev/libclc/source/opencl/lib/spirv/subnormal_config.cl create mode 100644 local/recipes/dev/libclc/source/test/add_sat.cl create mode 100644 local/recipes/dev/libclc/source/test/as_type.cl create mode 100644 local/recipes/dev/libclc/source/test/convert.cl create mode 100644 local/recipes/dev/libclc/source/test/cos.cl create mode 100644 local/recipes/dev/libclc/source/test/cross.cl create mode 100644 local/recipes/dev/libclc/source/test/fabs.cl create mode 100644 local/recipes/dev/libclc/source/test/get_group_id.cl create mode 100644 local/recipes/dev/libclc/source/test/rsqrt.cl create mode 100644 local/recipes/dev/libclc/source/test/subsat.cl create mode 100644 local/recipes/dev/libclc/source/utils/gen_convert.py create mode 100644 local/recipes/dev/libclc/source/utils/prepare-builtins.cpp create mode 100644 local/recipes/dev/libclc/source/www/index.html create mode 120000 recipes/dev/libclc diff --git a/local/recipes/dev/libclc/recipe.toml b/local/recipes/dev/libclc/recipe.toml new file mode 100644 index 0000000000..acff2a1477 --- /dev/null +++ b/local/recipes/dev/libclc/recipe.toml @@ -0,0 +1,124 @@ +[package] +name = "libclc" +# Red Bear OS internal libclc. Upstream is llvm-project's libclc +# (https://github.com/llvm/llvm-project/tree/main/libclc). The source +# is vendored from the same revision as llvm21 (redox-2025-10-03). +# The version follows the Red Bear OS branch per local/AGENTS.md. +version = "0.3.1" +description = "libclc — Red Bear OS port of the OpenCL C library requirements (amdgcn, r600, spirv, generic targets). Provides the .bc bitcode files Mesa's clc tool consumes for hardware GPU drivers (iris, radeonsi, llvmpipe)." + +[source] +# Vendored from the same revision as llvm21 / clang21. +git = "https://gitlab.redox-os.org/redox-os/llvm-project.git" +upstream = "https://github.com/llvm/llvm-project.git" +branch = "redox-2025-10-03" +path_in_repo = "libclc" +shallow_clone = true + +[build] +template = "custom" +# Build depends on the HOST clang (built by clang21) and the +# LLVMConfig.cmake (provided by llvm21's install). +dependencies = [ + "clang21", + "llvm21", +] +dev-dependencies = [ + "clang21.dev", + "llvm21.dev", +] +script = ''' +DYNAMIC_INIT +ARCH="$(echo "${TARGET}" | cut -d - -f1)" + +# libclc is built with the HOST clang (not the cross-compiler): +# it produces .bc bitcode files that are architecture-independent +# for the GPU targets Mesa cares about (amdgcn, r600, spirv, +# generic). The output is then consumed at runtime by Mesa's clc +# tool via the dependency('libclc') pkg-config lookup. + +# Save the cross-compile environment so we can use the HOST +# toolchain (Clang) to compile OpenCL kernels to bitcode. +_SAVED_LDFLAGS="${LDFLAGS:-}" +_SAVED_CFLAGS="${CFLAGS:-}" +_SAVED_CXXFLAGS="${CXXFLAGS:-}" +_SAVED_CPPFLAGS="${CPPFLAGS:-}" +unset LDFLAGS CFLAGS CXXFLAGS CPPFLAGS + +# Generate a NATIVE toolchain file. We can't use cookbook_cmake +# because that targets the cross sysroot; libclc needs the host. +generate_cookbook_cmake_file "${COOKBOOK_HOST_TARGET}" "" "/usr" native_libclc.cmake + +# Override the CMAKE_CXX_COMPILER etc. to point at the HOST clang +# that comes from the cookbook sysroot (clang21 build). The cookbook +# sysroot contains both the host Clang binary and the LLVM tools +# that libclc needs to find via LLVM_DIR. +cat >> native_libclc.cmake <<'NATIVE_EOF' +set(CMAKE_C_COMPILER "${COOKBOOK_SYSROOT}/bin/clang-21" CACHE FILEPATH "" FORCE) +set(CMAKE_CXX_COMPILER "${COOKBOOK_SYSROOT}/bin/clang-21" CACHE FILEPATH "" FORCE) +set(CMAKE_ASM_COMPILER "${COOKBOOK_SYSROOT}/bin/clang-21" CACHE FILEPATH "" FORCE) +set(CMAKE_AR "${COOKBOOK_SYSROOT}/bin/llvm-ar" CACHE FILEPATH "" FORCE) +set(CMAKE_NM "${COOKBOOK_SYSROOT}/bin/llvm-nm" CACHE FILEPATH "" FORCE) +set(CMAKE_RANLIB "${COOKBOOK_SYSROOT}/bin/llvm-ranlib" CACHE FILEPATH "" FORCE) +set(CMAKE_C_FLAGS_INIT "" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_INIT "" CACHE STRING "" FORCE) +set(CMAKE_EXE_LINKER_FLAGS_INIT "" CACHE STRING "" FORCE) +set(CMAKE_SHARED_LINKER_FLAGS_INIT "" CACHE STRING "" FORCE) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM "BYPASS" CACHE STRING "" FORCE) +set(LLVM_DIR "${COOKBOOK_SYSROOT}/lib/cmake/llvm" CACHE PATH "" FORCE) +set(LIBCLC_STANDALONE_BUILD TRUE CACHE BOOL "" FORCE) +NATIVE_EOF + +# Run cmake with the host-native toolchain. LIBCLC_TARGETS_TO_BUILD +# is the list of GPU targets Mesa consumes. Default "all" includes +# targets Mesa does not need (ptx-nvidiacl for nvidia, clspv for +# Vulkan-SPIR-V path). Restrict to what Mesa's clc tool actually +# requires: amdgcn, amdgcn-amdhsa, r600, generic, spirv. +COOKBOOK_CMAKE_FLAGS+=( + -DCMAKE_TOOLCHAIN_FILE="$(realpath native_libclc.cmake)" + -DCMAKE_BUILD_TYPE=Release + -DLLVM_DIR="${COOKBOOK_SYSROOT}/lib/cmake/llvm" + -DLIBCLC_STANDALONE_BUILD=TRUE + -DLIBCLC_TARGETS_TO_BUILD="amdgcn;amdgcn-amdhsa;r600;generic;spirv" + -DENABLE_RUNTIME_SUBNORMAL=OFF + -DCMAKE_INSTALL_PREFIX="${COOKBOOK_STAGE}/usr" + -DCMAKE_INSTALL_LIBDIR=lib + -DCMAKE_INSTALL_INCLUDEDIR=include + -DCMAKE_INSTALL_DATADIR=share + -DLLVM_TARGETS_TO_BUILD="$ARCH" + -G Ninja + -Wno-dev +) + +# Restore the cross-compile environment (libclc install is the only +# step that uses the host toolchain; if subsequent install steps +# are added to the recipe, they'd want the cross env). +export LDFLAGS="$_SAVED_LDFLAGS" +export CFLAGS="$_SAVED_CFLAGS" +export CXXFLAGS="$_SAVED_CXXFLAGS" +export CPPFLAGS="$_SAVED_CPPFLAGS" + +# Source dir is the path_in_repo subdir of the cloned llvm-project. +"${COOKBOOK_CMAKE}" "${COOKBOOK_SOURCE}" "${COOKBOOK_CMAKE_FLAGS[@]}" +"${COOKBOOK_NINJA}" -j"${COOKBOOK_MAKE_JOBS}" +DESTDIR="${COOKBOOK_STAGE}/stage" "${COOKBOOK_NINJA}" install + +# Move installed files from $COOKBOOK_STAGE/stage to $COOKBOOK_STAGE. +# The DESTDIR install above places everything under +# $COOKBOOK_STAGE/stage; flatten the extra stage dir. +if [ -d "${COOKBOOK_STAGE}/stage" ]; then + cp -a "${COOKBOOK_STAGE}/stage/." "${COOKBOOK_STAGE}/" + rm -rf "${COOKBOOK_STAGE}/stage" +fi + +# Mesa's clc tool expects the .bc files at /clc where +# libexecdir is /share/clc (per the libclc.pc.in template). +# The cmake install above places them at $COOKBOOK_STAGE/usr/share/clc +# which is the right path; no further action needed. +''' + +[[optional-packages]] +name = "dev" +files = [ + "usr/include/**", +] diff --git a/local/recipes/dev/libclc/source/CMakeLists.txt b/local/recipes/dev/libclc/source/CMakeLists.txt new file mode 100644 index 0000000000..c98e204346 --- /dev/null +++ b/local/recipes/dev/libclc/source/CMakeLists.txt @@ -0,0 +1,486 @@ +cmake_minimum_required(VERSION 3.20.0) + +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + project(libclc VERSION 0.2.0 LANGUAGES CXX C) +endif() +set(LLVM_SUBPROJECT_TITLE "libclc") + +set(CMAKE_CXX_STANDARD 17) + +# Add path for custom modules +list( INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) + +set( LIBCLC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) +set( LIBCLC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) +set( LIBCLC_OBJFILE_DIR ${LIBCLC_BINARY_DIR}/obj.libclc.dir ) + +include( AddLibclc ) + +include( GNUInstallDirs ) +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS + # OpenCL libraries + opencl/lib/amdgcn-amdhsa/SOURCES; + opencl/lib/amdgcn/SOURCES; + opencl/lib/clspv/SOURCES; + opencl/lib/generic/SOURCES; + opencl/lib/ptx-nvidiacl/SOURCES; + opencl/lib/r600/SOURCES; + opencl/lib/spirv/SOURCES; + # CLC internal libraries + clc/lib/generic/SOURCES; + clc/lib/amdgcn/SOURCES; + clc/lib/amdgpu/SOURCES; + clc/lib/clspv/SOURCES; + clc/lib/r600/SOURCES; + clc/lib/spirv/SOURCES; +) + +set( LIBCLC_MIN_LLVM 3.9.0 ) + +set( LIBCLC_TARGETS_TO_BUILD "all" + CACHE STRING "Semicolon-separated list of libclc targets to build, or 'all'." ) + +option( ENABLE_RUNTIME_SUBNORMAL "Enable runtime linking of subnormal support." OFF ) + +if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) + # Out-of-tree configuration + set( LIBCLC_STANDALONE_BUILD TRUE ) + + find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}") + include(AddLLVM) + + message( STATUS "libclc LLVM version: ${LLVM_PACKAGE_VERSION}" ) + + if( LLVM_PACKAGE_VERSION VERSION_LESS LIBCLC_MIN_LLVM ) + message( FATAL_ERROR "libclc needs at least LLVM ${LIBCLC_MIN_LLVM}" ) + endif() + + # Import required tools + if( NOT EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} ) + foreach( tool IN ITEMS clang llvm-as llvm-link opt ) + find_program( LLVM_TOOL_${tool} ${tool} PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH ) + set( ${tool}_exe ${LLVM_TOOL_${tool}} ) + set( ${tool}_target ) + endforeach() + endif() +else() + # In-tree configuration + set( LIBCLC_STANDALONE_BUILD FALSE ) + + set( LLVM_PACKAGE_VERSION ${LLVM_VERSION} ) + + # Note that we check this later (for both build types) but we can provide a + # more useful error message when built in-tree. We assume that LLVM tools are + # always available so don't warn here. + if( NOT LLVM_RUNTIMES_BUILD AND NOT clang IN_LIST LLVM_ENABLE_PROJECTS ) + message(FATAL_ERROR "Clang is not enabled, but is required to build libclc in-tree") + endif() + + if( NOT EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} ) + get_host_tool_path( clang CLANG clang_exe clang_target ) + get_host_tool_path( llvm-as LLVM_AS llvm-as_exe llvm-as_target ) + get_host_tool_path( llvm-link LLVM_LINK llvm-link_exe llvm-link_target ) + get_host_tool_path( opt OPT opt_exe opt_target ) + endif() +endif() + +if( EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} ) + message( WARNING "Using custom LLVM tools to build libclc: " + "${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR}, " + " ensure the tools are up to date." ) + # Note - use a differently named variable than LLVM_TOOL_${tool} as above, as + # the variable name is used to cache the result of find_program. If we used + # the same name, a user wouldn't be able to switch a build between default + # and custom tools. + foreach( tool IN ITEMS clang llvm-as llvm-link opt ) + find_program( LLVM_CUSTOM_TOOL_${tool} ${tool} + PATHS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH ) + set( ${tool}_exe ${LLVM_CUSTOM_TOOL_${tool}} ) + set( ${tool}_target ) + endforeach() +endif() + +foreach( tool IN ITEMS clang opt llvm-as llvm-link ) + if( NOT EXISTS "${${tool}_exe}" AND "${tool}_target" STREQUAL "" ) + message( FATAL_ERROR "libclc toolchain incomplete - missing tool ${tool}!" ) + endif() +endforeach() + +# llvm-spirv is an optional dependency, used to build spirv-* targets. +# It may be provided in-tree or externally. +if( TARGET llvm-spirv ) + get_host_tool_path( llvm-spirv LLVM_SPIRV llvm-spirv_exe llvm-spirv_target ) +else() + find_program( LLVM_SPIRV llvm-spirv HINTS ${LLVM_TOOLS_BINARY_DIR} ) + set( llvm-spirv_exe "${LLVM_SPIRV}" ) + set( llvm-spirv_target ) +endif() + +# List of all targets. Note that some are added dynamically below. +set( LIBCLC_TARGETS_ALL + amdgcn-- + amdgcn--amdhsa + clspv-- + clspv64-- + r600-- + nvptx-- + nvptx64-- + nvptx--nvidiacl + nvptx64--nvidiacl +) + +# mesa3d environment is only available since LLVM 4.0 +if( LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 4.0.0 ) + list( APPEND LIBCLC_TARGETS_ALL amdgcn-mesa-mesa3d ) +endif() + +# spirv-mesa3d and spirv64-mesa3d targets can only be built with the (optional) +# llvm-spirv external tool. +if( llvm-spirv_exe ) + list( APPEND LIBCLC_TARGETS_ALL spirv-mesa3d- spirv64-mesa3d- ) +endif() + +# Verify that the user hasn't requested mesa3d targets without an available +# llvm-spirv tool. +if( "spirv-mesa3d-" IN_LIST LIBCLC_TARGETS_TO_BUILD OR "spirv64-mesa3d-" IN_LIST LIBCLC_TARGETS_TO_BUILD ) + if( NOT llvm-spirv_exe ) + message( FATAL_ERROR "SPIR-V targets requested, but spirv-tools is not installed" ) + endif() +endif() + +if( LIBCLC_TARGETS_TO_BUILD STREQUAL "all" ) + set( LIBCLC_TARGETS_TO_BUILD ${LIBCLC_TARGETS_ALL} ) +else() + foreach(TARGET_TO_BUILD ${LIBCLC_TARGETS_TO_BUILD}) + if (NOT ${TARGET_TO_BUILD} IN_LIST LIBCLC_TARGETS_ALL) + message ( FATAL_ERROR "Unknown target in LIBCLC_TARGETS_TO_BUILD: \"${TARGET_TO_BUILD}\"\n" + "Valid targets are: ${LIBCLC_TARGETS_ALL}\n") + endif() + endforeach() +endif() + +list( SORT LIBCLC_TARGETS_TO_BUILD ) + +# Construct LLVM version define +set( LLVM_VERSION_DEFINE "-DHAVE_LLVM=0x${LLVM_VERSION_MAJOR}0${LLVM_VERSION_MINOR}" ) + +# This needs to be set before any target that needs it +# We need to use LLVM_INCLUDE_DIRS here, because if we are linking to an +# llvm build directory, this includes $src/llvm/include which is where all the +# headers are not $build/include/ which is what LLVM_INCLUDE_DIR is set to. +include_directories( ${LLVM_INCLUDE_DIRS} ) + +# Setup prepare_builtins tools +set(LLVM_LINK_COMPONENTS + BitReader + BitWriter + Core + IRReader + Support +) +if( LIBCLC_STANDALONE_BUILD ) + add_llvm_executable( prepare_builtins utils/prepare-builtins.cpp ) + set( prepare_builtins_exe prepare_builtins ) + set( prepare_builtins_target prepare_builtins ) +else() + add_llvm_utility( prepare_builtins utils/prepare-builtins.cpp ) + setup_host_tool( prepare_builtins PREPARE_BUILTINS prepare_builtins_exe prepare_builtins_target ) +endif() +target_compile_definitions( prepare_builtins PRIVATE ${LLVM_VERSION_DEFINE} ) +# These were not properly reported in early LLVM and we don't need them +target_compile_options( prepare_builtins PRIVATE -fno-rtti -fno-exceptions ) + +# Setup arch devices +set( r600--_devices cedar cypress barts cayman ) +set( amdgcn--_devices tahiti ) +set( amdgcn-mesa-mesa3d_devices ${amdgcn--_devices} ) +set( amdgcn--amdhsa_devices none ) +set( clspv--_devices none ) +set( clspv64--_devices none ) +set( nvptx--_devices none ) +set( nvptx64--_devices none ) +set( nvptx--nvidiacl_devices none ) +set( nvptx64--nvidiacl_devices none ) +set( spirv-mesa3d-_devices none ) +set( spirv64-mesa3d-_devices none ) + +# Setup aliases +set( cedar_aliases palm sumo sumo2 redwood juniper ) +set( cypress_aliases hemlock ) +set( barts_aliases turks caicos ) +set( cayman_aliases aruba ) +set( tahiti_aliases pitcairn verde oland hainan bonaire kabini kaveri hawaii + mullins tonga tongapro iceland carrizo fiji stoney polaris10 polaris11 + gfx602 gfx705 gfx805 + gfx900 gfx902 gfx904 gfx906 gfx908 gfx909 gfx90a gfx90c gfx942 gfx950 + gfx1010 gfx1011 gfx1012 gfx1013 + gfx1030 gfx1031 gfx1032 gfx1033 gfx1034 gfx1035 gfx1036 + gfx1100 gfx1101 gfx1102 gfx1103 + gfx1150 gfx1151 gfx1152 gfx1153 + gfx1200 gfx1201 +) + +# pkg-config file +configure_file( libclc.pc.in libclc.pc @ONLY ) +install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig" ) + +if( ENABLE_RUNTIME_SUBNORMAL ) + foreach( file IN ITEMS subnormal_use_default subnormal_disable ) + link_bc( + TARGET ${file} + INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/${file}.ll + ) + install( + FILES $ + DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" + ) + endforeach() +endif() + +find_package( Python3 REQUIRED COMPONENTS Interpreter ) +file( TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/utils/gen_convert.py script_loc ) +add_custom_command( + OUTPUT convert.cl + COMMAND ${Python3_EXECUTABLE} ${script_loc} > convert.cl + DEPENDS ${script_loc} ) +add_custom_target( generate-convert.cl DEPENDS convert.cl ) +set_target_properties( generate-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" ) + +add_custom_command( + OUTPUT clc-convert.cl + COMMAND ${Python3_EXECUTABLE} ${script_loc} --clc > clc-convert.cl + DEPENDS ${script_loc} ) +add_custom_target( generate-clc-convert.cl DEPENDS clc-convert.cl ) +set_target_properties( generate-clc-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" ) + +if ( clspv-- IN_LIST LIBCLC_TARGETS_TO_BUILD OR clspv64-- IN_LIST LIBCLC_TARGETS_TO_BUILD ) + add_custom_command( + OUTPUT clspv-convert.cl + COMMAND ${Python3_EXECUTABLE} ${script_loc} --clspv > clspv-convert.cl + DEPENDS ${script_loc} ) + add_custom_target( generate-clspv-convert.cl DEPENDS clspv-convert.cl ) + set_target_properties( generate-clspv-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" ) +endif() + +set_source_files_properties( + # CLC builtins + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_cos.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_divide.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_exp10.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_exp2.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_exp.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_log10.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_log2.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_log.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_powr.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_recip.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_rsqrt.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_sin.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_sqrt.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_tan.cl + # Target-specific CLC builtins + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/amdgpu/math/clc_native_exp2.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/amdgpu/math/clc_native_exp.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/amdgpu/math/clc_native_log10.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/r600/math/clc_native_rsqrt.cl + # OpenCL builtins + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_cos.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_divide.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_exp.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_exp10.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_exp2.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_log.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_log10.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_log2.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_powr.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_recip.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_rsqrt.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_sin.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_sqrt.cl + ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_tan.cl + PROPERTIES COMPILE_OPTIONS -fapprox-func +) + +enable_testing() + +foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) + message( STATUS "libclc target '${t}' is enabled" ) + string( REPLACE "-" ";" TRIPLE ${t} ) + list( GET TRIPLE 0 ARCH ) + list( GET TRIPLE 1 VENDOR ) + list( GET TRIPLE 2 OS ) + + set( opencl_dirs ) + + if( ${ARCH} STREQUAL r600 OR ${ARCH} STREQUAL amdgcn ) + list( APPEND opencl_dirs amdgpu ) + endif() + + # Some targets' directories alias others + if( ${ARCH} STREQUAL nvptx OR ${ARCH} STREQUAL nvptx64 ) + set( DARCH ptx ) + elseif( ${ARCH} STREQUAL clspv OR ${ARCH} STREQUAL clspv64 ) + set( DARCH clspv ) + elseif( ${ARCH} STREQUAL spirv OR ${ARCH} STREQUAL spirv64 ) + set( DARCH spirv ) + elseif( ${ARCH} STREQUAL amdgcn-mesa3d ) + set( DARCH amdgcn-amdhsa ) + else() + set( DARCH ${ARCH} ) + endif() + + # Append a variety of target- and triple-based directories to search, + # increasing in specificity. + list( APPEND opencl_dirs ${DARCH} ${DARCH}-${OS} ${DARCH}-${VENDOR}-${OS} ) + + # The 'generic' directory contains all of the generic implementations of the + # builtins. It is included first so it has the lowest search priority, + # allowing targets to override builtins based on file names found later in + # the list of search directories. + # CLC builds all builtins for all targets, so unconditionally prepend the + # 'generic' directory. + set( clc_dirs generic ${opencl_dirs} ) + # Some OpenCL targets don't build all builtins, in which case they don't want + # the 'generic' directory. Otherwise, prepend the 'generic' directory. + if ( NOT ARCH STREQUAL spirv AND NOT ARCH STREQUAL spirv64 AND + NOT ARCH STREQUAL clspv AND NOT ARCH STREQUAL clspv64) + list( PREPEND opencl_dirs generic ) + endif() + + set( clc_lib_files ) + set( clc_gen_files clc-convert.cl ) + + libclc_configure_lib_source( + clc_lib_files + LIB_ROOT_DIR clc + DIRS ${clc_dirs} + ) + + set( opencl_lib_files ) + set( opencl_gen_files ) + + if( NOT ARCH STREQUAL spirv AND NOT ARCH STREQUAL spirv64 ) + if( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 ) + list( APPEND opencl_gen_files clspv-convert.cl ) + else() + list( APPEND opencl_gen_files convert.cl ) + if ( NOT ENABLE_RUNTIME_SUBNORMAL ) + list( APPEND opencl_lib_files opencl/lib/generic/subnormal_use_default.ll ) + endif() + endif() + endif() + + libclc_configure_lib_source( + opencl_lib_files + LIB_ROOT_DIR opencl + DIRS ${opencl_dirs} + ) + + foreach( d ${${t}_devices} ) + get_libclc_device_info( + TRIPLE ${t} + DEVICE ${d} + CPU cpu + ARCH_SUFFIX arch_suffix + CLANG_TRIPLE clang_triple + ) + + message( STATUS " device: ${d} ( ${${d}_aliases} )" ) + + if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 ) + set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV ) + set( opt_flags ) + set( spvflags --spirv-max-version=1.1 ) + set( MACRO_ARCH SPIRV32 ) + if( ARCH STREQUAL spirv64 ) + set( MACRO_ARCH SPIRV64 ) + endif() + elseif( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 ) + set( build_flags "-Wno-unknown-assumption" -DCLC_CLSPV ) + set( opt_flags -O3 ) + set( MACRO_ARCH CLSPV32 ) + if( ARCH STREQUAL clspv64 ) + set( MACRO_ARCH CLSPV64 ) + endif() + else() + set( build_flags ) + set( opt_flags -O3 ) + set( MACRO_ARCH ${ARCH} ) + endif() + + set( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR}/${arch_suffix}" ) + file( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} ) + + # Build for OpenCL 3.0 independently of the target or device. + list( APPEND build_flags -cl-std=CL3.0 ) + + string( TOUPPER "CLC_${MACRO_ARCH}" CLC_TARGET_DEFINE ) + + list( APPEND build_flags + -D${CLC_TARGET_DEFINE} + # All libclc builtin libraries see CLC headers + -I${CMAKE_CURRENT_SOURCE_DIR}/clc/include + # Error on undefined macros + -Werror=undef + ) + + if( NOT "${cpu}" STREQUAL "" ) + list( APPEND build_flags -mcpu=${cpu} ) + endif() + + # Generic address space support. + # Note: when declaring builtins, we must consider that even if a target + # formally/nominally supports the generic address space, in practice that + # target may map it to the same target address space as another address + # space (often the private one). In such cases we must be careful not to + # multiply-define a builtin in a single target address space, as it would + # result in a mangling clash. + # For this reason we must consider the target support of the generic + # address space separately from the *implementation* decision about whether + # to declare certain builtins in that address space. + # Note: we assume that if there is no distinct generic address space, it + # maps to the private address space. + set ( private_addrspace_val 0 ) + set ( generic_addrspace_val 0 ) + if( ARCH STREQUAL amdgcn OR ARCH STREQUAL r600 OR ARCH STREQUAL amdgcn-amdhsa ) + set ( private_addrspace_val 5 ) + endif() + if( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64) + set ( generic_addrspace_val 4 ) + endif() + list( APPEND build_flags + -D__CLC_PRIVATE_ADDRSPACE_VAL=${private_addrspace_val} + -D__CLC_GENERIC_ADDRSPACE_VAL=${generic_addrspace_val} + ) + + set( clc_build_flags ${build_flags} -DCLC_INTERNAL ) + + add_libclc_builtin_set( + CLC_INTERNAL + ARCH ${ARCH} + ARCH_SUFFIX clc-${arch_suffix} + TRIPLE ${clang_triple} + COMPILE_FLAGS ${clc_build_flags} + OPT_FLAGS ${opt_flags} + LIB_FILES ${clc_lib_files} + GEN_FILES ${clc_gen_files} + ) + + list( APPEND build_flags + -I${CMAKE_CURRENT_SOURCE_DIR}/opencl/include + ) + + add_libclc_builtin_set( + ARCH ${ARCH} + ARCH_SUFFIX ${arch_suffix} + TRIPLE ${clang_triple} + COMPILE_FLAGS ${build_flags} + OPT_FLAGS ${opt_flags} + LIB_FILES ${opencl_lib_files} + GEN_FILES ${opencl_gen_files} + ALIASES ${${d}_aliases} + # Link in the CLC builtins and internalize their symbols + INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix} + ) + endforeach( d ) +endforeach( t ) diff --git a/local/recipes/dev/libclc/source/CREDITS.TXT b/local/recipes/dev/libclc/source/CREDITS.TXT new file mode 100644 index 0000000000..b18d40bd73 --- /dev/null +++ b/local/recipes/dev/libclc/source/CREDITS.TXT @@ -0,0 +1,2 @@ +N: Peter Collingbourne +E: peter@pcc.me.uk diff --git a/local/recipes/dev/libclc/source/LICENSE.TXT b/local/recipes/dev/libclc/source/LICENSE.TXT new file mode 100644 index 0000000000..e05adfb136 --- /dev/null +++ b/local/recipes/dev/libclc/source/LICENSE.TXT @@ -0,0 +1,299 @@ +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== + +The libclc library is dual licensed under both the University of Illinois +"BSD-Like" license and the MIT license. As a user of this code you may choose +to use it under either license. As a contributor, you agree to allow your code +to be used under both. + +Full text of the relevant licenses is included below. + +============================================================================== + +Copyright (c) 2011-2019 by the contributors listed in CREDITS.TXT + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * The names of the contributors may not be used to endorse or promote + products derived from this Software without specific prior written + permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== + +Copyright (c) 2011-2014 by the contributors listed in CREDITS.TXT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/local/recipes/dev/libclc/source/Maintainers.md b/local/recipes/dev/libclc/source/Maintainers.md new file mode 100644 index 0000000000..ac869b6945 --- /dev/null +++ b/local/recipes/dev/libclc/source/Maintainers.md @@ -0,0 +1,17 @@ +# libclc Maintainers + +This file is a list of the +[maintainers](https://llvm.org/docs/DeveloperPolicy.html#maintainers) for +libclc. + +## Current Maintainers + +The following people are the active maintainers for the project. Please reach +out to them for code reviews, questions about their area of expertise, or other +assistance. + +Fraser Cormack \ +fraser@codeplay.com (email), [frasercrmck](https://github.com/frasercrmck) (GitHub) + +Tom Stellard \ +tstellar@redhat.com (email), [tstellar](https://github.com/tstellar) (GitHub) diff --git a/local/recipes/dev/libclc/source/README.md b/local/recipes/dev/libclc/source/README.md new file mode 100644 index 0000000000..34f329d861 --- /dev/null +++ b/local/recipes/dev/libclc/source/README.md @@ -0,0 +1,67 @@ +# libclc + +libclc is an open source implementation of the library +requirements of the OpenCL C programming language, as specified by the +OpenCL 1.1 Specification. The following sections of the specification +impose library requirements: + + * 6.1: Supported Data Types + * 6.2.3: Explicit Conversions + * 6.2.4.2: Reinterpreting Types Using as_type() and as_typen() + * 6.9: Preprocessor Directives and Macros + * 6.11: Built-in Functions + * 9.3: Double Precision Floating-Point + * 9.4: 64-bit Atomics + * 9.5: Writing to 3D image memory objects + * 9.6: Half Precision Floating-Point + +libclc is intended to be used with the Clang compiler's OpenCL frontend. + +libclc is designed to be portable and extensible. To this end, it provides +generic implementations of most library requirements, allowing the target +to override the generic implementation at the granularity of individual +functions. + +libclc currently supports PTX, AMDGPU, SPIRV and CLSPV targets, but support for +more targets is welcome. + +## Compiling and installing + +(in the following instructions you can use `make` or `ninja`) + +For an in-tree build, Clang must also be built at the same time: +``` +$ cmake /llvm-project/llvm/CMakeLists.txt -DLLVM_ENABLE_PROJECTS="libclc;clang" \ + -DCMAKE_BUILD_TYPE=Release -G Ninja +$ ninja +``` +Then install: +``` +$ ninja install +``` +Note you can use the `DESTDIR` Makefile variable to do staged installs. +``` +$ DESTDIR=/path/for/staged/install ninja install +``` +To build out of tree, or in other words, against an existing LLVM build or install: +``` +$ cmake /llvm-project/libclc/CMakeLists.txt -DCMAKE_BUILD_TYPE=Release \ + -G Ninja -DLLVM_DIR=$(/llvm-config --cmakedir) +$ ninja +``` +Then install as before. + +In both cases this will include all supported targets. You can choose which +targets are enabled by passing `-DLIBCLC_TARGETS_TO_BUILD` to CMake. The default +is `all`. + +In both cases, the LLVM used must include the targets you want libclc support for +(`AMDGPU` and `NVPTX` are enabled in LLVM by default). Apart from `SPIRV` where you do +not need an LLVM target but you do need the +[llvm-spirv tool](https://github.com/KhronosGroup/SPIRV-LLVM-Translator) available. +Either build this in-tree, or place it in the directory pointed to by +`LLVM_TOOLS_BINARY_DIR`. + +## Website + +https://libclc.llvm.org/ diff --git a/local/recipes/dev/libclc/source/check_external_calls.sh b/local/recipes/dev/libclc/source/check_external_calls.sh new file mode 100755 index 0000000000..25792e249d --- /dev/null +++ b/local/recipes/dev/libclc/source/check_external_calls.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +FILE=$1 +BIN_DIR=$2 +if [ ! -f $FILE ]; then + echo "ERROR: Not a file: $FILE" + exit 3 +fi +ret=0 + +DIS="$BIN_DIR/llvm-dis" +if [ ! -x $DIS ]; then + echo "ERROR: Disassembler '$DIS' is not executable" + exit 3 +fi + +TMP_FILE=$(mktemp) + +# Check for calls. Calls to llvm intrinsics are OK +$DIS < $FILE | grep ' call ' | grep -v '@llvm' > "$TMP_FILE" +COUNT=$(wc -l < "$TMP_FILE") + +if [ "$COUNT" -ne "0" ]; then + echo "ERROR: $COUNT unresolved calls detected in $FILE" + cat $TMP_FILE + ret=1 +else + echo "File $FILE is OK" +fi +exit $ret diff --git a/local/recipes/dev/libclc/source/clc/include/clc/async/clc_prefetch.h b/local/recipes/dev/libclc/source/clc/include/clc/async/clc_prefetch.h new file mode 100644 index 0000000000..a416d97fa0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/async/clc_prefetch.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_ASYNC_CLC_PREFETCH_H__ +#define __CLC_ASYNC_CLC_PREFETCH_H__ + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include + +#endif // __CLC_ASYNC_CLC_PREFETCH_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/async/clc_prefetch.inc b/local/recipes/dev/libclc/source/clc/include/clc/async/clc_prefetch.inc new file mode 100644 index 0000000000..178646efb9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/async/clc_prefetch.inc @@ -0,0 +1,10 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL void __clc_prefetch(const global __CLC_GENTYPE *p, + size_t num_gentypes); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/clc_as_type.h b/local/recipes/dev/libclc/source/clc/include/clc/clc_as_type.h new file mode 100644 index 0000000000..62fee71da8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/clc_as_type.h @@ -0,0 +1,90 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_CLC_AS_TYPE_H__ +#define __CLC_CLC_AS_TYPE_H__ + +#define __clc_as_char(x) __builtin_astype(x, char) +#define __clc_as_uchar(x) __builtin_astype(x, uchar) +#define __clc_as_short(x) __builtin_astype(x, short) +#define __clc_as_ushort(x) __builtin_astype(x, ushort) +#define __clc_as_int(x) __builtin_astype(x, int) +#define __clc_as_uint(x) __builtin_astype(x, uint) +#define __clc_as_long(x) __builtin_astype(x, long) +#define __clc_as_ulong(x) __builtin_astype(x, ulong) +#define __clc_as_float(x) __builtin_astype(x, float) + +#define __clc_as_char2(x) __builtin_astype(x, char2) +#define __clc_as_uchar2(x) __builtin_astype(x, uchar2) +#define __clc_as_short2(x) __builtin_astype(x, short2) +#define __clc_as_ushort2(x) __builtin_astype(x, ushort2) +#define __clc_as_int2(x) __builtin_astype(x, int2) +#define __clc_as_uint2(x) __builtin_astype(x, uint2) +#define __clc_as_long2(x) __builtin_astype(x, long2) +#define __clc_as_ulong2(x) __builtin_astype(x, ulong2) +#define __clc_as_float2(x) __builtin_astype(x, float2) + +#define __clc_as_char3(x) __builtin_astype(x, char3) +#define __clc_as_uchar3(x) __builtin_astype(x, uchar3) +#define __clc_as_short3(x) __builtin_astype(x, short3) +#define __clc_as_ushort3(x) __builtin_astype(x, ushort3) +#define __clc_as_int3(x) __builtin_astype(x, int3) +#define __clc_as_uint3(x) __builtin_astype(x, uint3) +#define __clc_as_long3(x) __builtin_astype(x, long3) +#define __clc_as_ulong3(x) __builtin_astype(x, ulong3) +#define __clc_as_float3(x) __builtin_astype(x, float3) + +#define __clc_as_char4(x) __builtin_astype(x, char4) +#define __clc_as_uchar4(x) __builtin_astype(x, uchar4) +#define __clc_as_short4(x) __builtin_astype(x, short4) +#define __clc_as_ushort4(x) __builtin_astype(x, ushort4) +#define __clc_as_int4(x) __builtin_astype(x, int4) +#define __clc_as_uint4(x) __builtin_astype(x, uint4) +#define __clc_as_long4(x) __builtin_astype(x, long4) +#define __clc_as_ulong4(x) __builtin_astype(x, ulong4) +#define __clc_as_float4(x) __builtin_astype(x, float4) + +#define __clc_as_char8(x) __builtin_astype(x, char8) +#define __clc_as_uchar8(x) __builtin_astype(x, uchar8) +#define __clc_as_short8(x) __builtin_astype(x, short8) +#define __clc_as_ushort8(x) __builtin_astype(x, ushort8) +#define __clc_as_int8(x) __builtin_astype(x, int8) +#define __clc_as_uint8(x) __builtin_astype(x, uint8) +#define __clc_as_long8(x) __builtin_astype(x, long8) +#define __clc_as_ulong8(x) __builtin_astype(x, ulong8) +#define __clc_as_float8(x) __builtin_astype(x, float8) + +#define __clc_as_char16(x) __builtin_astype(x, char16) +#define __clc_as_uchar16(x) __builtin_astype(x, uchar16) +#define __clc_as_short16(x) __builtin_astype(x, short16) +#define __clc_as_ushort16(x) __builtin_astype(x, ushort16) +#define __clc_as_int16(x) __builtin_astype(x, int16) +#define __clc_as_uint16(x) __builtin_astype(x, uint16) +#define __clc_as_long16(x) __builtin_astype(x, long16) +#define __clc_as_ulong16(x) __builtin_astype(x, ulong16) +#define __clc_as_float16(x) __builtin_astype(x, float16) + +#ifdef cl_khr_fp64 +#define __clc_as_double(x) __builtin_astype(x, double) +#define __clc_as_double2(x) __builtin_astype(x, double2) +#define __clc_as_double3(x) __builtin_astype(x, double3) +#define __clc_as_double4(x) __builtin_astype(x, double4) +#define __clc_as_double8(x) __builtin_astype(x, double8) +#define __clc_as_double16(x) __builtin_astype(x, double16) +#endif + +#ifdef cl_khr_fp16 +#define __clc_as_half(x) __builtin_astype(x, half) +#define __clc_as_half2(x) __builtin_astype(x, half2) +#define __clc_as_half3(x) __builtin_astype(x, half3) +#define __clc_as_half4(x) __builtin_astype(x, half4) +#define __clc_as_half8(x) __builtin_astype(x, half8) +#define __clc_as_half16(x) __builtin_astype(x, half16) +#endif + +#endif // __CLC_CLC_AS_TYPE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/clc_convert.h b/local/recipes/dev/libclc/source/clc/include/clc/clc_convert.h new file mode 100644 index 0000000000..ab41e5abb9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/clc_convert.h @@ -0,0 +1,108 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_CLC_CONVERT_H__ +#define __CLC_CLC_CONVERT_H__ + +#include + +#define _CLC_CONVERT_DECL(FROM_TYPE, TO_TYPE, SUFFIX) \ + _CLC_OVERLOAD _CLC_DECL TO_TYPE __clc_convert_##TO_TYPE##SUFFIX(FROM_TYPE x); + +#define _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, TO_TYPE, SUFFIX) \ + _CLC_CONVERT_DECL(FROM_TYPE, TO_TYPE, SUFFIX) \ + _CLC_CONVERT_DECL(FROM_TYPE##2, TO_TYPE##2, SUFFIX) \ + _CLC_CONVERT_DECL(FROM_TYPE##3, TO_TYPE##3, SUFFIX) \ + _CLC_CONVERT_DECL(FROM_TYPE##4, TO_TYPE##4, SUFFIX) \ + _CLC_CONVERT_DECL(FROM_TYPE##8, TO_TYPE##8, SUFFIX) \ + _CLC_CONVERT_DECL(FROM_TYPE##16, TO_TYPE##16, SUFFIX) + +#define _CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, char, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, uchar, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, int, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, uint, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, short, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, ushort, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, long, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, ulong, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, float, SUFFIX) + +#if defined(cl_khr_fp64) && defined(cl_khr_fp16) +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#define _CLC_VECTOR_CONVERT_FROM(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, double, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, half, SUFFIX) +#elif defined(cl_khr_fp64) +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#define _CLC_VECTOR_CONVERT_FROM(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, double, SUFFIX) +#elif defined(cl_khr_fp16) +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#define _CLC_VECTOR_CONVERT_FROM(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, half, SUFFIX) +#else +#define _CLC_VECTOR_CONVERT_FROM(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) +#endif + +#define _CLC_VECTOR_CONVERT_TO1(SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(char, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(uchar, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(int, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(uint, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(short, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(ushort, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(long, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(ulong, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(float, SUFFIX) + +#if defined(cl_khr_fp64) && defined(cl_khr_fp16) +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#define _CLC_VECTOR_CONVERT_TO(SUFFIX) \ + _CLC_VECTOR_CONVERT_TO1(SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(double, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(half, SUFFIX) +#elif defined(cl_khr_fp64) +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#define _CLC_VECTOR_CONVERT_TO(SUFFIX) \ + _CLC_VECTOR_CONVERT_TO1(SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(double, SUFFIX) +#elif defined(cl_khr_fp16) +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#define _CLC_VECTOR_CONVERT_TO(SUFFIX) \ + _CLC_VECTOR_CONVERT_TO1(SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(half, SUFFIX) +#else +#define _CLC_VECTOR_CONVERT_TO(SUFFIX) _CLC_VECTOR_CONVERT_TO1(SUFFIX) +#endif + +#define _CLC_VECTOR_CONVERT_TO_SUFFIX(ROUND) \ + _CLC_VECTOR_CONVERT_TO(_sat##ROUND) \ + _CLC_VECTOR_CONVERT_TO(ROUND) + +_CLC_VECTOR_CONVERT_TO_SUFFIX(_rtn) +_CLC_VECTOR_CONVERT_TO_SUFFIX(_rte) +_CLC_VECTOR_CONVERT_TO_SUFFIX(_rtz) +_CLC_VECTOR_CONVERT_TO_SUFFIX(_rtp) +_CLC_VECTOR_CONVERT_TO_SUFFIX() + +#undef _CLC_VECTOR_CONVERT_TO_SUFFIX +#undef _CLC_VECTOR_CONVERT_TO +#undef _CLC_VECTOR_CONVERT_TO1 +#undef _CLC_VECTOR_CONVERT_FROM +#undef _CLC_VECTOR_CONVERT_FROM1 +#undef _CLC_VECTOR_CONVERT_DECL +#undef _CLC_CONVERT_DECL + +#endif // __CLC_CLC_CONVERT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/clcfunc.h b/local/recipes/dev/libclc/source/clc/include/clc/clcfunc.h new file mode 100644 index 0000000000..10b9cdd099 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/clcfunc.h @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_CLCFUNC_H_ +#define __CLC_CLCFUNC_H_ + +#define _CLC_OVERLOAD __attribute__((overloadable)) +#define _CLC_DECL +#define _CLC_INLINE __attribute__((always_inline)) inline + +// avoid inlines for SPIR-V related targets since we'll optimise later in the +// chain +#if defined(CLC_SPIRV) +#define _CLC_DEF +#elif defined(CLC_CLSPV) +#define _CLC_DEF __attribute__((noinline)) __attribute__((clspv_libclc_builtin)) +#else +#define _CLC_DEF __attribute__((always_inline)) +#endif + +#if __OPENCL_C_VERSION__ == CL_VERSION_2_0 || \ + (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \ + defined(__opencl_c_generic_address_space)) +#define _CLC_GENERIC_AS_SUPPORTED 1 +#if __CLC_PRIVATE_ADDRSPACE_VAL != __CLC_GENERIC_ADDRSPACE_VAL +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 1 +#else +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0 +#endif +#else +#define _CLC_GENERIC_AS_SUPPORTED 0 +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0 +#endif + +#endif // __CLC_CLCFUNC_H_ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/clcmacro.h b/local/recipes/dev/libclc/source/clc/include/clc/clcmacro.h new file mode 100644 index 0000000000..5c67c937cb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/clcmacro.h @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_CLCMACRO_H__ +#define __CLC_CLCMACRO_H__ + +#include +#include + +#define _CLC_V_V_VP_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE, \ + ADDR_SPACE, ARG2_TYPE) \ + DECLSPEC __CLC_XCONCAT(RET_TYPE, 2) \ + FUNCTION(__CLC_XCONCAT(ARG1_TYPE, 2) x, \ + ADDR_SPACE __CLC_XCONCAT(ARG2_TYPE, 2) * y) { \ + ADDR_SPACE ARG2_TYPE *ptr = (ADDR_SPACE ARG2_TYPE *)y; \ + return (__CLC_XCONCAT(RET_TYPE, 2))(FUNCTION(x.s0, ptr), \ + FUNCTION(x.s1, ptr + 1)); \ + } \ + \ + DECLSPEC __CLC_XCONCAT(RET_TYPE, 3) \ + FUNCTION(__CLC_XCONCAT(ARG1_TYPE, 3) x, \ + ADDR_SPACE __CLC_XCONCAT(ARG2_TYPE, 3) * y) { \ + ADDR_SPACE ARG2_TYPE *ptr = (ADDR_SPACE ARG2_TYPE *)y; \ + return (__CLC_XCONCAT(RET_TYPE, 3))(FUNCTION(x.s0, ptr), \ + FUNCTION(x.s1, ptr + 1), \ + FUNCTION(x.s2, ptr + 2)); \ + } \ + \ + DECLSPEC __CLC_XCONCAT(RET_TYPE, 4) \ + FUNCTION(__CLC_XCONCAT(ARG1_TYPE, 4) x, \ + ADDR_SPACE __CLC_XCONCAT(ARG2_TYPE, 4) * y) { \ + ADDR_SPACE ARG2_TYPE *ptr = (ADDR_SPACE ARG2_TYPE *)y; \ + return (__CLC_XCONCAT(RET_TYPE, 4))( \ + FUNCTION(x.s0, ptr), FUNCTION(x.s1, ptr + 1), FUNCTION(x.s2, ptr + 2), \ + FUNCTION(x.s3, ptr + 3)); \ + } \ + \ + DECLSPEC __CLC_XCONCAT(RET_TYPE, 8) \ + FUNCTION(__CLC_XCONCAT(ARG1_TYPE, 8) x, \ + ADDR_SPACE __CLC_XCONCAT(ARG2_TYPE, 8) * y) { \ + ADDR_SPACE ARG2_TYPE *ptr = (ADDR_SPACE ARG2_TYPE *)y; \ + return (__CLC_XCONCAT(RET_TYPE, 8))( \ + FUNCTION(x.s0, ptr), FUNCTION(x.s1, ptr + 1), FUNCTION(x.s2, ptr + 2), \ + FUNCTION(x.s3, ptr + 3), FUNCTION(x.s4, ptr + 4), \ + FUNCTION(x.s5, ptr + 5), FUNCTION(x.s6, ptr + 6), \ + FUNCTION(x.s7, ptr + 7)); \ + } \ + \ + DECLSPEC __CLC_XCONCAT(RET_TYPE, 16) \ + FUNCTION(__CLC_XCONCAT(ARG1_TYPE, 16) x, \ + ADDR_SPACE __CLC_XCONCAT(ARG2_TYPE, 16) * y) { \ + ADDR_SPACE ARG2_TYPE *ptr = (ADDR_SPACE ARG2_TYPE *)y; \ + return (__CLC_XCONCAT(RET_TYPE, 16))( \ + FUNCTION(x.s0, ptr), FUNCTION(x.s1, ptr + 1), FUNCTION(x.s2, ptr + 2), \ + FUNCTION(x.s3, ptr + 3), FUNCTION(x.s4, ptr + 4), \ + FUNCTION(x.s5, ptr + 5), FUNCTION(x.s6, ptr + 6), \ + FUNCTION(x.s7, ptr + 7), FUNCTION(x.s8, ptr + 8), \ + FUNCTION(x.s9, ptr + 9), FUNCTION(x.sa, ptr + 10), \ + FUNCTION(x.sb, ptr + 11), FUNCTION(x.sc, ptr + 12), \ + FUNCTION(x.sd, ptr + 13), FUNCTION(x.se, ptr + 14), \ + FUNCTION(x.sf, ptr + 15)); \ + } + +#endif // __CLC_CLCMACRO_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/clctypes.h b/local/recipes/dev/libclc/source/clc/include/clc/clctypes.h new file mode 100644 index 0000000000..2187c25359 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/clctypes.h @@ -0,0 +1,108 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_CLCTYPES_H_ +#define __CLC_CLCTYPES_H_ + +/* 6.1.1 Built-in Scalar Data Types */ + +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + +typedef __SIZE_TYPE__ size_t; +typedef __PTRDIFF_TYPE__ ptrdiff_t; + +#define __stdint_join3(a, b, c) a##b##c + +#define __intn_t(n) __stdint_join3(__INT, n, _TYPE__) +#define __uintn_t(n) __stdint_join3(unsigned __INT, n, _TYPE__) + +typedef __intn_t(__INTPTR_WIDTH__) intptr_t; +typedef __uintn_t(__INTPTR_WIDTH__) uintptr_t; + +#undef __uintn_t +#undef __intn_t +#undef __stdint_join3 + +/* 6.1.2 Built-in Vector Data Types */ + +typedef __attribute__((ext_vector_type(2))) char char2; +typedef __attribute__((ext_vector_type(3))) char char3; +typedef __attribute__((ext_vector_type(4))) char char4; +typedef __attribute__((ext_vector_type(8))) char char8; +typedef __attribute__((ext_vector_type(16))) char char16; + +typedef __attribute__((ext_vector_type(2))) uchar uchar2; +typedef __attribute__((ext_vector_type(3))) uchar uchar3; +typedef __attribute__((ext_vector_type(4))) uchar uchar4; +typedef __attribute__((ext_vector_type(8))) uchar uchar8; +typedef __attribute__((ext_vector_type(16))) uchar uchar16; + +typedef __attribute__((ext_vector_type(2))) short short2; +typedef __attribute__((ext_vector_type(3))) short short3; +typedef __attribute__((ext_vector_type(4))) short short4; +typedef __attribute__((ext_vector_type(8))) short short8; +typedef __attribute__((ext_vector_type(16))) short short16; + +typedef __attribute__((ext_vector_type(2))) ushort ushort2; +typedef __attribute__((ext_vector_type(3))) ushort ushort3; +typedef __attribute__((ext_vector_type(4))) ushort ushort4; +typedef __attribute__((ext_vector_type(8))) ushort ushort8; +typedef __attribute__((ext_vector_type(16))) ushort ushort16; + +typedef __attribute__((ext_vector_type(2))) int int2; +typedef __attribute__((ext_vector_type(3))) int int3; +typedef __attribute__((ext_vector_type(4))) int int4; +typedef __attribute__((ext_vector_type(8))) int int8; +typedef __attribute__((ext_vector_type(16))) int int16; + +typedef __attribute__((ext_vector_type(2))) uint uint2; +typedef __attribute__((ext_vector_type(3))) uint uint3; +typedef __attribute__((ext_vector_type(4))) uint uint4; +typedef __attribute__((ext_vector_type(8))) uint uint8; +typedef __attribute__((ext_vector_type(16))) uint uint16; + +typedef __attribute__((ext_vector_type(2))) long long2; +typedef __attribute__((ext_vector_type(3))) long long3; +typedef __attribute__((ext_vector_type(4))) long long4; +typedef __attribute__((ext_vector_type(8))) long long8; +typedef __attribute__((ext_vector_type(16))) long long16; + +typedef __attribute__((ext_vector_type(2))) ulong ulong2; +typedef __attribute__((ext_vector_type(3))) ulong ulong3; +typedef __attribute__((ext_vector_type(4))) ulong ulong4; +typedef __attribute__((ext_vector_type(8))) ulong ulong8; +typedef __attribute__((ext_vector_type(16))) ulong ulong16; + +typedef __attribute__((ext_vector_type(2))) float float2; +typedef __attribute__((ext_vector_type(3))) float float3; +typedef __attribute__((ext_vector_type(4))) float float4; +typedef __attribute__((ext_vector_type(8))) float float8; +typedef __attribute__((ext_vector_type(16))) float float16; + +/* 9.3 Double Precision Floating-Point */ + +#ifdef cl_khr_fp64 +typedef __attribute__((ext_vector_type(2))) double double2; +typedef __attribute__((ext_vector_type(3))) double double3; +typedef __attribute__((ext_vector_type(4))) double double4; +typedef __attribute__((ext_vector_type(8))) double double8; +typedef __attribute__((ext_vector_type(16))) double double16; +#endif + +#ifdef cl_khr_fp16 +typedef __attribute__((ext_vector_type(2))) half half2; +typedef __attribute__((ext_vector_type(3))) half half3; +typedef __attribute__((ext_vector_type(4))) half half4; +typedef __attribute__((ext_vector_type(8))) half half8; +typedef __attribute__((ext_vector_type(16))) half half16; +#endif + +#endif // __CLC_CLCTYPES_H_ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/common/clc_degrees.h b/local/recipes/dev/libclc/source/clc/include/clc/common/clc_degrees.h new file mode 100644 index 0000000000..e633344c29 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/common/clc_degrees.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_COMMON_CLC_DEGREES_H__ +#define __CLC_COMMON_CLC_DEGREES_H__ + +#define __CLC_BODY +#define FUNCTION __clc_degrees + +#include + +#undef FUNCTION + +#endif // __CLC_COMMON_CLC_DEGREES_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/common/clc_radians.h b/local/recipes/dev/libclc/source/clc/include/clc/common/clc_radians.h new file mode 100644 index 0000000000..0b075efbcc --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/common/clc_radians.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_COMMON_CLC_RADIANS_H__ +#define __CLC_COMMON_CLC_RADIANS_H__ + +#define __CLC_BODY +#define FUNCTION __clc_radians + +#include + +#undef FUNCTION + +#endif // __CLC_COMMON_CLC_RADIANS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/common/clc_sign.h b/local/recipes/dev/libclc/source/clc/include/clc/common/clc_sign.h new file mode 100644 index 0000000000..0a8c4cc94d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/common/clc_sign.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_COMMON_CLC_SIGN_H__ +#define __CLC_COMMON_CLC_SIGN_H__ + +#define FUNCTION __clc_sign +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_COMMON_CLC_SIGN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/common/clc_smoothstep.h b/local/recipes/dev/libclc/source/clc/include/clc/common/clc_smoothstep.h new file mode 100644 index 0000000000..80a28a1bbb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/common/clc_smoothstep.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_COMMON_CLC_SMOOTHSTEP_H__ +#define __CLC_COMMON_CLC_SMOOTHSTEP_H__ + +// note: Unlike OpenCL __clc_smoothstep is only defined for three matching +// argument types. + +#define __CLC_BODY +#include + +#endif // __CLC_COMMON_CLC_SMOOTHSTEP_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/common/clc_smoothstep.inc b/local/recipes/dev/libclc/source/clc/include/clc/common/clc_smoothstep.inc new file mode 100644 index 0000000000..158c578d73 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/common/clc_smoothstep.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_smoothstep(__CLC_GENTYPE edge0, + __CLC_GENTYPE edge1, + __CLC_GENTYPE x); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/common/clc_step.h b/local/recipes/dev/libclc/source/clc/include/clc/common/clc_step.h new file mode 100644 index 0000000000..96b4759cab --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/common/clc_step.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_COMMON_CLC_STEP_H__ +#define __CLC_COMMON_CLC_STEP_H__ + +#define FUNCTION __clc_step +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_COMMON_CLC_STEP_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/float/definitions.h b/local/recipes/dev/libclc/source/clc/include/clc/float/definitions.h new file mode 100644 index 0000000000..9db49fa54d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/float/definitions.h @@ -0,0 +1,96 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#define MAXFLOAT 0x1.fffffep127f +#define HUGE_VALF __builtin_huge_valf() +#define INFINITY __builtin_inff() + +#define FLT_DIG 6 +#define FLT_MANT_DIG 24 +#define FLT_MAX_10_EXP +38 +#define FLT_MAX_EXP +128 +#define FLT_MIN_10_EXP -37 +#define FLT_MIN_EXP -125 +#define FLT_RADIX 2 +#define FLT_MAX MAXFLOAT +#define FLT_MIN 0x1.0p-126f +#define FLT_EPSILON 0x1.0p-23f +#define FLT_NAN __builtin_nanf("") + +#define FP_ILOGB0 (-2147483647 - 1) +#define FP_ILOGBNAN 2147483647 + +#define M_E_F 0x1.5bf0a8p+1f +#define M_LOG2E_F 0x1.715476p+0f +#define M_LOG10E_F 0x1.bcb7b2p-2f +#define M_LN2_F 0x1.62e430p-1f +#define M_LN10_F 0x1.26bb1cp+1f +#define M_PI_F 0x1.921fb6p+1f +#define M_PI_2_F 0x1.921fb6p+0f +#define M_PI_4_F 0x1.921fb6p-1f +#define M_1_PI_F 0x1.45f306p-2f +#define M_2_PI_F 0x1.45f306p-1f +#define M_2_SQRTPI_F 0x1.20dd76p+0f +#define M_SQRT2_F 0x1.6a09e6p+0f +#define M_SQRT1_2_F 0x1.6a09e6p-1f + +#define M_LOG210_F 0x1.a934f0p+1f + +#ifdef cl_khr_fp64 + +#define HUGE_VAL __builtin_huge_val() + +#define DBL_DIG 15 +#define DBL_MANT_DIG 53 +#define DBL_MAX_10_EXP +308 +#define DBL_MAX_EXP +1024 +#define DBL_MIN_10_EXP -307 +#define DBL_MIN_EXP -1021 +#define DBL_MAX 0x1.fffffffffffffp1023 +#define DBL_MIN 0x1.0p-1022 +#define DBL_EPSILON 0x1.0p-52 +#define DBL_NAN __builtin_nan("") + +#define M_E 0x1.5bf0a8b145769p+1 +#define M_LOG2E 0x1.71547652b82fep+0 +#define M_LOG10E 0x1.bcb7b1526e50ep-2 +#define M_LN2 0x1.62e42fefa39efp-1 +#define M_LN10 0x1.26bb1bbb55516p+1 +#define M_PI 0x1.921fb54442d18p+1 +#define M_PI_2 0x1.921fb54442d18p+0 +#define M_PI_4 0x1.921fb54442d18p-1 +#define M_1_PI 0x1.45f306dc9c883p-2 +#define M_2_PI 0x1.45f306dc9c883p-1 +#define M_2_SQRTPI 0x1.20dd750429b6dp+0 +#define M_SQRT2 0x1.6a09e667f3bcdp+0 +#define M_SQRT1_2 0x1.6a09e667f3bcdp-1 + +#ifdef __CLC_INTERNAL +#define M_LOG210 0x1.a934f0979a371p+1 +#endif + +#endif + +#ifdef cl_khr_fp16 + +#define HALF_DIG 3 +#define HALF_MANT_DIG 11 +#define HALF_MAX_10_EXP +4 +#define HALF_MAX_EXP +16 +#define HALF_MIN_10_EXP -4 +#define HALF_MIN_EXP -13 + +#define HALF_RADIX 2 +#define HALF_MAX 0x1.ffcp15h +#define HALF_MIN 0x1.0p-14h +#define HALF_EPSILON 0x1.0p-10h +#define HALF_NAN __builtin_nanf16("") + +#define M_LOG2E_H 0x1.714p+0h + +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/geometric/binary_decl.inc b/local/recipes/dev/libclc/source/clc/include/clc/geometric/binary_decl.inc new file mode 100644 index 0000000000..342d97a802 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/geometric/binary_decl.inc @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// Geometric functions are only defined for scalar, vec2, vec3 and vec4 +#if (__CLC_VECSIZE_OR_1 == 1 || __CLC_VECSIZE_OR_1 == 2 || \ + __CLC_VECSIZE_OR_1 == 3 || __CLC_VECSIZE_OR_1 == 4) + +_CLC_OVERLOAD _CLC_DECL __CLC_SCALAR_GENTYPE FUNCTION(__CLC_GENTYPE a, + __CLC_GENTYPE b); + +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/geometric/binary_def.inc b/local/recipes/dev/libclc/source/clc/include/clc/geometric/binary_def.inc new file mode 100644 index 0000000000..ad4fa4c016 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/geometric/binary_def.inc @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +// Geometric functions are only defined for scalar, vec2, vec3 and vec4 +#if (__CLC_VECSIZE_OR_1 == 1 || __CLC_VECSIZE_OR_1 == 2 || \ + __CLC_VECSIZE_OR_1 == 3 || __CLC_VECSIZE_OR_1 == 4) + +_CLC_OVERLOAD _CLC_DEF __CLC_SCALAR_GENTYPE FUNCTION(__CLC_GENTYPE a, + __CLC_GENTYPE b) { + return __IMPL_FUNCTION(FUNCTION)(a, b); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_cross.h b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_cross.h new file mode 100644 index 0000000000..e5aa913abf --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_cross.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_GEOMETRIC_CLC_CROSS_H__ +#define __CLC_GEOMETRIC_CLC_CROSS_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL float3 __clc_cross(float3 p0, float3 p1); +_CLC_OVERLOAD _CLC_DECL float4 __clc_cross(float4 p0, float4 p1); + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DECL double3 __clc_cross(double3 p0, double3 p1); +_CLC_OVERLOAD _CLC_DECL double4 __clc_cross(double4 p0, double4 p1); + +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DECL half3 __clc_cross(half3 p0, half3 p1); +_CLC_OVERLOAD _CLC_DECL half4 __clc_cross(half4 p0, half4 p1); + +#endif + +#endif // __CLC_GEOMETRIC_CLC_CROSS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_distance.h b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_distance.h new file mode 100644 index 0000000000..666e2c881b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_distance.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_GEOMETRIC_CLC_DISTANCE_H__ +#define __CLC_GEOMETRIC_CLC_DISTANCE_H__ + +#define FUNCTION __clc_distance +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_GEOMETRIC_CLC_DISTANCE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_dot.h b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_dot.h new file mode 100644 index 0000000000..4bfed6e3ab --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_dot.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_GEOMETRIC_CLC_DOT_H__ +#define __CLC_GEOMETRIC_CLC_DOT_H__ + +#define FUNCTION __clc_dot +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_GEOMETRIC_CLC_DOT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_fast_distance.h b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_fast_distance.h new file mode 100644 index 0000000000..2932d0147a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_fast_distance.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_GEOMETRIC_CLC_FAST_DISTANCE_H__ +#define __CLC_GEOMETRIC_CLC_FAST_DISTANCE_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_fast_distance +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_GEOMETRIC_CLC_FAST_DISTANCE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_fast_length.h b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_fast_length.h new file mode 100644 index 0000000000..903ecc8b91 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_fast_length.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_GEOMETRIC_CLC_FAST_LENGTH_H__ +#define __CLC_GEOMETRIC_CLC_FAST_LENGTH_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_fast_length +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_GEOMETRIC_CLC_FAST_LENGTH_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_fast_normalize.h b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_fast_normalize.h new file mode 100644 index 0000000000..a91862fe61 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_fast_normalize.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_GEOMETRIC_CLC_FAST_NORMALIZE_H__ +#define __CLC_GEOMETRIC_CLC_FAST_NORMALIZE_H__ + +#define __FLOAT_ONLY +#define __CLC_GEOMETRIC_RET_GENTYPE +#define FUNCTION __clc_fast_normalize +#define __CLC_BODY +#include + +#undef FUNCTION +#undef __CLC_GEOMETRIC_RET_GENTYPE + +#endif // __CLC_GEOMETRIC_CLC_FAST_NORMALIZE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_length.h b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_length.h new file mode 100644 index 0000000000..35b206e6c3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_length.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_GEOMETRIC_CLC_LENGTH_H__ +#define __CLC_GEOMETRIC_CLC_LENGTH_H__ + +#define FUNCTION __clc_length +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_GEOMETRIC_CLC_LENGTH_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_normalize.h b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_normalize.h new file mode 100644 index 0000000000..745ed7f488 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/geometric/clc_normalize.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_GEOMETRIC_CLC_NORMALIZE_H__ +#define __CLC_GEOMETRIC_CLC_NORMALIZE_H__ + +#define __CLC_GEOMETRIC_RET_GENTYPE +#define FUNCTION __clc_normalize +#define __CLC_BODY +#include + +#undef FUNCTION +#undef __CLC_GEOMETRIC_RET_GENTYPE + +#endif // __CLC_GEOMETRIC_CLC_NORMALIZE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/geometric/unary_decl.inc b/local/recipes/dev/libclc/source/clc/include/clc/geometric/unary_decl.inc new file mode 100644 index 0000000000..cff66000fc --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/geometric/unary_decl.inc @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// Geometric functions are only defined for scalar, vec2, vec3 and vec4 +#if (__CLC_VECSIZE_OR_1 == 1 || __CLC_VECSIZE_OR_1 == 2 || \ + __CLC_VECSIZE_OR_1 == 3 || __CLC_VECSIZE_OR_1 == 4) + +_CLC_OVERLOAD _CLC_DECL +#ifdef __CLC_GEOMETRIC_RET_GENTYPE + __CLC_GENTYPE +#else + __CLC_SCALAR_GENTYPE +#endif + FUNCTION(__CLC_GENTYPE a); + +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/geometric/unary_def.inc b/local/recipes/dev/libclc/source/clc/include/clc/geometric/unary_def.inc new file mode 100644 index 0000000000..ea90de0ec5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/geometric/unary_def.inc @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +// Geometric functions are only defined for scalar, vec2, vec3 and vec4 +#if (__CLC_VECSIZE_OR_1 == 1 || __CLC_VECSIZE_OR_1 == 2 || \ + __CLC_VECSIZE_OR_1 == 3 || __CLC_VECSIZE_OR_1 == 4) + +_CLC_OVERLOAD _CLC_DEF +#ifdef __CLC_GEOMETRIC_RET_GENTYPE + __CLC_GENTYPE +#else + __CLC_SCALAR_GENTYPE +#endif + FUNCTION(__CLC_GENTYPE a) { + return __IMPL_FUNCTION(FUNCTION)(a); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs.h new file mode 100644 index 0000000000..a3474dbe7d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs.h @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_ABS_H__ +#define __CLC_INTEGER_CLC_ABS_H__ + +#define __CLC_BODY +#include + +#endif // __CLC_INTEGER_CLC_ABS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs.inc b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs.inc new file mode 100644 index 0000000000..f1e2c5a514 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs.inc @@ -0,0 +1,9 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_U_GENTYPE __clc_abs(__CLC_GENTYPE x); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs_diff.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs_diff.h new file mode 100644 index 0000000000..1bad6dc0f4 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs_diff.h @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_ABS_DIFF_H__ +#define __CLC_INTEGER_CLC_ABS_DIFF_H__ + +#define __CLC_BODY +#include + +#endif // __CLC_INTEGER_CLC_ABS_DIFF_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs_diff.inc b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs_diff.inc new file mode 100644 index 0000000000..2514a37b78 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_abs_diff.inc @@ -0,0 +1,10 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_U_GENTYPE __clc_abs_diff(__CLC_GENTYPE x, + __CLC_GENTYPE y); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_add_sat.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_add_sat.h new file mode 100644 index 0000000000..be095d3822 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_add_sat.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_ADD_SAT_H__ +#define __CLC_INTEGER_CLC_ADD_SAT_H__ + +#define FUNCTION __clc_add_sat +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_INTEGER_CLC_ADD_SAT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_clz.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_clz.h new file mode 100644 index 0000000000..3e0530bad6 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_clz.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_CLZ_H__ +#define __CLC_INTEGER_CLC_CLZ_H__ + +#define FUNCTION __clc_clz +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_INTEGER_CLC_CLZ_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_ctz.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_ctz.h new file mode 100644 index 0000000000..1495dc5560 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_ctz.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_CTZ_H__ +#define __CLC_INTEGER_CLC_CTZ_H__ + +#define FUNCTION __clc_ctz +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_INTEGER_CLC_CTZ_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_hadd.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_hadd.h new file mode 100644 index 0000000000..7aaee9b601 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_hadd.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_HADD_H__ +#define __CLC_INTEGER_CLC_HADD_H__ + +#define FUNCTION __clc_hadd +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_INTEGER_CLC_HADD_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mad24.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mad24.h new file mode 100644 index 0000000000..121840f81d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mad24.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_MAD24_H__ +#define __CLC_INTEGER_CLC_MAD24_H__ + +#define FUNCTION __clc_mad24 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_INTEGER_CLC_MAD24_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mad_hi.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mad_hi.h new file mode 100644 index 0000000000..07e8c0bb6b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mad_hi.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_MAD_HI_H__ +#define __CLC_INTEGER_CLC_MAD_HI_H__ + +#include + +#define __clc_mad_hi(a, b, c) (__clc_mul_hi((a), (b)) + (c)) + +#endif // __CLC_INTEGER_CLC_MAD_HI_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mad_sat.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mad_sat.h new file mode 100644 index 0000000000..0c418068ca --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mad_sat.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_MAD_SAT_H__ +#define __CLC_INTEGER_CLC_MAD_SAT_H__ + +#define FUNCTION __clc_mad_sat +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_INTEGER_CLC_MAD_SAT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mul24.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mul24.h new file mode 100644 index 0000000000..9310458d59 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mul24.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_MUL24_H__ +#define __CLC_INTEGER_CLC_MUL24_H__ + +#define FUNCTION __clc_mul24 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_INTEGER_CLC_MUL24_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mul_hi.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mul_hi.h new file mode 100644 index 0000000000..6542f237d0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_mul_hi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_MUL_HI_H__ +#define __CLC_INTEGER_CLC_MUL_HI_H__ + +#define FUNCTION __clc_mul_hi +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_INTEGER_CLC_MUL_HI_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_popcount.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_popcount.h new file mode 100644 index 0000000000..8ece2e9988 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_popcount.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_POPCOUNT_H__ +#define __CLC_INTEGER_CLC_POPCOUNT_H__ + +#define FUNCTION __clc_popcount +#define __CLC_BODY + +#include + +#undef __CLC_INTRINSIC +#undef FUNCTION + +#endif // __CLC_INTEGER_CLC_POPCOUNT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_rhadd.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_rhadd.h new file mode 100644 index 0000000000..882f950656 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_rhadd.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_RHADD_H__ +#define __CLC_INTEGER_CLC_RHADD_H__ + +#define FUNCTION __clc_rhadd +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_INTEGER_CLC_RHADD_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_rotate.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_rotate.h new file mode 100644 index 0000000000..61cf08788e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_rotate.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_ROTATE_H__ +#define __CLC_INTEGER_CLC_ROTATE_H__ + +#define FUNCTION __clc_rotate +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_INTEGER_CLC_ROTATE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_sub_sat.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_sub_sat.h new file mode 100644 index 0000000000..1b694a4a17 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_sub_sat.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_SUB_SAT_H__ +#define __CLC_INTEGER_CLC_SUB_SAT_H__ + +#define FUNCTION __clc_sub_sat +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_INTEGER_CLC_SUB_SAT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_upsample.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_upsample.h new file mode 100644 index 0000000000..51728dfd6e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/clc_upsample.h @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_CLC_UPSAMPLE_H__ +#define __CLC_INTEGER_CLC_UPSAMPLE_H__ + +#include +#include + +#define __CLC_UPSAMPLE_DECL(BGENTYPE, GENTYPE, UGENTYPE) \ + _CLC_OVERLOAD _CLC_DECL BGENTYPE __clc_upsample(GENTYPE hi, UGENTYPE lo); + +#define __CLC_UPSAMPLE_VEC(BGENTYPE, GENTYPE, UGENTYPE) \ + __CLC_UPSAMPLE_DECL(BGENTYPE, GENTYPE, UGENTYPE) \ + __CLC_UPSAMPLE_DECL(BGENTYPE##2, GENTYPE##2, UGENTYPE##2) \ + __CLC_UPSAMPLE_DECL(BGENTYPE##3, GENTYPE##3, UGENTYPE##3) \ + __CLC_UPSAMPLE_DECL(BGENTYPE##4, GENTYPE##4, UGENTYPE##4) \ + __CLC_UPSAMPLE_DECL(BGENTYPE##8, GENTYPE##8, UGENTYPE##8) \ + __CLC_UPSAMPLE_DECL(BGENTYPE##16, GENTYPE##16, UGENTYPE##16) + +#define __CLC_UPSAMPLE_TYPES() \ + __CLC_UPSAMPLE_VEC(short, char, uchar) \ + __CLC_UPSAMPLE_VEC(ushort, uchar, uchar) \ + __CLC_UPSAMPLE_VEC(int, short, ushort) \ + __CLC_UPSAMPLE_VEC(uint, ushort, ushort) \ + __CLC_UPSAMPLE_VEC(long, int, uint) \ + __CLC_UPSAMPLE_VEC(ulong, uint, uint) + +__CLC_UPSAMPLE_TYPES() + +#undef __CLC_UPSAMPLE_TYPES +#undef __CLC_UPSAMPLE_DECL +#undef __CLC_UPSAMPLE_VEC + +#endif // __CLC_INTEGER_CLC_UPSAMPLE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/definitions.h b/local/recipes/dev/libclc/source/clc/include/clc/integer/definitions.h new file mode 100644 index 0000000000..ae2b52d21e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/definitions.h @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTEGER_DEFINITIONS_H__ +#define __CLC_INTEGER_DEFINITIONS_H__ + +#define CHAR_BIT 8 +#define INT_MAX 2147483647 +#define INT_MIN (-2147483647 - 1) +#define LONG_MAX 0x7fffffffffffffffL +#define LONG_MIN (-0x7fffffffffffffffL - 1) +#define CHAR_MAX SCHAR_MAX +#define CHAR_MIN SCHAR_MIN +#define SCHAR_MAX 127 +#define SCHAR_MIN (-127 - 1) +#define SHRT_MAX 32767 +#define SHRT_MIN (-32767 - 1) +#define UCHAR_MAX 255 +#define UCHAR_MIN 0 +#define USHRT_MAX 65535 +#define USHRT_MIN 0 +#define UINT_MAX 0xffffffff +#define UINT_MIN 0 +#define ULONG_MAX 0xffffffffffffffffUL +#define ULONG_MIN 0UL + +#endif // __CLC_INTEGER_DEFINITIONS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/gentype.inc b/local/recipes/dev/libclc/source/clc/include/clc/integer/gentype.inc new file mode 100644 index 0000000000..b2b603e272 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/gentype.inc @@ -0,0 +1,602 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __CLC_AS_GENTYPE __CLC_XCONCAT(__clc_as_, __CLC_GENTYPE) +#define __CLC_CONVERT_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_GENTYPE) + +#define __CLC_AS_U_GENTYPE __CLC_XCONCAT(__clc_as_, __CLC_U_GENTYPE) +#define __CLC_CONVERT_U_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_U_GENTYPE) + +#define __CLC_AS_S_GENTYPE __CLC_XCONCAT(__clc_as_, __CLC_S_GENTYPE) +#define __CLC_CONVERT_S_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_S_GENTYPE) + +// These 2 defines only change when switching between data sizes or base types +// to keep this file manageable. +#define __CLC_GENSIZE 8 +#define __CLC_SCALAR_GENTYPE char + +#define __CLC_GENTYPE char +#define __CLC_U_GENTYPE uchar +#define __CLC_S_GENTYPE char +#define __CLC_SCALAR +#define __CLC_VECSIZE +#define __CLC_VECSIZE_OR_1 1 +#include __CLC_BODY +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_VECSIZE +#undef __CLC_SCALAR +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_VECSIZE_OR_1 __CLC_VECSIZE + +#define __CLC_GENTYPE char2 +#define __CLC_U_GENTYPE uchar2 +#define __CLC_S_GENTYPE char2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE char3 +#define __CLC_U_GENTYPE uchar3 +#define __CLC_S_GENTYPE char3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE char4 +#define __CLC_U_GENTYPE uchar4 +#define __CLC_S_GENTYPE char4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE char8 +#define __CLC_U_GENTYPE uchar8 +#define __CLC_S_GENTYPE char8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE char16 +#define __CLC_U_GENTYPE uchar16 +#define __CLC_S_GENTYPE char16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE +#undef __CLC_VECSIZE_OR_1 + +#undef __CLC_SCALAR_GENTYPE +#define __CLC_SCALAR_GENTYPE uchar + +#define __CLC_GENTYPE uchar +#define __CLC_U_GENTYPE uchar +#define __CLC_S_GENTYPE char +#define __CLC_SCALAR +#define __CLC_VECSIZE +#define __CLC_VECSIZE_OR_1 1 +#include __CLC_BODY +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_VECSIZE +#undef __CLC_SCALAR +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_VECSIZE_OR_1 __CLC_VECSIZE + +#define __CLC_GENTYPE uchar2 +#define __CLC_U_GENTYPE uchar2 +#define __CLC_S_GENTYPE char2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uchar3 +#define __CLC_U_GENTYPE uchar3 +#define __CLC_S_GENTYPE char3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uchar4 +#define __CLC_U_GENTYPE uchar4 +#define __CLC_S_GENTYPE char4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uchar8 +#define __CLC_U_GENTYPE uchar8 +#define __CLC_S_GENTYPE char8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uchar16 +#define __CLC_U_GENTYPE uchar16 +#define __CLC_S_GENTYPE char16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE +#undef __CLC_VECSIZE_OR_1 + +#undef __CLC_GENSIZE +#define __CLC_GENSIZE 16 +#undef __CLC_SCALAR_GENTYPE +#define __CLC_SCALAR_GENTYPE short + +#define __CLC_GENTYPE short +#define __CLC_U_GENTYPE ushort +#define __CLC_S_GENTYPE short +#define __CLC_SCALAR +#define __CLC_VECSIZE +#define __CLC_VECSIZE_OR_1 1 +#include __CLC_BODY +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_VECSIZE +#undef __CLC_SCALAR +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_VECSIZE_OR_1 __CLC_VECSIZE + +#define __CLC_GENTYPE short2 +#define __CLC_U_GENTYPE ushort2 +#define __CLC_S_GENTYPE short2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE short3 +#define __CLC_U_GENTYPE ushort3 +#define __CLC_S_GENTYPE short3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE short4 +#define __CLC_U_GENTYPE ushort4 +#define __CLC_S_GENTYPE short4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE short8 +#define __CLC_U_GENTYPE ushort8 +#define __CLC_S_GENTYPE short8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE short16 +#define __CLC_U_GENTYPE ushort16 +#define __CLC_S_GENTYPE short16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE +#undef __CLC_VECSIZE_OR_1 + +#undef __CLC_SCALAR_GENTYPE +#define __CLC_SCALAR_GENTYPE ushort + +#define __CLC_GENTYPE ushort +#define __CLC_U_GENTYPE ushort +#define __CLC_S_GENTYPE short +#define __CLC_SCALAR +#define __CLC_VECSIZE +#define __CLC_VECSIZE_OR_1 1 +#include __CLC_BODY +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_VECSIZE +#undef __CLC_SCALAR +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_VECSIZE_OR_1 __CLC_VECSIZE + +#define __CLC_GENTYPE ushort2 +#define __CLC_U_GENTYPE ushort2 +#define __CLC_S_GENTYPE short2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE ushort3 +#define __CLC_U_GENTYPE ushort3 +#define __CLC_S_GENTYPE short3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE ushort4 +#define __CLC_U_GENTYPE ushort4 +#define __CLC_S_GENTYPE short4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE ushort8 +#define __CLC_U_GENTYPE ushort8 +#define __CLC_S_GENTYPE short8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE ushort16 +#define __CLC_U_GENTYPE ushort16 +#define __CLC_S_GENTYPE short16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE +#undef __CLC_VECSIZE_OR_1 + +#undef __CLC_GENSIZE +#define __CLC_GENSIZE 32 +#undef __CLC_SCALAR_GENTYPE +#define __CLC_SCALAR_GENTYPE int + +#define __CLC_GENTYPE int +#define __CLC_U_GENTYPE uint +#define __CLC_S_GENTYPE int +#define __CLC_SCALAR +#define __CLC_VECSIZE +#define __CLC_VECSIZE_OR_1 1 +#include __CLC_BODY +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_VECSIZE +#undef __CLC_SCALAR +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_VECSIZE_OR_1 __CLC_VECSIZE + +#define __CLC_GENTYPE int2 +#define __CLC_U_GENTYPE uint2 +#define __CLC_S_GENTYPE int2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE int3 +#define __CLC_U_GENTYPE uint3 +#define __CLC_S_GENTYPE int3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE int4 +#define __CLC_U_GENTYPE uint4 +#define __CLC_S_GENTYPE int4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE int8 +#define __CLC_U_GENTYPE uint8 +#define __CLC_S_GENTYPE int8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE int16 +#define __CLC_U_GENTYPE uint16 +#define __CLC_S_GENTYPE int16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE +#undef __CLC_VECSIZE_OR_1 + +#undef __CLC_SCALAR_GENTYPE +#define __CLC_SCALAR_GENTYPE uint + +#define __CLC_GENTYPE uint +#define __CLC_U_GENTYPE uint +#define __CLC_S_GENTYPE int +#define __CLC_SCALAR +#define __CLC_VECSIZE +#define __CLC_VECSIZE_OR_1 1 +#include __CLC_BODY +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_VECSIZE +#undef __CLC_SCALAR +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_VECSIZE_OR_1 __CLC_VECSIZE + +#define __CLC_GENTYPE uint2 +#define __CLC_U_GENTYPE uint2 +#define __CLC_S_GENTYPE int2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uint3 +#define __CLC_U_GENTYPE uint3 +#define __CLC_S_GENTYPE int3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uint4 +#define __CLC_U_GENTYPE uint4 +#define __CLC_S_GENTYPE int4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uint8 +#define __CLC_U_GENTYPE uint8 +#define __CLC_S_GENTYPE int8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uint16 +#define __CLC_U_GENTYPE uint16 +#define __CLC_S_GENTYPE int16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE +#undef __CLC_VECSIZE_OR_1 + +#undef __CLC_GENSIZE +#define __CLC_GENSIZE 64 +#undef __CLC_SCALAR_GENTYPE +#define __CLC_SCALAR_GENTYPE long + +#define __CLC_GENTYPE long +#define __CLC_U_GENTYPE ulong +#define __CLC_S_GENTYPE long +#define __CLC_SCALAR +#define __CLC_VECSIZE +#define __CLC_VECSIZE_OR_1 1 +#include __CLC_BODY +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_VECSIZE +#undef __CLC_SCALAR +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_VECSIZE_OR_1 __CLC_VECSIZE + +#define __CLC_GENTYPE long2 +#define __CLC_U_GENTYPE ulong2 +#define __CLC_S_GENTYPE long2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE long3 +#define __CLC_U_GENTYPE ulong3 +#define __CLC_S_GENTYPE long3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE long4 +#define __CLC_U_GENTYPE ulong4 +#define __CLC_S_GENTYPE long4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE long8 +#define __CLC_U_GENTYPE ulong8 +#define __CLC_S_GENTYPE long8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE long16 +#define __CLC_U_GENTYPE ulong16 +#define __CLC_S_GENTYPE long16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE +#undef __CLC_VECSIZE_OR_1 + +#undef __CLC_SCALAR_GENTYPE +#define __CLC_SCALAR_GENTYPE ulong + +#define __CLC_GENTYPE ulong +#define __CLC_U_GENTYPE ulong +#define __CLC_S_GENTYPE long +#define __CLC_SCALAR +#define __CLC_VECSIZE +#define __CLC_VECSIZE_OR_1 1 +#include __CLC_BODY +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_VECSIZE +#undef __CLC_SCALAR +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_VECSIZE_OR_1 __CLC_VECSIZE + +#define __CLC_GENTYPE ulong2 +#define __CLC_U_GENTYPE ulong2 +#define __CLC_S_GENTYPE long2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE ulong3 +#define __CLC_U_GENTYPE ulong3 +#define __CLC_S_GENTYPE long3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE ulong4 +#define __CLC_U_GENTYPE ulong4 +#define __CLC_S_GENTYPE long4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE ulong8 +#define __CLC_U_GENTYPE ulong8 +#define __CLC_S_GENTYPE long8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE ulong16 +#define __CLC_U_GENTYPE ulong16 +#define __CLC_S_GENTYPE long16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE +#undef __CLC_VECSIZE_OR_1 + +#undef __CLC_GENSIZE +#undef __CLC_SCALAR_GENTYPE +#undef __CLC_BODY + +#undef __CLC_CONVERT_S_GENTYPE +#undef __CLC_AS_S_GENTYPE + +#undef __CLC_CONVERT_U_GENTYPE +#undef __CLC_AS_U_GENTYPE + +#undef __CLC_CONVERT_GENTYPE +#undef __CLC_AS_GENTYPE diff --git a/local/recipes/dev/libclc/source/clc/include/clc/integer/gentype24.inc b/local/recipes/dev/libclc/source/clc/include/clc/integer/gentype24.inc new file mode 100644 index 0000000000..b787f25a3d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/integer/gentype24.inc @@ -0,0 +1,145 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_GENSIZE 32 +#undef __CLC_SCALAR_GENTYPE +#define __CLC_SCALAR_GENTYPE int + +#define __CLC_GENTYPE int +#define __CLC_U_GENTYPE uint +#define __CLC_S_GENTYPE int +#define __CLC_SCALAR 1 +#define __CLC_VECSIZE +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_SCALAR +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE int2 +#define __CLC_U_GENTYPE uint2 +#define __CLC_S_GENTYPE int2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE int3 +#define __CLC_U_GENTYPE uint3 +#define __CLC_S_GENTYPE int3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE int4 +#define __CLC_U_GENTYPE uint4 +#define __CLC_S_GENTYPE int4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE int8 +#define __CLC_U_GENTYPE uint8 +#define __CLC_S_GENTYPE int8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE int16 +#define __CLC_U_GENTYPE uint16 +#define __CLC_S_GENTYPE int16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#undef __CLC_SCALAR_GENTYPE +#define __CLC_SCALAR_GENTYPE uint + +#define __CLC_GENTYPE uint +#define __CLC_U_GENTYPE uint +#define __CLC_S_GENTYPE int +#define __CLC_SCALAR 1 +#define __CLC_VECSIZE +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_SCALAR +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uint2 +#define __CLC_U_GENTYPE uint2 +#define __CLC_S_GENTYPE int2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uint3 +#define __CLC_U_GENTYPE uint3 +#define __CLC_S_GENTYPE int3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uint4 +#define __CLC_U_GENTYPE uint4 +#define __CLC_S_GENTYPE int4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uint8 +#define __CLC_U_GENTYPE uint8 +#define __CLC_S_GENTYPE int8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#define __CLC_GENTYPE uint16 +#define __CLC_U_GENTYPE uint16 +#define __CLC_S_GENTYPE int16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE + +#undef __CLC_GENSIZE +#undef __CLC_SCALAR_GENTYPE +#undef __CLC_BODY diff --git a/local/recipes/dev/libclc/source/clc/include/clc/internal/clc.h b/local/recipes/dev/libclc/source/clc/include/clc/internal/clc.h new file mode 100644 index 0000000000..d9fb481280 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/internal/clc.h @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTERNAL_CLC_H_ +#define __CLC_INTERNAL_CLC_H_ + +#ifndef cl_clang_storage_class_specifiers +#error Implementation requires cl_clang_storage_class_specifiers extension! +#endif + +#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#endif + +/* Function Attributes */ +#include + +/* 6.1 Supported Data Types */ +#include + +/* 6.2.4.2 Reinterpreting Types Using __clc_as_type() and __clc_as_typen() */ +#include + +#pragma OPENCL EXTENSION all : disable + +#endif // __CLC_INTERNAL_CLC_H_ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/internal/math/clc_sw_fma.h b/local/recipes/dev/libclc/source/clc/include/clc/internal/math/clc_sw_fma.h new file mode 100644 index 0000000000..8497f4efd1 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/internal/math/clc_sw_fma.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_INTERNAL_MATH_CLC_SW_FMA_H__ +#define __CLC_INTERNAL_MATH_CLC_SW_FMA_H__ + +#define FUNCTION __clc_sw_fma +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_INTERNAL_MATH_CLC_SW_FMA_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/binary_decl_with_scalar_second_arg.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/binary_decl_with_scalar_second_arg.inc new file mode 100644 index 0000000000..1b2b9ff335 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/binary_decl_with_scalar_second_arg.inc @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE a, + __CLC_GENTYPE b); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE a, + __CLC_SCALAR_GENTYPE b); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/binary_def_via_fp32.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/binary_def_via_fp32.inc new file mode 100644 index 0000000000..b53a178bf0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/binary_def_via_fp32.inc @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return __CLC_CONVERT_GENTYPE( + FUNCTION(__CLC_CONVERT_FLOATN(x), __CLC_CONVERT_FLOATN(y))); +} diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_acos.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_acos.h new file mode 100644 index 0000000000..130e3111ec --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_acos.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ACOS_H__ +#define __CLC_MATH_CLC_ACOS_H__ + +#define __CLC_BODY +#define FUNCTION __clc_acos + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ACOS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_acosh.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_acosh.h new file mode 100644 index 0000000000..9b8c7184b9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_acosh.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ACOSH_H__ +#define __CLC_MATH_CLC_ACOSH_H__ + +#define __CLC_BODY +#define FUNCTION __clc_acosh + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ACOSH_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_acospi.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_acospi.h new file mode 100644 index 0000000000..6d4dc69490 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_acospi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ACOSPI_H__ +#define __CLC_MATH_CLC_ACOSPI_H__ + +#define __CLC_BODY +#define FUNCTION __clc_acospi + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ACOSPI_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_asin.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_asin.h new file mode 100644 index 0000000000..f3d69a7bf9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_asin.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ASIN_H__ +#define __CLC_MATH_CLC_ASIN_H__ + +#define __CLC_BODY +#define FUNCTION __clc_asin + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ASIN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_asinh.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_asinh.h new file mode 100644 index 0000000000..dc4530fa68 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_asinh.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ASINH_H__ +#define __CLC_MATH_CLC_ASINH_H__ + +#define __CLC_BODY +#define FUNCTION __clc_asinh + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ASINH_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_asinpi.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_asinpi.h new file mode 100644 index 0000000000..19d8ec3ad0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_asinpi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ASINPI_H__ +#define __CLC_MATH_CLC_ASINPI_H__ + +#define __CLC_BODY +#define FUNCTION __clc_asinpi + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ASINPI_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atan.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atan.h new file mode 100644 index 0000000000..9f10efeae9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atan.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ATAN_H__ +#define __CLC_MATH_CLC_ATAN_H__ + +#define __CLC_BODY +#define FUNCTION __clc_atan + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ATAN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atan2.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atan2.h new file mode 100644 index 0000000000..99bd0760f3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atan2.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ATAN2_H__ +#define __CLC_MATH_CLC_ATAN2_H__ + +#define __CLC_BODY +#define FUNCTION __clc_atan2 + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ATAN2_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atan2pi.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atan2pi.h new file mode 100644 index 0000000000..ae044b7bbf --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atan2pi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ATAN2PI_H__ +#define __CLC_MATH_CLC_ATAN2PI_H__ + +#define __CLC_BODY +#define FUNCTION __clc_atan2pi + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ATAN2PI_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atanh.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atanh.h new file mode 100644 index 0000000000..c1a95d4acb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atanh.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ATANH_H__ +#define __CLC_MATH_CLC_ATANH_H__ + +#define __CLC_BODY +#define FUNCTION __clc_atanh + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ATANH_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atanpi.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atanpi.h new file mode 100644 index 0000000000..43f752ecfe --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_atanpi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ATANPI_H__ +#define __CLC_MATH_CLC_ATANPI_H__ + +#define __CLC_BODY +#define FUNCTION __clc_atanpi + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ATANPI_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_cbrt.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_cbrt.inc new file mode 100644 index 0000000000..019b5174a9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_cbrt.inc @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_CBRT_H__ +#define __CLC_MATH_CLC_CBRT_H__ + +#define __CLC_BODY +#define FUNCTION __clc_cbrt + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_CBRT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ceil.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ceil.h new file mode 100644 index 0000000000..c60b794c83 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ceil.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_CEIL_H__ +#define __CLC_MATH_CLC_CEIL_H__ + +#define __CLC_BODY +#define FUNCTION __clc_ceil + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_CEIL_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_copysign.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_copysign.h new file mode 100644 index 0000000000..5976e42de2 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_copysign.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_COPYSIGN_H__ +#define __CLC_MATH_CLC_COPYSIGN_H__ + +#define __CLC_BODY +#define FUNCTION __clc_copysign + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_COPYSIGN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_cos.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_cos.h new file mode 100644 index 0000000000..3a1ae9342e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_cos.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_COS_H__ +#define __CLC_MATH_CLC_COS_H__ + +#define __CLC_BODY +#define FUNCTION __clc_cos + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_COS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_cosh.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_cosh.h new file mode 100644 index 0000000000..3033d76000 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_cosh.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_COSH_H__ +#define __CLC_MATH_CLC_COSH_H__ + +#define __CLC_BODY +#define FUNCTION __clc_cosh + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_COSH_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_cospi.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_cospi.h new file mode 100644 index 0000000000..3e4e73f096 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_cospi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_COSPI_H__ +#define __CLC_MATH_CLC_COSPI_H__ + +#define __CLC_BODY +#define FUNCTION __clc_cospi + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_COSPI_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ep_log.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ep_log.h new file mode 100644 index 0000000000..855e2f2b33 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ep_log.h @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_EP_LOG_H__ +#define __CLC_MATH_CLC_EP_LOG_H__ + +#define __CLC_BODY +#include + +#endif // __CLC_MATH_CLC_EP_LOG_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ep_log.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ep_log.inc new file mode 100644 index 0000000000..a255a6a453 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ep_log.inc @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 64 + +_CLC_DECL _CLC_OVERLOAD void __clc_ep_log(__CLC_GENTYPE x, + private __CLC_INTN *xexp, + private __CLC_GENTYPE *r1, + private __CLC_GENTYPE *r2); + +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_erf.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_erf.h new file mode 100644 index 0000000000..04b990c651 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_erf.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ERF_H__ +#define __CLC_MATH_CLC_ERF_H__ + +#define __CLC_BODY +#define FUNCTION __clc_erf + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ERF_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_erfc.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_erfc.h new file mode 100644 index 0000000000..be2578b4bf --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_erfc.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ERFC_H__ +#define __CLC_MATH_CLC_ERFC_H__ + +#define __CLC_BODY +#define FUNCTION __clc_erfc + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ERFC_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp.h new file mode 100644 index 0000000000..3551489344 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_EXP_H__ +#define __CLC_MATH_CLC_EXP_H__ + +#define __CLC_BODY +#define FUNCTION __clc_exp + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_EXP_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp10.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp10.h new file mode 100644 index 0000000000..c281ee84dd --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp10.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_EXP10_H__ +#define __CLC_MATH_CLC_EXP10_H__ + +#define __CLC_BODY +#define FUNCTION __clc_exp10 + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_EXP10_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp2.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp2.h new file mode 100644 index 0000000000..bb10f12d34 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp2.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_EXP2_H__ +#define __CLC_MATH_CLC_EXP2_H__ + +#define __CLC_BODY +#define FUNCTION __clc_exp2 + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_EXP2_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp_helper.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp_helper.h new file mode 100644 index 0000000000..0c5028bd23 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp_helper.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_EXP_HELPER +#define __CLC_MATH_CLC_EXP_HELPER + +#define __DOUBLE_ONLY +#define __CLC_BODY + +#include + +#endif // __CLC_MATH_CLC_EXP_HELPER diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp_helper.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp_helper.inc new file mode 100644 index 0000000000..cdf650405c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_exp_helper.inc @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_DECL _CLC_OVERLOAD __CLC_GENTYPE __clc_exp_helper(__CLC_GENTYPE x, + __CLC_GENTYPE x_min, + __CLC_GENTYPE x_max, + __CLC_GENTYPE r, + __CLC_INTN n); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_expm1.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_expm1.h new file mode 100644 index 0000000000..7a199dca17 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_expm1.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_EXPM1_H__ +#define __CLC_MATH_CLC_EXPM1_H__ + +#define __CLC_BODY +#define FUNCTION __clc_expm1 + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_EXPM1_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fabs.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fabs.h new file mode 100644 index 0000000000..8af3bb5721 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fabs.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_FABS_H__ +#define __CLC_MATH_CLC_FABS_H__ + +#define __CLC_BODY +#define FUNCTION __clc_fabs + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_FABS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fdim.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fdim.h new file mode 100644 index 0000000000..c678eb25f5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fdim.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_FDIM_H__ +#define __CLC_MATH_CLC_FDIM_H__ + +#define __CLC_BODY +#define FUNCTION __clc_fdim + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_FDIM_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_floor.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_floor.h new file mode 100644 index 0000000000..b3fe8ea95c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_floor.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_FLOOR_H__ +#define __CLC_MATH_CLC_FLOOR_H__ + +#define __CLC_BODY +#define FUNCTION __clc_floor + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_FLOOR_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fma.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fma.h new file mode 100644 index 0000000000..efe20bd150 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fma.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_FMA_H__ +#define __CLC_MATH_CLC_FMA_H__ + +#define FUNCTION __clc_fma +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_FMA_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fmax.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fmax.h new file mode 100644 index 0000000000..fd5d38987e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fmax.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_FMAX_H__ +#define __CLC_MATH_CLC_FMAX_H__ + +#define FUNCTION __clc_fmax +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_FMAX_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fmin.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fmin.h new file mode 100644 index 0000000000..9fcdb56475 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fmin.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_FMIN_H__ +#define __CLC_MATH_CLC_FMIN_H__ + +#define FUNCTION __clc_fmin +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_FMIN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fmod.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fmod.h new file mode 100644 index 0000000000..840bb850d7 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fmod.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_FMOD_H__ +#define __CLC_MATH_CLC_FMOD_H__ + +#define FUNCTION __clc_fmod +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_FMOD_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fract.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fract.h new file mode 100644 index 0000000000..26c402c796 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_fract.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_FRACT_H__ +#define __CLC_MATH_CLC_FRACT_H__ + +#define FUNCTION __clc_fract +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_FRACT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_frexp.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_frexp.h new file mode 100644 index 0000000000..e3c9f6b363 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_frexp.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_FREXP_H__ +#define __CLC_MATH_CLC_FREXP_H__ + +#define FUNCTION __clc_frexp +#define __CLC_BODY +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_FREXP_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_cos.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_cos.h new file mode 100644 index 0000000000..0f9f0b6144 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_cos.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_COS_H__ +#define __CLC_MATH_CLC_HALF_COS_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_cos +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_COS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_divide.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_divide.h new file mode 100644 index 0000000000..44d90f39b4 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_divide.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_DIVIDE_H__ +#define __CLC_MATH_CLC_HALF_DIVIDE_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_divide +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_DIVIDE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_exp.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_exp.h new file mode 100644 index 0000000000..158d28c16a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_exp.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_EXP_H__ +#define __CLC_MATH_CLC_HALF_EXP_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_exp +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_EXP_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_exp10.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_exp10.h new file mode 100644 index 0000000000..4982b618e5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_exp10.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_EXP10_H__ +#define __CLC_MATH_CLC_HALF_EXP10_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_exp10 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_EXP10_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_exp2.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_exp2.h new file mode 100644 index 0000000000..dc0f67659b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_exp2.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_EXP2_H__ +#define __CLC_MATH_CLC_HALF_EXP2_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_exp2 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_EXP2_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_log.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_log.h new file mode 100644 index 0000000000..df527e1a8f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_log.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_LOG_H__ +#define __CLC_MATH_CLC_HALF_LOG_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_log +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_LOG_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_log10.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_log10.h new file mode 100644 index 0000000000..47db4cd325 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_log10.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_LOG10_H__ +#define __CLC_MATH_CLC_HALF_LOG10_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_log10 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_LOG10_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_log2.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_log2.h new file mode 100644 index 0000000000..2b95b444b3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_log2.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_LOG2_H__ +#define __CLC_MATH_CLC_HALF_LOG2_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_log2 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_LOG2_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_powr.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_powr.h new file mode 100644 index 0000000000..2fd62213b8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_powr.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_POWR_H__ +#define __CLC_MATH_CLC_HALF_POWR_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_powr +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_POWR_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_recip.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_recip.h new file mode 100644 index 0000000000..d2ace8b7a1 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_recip.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_RECIP_H__ +#define __CLC_MATH_CLC_HALF_RECIP_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_recip +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_RECIP_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_rsqrt.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_rsqrt.h new file mode 100644 index 0000000000..a50dabccda --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_rsqrt.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_RSQRT_H__ +#define __CLC_MATH_CLC_HALF_RSQRT_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_rsqrt +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_RSQRT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_sin.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_sin.h new file mode 100644 index 0000000000..f79f6afc2b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_sin.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_SIN_H__ +#define __CLC_MATH_CLC_HALF_SIN_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_sin +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_SIN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_sqrt.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_sqrt.h new file mode 100644 index 0000000000..df5fc222a5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_sqrt.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_SQRT_H__ +#define __CLC_MATH_CLC_HALF_SQRT_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_sqrt +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_SQRT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_tan.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_tan.h new file mode 100644 index 0000000000..0f6ef87907 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_half_tan.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HALF_TAN_H__ +#define __CLC_MATH_CLC_HALF_TAN_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_tan +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HALF_TAN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_hypot.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_hypot.h new file mode 100644 index 0000000000..b2d69ebda9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_hypot.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_HYPOT_H__ +#define __CLC_MATH_CLC_HYPOT_H__ + +#define __CLC_BODY +#define FUNCTION __clc_hypot + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_HYPOT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ilogb.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ilogb.h new file mode 100644 index 0000000000..e02108ff14 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ilogb.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ILOGB_H__ +#define __CLC_MATH_CLC_ILOGB_H__ + +#define FUNCTION __clc_ilogb +#define __CLC_BODY +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ILOGB_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ldexp.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ldexp.h new file mode 100644 index 0000000000..e90732680e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ldexp.h @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_LDEXP_H__ +#define __CLC_MATH_CLC_LDEXP_H__ + +#define __CLC_BODY +#include + +#endif // __CLC_MATH_CLC_LDEXP_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ldexp.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ldexp.inc new file mode 100644 index 0000000000..9b88359d21 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_ldexp.inc @@ -0,0 +1,9 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_DECL _CLC_OVERLOAD __CLC_GENTYPE __clc_ldexp(__CLC_GENTYPE, __CLC_INTN); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_lgamma.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_lgamma.h new file mode 100644 index 0000000000..69b1ff9701 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_lgamma.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_LGAMMA_H__ +#define __CLC_MATH_CLC_LGAMMA_H__ + +#define __CLC_BODY +#define FUNCTION __clc_lgamma + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_LGAMMA_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_lgamma_r.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_lgamma_r.h new file mode 100644 index 0000000000..a98f760d80 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_lgamma_r.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_LGAMMA_R_H__ +#define __CLC_MATH_CLC_LGAMMA_R_H__ + +#define FUNCTION __clc_lgamma_r +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_LGAMMA_R_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_log.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_log.h new file mode 100644 index 0000000000..6bddb5ff74 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_log.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_LOG_H__ +#define __CLC_MATH_CLC_LOG_H__ + +#define FUNCTION __clc_log +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_LOG_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_log10.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_log10.h new file mode 100644 index 0000000000..e3a5b19eb4 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_log10.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_LOG10_H__ +#define __CLC_MATH_CLC_LOG10_H__ + +#define FUNCTION __clc_log10 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_LOG10_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_log1p.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_log1p.h new file mode 100644 index 0000000000..f502802daf --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_log1p.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_LOG1P_H__ +#define __CLC_MATH_CLC_LOG1P_H__ + +#define __CLC_BODY +#define FUNCTION __clc_log1p + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_LOG1P_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_log2.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_log2.h new file mode 100644 index 0000000000..7344cabaef --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_log2.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_LOG2_H__ +#define __CLC_MATH_CLC_LOG2_H__ + +#define FUNCTION __clc_log2 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_LOG2_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_logb.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_logb.h new file mode 100644 index 0000000000..1339d58191 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_logb.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_LOGB_H__ +#define __CLC_MATH_CLC_LOGB_H__ + +#define FUNCTION __clc_logb +#define __CLC_BODY +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_LOGB_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_mad.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_mad.h new file mode 100644 index 0000000000..72014b7c0e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_mad.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_MAD_H__ +#define __CLC_MATH_CLC_MAD_H__ + +#define __CLC_BODY +#define FUNCTION __clc_mad + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_MAD_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_maxmag.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_maxmag.h new file mode 100644 index 0000000000..058230e6eb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_maxmag.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_MAXMAG_H__ +#define __CLC_MATH_CLC_MAXMAG_H__ + +#define __CLC_BODY +#define FUNCTION __clc_maxmag + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_MAXMAG_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_minmag.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_minmag.h new file mode 100644 index 0000000000..581b957828 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_minmag.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_MINMAG_H__ +#define __CLC_MATH_CLC_MINMAG_H__ + +#define __CLC_BODY +#define FUNCTION __clc_minmag + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_MINMAG_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_modf.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_modf.h new file mode 100644 index 0000000000..fbdd3f8ffd --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_modf.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_MODF_H__ +#define __CLC_MATH_CLC_MODF_H__ + +#define FUNCTION __clc_modf +#define __CLC_BODY +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_MODF_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_nan.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_nan.h new file mode 100644 index 0000000000..45d91184cf --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_nan.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NAN_H__ +#define __CLC_MATH_CLC_NAN_H__ + +#define FUNCTION __clc_nan +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NAN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_nan.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_nan.inc new file mode 100644 index 0000000000..22604e0a57 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_nan.inc @@ -0,0 +1,10 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_nan(__CLC_U_GENTYPE code); +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_nan(__CLC_S_GENTYPE code); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_cos.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_cos.h new file mode 100644 index 0000000000..08d51baca1 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_cos.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_COS_H__ +#define __CLC_MATH_CLC_NATIVE_COS_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_cos +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_COS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_divide.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_divide.h new file mode 100644 index 0000000000..a10ed512f1 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_divide.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_DIVIDE_H__ +#define __CLC_MATH_CLC_NATIVE_DIVIDE_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_divide +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_DIVIDE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_exp.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_exp.h new file mode 100644 index 0000000000..30801fe2f8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_exp.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_EXP_H__ +#define __CLC_MATH_CLC_NATIVE_EXP_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_exp +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_EXP_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_exp10.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_exp10.h new file mode 100644 index 0000000000..91cf60ef6a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_exp10.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_EXP10_H__ +#define __CLC_MATH_CLC_NATIVE_EXP10_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_exp10 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_EXP10_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_exp2.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_exp2.h new file mode 100644 index 0000000000..fe47280536 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_exp2.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_EXP2_H__ +#define __CLC_MATH_CLC_NATIVE_EXP2_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_exp2 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_EXP2_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_log.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_log.h new file mode 100644 index 0000000000..25a7054d2a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_log.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_LOG_H__ +#define __CLC_MATH_CLC_NATIVE_LOG_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_log +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_LOG_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_log10.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_log10.h new file mode 100644 index 0000000000..d46124d655 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_log10.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_LOG10_H__ +#define __CLC_MATH_CLC_NATIVE_LOG10_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_log10 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_LOG10_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_log2.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_log2.h new file mode 100644 index 0000000000..8998553b49 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_log2.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_LOG2_H__ +#define __CLC_MATH_CLC_NATIVE_LOG2_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_log2 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_LOG2_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_powr.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_powr.h new file mode 100644 index 0000000000..932cfa66ae --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_powr.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_POWR_H__ +#define __CLC_MATH_CLC_NATIVE_POWR_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_powr +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_POWR_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_recip.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_recip.h new file mode 100644 index 0000000000..6b94cbc3d6 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_recip.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_RECIP_H__ +#define __CLC_MATH_CLC_NATIVE_RECIP_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_recip +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_RECIP_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_rsqrt.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_rsqrt.h new file mode 100644 index 0000000000..5fa870b3f8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_rsqrt.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_RSQRT_H__ +#define __CLC_MATH_CLC_NATIVE_RSQRT_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_rsqrt +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_RSQRT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_sin.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_sin.h new file mode 100644 index 0000000000..d25968c744 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_sin.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_SIN_H__ +#define __CLC_MATH_CLC_NATIVE_SIN_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_sin +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_SIN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_sqrt.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_sqrt.h new file mode 100644 index 0000000000..e8a28b7f70 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_sqrt.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_SQRT_H__ +#define __CLC_MATH_CLC_NATIVE_SQRT_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_sqrt +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_SQRT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_tan.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_tan.h new file mode 100644 index 0000000000..36fdd6d8c0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_native_tan.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NATIVE_TAN_H__ +#define __CLC_MATH_CLC_NATIVE_TAN_H__ + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_tan +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NATIVE_TAN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_nextafter.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_nextafter.h new file mode 100644 index 0000000000..d080a40a06 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_nextafter.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_NEXTAFTER_H__ +#define __CLC_MATH_CLC_NEXTAFTER_H__ + +#define __CLC_BODY +#define FUNCTION __clc_nextafter + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_NEXTAFTER_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_pow.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_pow.h new file mode 100644 index 0000000000..b33391e10a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_pow.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_POW_H__ +#define __CLC_MATH_CLC_POW_H__ + +#define __CLC_BODY +#define FUNCTION __clc_pow + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_POW_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_pown.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_pown.h new file mode 100644 index 0000000000..473bbe1603 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_pown.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_POWN_H__ +#define __CLC_MATH_CLC_POWN_H__ + +#define __CLC_BODY +#define FUNCTION __clc_pown + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_POWN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_powr.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_powr.h new file mode 100644 index 0000000000..a820516f18 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_powr.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_POWR_H__ +#define __CLC_MATH_CLC_POWR_H__ + +#define __CLC_BODY +#define FUNCTION __clc_powr + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_POWR_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_remainder.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_remainder.h new file mode 100644 index 0000000000..bc53b04304 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_remainder.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_REMAINDER_H__ +#define __CLC_MATH_CLC_REMAINDER_H__ + +#define FUNCTION __clc_remainder +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_REMAINDER_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_remquo.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_remquo.h new file mode 100644 index 0000000000..b46f94ba94 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_remquo.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_REMQUO_H__ +#define __CLC_MATH_CLC_REMQUO_H__ + +#define FUNCTION __clc_remquo +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_REMQUO_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_rint.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_rint.h new file mode 100644 index 0000000000..c446c75764 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_rint.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_RINT_H__ +#define __CLC_MATH_CLC_RINT_H__ + +#define __CLC_BODY +#define FUNCTION __clc_rint + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_RINT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_rootn.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_rootn.h new file mode 100644 index 0000000000..fb7817ee25 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_rootn.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ROOTN_H__ +#define __CLC_MATH_CLC_ROOTN_H__ + +#define __CLC_BODY +#define FUNCTION __clc_rootn + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ROOTN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_round.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_round.h new file mode 100644 index 0000000000..fd1872a5cf --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_round.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_ROUND_H__ +#define __CLC_MATH_CLC_ROUND_H__ + +#define __CLC_BODY +#define FUNCTION __clc_round + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_ROUND_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_rsqrt.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_rsqrt.h new file mode 100644 index 0000000000..1690ede1b8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_rsqrt.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_RSQRT_H__ +#define __CLC_MATH_CLC_RSQRT_H__ + +#define __CLC_BODY +#define FUNCTION __clc_rsqrt + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_RSQRT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sin.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sin.h new file mode 100644 index 0000000000..89ae444eb6 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sin.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_SIN_H__ +#define __CLC_MATH_CLC_SIN_H__ + +#define __CLC_BODY +#define FUNCTION __clc_sin + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_SIN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos.h new file mode 100644 index 0000000000..bf3e0806db --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_SINCOS_H__ +#define __CLC_MATH_CLC_SINCOS_H__ + +#define __CLC_BODY +#define FUNCTION __clc_sincos + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_SINCOS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_helpers.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_helpers.h new file mode 100644 index 0000000000..f9ceba3bf2 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_helpers.h @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_SINCOS_HELPERS_H__ +#define __CLC_MATH_CLC_SINCOS_HELPERS_H__ + +#define __FLOAT_ONLY +#define __CLC_BODY + +#include + +#define __DOUBLE_ONLY +#define __CLC_BODY + +#include + +#endif // __CLC_MATH_CLC_SINCOS_HELPERS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_helpers.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_helpers.inc new file mode 100644 index 0000000000..4daff92955 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_helpers.inc @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_DECL _CLC_OVERLOAD __CLC_FLOATN __clc_sinf_piby4(__CLC_FLOATN x, + __CLC_FLOATN y); +_CLC_DECL _CLC_OVERLOAD __CLC_FLOATN __clc_cosf_piby4(__CLC_FLOATN x, + __CLC_FLOATN y); +_CLC_DECL _CLC_OVERLOAD __CLC_FLOATN __clc_tanf_piby4(__CLC_FLOATN x, + __CLC_INTN regn); + +_CLC_DECL _CLC_OVERLOAD __CLC_INTN __clc_argReductionS(private __CLC_FLOATN *r, + private __CLC_FLOATN *rr, + __CLC_FLOATN x); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_helpers_fp64.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_helpers_fp64.inc new file mode 100644 index 0000000000..09c6e1c965 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_helpers_fp64.inc @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_DECL _CLC_OVERLOAD void +__clc_remainder_piby2_medium(__CLC_DOUBLEN x, private __CLC_DOUBLEN *r, + private __CLC_DOUBLEN *rr, + private __CLC_INTN *regn); + +_CLC_DECL _CLC_OVERLOAD void +__clc_remainder_piby2_large(__CLC_DOUBLEN x, private __CLC_DOUBLEN *r, + private __CLC_DOUBLEN *rr, + private __CLC_INTN *regn); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_piby4.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_piby4.h new file mode 100644 index 0000000000..50608ae24e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_piby4.h @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_piby4.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_piby4.inc new file mode 100644 index 0000000000..91ec518b70 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sincos_piby4.inc @@ -0,0 +1,174 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +// Evaluate single precisions in and cos of value in interval [-pi/4, pi/4] +_CLC_INLINE _CLC_OVERLOAD void +__clc_sincos_piby4(__CLC_GENTYPE x, private __CLC_GENTYPE *sinval, + private __CLC_GENTYPE *cosval) { + // Taylor series for sin(x) is x - x^3/3! + x^5/5! - x^7/7! ... + // = x * (1 - x^2/3! + x^4/5! - x^6/7! ... + // = x * f(w) + // where w = x*x and f(w) = (1 - w/3! + w^2/5! - w^3/7! ... + // We use a minimax approximation of (f(w) - 1) / w + // because this produces an expansion in even powers of x. + + // Taylor series for cos(x) is 1 - x^2/2! + x^4/4! - x^6/6! ... + // = f(w) + // where w = x*x and f(w) = (1 - w/2! + w^2/4! - w^3/6! ... + // We use a minimax approximation of (f(w) - 1 + w/2) / (w*w) + // because this produces an expansion in even powers of x. + + const __CLC_GENTYPE sc1 = -0.166666666638608441788607926e0F; + const __CLC_GENTYPE sc2 = 0.833333187633086262120839299e-2F; + const __CLC_GENTYPE sc3 = -0.198400874359527693921333720e-3F; + const __CLC_GENTYPE sc4 = 0.272500015145584081596826911e-5F; + + const __CLC_GENTYPE cc1 = 0.41666666664325175238031e-1F; + const __CLC_GENTYPE cc2 = -0.13888887673175665567647e-2F; + const __CLC_GENTYPE cc3 = 0.24800600878112441958053e-4F; + const __CLC_GENTYPE cc4 = -0.27301013343179832472841e-6F; + + __CLC_GENTYPE x2 = x * x; + + *sinval = __clc_mad( + x * x2, __clc_mad(x2, __clc_mad(x2, __clc_mad(x2, sc4, sc3), sc2), sc1), + x); + *cosval = __clc_mad( + x2 * x2, __clc_mad(x2, __clc_mad(x2, __clc_mad(x2, cc4, cc3), cc2), cc1), + __clc_mad(x2, -0.5f, 1.0f)); +} + +#elif __CLC_FPSIZE == 64 + +_CLC_INLINE _CLC_OVERLOAD void +__clc_sincos_piby4(__CLC_GENTYPE x, __CLC_GENTYPE xx, + private __CLC_GENTYPE *sinval, + private __CLC_GENTYPE *cosval) { + // Taylor series for sin(x) is x - x^3/3! + x^5/5! - x^7/7! ... + // = x * (1 - x^2/3! + x^4/5! - x^6/7! ... + // = x * f(w) + // where w = x*x and f(w) = (1 - w/3! + w^2/5! - w^3/7! ... + // We use a minimax approximation of (f(w) - 1) / w + // because this produces an expansion in even powers of x. + // If xx (the tail of x) is non-zero, we add a correction + // term g(x,xx) = (1-x*x/2)*xx to the result, where g(x,xx) + // is an approximation to cos(x)*sin(xx) valid because + // xx is tiny relative to x. + + // Taylor series for cos(x) is 1 - x^2/2! + x^4/4! - x^6/6! ... + // = f(w) + // where w = x*x and f(w) = (1 - w/2! + w^2/4! - w^3/6! ... + // We use a minimax approximation of (f(w) - 1 + w/2) / (w*w) + // because this produces an expansion in even powers of x. + // If xx (the tail of x) is non-zero, we subtract a correction + // term g(x,xx) = x*xx to the result, where g(x,xx) + // is an approximation to sin(x)*sin(xx) valid because + // xx is tiny relative to x. + + const __CLC_GENTYPE sc1 = -0.166666666666666646259241729; + const __CLC_GENTYPE sc2 = 0.833333333333095043065222816e-2; + const __CLC_GENTYPE sc3 = -0.19841269836761125688538679e-3; + const __CLC_GENTYPE sc4 = 0.275573161037288022676895908448e-5; + const __CLC_GENTYPE sc5 = -0.25051132068021699772257377197e-7; + const __CLC_GENTYPE sc6 = 0.159181443044859136852668200e-9; + + const __CLC_GENTYPE cc1 = 0.41666666666666665390037e-1; + const __CLC_GENTYPE cc2 = -0.13888888888887398280412e-2; + const __CLC_GENTYPE cc3 = 0.248015872987670414957399e-4; + const __CLC_GENTYPE cc4 = -0.275573172723441909470836e-6; + const __CLC_GENTYPE cc5 = 0.208761463822329611076335e-8; + const __CLC_GENTYPE cc6 = -0.113826398067944859590880e-10; + + __CLC_GENTYPE x2 = x * x; + __CLC_GENTYPE x3 = x2 * x; + __CLC_GENTYPE r = (__CLC_GENTYPE)0.5 * x2; + __CLC_GENTYPE t = (__CLC_GENTYPE)1.0 - r; + + __CLC_GENTYPE sp = __clc_fma( + __clc_fma(__clc_fma(__clc_fma(sc6, x2, sc5), x2, sc4), x2, sc3), x2, sc2); + + __CLC_GENTYPE cp = + t + + __clc_fma(__clc_fma(__clc_fma(__clc_fma(__clc_fma(__clc_fma(cc6, x2, cc5), + x2, cc4), + x2, cc3), + x2, cc2), + x2, cc1), + x2 * x2, __clc_fma(x, xx, (1.0 - t) - r)); + + *sinval = + x - __clc_fma(-x3, sc1, __clc_fma(__clc_fma(-x3, sp, 0.5 * xx), x2, -xx)); + *cosval = cp; +} + +_CLC_INLINE _CLC_OVERLOAD void __clc_tan_piby4(__CLC_GENTYPE x, + __CLC_GENTYPE xx, + private __CLC_GENTYPE *leadval, + private __CLC_GENTYPE *tailval) { + // 0x3fe921fb54442d18 + const __CLC_GENTYPE piby4_lead = 7.85398163397448278999e-01; + // 0x3c81a62633145c06 + const __CLC_GENTYPE piby4_tail = 3.06161699786838240164e-17; + + // In order to maintain relative precision transform using the identity: + // tan(pi/4-x) = (1-tan(x))/(1+tan(x)) for arguments close to pi/4. + // Similarly use tan(x-pi/4) = (tan(x)-1)/(tan(x)+1) close to -pi/4. + + __CLC_LONGN ca = x > 0.68; + __CLC_LONGN cb = x < -0.68; + __CLC_GENTYPE transform = ca ? 1.0 : 0.0; + transform = cb ? -1.0 : transform; + + __CLC_GENTYPE tx = __clc_fma(-transform, x, piby4_lead) + + __clc_fma(-transform, xx, piby4_tail); + __CLC_LONGN c = ca | cb; + x = c ? tx : x; + xx = c ? 0.0 : xx; + + // Core Remez [2,3] approximation to tan(x+xx) on the interval [0,0.68]. + __CLC_GENTYPE t1 = x; + __CLC_GENTYPE r = __clc_fma(2.0, x * xx, x * x); + + __CLC_GENTYPE a = __clc_fma(r, + __clc_fma(r, 0.224044448537022097264602535574e-3, + -0.229345080057565662883358588111e-1), + 0.372379159759792203640806338901e0); + + __CLC_GENTYPE b = + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, -0.232371494088563558304549252913e-3, + 0.260656620398645407524064091208e-1), + -0.515658515729031149329237816945e0), + 0.111713747927937668539901657944e1); + + __CLC_GENTYPE t2 = __clc_fma(MATH_DIVIDE(a, b), x * r, xx); + + __CLC_GENTYPE tp = t1 + t2; + + // Compute -1.0/(t1 + t2) accurately + __CLC_GENTYPE z1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(tp) & 0xffffffff00000000L); + __CLC_GENTYPE z2 = t2 - (z1 - t1); + __CLC_GENTYPE trec = -MATH_RECIP(tp); + __CLC_GENTYPE trec_top = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(trec) & 0xffffffff00000000L); + + __CLC_GENTYPE tpr = __clc_fma( + __clc_fma(trec_top, z2, __clc_fma(trec_top, z1, 1.0)), trec, trec_top); + + __CLC_GENTYPE tpt = transform * (1.0 - MATH_DIVIDE(2.0 * tp, 1.0 + tp)); + __CLC_GENTYPE tptr = transform * (MATH_DIVIDE(2.0 * tp, tp - 1.0) - 1.0); + + *leadval = c ? tpt : tp; + *tailval = c ? tptr : tpr; +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sinh.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sinh.h new file mode 100644 index 0000000000..c94d8e37ac --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sinh.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_SINH_H__ +#define __CLC_MATH_CLC_SINH_H__ + +#define __CLC_BODY +#define FUNCTION __clc_sinh + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_SINH_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sinpi.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sinpi.h new file mode 100644 index 0000000000..725e559600 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sinpi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_SINPI_H__ +#define __CLC_MATH_CLC_SINPI_H__ + +#define __CLC_BODY +#define FUNCTION __clc_sinpi + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_SINPI_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sqrt.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sqrt.h new file mode 100644 index 0000000000..74aea8e858 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_sqrt.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_SQRT_H__ +#define __CLC_MATH_CLC_SQRT_H__ + +#define __CLC_BODY +#define FUNCTION __clc_sqrt + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_SQRT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_subnormal_config.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_subnormal_config.h new file mode 100644 index 0000000000..14693ed01e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_subnormal_config.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#ifndef __CLC_MATH_CLC_SUBNORMAL_CONFIG_H__ +#define __CLC_MATH_CLC_SUBNORMAL_CONFIG_H__ + +#include + +_CLC_DECL bool __clc_subnormals_disabled(); +_CLC_DECL bool __clc_fp16_subnormals_supported(); +_CLC_DECL bool __clc_fp32_subnormals_supported(); +_CLC_DECL bool __clc_fp64_subnormals_supported(); + +#endif // __CLC_MATH_CLC_SUBNORMAL_CONFIG_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_tan.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_tan.h new file mode 100644 index 0000000000..d16370420a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_tan.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_TAN_H__ +#define __CLC_MATH_CLC_TAN_H__ + +#define __CLC_BODY +#define FUNCTION __clc_tan + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_TAN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_tanh.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_tanh.h new file mode 100644 index 0000000000..2c860c165c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_tanh.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_TANH_H__ +#define __CLC_MATH_CLC_TANH_H__ + +#define __CLC_BODY +#define FUNCTION __clc_tanh + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_TANH_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_tanpi.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_tanpi.h new file mode 100644 index 0000000000..2691fa696c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_tanpi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_TANPI_H__ +#define __CLC_MATH_CLC_TANPI_H__ + +#define __CLC_BODY +#define FUNCTION __clc_tanpi + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_TANPI_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_tgamma.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_tgamma.h new file mode 100644 index 0000000000..d067703c2e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_tgamma.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_TGAMMA_H__ +#define __CLC_MATH_CLC_TGAMMA_H__ + +#define __CLC_BODY +#define FUNCTION __clc_tgamma + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_TGAMMA_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/clc_trunc.h b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_trunc.h new file mode 100644 index 0000000000..6a8353a4f6 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/clc_trunc.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_CLC_TRUNC_H__ +#define __CLC_MATH_CLC_TRUNC_H__ + +#define __CLC_BODY +#define FUNCTION __clc_trunc + +#include + +#undef FUNCTION + +#endif // __CLC_MATH_CLC_TRUNC_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/gentype.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/gentype.inc new file mode 100644 index 0000000000..d74a9932bd --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/gentype.inc @@ -0,0 +1,355 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +// Define some useful macros for type conversions. +#define __CLC_AS_GENTYPE __CLC_XCONCAT(__clc_as_, __CLC_GENTYPE) +#define __CLC_CONVERT_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_GENTYPE) + +// Define some macros for types matching the same vector size as __CLC_GENTYPE. +#define __CLC_HALFN __CLC_XCONCAT(half, __CLC_VECSIZE) +#define __CLC_FLOATN __CLC_XCONCAT(float, __CLC_VECSIZE) +#define __CLC_DOUBLEN __CLC_XCONCAT(double, __CLC_VECSIZE) + +#define __CLC_CHARN __CLC_XCONCAT(char, __CLC_VECSIZE) +#define __CLC_SHORTN __CLC_XCONCAT(short, __CLC_VECSIZE) +#define __CLC_INTN __CLC_XCONCAT(int, __CLC_VECSIZE) +#define __CLC_LONGN __CLC_XCONCAT(long, __CLC_VECSIZE) + +#define __CLC_UCHARN __CLC_XCONCAT(uchar, __CLC_VECSIZE) +#define __CLC_USHORTN __CLC_XCONCAT(ushort, __CLC_VECSIZE) +#define __CLC_UINTN __CLC_XCONCAT(uint, __CLC_VECSIZE) +#define __CLC_ULONGN __CLC_XCONCAT(ulong, __CLC_VECSIZE) + +#define __CLC_AS_HALFN __CLC_XCONCAT(__clc_as_, __CLC_HALFN) +#define __CLC_AS_FLOATN __CLC_XCONCAT(__clc_as_, __CLC_FLOATN) +#define __CLC_AS_DOUBLEN __CLC_XCONCAT(__clc_as_, __CLC_DOUBLEN) + +#define __CLC_AS_CHARN __CLC_XCONCAT(__clc_as_, __CLC_CHARN) +#define __CLC_AS_SHORTN __CLC_XCONCAT(__clc_as_, __CLC_SHORTN) +#define __CLC_AS_INTN __CLC_XCONCAT(__clc_as_, __CLC_INTN) +#define __CLC_AS_LONGN __CLC_XCONCAT(__clc_as_, __CLC_LONGN) + +#define __CLC_AS_UCHARN __CLC_XCONCAT(__clc_as_, __CLC_UCHARN) +#define __CLC_AS_USHORTN __CLC_XCONCAT(__clc_as_, __CLC_USHORTN) +#define __CLC_AS_UINTN __CLC_XCONCAT(__clc_as_, __CLC_UINTN) +#define __CLC_AS_ULONGN __CLC_XCONCAT(__clc_as_, __CLC_ULONGN) + +#define __CLC_CONVERT_HALFN __CLC_XCONCAT(__clc_convert_half, __CLC_VECSIZE) +#define __CLC_CONVERT_FLOATN __CLC_XCONCAT(__clc_convert_float, __CLC_VECSIZE) +#define __CLC_CONVERT_DOUBLEN __CLC_XCONCAT(__clc_convert_double, __CLC_VECSIZE) + +#define __CLC_CONVERT_CHARN __CLC_XCONCAT(__clc_convert_, __CLC_CHARN) +#define __CLC_CONVERT_SHORTN __CLC_XCONCAT(__clc_convert_, __CLC_SHORTN) +#define __CLC_CONVERT_INTN __CLC_XCONCAT(__clc_convert_, __CLC_INTN) +#define __CLC_CONVERT_LONGN __CLC_XCONCAT(__clc_convert_, __CLC_LONGN) + +#define __CLC_CONVERT_UCHARN __CLC_XCONCAT(__clc_convert_, __CLC_UCHARN) +#define __CLC_CONVERT_USHORTN __CLC_XCONCAT(__clc_convert_, __CLC_USHORTN) +#define __CLC_CONVERT_UINTN __CLC_XCONCAT(__clc_convert_, __CLC_UINTN) +#define __CLC_CONVERT_ULONGN __CLC_XCONCAT(__clc_convert_, __CLC_ULONGN) + +#define __CLC_CONVERT_BIT_INTN __CLC_XCONCAT(__clc_convert_, __CLC_BIT_INTN) + +// See definitions of __CLC_S_GENTYPE/__CLC_U_GENTYPE below, which depend on the +// specific size of floating-point type. These are the signed and unsigned +// integers of the same bitwidth and element count as the GENTYPE. They match +// the naming conventions in the integer version gentype.inc, for +// convenience. +#define __CLC_AS_S_GENTYPE __CLC_XCONCAT(__clc_as_, __CLC_S_GENTYPE) +#define __CLC_AS_U_GENTYPE __CLC_XCONCAT(__clc_as_, __CLC_U_GENTYPE) + +#define __CLC_CONVERT_S_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_S_GENTYPE) +#define __CLC_CONVERT_U_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_U_GENTYPE) + +#if (!defined(__HALF_ONLY) && !defined(__DOUBLE_ONLY)) +#define __CLC_SCALAR_GENTYPE float +#define __CLC_FPSIZE 32 +#define __CLC_FP_LIT(x) (__CLC_GENTYPE) x##F +#define __CLC_GENTYPE_NAN (__CLC_GENTYPE) FLT_NAN + +#define __CLC_S_GENTYPE __CLC_XCONCAT(int, __CLC_VECSIZE) +#define __CLC_U_GENTYPE __CLC_XCONCAT(uint, __CLC_VECSIZE) + +#define __CLC_GENTYPE float +#define __CLC_BIT_INTN int +#define __CLC_SCALAR +#define __CLC_VECSIZE +#define __CLC_VECSIZE_OR_1 1 +#include __CLC_BODY +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN +#undef __CLC_SCALAR + +#define __CLC_VECSIZE_OR_1 __CLC_VECSIZE + +#define __CLC_GENTYPE float2 +#define __CLC_BIT_INTN int2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#define __CLC_GENTYPE float3 +#define __CLC_BIT_INTN int3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#define __CLC_GENTYPE float4 +#define __CLC_BIT_INTN int4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#define __CLC_GENTYPE float8 +#define __CLC_BIT_INTN int8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#define __CLC_GENTYPE float16 +#define __CLC_BIT_INTN int16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE +#undef __CLC_GENTYPE_NAN +#undef __CLC_FP_LIT +#undef __CLC_FPSIZE +#undef __CLC_SCALAR_GENTYPE + +#endif + +#if (!defined(__HALF_ONLY) && !defined(__FLOAT_ONLY)) +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +#define __CLC_SCALAR_GENTYPE double +#define __CLC_FPSIZE 64 +#define __CLC_FP_LIT(x) (__CLC_GENTYPE)(x) +#define __CLC_GENTYPE_NAN (__CLC_GENTYPE) DBL_NAN + +#define __CLC_S_GENTYPE __CLC_XCONCAT(long, __CLC_VECSIZE) +#define __CLC_U_GENTYPE __CLC_XCONCAT(ulong, __CLC_VECSIZE) + +#define __CLC_SCALAR +#define __CLC_VECSIZE +#define __CLC_VECSIZE_OR_1 1 +#define __CLC_GENTYPE double +#define __CLC_BIT_INTN long +#include __CLC_BODY +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN +#undef __CLC_VECSIZE +#undef __CLC_SCALAR + +#define __CLC_VECSIZE_OR_1 __CLC_VECSIZE + +#define __CLC_GENTYPE double2 +#define __CLC_BIT_INTN long2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#define __CLC_GENTYPE double3 +#define __CLC_BIT_INTN long3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#define __CLC_GENTYPE double4 +#define __CLC_BIT_INTN long4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#define __CLC_GENTYPE double8 +#define __CLC_BIT_INTN long8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#define __CLC_GENTYPE double16 +#define __CLC_BIT_INTN long16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE +#undef __CLC_GENTYPE_NAN +#undef __CLC_FP_LIT +#undef __CLC_FPSIZE +#undef __CLC_SCALAR_GENTYPE +#endif +#endif + +#if (!defined(__FLOAT_ONLY) && !defined(__DOUBLE_ONLY)) +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +#define __CLC_SCALAR_GENTYPE half +#define __CLC_FPSIZE 16 +#define __CLC_FP_LIT(x) (__CLC_GENTYPE) x##H +#define __CLC_GENTYPE_NAN (__CLC_GENTYPE) HALF_NAN + +#define __CLC_S_GENTYPE __CLC_XCONCAT(short, __CLC_VECSIZE) +#define __CLC_U_GENTYPE __CLC_XCONCAT(ushort, __CLC_VECSIZE) + +#define __CLC_SCALAR +#define __CLC_VECSIZE +#define __CLC_VECSIZE_OR_1 1 +#define __CLC_GENTYPE half +#define __CLC_BIT_INTN short +#include __CLC_BODY +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_VECSIZE +#undef __CLC_SCALAR + +#define __CLC_VECSIZE_OR_1 __CLC_VECSIZE + +#define __CLC_GENTYPE half2 +#define __CLC_BIT_INTN short2 +#define __CLC_VECSIZE 2 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#define __CLC_GENTYPE half3 +#define __CLC_BIT_INTN short3 +#define __CLC_VECSIZE 3 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#define __CLC_GENTYPE half4 +#define __CLC_BIT_INTN short4 +#define __CLC_VECSIZE 4 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#define __CLC_GENTYPE half8 +#define __CLC_BIT_INTN short8 +#define __CLC_VECSIZE 8 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#define __CLC_GENTYPE half16 +#define __CLC_BIT_INTN short16 +#define __CLC_VECSIZE 16 +#include __CLC_BODY +#undef __CLC_VECSIZE +#undef __CLC_GENTYPE +#undef __CLC_BIT_INTN + +#undef __CLC_VECSIZE_OR_1 +#undef __CLC_U_GENTYPE +#undef __CLC_S_GENTYPE +#undef __CLC_GENTYPE_NAN +#undef __CLC_FP_LIT +#undef __CLC_FPSIZE +#undef __CLC_SCALAR_GENTYPE +#endif +#endif + +#undef __CLC_BODY + +#undef __CLC_AS_U_GENTYPE +#undef __CLC_AS_S_GENTYPE + +#undef __CLC_CONVERT_U_GENTYPE +#undef __CLC_CONVERT_S_GENTYPE + +#undef __CLC_AS_CHARN +#undef __CLC_AS_SHORTN +#undef __CLC_AS_INTN +#undef __CLC_AS_LONGN + +#undef __CLC_AS_HALFN +#undef __CLC_AS_FLOATN +#undef __CLC_AS_DOUBLEN + +#undef __CLC_AS_UCHARN +#undef __CLC_AS_USHORTN +#undef __CLC_AS_UINTN +#undef __CLC_AS_ULONGN + +#undef __CLC_CONVERT_HALFN +#undef __CLC_CONVERT_FLOATN +#undef __CLC_CONVERT_DOUBLEN + +#undef __CLC_CONVERT_CHARN +#undef __CLC_CONVERT_SHORTN +#undef __CLC_CONVERT_INTN +#undef __CLC_CONVERT_LONGN + +#undef __CLC_CONVERT_UCHARN +#undef __CLC_CONVERT_USHORTN +#undef __CLC_CONVERT_UINTN +#undef __CLC_CONVERT_ULONGN + +#undef __CLC_CONVERT_BIT_INTN + +#undef __CLC_ULONGN +#undef __CLC_UINTN +#undef __CLC_USHORTN +#undef __CLC_UCHARN + +#undef __CLC_LONGN +#undef __CLC_INTN +#undef __CLC_SHORTN +#undef __CLC_CHARN + +#undef __CLC_DOUBLEN +#undef __CLC_FLOATN +#undef __CLC_HALFN + +#undef __CLC_AS_GENTYPE +#undef __CLC_CONVERT_GENTYPE + +#undef __HALF_ONLY +#undef __FLOAT_ONLY +#undef __DOUBLE_ONLY diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/math.h b/local/recipes/dev/libclc/source/clc/include/clc/math/math.h new file mode 100644 index 0000000000..5df53f1b5e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/math.h @@ -0,0 +1,125 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_MATH_H__ +#define __CLC_MATH_MATH_H__ + +#include +#include +#include + +#define SNAN 0x001 +#define QNAN 0x002 +#define NINF 0x004 +#define NNOR 0x008 +#define NSUB 0x010 +#define NZER 0x020 +#define PZER 0x040 +#define PSUB 0x080 +#define PNOR 0x100 +#define PINF 0x200 + +#if (defined __AMDGCN__ || defined __R600__) && !defined __HAS_FMAF__ +#define __CLC_HAVE_HW_FMA32() (0) +#elif defined(CLC_SPIRV) +bool __attribute__((noinline)) __clc_runtime_has_hw_fma32(void); +#define __CLC_HAVE_HW_FMA32() __clc_runtime_has_hw_fma32() +#else +#define __CLC_HAVE_HW_FMA32() (1) +#endif + +#define HAVE_BITALIGN() (0) +#define HAVE_FAST_FMA32() (0) + +#define MATH_DIVIDE(X, Y) ((X) / (Y)) +#define MATH_RECIP(X) (1.0f / (X)) +#define MATH_SQRT(X) sqrt(X) + +#define SIGNBIT_SP32 0x80000000 +#define EXSIGNBIT_SP32 0x7fffffff +#define EXPBITS_SP32 0x7f800000 +#define MANTBITS_SP32 0x007fffff +#define ONEEXPBITS_SP32 0x3f800000 +#define TWOEXPBITS_SP32 0x40000000 +#define HALFEXPBITS_SP32 0x3f000000 +#define IMPBIT_SP32 0x00800000 +#define QNANBITPATT_SP32 0x7fc00000 +#define INDEFBITPATT_SP32 0xffc00000 +#define PINFBITPATT_SP32 0x7f800000 +#define NINFBITPATT_SP32 0xff800000 +#define NUMEXPBITS_SP32 8 +#define EXPBIAS_SP32 127 +#define EXPSHIFTBITS_SP32 23 +#define BIASEDEMIN_SP32 1 +#define EMIN_SP32 -126 +#define BIASEDEMAX_SP32 254 +#define EMAX_SP32 127 +#define LAMBDA_SP32 1.0e30 +#define MANTLENGTH_SP32 24 +#define BASEDIGITS_SP32 7 + +#define LOG_MAGIC_NUM_SP32 (1 + NUMEXPBITS_SP32 - EXPBIAS_SP32) + +_CLC_OVERLOAD _CLC_INLINE float __clc_flush_denormal_if_not_supported(float x) { + int ix = __clc_as_int(x); + if (!__clc_fp32_subnormals_supported() && ((ix & EXPBITS_SP32) == 0) && + ((ix & MANTBITS_SP32) != 0)) { + ix &= SIGNBIT_SP32; + x = __clc_as_float(ix); + } + return x; +} + +#ifdef cl_khr_fp64 + +#define SIGNBIT_DP64 0x8000000000000000L +#define EXSIGNBIT_DP64 0x7fffffffffffffffL +#define EXPBITS_DP64 0x7ff0000000000000L +#define MANTBITS_DP64 0x000fffffffffffffL +#define ONEEXPBITS_DP64 0x3ff0000000000000L +#define TWOEXPBITS_DP64 0x4000000000000000L +#define HALFEXPBITS_DP64 0x3fe0000000000000L +#define IMPBIT_DP64 0x0010000000000000L +#define QNANBITPATT_DP64 0x7ff8000000000000L +#define INDEFBITPATT_DP64 0xfff8000000000000L +#define PINFBITPATT_DP64 0x7ff0000000000000L +#define NINFBITPATT_DP64 0xfff0000000000000L +#define NUMEXPBITS_DP64 11 +#define EXPBIAS_DP64 1023 +#define EXPSHIFTBITS_DP64 52 +#define BIASEDEMIN_DP64 1 +#define EMIN_DP64 -1022 +#define BIASEDEMAX_DP64 2046 /* 0x7fe */ +#define EMAX_DP64 1023 /* 0x3ff */ +#define LAMBDA_DP64 1.0e300 +#define MANTLENGTH_DP64 53 +#define BASEDIGITS_DP64 15 + +#define LOG_MAGIC_NUM_DP64 (1 + NUMEXPBITS_DP64 - EXPBIAS_DP64) + +#endif // cl_khr_fp64 + +#ifdef cl_khr_fp16 + +#define SIGNBIT_FP16 0x8000 +#define EXSIGNBIT_FP16 0x7fff +#define EXPBITS_FP16 0x7c00 +#define MANTBITS_FP16 0x03ff +#define PINFBITPATT_FP16 0x7c00 +#define NINFBITPATT_FP16 0xfc00 +#define NUMEXPBITS_FP16 5 +#define EXPBIAS_FP16 15 +#define EXPSHIFTBITS_FP16 10 + +#define LOG_MAGIC_NUM_FP16 (1 + NUMEXPBITS_FP16 - EXPBIAS_FP16) + +#endif // cl_khr_fp16 + +#define ALIGNED(x) __attribute__((aligned(x))) + +#endif // __CLC_MATH_MATH_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/remquo_decl.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/remquo_decl.inc new file mode 100644 index 0000000000..24d96b0488 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/remquo_decl.inc @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, __CLC_GENTYPE y, + private __CLC_INTN *q); + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, __CLC_GENTYPE y, + global __CLC_INTN *q); + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, __CLC_GENTYPE y, + local __CLC_INTN *q); +#if _CLC_GENERIC_AS_SUPPORTED +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, __CLC_GENTYPE y, + generic __CLC_INTN *q); +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/tables.h b/local/recipes/dev/libclc/source/clc/include/clc/math/tables.h new file mode 100644 index 0000000000..0fec778b53 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/tables.h @@ -0,0 +1,105 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MATH_TABLES_H__ +#define __CLC_MATH_TABLES_H__ + +#include + +#define TABLE_SPACE __constant + +#define TABLE_MANGLE(NAME) __clc_##NAME + +#define DECLARE_TABLE(TYPE, NAME, LENGTH) TABLE_SPACE TYPE NAME[LENGTH] + +#define TABLE_FUNCTION(TYPE, TABLE, NAME) \ + TYPE TABLE_MANGLE(NAME)(size_t idx) { return TABLE[idx]; } + +#define CLC_TABLE_FUNCTION(TYPE, TABLE, NAME) \ + _CLC_DEF _CLC_OVERLOAD TYPE TABLE_MANGLE(NAME)(int idx) { \ + return TABLE[idx]; \ + } \ + _CLC_DEF _CLC_OVERLOAD TYPE##2 TABLE_MANGLE(NAME)(int##2 idx) { \ + return (TYPE##2){TABLE[idx.s0], TABLE[idx.s1]}; \ + } \ + _CLC_DEF _CLC_OVERLOAD TYPE##3 TABLE_MANGLE(NAME)(int##3 idx) { \ + return (TYPE##3){TABLE[idx.s0], TABLE[idx.s1], TABLE[idx.s2]}; \ + } \ + _CLC_DEF _CLC_OVERLOAD TYPE##4 TABLE_MANGLE(NAME)(int##4 idx) { \ + return (TYPE##4){TABLE[idx.s0], TABLE[idx.s1], TABLE[idx.s2], \ + TABLE[idx.s3]}; \ + } \ + _CLC_DEF _CLC_OVERLOAD TYPE##8 TABLE_MANGLE(NAME)(int##8 idx) { \ + return (TYPE##8){TABLE[idx.s0], TABLE[idx.s1], TABLE[idx.s2], \ + TABLE[idx.s3], TABLE[idx.s4], TABLE[idx.s5], \ + TABLE[idx.s6], TABLE[idx.s7]}; \ + } \ + _CLC_DEF _CLC_OVERLOAD TYPE##16 TABLE_MANGLE(NAME)(int##16 idx) { \ + return (TYPE##16){ \ + TABLE[idx.s0], TABLE[idx.s1], TABLE[idx.s2], TABLE[idx.s3], \ + TABLE[idx.s4], TABLE[idx.s5], TABLE[idx.s6], TABLE[idx.s7], \ + TABLE[idx.s8], TABLE[idx.s9], TABLE[idx.sA], TABLE[idx.sB], \ + TABLE[idx.sC], TABLE[idx.sD], TABLE[idx.sE], TABLE[idx.sF]}; \ + } + +#define TABLE_FUNCTION_DECL(TYPE, NAME) TYPE TABLE_MANGLE(NAME)(size_t idx); + +#define CLC_TABLE_FUNCTION_DECL(TYPE, NAME) \ + _CLC_DECL _CLC_OVERLOAD TYPE TABLE_MANGLE(NAME)(int idx); \ + _CLC_DECL _CLC_OVERLOAD TYPE##2 TABLE_MANGLE(NAME)(int##2 idx); \ + _CLC_DECL _CLC_OVERLOAD TYPE##3 TABLE_MANGLE(NAME)(int##3 idx); \ + _CLC_DECL _CLC_OVERLOAD TYPE##4 TABLE_MANGLE(NAME)(int##4 idx); \ + _CLC_DECL _CLC_OVERLOAD TYPE##8 TABLE_MANGLE(NAME)(int##8 idx); \ + _CLC_DECL _CLC_OVERLOAD TYPE##16 TABLE_MANGLE(NAME)(int##16 idx); + +#define USE_TABLE(NAME, IDX) TABLE_MANGLE(NAME)(IDX) + +TABLE_FUNCTION_DECL(float2, log2_tbl); +TABLE_FUNCTION_DECL(float2, log10_tbl); + +CLC_TABLE_FUNCTION_DECL(float, log_inv_tbl_ep_head); +CLC_TABLE_FUNCTION_DECL(float, log_inv_tbl_ep_tail); +CLC_TABLE_FUNCTION_DECL(float, loge_tbl_lo); +CLC_TABLE_FUNCTION_DECL(float, loge_tbl_hi); +CLC_TABLE_FUNCTION_DECL(float, log_inv_tbl); +CLC_TABLE_FUNCTION_DECL(float, exp_tbl); +CLC_TABLE_FUNCTION_DECL(float, exp_tbl_ep_head); +CLC_TABLE_FUNCTION_DECL(float, exp_tbl_ep_tail); +CLC_TABLE_FUNCTION_DECL(float, cbrt_tbl_head); +CLC_TABLE_FUNCTION_DECL(float, cbrt_tbl_tail); +CLC_TABLE_FUNCTION_DECL(float, sinhcosh_tbl_head); +CLC_TABLE_FUNCTION_DECL(float, sinhcosh_tbl_tail); +CLC_TABLE_FUNCTION_DECL(ulong, pibits_tbl); + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +CLC_TABLE_FUNCTION_DECL(double, ln_tbl_lo); +CLC_TABLE_FUNCTION_DECL(double, ln_tbl_hi); +CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_head); +CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_tail); +CLC_TABLE_FUNCTION_DECL(double, two_to_jby64_ep_tbl_head); +CLC_TABLE_FUNCTION_DECL(double, two_to_jby64_ep_tbl_tail); +CLC_TABLE_FUNCTION_DECL(double, sinh_tbl_head); +CLC_TABLE_FUNCTION_DECL(double, sinh_tbl_tail); +CLC_TABLE_FUNCTION_DECL(double, cosh_tbl_head); +CLC_TABLE_FUNCTION_DECL(double, cosh_tbl_tail); +CLC_TABLE_FUNCTION_DECL(double, cbrt_inv_tbl); +CLC_TABLE_FUNCTION_DECL(double, cbrt_dbl_tbl_head); +CLC_TABLE_FUNCTION_DECL(double, cbrt_dbl_tbl_tail); +CLC_TABLE_FUNCTION_DECL(double, cbrt_rem_tbl_head); +CLC_TABLE_FUNCTION_DECL(double, cbrt_rem_tbl_tail); +CLC_TABLE_FUNCTION_DECL(double, powlog_tbl_head); +CLC_TABLE_FUNCTION_DECL(double, powlog_tbl_tail); +CLC_TABLE_FUNCTION_DECL(double, log_f_inv_tbl_head); +CLC_TABLE_FUNCTION_DECL(double, log_f_inv_tbl_tail); + +#endif // cl_khr_fp64 + +#endif // __CLC_MATH_TABLES_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl.inc new file mode 100644 index 0000000000..ce1a71b828 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl.inc @@ -0,0 +1,9 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl_with_int_ptr.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl_with_int_ptr.inc new file mode 100644 index 0000000000..d62046a529 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl_with_int_ptr.inc @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + global __CLC_INTN *iptr); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + local __CLC_INTN *iptr); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + private __CLC_INTN *iptr); +#if _CLC_GENERIC_AS_SUPPORTED +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + generic __CLC_INTN *iptr); +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl_with_int_return.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl_with_int_return.inc new file mode 100644 index 0000000000..ed8d0a1250 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl_with_int_return.inc @@ -0,0 +1,9 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_INTN FUNCTION(__CLC_GENTYPE x); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl_with_ptr.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl_with_ptr.inc new file mode 100644 index 0000000000..ca0077bec5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_decl_with_ptr.inc @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + global __CLC_GENTYPE *ptr); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + local __CLC_GENTYPE *ptr); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + private __CLC_GENTYPE *ptr); + +#if _CLC_GENERIC_AS_SUPPORTED +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + generic __CLC_GENTYPE *ptr); +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_via_fp32.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_via_fp32.inc new file mode 100644 index 0000000000..f109e8ec4a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_via_fp32.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(FUNCTION(__CLC_CONVERT_FLOATN(x))); +} diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_with_int_ptr.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_with_int_ptr.inc new file mode 100644 index 0000000000..a8ed34ad04 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_with_int_ptr.inc @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + private __CLC_INTN *iptr) { + return __IMPL_FUNCTION(FUNCTION)(x, iptr); +} + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + global __CLC_INTN *iptr) { + return __IMPL_FUNCTION(FUNCTION)(x, iptr); +} + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + local __CLC_INTN *iptr) { + return __IMPL_FUNCTION(FUNCTION)(x, iptr); +} + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + generic __CLC_INTN *iptr) { + return __IMPL_FUNCTION(FUNCTION)(x, iptr); +} +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_with_int_return.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_with_int_return.inc new file mode 100644 index 0000000000..c7bb84cf5f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_with_int_return.inc @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_INTN FUNCTION(__CLC_GENTYPE a) { + return __IMPL_FUNCTION(FUNCTION)(a); +} diff --git a/local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_with_ptr.inc b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_with_ptr.inc new file mode 100644 index 0000000000..c3faa9aab8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/math/unary_def_with_ptr.inc @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + private __CLC_GENTYPE *ptr) { + return __IMPL_FUNCTION(FUNCTION)(x, ptr); +} + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + global __CLC_GENTYPE *ptr) { + return __IMPL_FUNCTION(FUNCTION)(x, ptr); +} + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + local __CLC_GENTYPE *ptr) { + return __IMPL_FUNCTION(FUNCTION)(x, ptr); +} + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + generic __CLC_GENTYPE *ptr) { + return __IMPL_FUNCTION(FUNCTION)(x, ptr); +} +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/misc/clc_shuffle.h b/local/recipes/dev/libclc/source/clc/include/clc/misc/clc_shuffle.h new file mode 100644 index 0000000000..1e9ec6828f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/misc/clc_shuffle.h @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MISC_CLC_SHUFFLE_H__ +#define __CLC_MISC_CLC_SHUFFLE_H__ + +#define FUNCTION __clc_shuffle + +// Integer-type decls +#define __CLC_BODY +#include + +// Floating-point decls +#define __CLC_BODY +#include + +#undef FUNCTION + +#endif // __CLC_MISC_CLC_SHUFFLE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/misc/clc_shuffle2.h b/local/recipes/dev/libclc/source/clc/include/clc/misc/clc_shuffle2.h new file mode 100644 index 0000000000..fb5361cfeb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/misc/clc_shuffle2.h @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_MISC_CLC_SHUFFLE2_H__ +#define __CLC_MISC_CLC_SHUFFLE2_H__ + +#define FUNCTION __clc_shuffle2 + +// Integer-type decls +#define __CLC_BODY +#include + +// Floating-point decls +#define __CLC_BODY +#include + +#undef FUNCTION + +#endif // __CLC_MISC_CLC_SHUFFLE2_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle2_decl.inc b/local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle2_decl.inc new file mode 100644 index 0000000000..47fd5e28a3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle2_decl.inc @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if (__CLC_VECSIZE_OR_1 == 2 || __CLC_VECSIZE_OR_1 == 4 || \ + __CLC_VECSIZE_OR_1 == 8 || __CLC_VECSIZE_OR_1 == 16) + +// The return type is same base type as the input type, with the same vector +// size as the mask. Elements in the mask must be the same size (number of bits) +// as the input value., e.g. char8 ret = shuffle(char2 x, uchar8 mask); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 2) x, + __CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 2) y, __CLC_U_GENTYPE mask); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 4) x, + __CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 4) y, __CLC_U_GENTYPE mask); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 8) x, + __CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 8) y, __CLC_U_GENTYPE mask); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 16) x, + __CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 16) y, __CLC_U_GENTYPE mask); + +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle2_def.inc b/local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle2_def.inc new file mode 100644 index 0000000000..0415b8c187 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle2_def.inc @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if (__CLC_VECSIZE_OR_1 == 2 || __CLC_VECSIZE_OR_1 == 4 || \ + __CLC_VECSIZE_OR_1 == 8 || __CLC_VECSIZE_OR_1 == 16) + +#include + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +// The return type is same base type as the input type, with the same vector +// size as the mask. Elements in the mask must be the same size (number of bits) +// as the input value., e.g. char8 ret = shuffle(char2 x, uchar8 mask); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 2) x, + __CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 2) y, __CLC_U_GENTYPE mask) { + return __IMPL_FUNCTION(FUNCTION)(x, y, mask); +} +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 4) x, + __CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 4) y, __CLC_U_GENTYPE mask) { + return __IMPL_FUNCTION(FUNCTION)(x, y, mask); +} +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 8) x, + __CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 8) y, __CLC_U_GENTYPE mask) { + return __IMPL_FUNCTION(FUNCTION)(x, y, mask); +} +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 16) x, + __CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 16) y, __CLC_U_GENTYPE mask) { + return __IMPL_FUNCTION(FUNCTION)(x, y, mask); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle_decl.inc b/local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle_decl.inc new file mode 100644 index 0000000000..c6c64d5b5f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle_decl.inc @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if (__CLC_VECSIZE_OR_1 == 2 || __CLC_VECSIZE_OR_1 == 4 || \ + __CLC_VECSIZE_OR_1 == 8 || __CLC_VECSIZE_OR_1 == 16) + +// The return type is same base type as the input type, with the same vector +// size as the mask. Elements in the mask must be the same size (number of bits) +// as the input value., e.g. char8 ret = shuffle(char2 x, uchar8 mask); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 2) x, __CLC_U_GENTYPE mask); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 4) x, __CLC_U_GENTYPE mask); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 8) x, __CLC_U_GENTYPE mask); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 16) x, __CLC_U_GENTYPE mask); + +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle_def.inc b/local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle_def.inc new file mode 100644 index 0000000000..d2a088498f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/misc/shuffle_def.inc @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if (__CLC_VECSIZE_OR_1 == 2 || __CLC_VECSIZE_OR_1 == 4 || \ + __CLC_VECSIZE_OR_1 == 8 || __CLC_VECSIZE_OR_1 == 16) + +#include + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +// The return type is same base type as the input type, with the same vector +// size as the mask. Elements in the mask must be the same size (number of bits) +// as the input value., e.g. char8 ret = shuffle(char2 x, uchar8 mask); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 2) x, __CLC_U_GENTYPE mask) { + return __IMPL_FUNCTION(FUNCTION)(x, mask); +} +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 4) x, __CLC_U_GENTYPE mask) { + return __IMPL_FUNCTION(FUNCTION)(x, mask); +} +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 8) x, __CLC_U_GENTYPE mask) { + return __IMPL_FUNCTION(FUNCTION)(x, mask); +} +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE +FUNCTION(__CLC_XCONCAT(__CLC_SCALAR_GENTYPE, 16) x, __CLC_U_GENTYPE mask) { + return __IMPL_FUNCTION(FUNCTION)(x, mask); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/binary_decl.inc b/local/recipes/dev/libclc/source/clc/include/clc/relational/binary_decl.inc new file mode 100644 index 0000000000..bcdf5238b8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/binary_decl.inc @@ -0,0 +1,9 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_INTN FUNCTION(__CLC_FLOATN a, __CLC_FLOATN b); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_all.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_all.h new file mode 100644 index 0000000000..4d01fb7795 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_all.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ALL_H__ +#define __CLC_RELATIONAL_CLC_ALL_H__ + +#include +#include + +#define _CLC_ALL_DECL(TYPE) _CLC_OVERLOAD _CLC_DECL int __clc_all(TYPE v); + +#define _CLC_VECTOR_ALL_DECL(TYPE) \ + _CLC_ALL_DECL(TYPE) \ + _CLC_ALL_DECL(TYPE##2) \ + _CLC_ALL_DECL(TYPE##3) \ + _CLC_ALL_DECL(TYPE##4) \ + _CLC_ALL_DECL(TYPE##8) \ + _CLC_ALL_DECL(TYPE##16) + +_CLC_VECTOR_ALL_DECL(char) +_CLC_VECTOR_ALL_DECL(short) +_CLC_VECTOR_ALL_DECL(int) +_CLC_VECTOR_ALL_DECL(long) + +#undef _CLC_ALL_DECL +#undef _CLC_VECTOR_ALL_DECL + +#endif // __CLC_RELATIONAL_CLC_ALL_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_any.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_any.h new file mode 100644 index 0000000000..1e287af58d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_any.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ANY_H__ +#define __CLC_RELATIONAL_CLC_ANY_H__ + +#include +#include + +#define _CLC_ANY_DECL(TYPE) _CLC_OVERLOAD _CLC_DECL int __clc_any(TYPE v); + +#define _CLC_VECTOR_ANY_DECL(TYPE) \ + _CLC_ANY_DECL(TYPE) \ + _CLC_ANY_DECL(TYPE##2) \ + _CLC_ANY_DECL(TYPE##3) \ + _CLC_ANY_DECL(TYPE##4) \ + _CLC_ANY_DECL(TYPE##8) \ + _CLC_ANY_DECL(TYPE##16) + +_CLC_VECTOR_ANY_DECL(char) +_CLC_VECTOR_ANY_DECL(short) +_CLC_VECTOR_ANY_DECL(int) +_CLC_VECTOR_ANY_DECL(long) + +#undef _CLC_ANY_DECL +#undef _CLC_VECTOR_ANY_DECL + +#endif // __CLC_RELATIONAL_CLC_ANY_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_bitselect.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_bitselect.h new file mode 100644 index 0000000000..5490ea7374 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_bitselect.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_BITSELECT_H__ +#define __CLC_RELATIONAL_CLC_BITSELECT_H__ + +#define __CLC_BODY +#include +#define __CLC_BODY +#include + +#endif // __CLC_RELATIONAL_CLC_BITSELECT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_bitselect.inc b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_bitselect.inc new file mode 100644 index 0000000000..b81cfc2ef0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_bitselect.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_bitselect(__CLC_GENTYPE x, + __CLC_GENTYPE y, + __CLC_GENTYPE z); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isequal.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isequal.h new file mode 100644 index 0000000000..f3789f5956 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isequal.h @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISEQUAL_H__ +#define __CLC_RELATIONAL_CLC_ISEQUAL_H__ + +#include +#include + +#define _CLC_ISEQUAL_DECL(TYPE, RETTYPE) \ + _CLC_OVERLOAD _CLC_DECL RETTYPE __clc_isequal(TYPE x, TYPE y); + +#define _CLC_VECTOR_ISEQUAL_DECL(TYPE, RETTYPE) \ + _CLC_ISEQUAL_DECL(TYPE##2, RETTYPE##2) \ + _CLC_ISEQUAL_DECL(TYPE##3, RETTYPE##3) \ + _CLC_ISEQUAL_DECL(TYPE##4, RETTYPE##4) \ + _CLC_ISEQUAL_DECL(TYPE##8, RETTYPE##8) \ + _CLC_ISEQUAL_DECL(TYPE##16, RETTYPE##16) + +_CLC_ISEQUAL_DECL(float, int) +_CLC_VECTOR_ISEQUAL_DECL(float, int) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +_CLC_ISEQUAL_DECL(double, int) +_CLC_VECTOR_ISEQUAL_DECL(double, long) +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +_CLC_ISEQUAL_DECL(half, int) +_CLC_VECTOR_ISEQUAL_DECL(half, short) +#endif + +#undef _CLC_ISEQUAL_DECL +#undef _CLC_VECTOR_ISEQUAL_DECL + +#endif // __CLC_RELATIONAL_CLC_ISEQUAL_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isfinite.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isfinite.h new file mode 100644 index 0000000000..5e71ec7a06 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isfinite.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISFINITE_H__ +#define __CLC_RELATIONAL_CLC_ISFINITE_H__ + +#define FUNCTION __clc_isfinite +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_RELATIONAL_CLC_ISFINITE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isgreater.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isgreater.h new file mode 100644 index 0000000000..e2e6911a80 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isgreater.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISGREATER_H__ +#define __CLC_RELATIONAL_CLC_ISGREATER_H__ + +#define FUNCTION __clc_isgreater +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_RELATIONAL_CLC_ISGREATER_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isgreaterequal.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isgreaterequal.h new file mode 100644 index 0000000000..3fe8835aff --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isgreaterequal.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISGREATEREQUAL_H__ +#define __CLC_RELATIONAL_CLC_ISGREATEREQUAL_H__ + +#define FUNCTION __clc_isgreaterequal +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_RELATIONAL_CLC_ISGREATEREQUAL_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isinf.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isinf.h new file mode 100644 index 0000000000..39a9de6c43 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isinf.h @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISINF_H__ +#define __CLC_RELATIONAL_CLC_ISINF_H__ + +#include +#include + +#define _CLC_ISINF_DECL(RET_TYPE, ARG_TYPE) \ + _CLC_OVERLOAD _CLC_DECL RET_TYPE __clc_isinf(ARG_TYPE); + +#define _CLC_VECTOR_ISINF_DECL(RET_TYPE, ARG_TYPE) \ + _CLC_ISINF_DECL(RET_TYPE##2, ARG_TYPE##2) \ + _CLC_ISINF_DECL(RET_TYPE##3, ARG_TYPE##3) \ + _CLC_ISINF_DECL(RET_TYPE##4, ARG_TYPE##4) \ + _CLC_ISINF_DECL(RET_TYPE##8, ARG_TYPE##8) \ + _CLC_ISINF_DECL(RET_TYPE##16, ARG_TYPE##16) + +_CLC_ISINF_DECL(int, float) +_CLC_VECTOR_ISINF_DECL(int, float) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +_CLC_ISINF_DECL(int, double) +_CLC_VECTOR_ISINF_DECL(long, double) +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +_CLC_ISINF_DECL(int, half) +_CLC_VECTOR_ISINF_DECL(short, half) +#endif + +#undef _CLC_ISINF_DECL +#undef _CLC_VECTOR_ISINF_DECL + +#endif // __CLC_RELATIONAL_CLC_ISINF_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isless.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isless.h new file mode 100644 index 0000000000..01384cf6fa --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isless.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISLESS_H__ +#define __CLC_RELATIONAL_CLC_ISLESS_H__ + +#define FUNCTION __clc_isless +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_RELATIONAL_CLC_ISLESS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_islessequal.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_islessequal.h new file mode 100644 index 0000000000..a4b77a451b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_islessequal.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISLESSEQUAL_H__ +#define __CLC_RELATIONAL_CLC_ISLESSEQUAL_H__ + +#define FUNCTION __clc_islessequal +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_RELATIONAL_CLC_ISLESSEQUAL_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_islessgreater.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_islessgreater.h new file mode 100644 index 0000000000..9fb6d641bf --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_islessgreater.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISLESSGREATER_H__ +#define __CLC_RELATIONAL_CLC_ISLESSGREATER_H__ + +#define FUNCTION __clc_islessgreater +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_RELATIONAL_CLC_ISLESSGREATER_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isnan.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isnan.h new file mode 100644 index 0000000000..d0821a3c52 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isnan.h @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISNAN_H__ +#define __CLC_RELATIONAL_CLC_ISNAN_H__ + +#include +#include + +#define _CLC_ISNAN_DECL(RET_TYPE, ARG_TYPE) \ + _CLC_OVERLOAD _CLC_DECL RET_TYPE __clc_isnan(ARG_TYPE); + +#define _CLC_VECTOR_ISNAN_DECL(RET_TYPE, ARG_TYPE) \ + _CLC_ISNAN_DECL(RET_TYPE##2, ARG_TYPE##2) \ + _CLC_ISNAN_DECL(RET_TYPE##3, ARG_TYPE##3) \ + _CLC_ISNAN_DECL(RET_TYPE##4, ARG_TYPE##4) \ + _CLC_ISNAN_DECL(RET_TYPE##8, ARG_TYPE##8) \ + _CLC_ISNAN_DECL(RET_TYPE##16, ARG_TYPE##16) + +_CLC_ISNAN_DECL(int, float) +_CLC_VECTOR_ISNAN_DECL(int, float) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +_CLC_ISNAN_DECL(int, double) +_CLC_VECTOR_ISNAN_DECL(long, double) +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +_CLC_ISNAN_DECL(int, half) +_CLC_VECTOR_ISNAN_DECL(short, half) +#endif + +#undef _CLC_ISNAN_DECL +#undef _CLC_VECTOR_ISNAN_DECL + +#endif // __CLC_RELATIONAL_CLC_ISNAN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isnormal.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isnormal.h new file mode 100644 index 0000000000..d580fed5a7 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isnormal.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISNORMAL_H__ +#define __CLC_RELATIONAL_CLC_ISNORMAL_H__ + +#define FUNCTION __clc_isnormal +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_RELATIONAL_CLC_ISNORMAL_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isnotequal.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isnotequal.h new file mode 100644 index 0000000000..16982fc3c5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isnotequal.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISNOTEQUAL_H__ +#define __CLC_RELATIONAL_CLC_ISNOTEQUAL_H__ + +#define FUNCTION __clc_isnotequal +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_RELATIONAL_CLC_ISNOTEQUAL_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isordered.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isordered.h new file mode 100644 index 0000000000..7ba2666210 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isordered.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISORDERED_H__ +#define __CLC_RELATIONAL_CLC_ISORDERED_H__ + +#define FUNCTION __clc_isordered +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_RELATIONAL_CLC_ISORDERED_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isunordered.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isunordered.h new file mode 100644 index 0000000000..eac158d245 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_isunordered.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_ISUNORDERED_H__ +#define __CLC_RELATIONAL_CLC_ISUNORDERED_H__ + +#define FUNCTION __clc_isunordered +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_RELATIONAL_CLC_ISUNORDERED_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_select.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_select.h new file mode 100644 index 0000000000..de0a9afa6b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_select.h @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_SELECT_H__ +#define __CLC_RELATIONAL_CLC_SELECT_H__ + +#include + +#define __CLC_SELECT_FN __clc_select + +#define __CLC_BODY +#include +#define __CLC_BODY +#include + +#undef __CLC_SELECT_FN + +#endif // __CLC_RELATIONAL_CLC_SELECT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_select_decl.inc b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_select_decl.inc new file mode 100644 index 0000000000..1cf026dc8d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_select_decl.inc @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x, + __CLC_GENTYPE y, + __CLC_S_GENTYPE z); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x, + __CLC_GENTYPE y, + __CLC_U_GENTYPE z); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_select_impl.inc b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_select_impl.inc new file mode 100644 index 0000000000..4e2d7c030c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_select_impl.inc @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x, + __CLC_GENTYPE y, + __CLC_S_GENTYPE z) { + __CLC_SELECT_DEF(x, y, z); +} + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x, + __CLC_GENTYPE y, + __CLC_U_GENTYPE z) { + __CLC_SELECT_DEF(x, y, z); +} diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_signbit.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_signbit.h new file mode 100644 index 0000000000..892263a09e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/clc_signbit.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_CLC_SIGNBIT_H__ +#define __CLC_RELATIONAL_CLC_SIGNBIT_H__ + +#define FUNCTION __clc_signbit +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_RELATIONAL_CLC_SIGNBIT_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/floatn.inc b/local/recipes/dev/libclc/source/clc/include/clc/relational/floatn.inc new file mode 100644 index 0000000000..263937f6ee --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/floatn.inc @@ -0,0 +1,132 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_FLOATN float +#define __CLC_INTN int +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN float2 +#define __CLC_INTN int2 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN float3 +#define __CLC_INTN int3 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN float4 +#define __CLC_INTN int4 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN float8 +#define __CLC_INTN int8 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN float16 +#define __CLC_INTN int16 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#undef __CLC_FLOAT +#undef __CLC_INT + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +#define __CLC_FLOATN double +#define __CLC_INTN int +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN double2 +#define __CLC_INTN long2 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN double3 +#define __CLC_INTN long3 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN double4 +#define __CLC_INTN long4 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN double8 +#define __CLC_INTN long8 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN double16 +#define __CLC_INTN long16 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#endif +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +#define __CLC_FLOATN half +#define __CLC_INTN int +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN half2 +#define __CLC_INTN short2 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN half3 +#define __CLC_INTN short3 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN half4 +#define __CLC_INTN short4 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN half8 +#define __CLC_INTN short8 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#define __CLC_FLOATN half16 +#define __CLC_INTN short16 +#include __CLC_BODY +#undef __CLC_INTN +#undef __CLC_FLOATN + +#endif + +#undef __CLC_BODY diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/relational.h b/local/recipes/dev/libclc/source/clc/include/clc/relational/relational.h new file mode 100644 index 0000000000..e2b577019a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/relational.h @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_RELATIONAL_RELATIONAL_H__ +#define __CLC_RELATIONAL_RELATIONAL_H__ + +/* + * Contains relational macros that have to return 1 for scalar and -1 for vector + * when the result is true. + */ + +#define _CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(RET_TYPE, RET_TYPE_VEC, FUNCTION, \ + ARG1_TYPE, ARG2_TYPE) \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \ + return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##2 FUNCTION(ARG1_TYPE##2 x, \ + ARG2_TYPE##2 y) { \ + return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##3 FUNCTION(ARG1_TYPE##3 x, \ + ARG2_TYPE##3 y) { \ + return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##4 FUNCTION(ARG1_TYPE##4 x, \ + ARG2_TYPE##4 y) { \ + return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##8 FUNCTION(ARG1_TYPE##8 x, \ + ARG2_TYPE##8 y) { \ + return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##16 FUNCTION(ARG1_TYPE##16 x, \ + ARG2_TYPE##16 y) { \ + return _CLC_RELATIONAL_OP(x, y); \ + } + +#define fcNan (__FPCLASS_SNAN | __FPCLASS_QNAN) +#define fcInf (__FPCLASS_POSINF | __FPCLASS_NEGINF) +#define fcNormal (__FPCLASS_POSNORMAL | __FPCLASS_NEGNORMAL) +#define fcPosFinite \ + (__FPCLASS_POSNORMAL | __FPCLASS_POSSUBNORMAL | __FPCLASS_POSZERO) +#define fcNegFinite \ + (__FPCLASS_NEGNORMAL | __FPCLASS_NEGSUBNORMAL | __FPCLASS_NEGZERO) +#define fcFinite (fcPosFinite | fcNegFinite) + +#define _CLC_DEFINE_ISFPCLASS_VEC(RET_TYPE, FUNCTION, MASK, ARG_TYPE) \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ + return (RET_TYPE)(__builtin_isfpclass(x, (MASK)) != (RET_TYPE)0); \ + } + +#define _CLC_DEFINE_ISFPCLASS(RET_TYPE, VEC_RET_TYPE, FUNCTION, MASK, \ + ARG_TYPE) \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ + return __builtin_isfpclass(x, (MASK)); \ + } \ + _CLC_DEFINE_ISFPCLASS_VEC(VEC_RET_TYPE##2, FUNCTION, MASK, ARG_TYPE##2) \ + _CLC_DEFINE_ISFPCLASS_VEC(VEC_RET_TYPE##3, FUNCTION, MASK, ARG_TYPE##3) \ + _CLC_DEFINE_ISFPCLASS_VEC(VEC_RET_TYPE##4, FUNCTION, MASK, ARG_TYPE##4) \ + _CLC_DEFINE_ISFPCLASS_VEC(VEC_RET_TYPE##8, FUNCTION, MASK, ARG_TYPE##8) \ + _CLC_DEFINE_ISFPCLASS_VEC(VEC_RET_TYPE##16, FUNCTION, MASK, ARG_TYPE##16) + +#endif // __CLC_RELATIONAL_RELATIONAL_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/relational/unary_decl.inc b/local/recipes/dev/libclc/source/clc/include/clc/relational/unary_decl.inc new file mode 100644 index 0000000000..b9fb36c905 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/relational/unary_decl.inc @@ -0,0 +1,9 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_INTN FUNCTION(__CLC_FLOATN x); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_decl.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_decl.inc new file mode 100644 index 0000000000..ff4739dcdb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_decl.inc @@ -0,0 +1,10 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + __CLC_GENTYPE y); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_decl_with_int_second_arg.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_decl_with_int_second_arg.inc new file mode 100644 index 0000000000..a86d89b4fc --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_decl_with_int_second_arg.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, __CLC_INTN y); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_decl_with_scalar_second_arg.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_decl_with_scalar_second_arg.inc new file mode 100644 index 0000000000..05a5339317 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_decl_with_scalar_second_arg.inc @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + __CLC_GENTYPE y); + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, + __CLC_SCALAR_GENTYPE y); +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def.inc new file mode 100644 index 0000000000..9ab5a7c5a7 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def.inc @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE a, + __CLC_GENTYPE b) { + return __IMPL_FUNCTION(FUNCTION)(a, b); +} diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def_scalarize.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def_scalarize.inc new file mode 100644 index 0000000000..53d4d3fa23 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def_scalarize.inc @@ -0,0 +1,131 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifdef __CLC_SCALAR + +#ifndef __CLC_MIN_VECSIZE +#define __CLC_MIN_VECSIZE 2 +#endif + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION FUNCTION +#endif + +#ifndef __CLC_DEF_SPEC +#define __CLC_DEF_SPEC _CLC_DEF +#endif + +#ifndef __CLC_RET_TYPE +#define __CLC_RET_TYPE __CLC_GENTYPE +#endif + +#ifndef __CLC_ARG1_TYPE +#define __CLC_ARG1_TYPE __CLC_GENTYPE +#endif + +#ifndef __CLC_ARG2_TYPE +#define __CLC_ARG2_TYPE __CLC_GENTYPE +#endif + +#if __CLC_MIN_VECSIZE == 1 +_CLC_OVERLOAD __CLC_DEF_SPEC __CLC_RET_TYPE FUNCTION(__CLC_ARG1_TYPE x, + __CLC_ARG2_TYPE y) { + return __IMPL_FUNCTION(x, y); +} +#endif // __CLC_MIN_VECSIZE == 1 + +#if __CLC_MIN_VECSIZE <= 2 +#define __CLC_RET_TYPE2 __CLC_XCONCAT(__CLC_RET_TYPE, 2) +#define __CLC_ARG1_TYPE2 __CLC_XCONCAT(__CLC_ARG1_TYPE, 2) +#define __CLC_ARG2_TYPE2 __CLC_XCONCAT(__CLC_ARG2_TYPE, 2) +_CLC_OVERLOAD __CLC_DEF_SPEC __CLC_RET_TYPE2 FUNCTION(__CLC_ARG1_TYPE2 x, + __CLC_ARG2_TYPE2 y) { + return (__CLC_RET_TYPE2)(__IMPL_FUNCTION(x.s0, y.s0), + __IMPL_FUNCTION(x.s1, y.s1)); +} +#undef __CLC_RET_TYPE2 +#undef __CLC_ARG1_TYPE2 +#undef __CLC_ARG2_TYPE2 +#endif // __CLC_MIN_VECSIZE <= 2 + +#if __CLC_MIN_VECSIZE > 3 +#error "__CLC_MIN_VECSIZE > 3 isn't implemented" +#endif + +#define __CLC_RET_TYPE3 __CLC_XCONCAT(__CLC_RET_TYPE, 3) +#define __CLC_ARG1_TYPE3 __CLC_XCONCAT(__CLC_ARG1_TYPE, 3) +#define __CLC_ARG2_TYPE3 __CLC_XCONCAT(__CLC_ARG2_TYPE, 3) +_CLC_OVERLOAD __CLC_DEF_SPEC __CLC_RET_TYPE3 FUNCTION(__CLC_ARG1_TYPE3 x, + __CLC_ARG2_TYPE3 y) { + return (__CLC_RET_TYPE3)(__IMPL_FUNCTION(x.s0, y.s0), + __IMPL_FUNCTION(x.s1, y.s1), + __IMPL_FUNCTION(x.s2, y.s2)); +} +#undef __CLC_RET_TYPE3 +#undef __CLC_ARG1_TYPE3 +#undef __CLC_ARG2_TYPE3 + +#define __CLC_RET_TYPE4 __CLC_XCONCAT(__CLC_RET_TYPE, 4) +#define __CLC_ARG1_TYPE4 __CLC_XCONCAT(__CLC_ARG1_TYPE, 4) +#define __CLC_ARG2_TYPE4 __CLC_XCONCAT(__CLC_ARG2_TYPE, 4) +_CLC_OVERLOAD __CLC_DEF_SPEC __CLC_RET_TYPE4 FUNCTION(__CLC_ARG1_TYPE4 x, + __CLC_ARG2_TYPE4 y) { + return (__CLC_RET_TYPE4)(__IMPL_FUNCTION(x.s0, y.s0), + __IMPL_FUNCTION(x.s1, y.s1), + __IMPL_FUNCTION(x.s2, y.s2), + __IMPL_FUNCTION(x.s3, y.s3)); +} +#undef __CLC_RET_TYPE4 +#undef __CLC_ARG1_TYPE4 +#undef __CLC_ARG2_TYPE4 + +#define __CLC_RET_TYPE8 __CLC_XCONCAT(__CLC_RET_TYPE, 8) +#define __CLC_ARG1_TYPE8 __CLC_XCONCAT(__CLC_ARG1_TYPE, 8) +#define __CLC_ARG2_TYPE8 __CLC_XCONCAT(__CLC_ARG2_TYPE, 8) +_CLC_OVERLOAD __CLC_DEF_SPEC __CLC_RET_TYPE8 FUNCTION(__CLC_ARG1_TYPE8 x, + __CLC_ARG2_TYPE8 y) { + return ( + __CLC_RET_TYPE8)(__IMPL_FUNCTION(x.s0, y.s0), __IMPL_FUNCTION(x.s1, y.s1), + __IMPL_FUNCTION(x.s2, y.s2), __IMPL_FUNCTION(x.s3, y.s3), + __IMPL_FUNCTION(x.s4, y.s4), __IMPL_FUNCTION(x.s5, y.s5), + __IMPL_FUNCTION(x.s6, y.s6), + __IMPL_FUNCTION(x.s7, y.s7)); +} +#undef __CLC_RET_TYPE8 +#undef __CLC_ARG1_TYPE8 +#undef __CLC_ARG2_TYPE8 + +#define __CLC_RET_TYPE16 __CLC_XCONCAT(__CLC_RET_TYPE, 16) +#define __CLC_ARG1_TYPE16 __CLC_XCONCAT(__CLC_ARG1_TYPE, 16) +#define __CLC_ARG2_TYPE16 __CLC_XCONCAT(__CLC_ARG2_TYPE, 16) +_CLC_OVERLOAD __CLC_DEF_SPEC __CLC_RET_TYPE16 FUNCTION(__CLC_ARG1_TYPE16 x, + __CLC_ARG2_TYPE16 y) { + return (__CLC_RET_TYPE16)(__IMPL_FUNCTION(x.s0, y.s0), + __IMPL_FUNCTION(x.s1, y.s1), + __IMPL_FUNCTION(x.s2, y.s2), + __IMPL_FUNCTION(x.s3, y.s3), + __IMPL_FUNCTION(x.s4, y.s4), + __IMPL_FUNCTION(x.s5, y.s5), + __IMPL_FUNCTION(x.s6, y.s6), + __IMPL_FUNCTION(x.s7, y.s7), + __IMPL_FUNCTION(x.s8, y.s8), + __IMPL_FUNCTION(x.s9, y.s9), + __IMPL_FUNCTION(x.sa, y.sa), + __IMPL_FUNCTION(x.sb, y.sb), + __IMPL_FUNCTION(x.sc, y.sc), + __IMPL_FUNCTION(x.sd, y.sd), + __IMPL_FUNCTION(x.se, y.se), + __IMPL_FUNCTION(x.sf, y.sf)); +} +#undef __CLC_RET_TYPE16 +#undef __CLC_ARG1_TYPE16 +#undef __CLC_ARG2_TYPE16 + +#endif // __CLC_SCALAR diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def_with_int_second_arg.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def_with_int_second_arg.inc new file mode 100644 index 0000000000..262b6b21cc --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def_with_int_second_arg.inc @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, __CLC_INTN y) { + return __IMPL_FUNCTION(FUNCTION)(x, y); +} diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def_with_scalar_second_arg.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def_with_scalar_second_arg.inc new file mode 100644 index 0000000000..103f775ab8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/binary_def_with_scalar_second_arg.inc @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE a, + __CLC_GENTYPE b) { + return __IMPL_FUNCTION(FUNCTION)(a, b); +} + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE a, + __CLC_SCALAR_GENTYPE b) { + return __IMPL_FUNCTION(FUNCTION)(a, (__CLC_GENTYPE)b); +} +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_clamp.h b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_clamp.h new file mode 100644 index 0000000000..c4a482d122 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_clamp.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_SHARED_CLC_CLAMP_H__ +#define __CLC_SHARED_CLC_CLAMP_H__ + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include + +#endif // __CLC_SHARED_CLC_CLAMP_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_clamp.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_clamp.inc new file mode 100644 index 0000000000..c1280a6f69 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_clamp.inc @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_clamp(__CLC_GENTYPE x, + __CLC_GENTYPE y, + __CLC_GENTYPE z); + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_clamp(__CLC_GENTYPE x, + __CLC_SCALAR_GENTYPE y, + __CLC_SCALAR_GENTYPE z); +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_less_aligned_types.h b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_less_aligned_types.h new file mode 100644 index 0000000000..73e436147c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_less_aligned_types.h @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Defines types to be used with (CLC) vstore and vload functions. These are +// vector types whose alignment is that of their respective scalar types. +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_SHARED_CLC_LESS_ALIGNED_TYPES_H__ +#define __CLC_SHARED_CLC_LESS_ALIGNED_TYPES_H__ + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include + +#endif // __CLC_SHARED_CLC_LESS_ALIGNED_TYPES_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_less_aligned_types.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_less_aligned_types.inc new file mode 100644 index 0000000000..45d69ea72f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_less_aligned_types.inc @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Defines types to be used with (CLC) vstore and vload functions. These are +// vector types whose alignment is that of their respective scalar types. +// +//===----------------------------------------------------------------------===// + +#ifdef __CLC_SCALAR + +typedef __CLC_GENTYPE __CLC_XCONCAT(less_aligned_, __CLC_GENTYPE); + +#else + +typedef __CLC_GENTYPE __CLC_XCONCAT(less_aligned_, __CLC_GENTYPE) + __attribute__((aligned(sizeof(__CLC_SCALAR_GENTYPE)))); + +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_max.h b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_max.h new file mode 100644 index 0000000000..470d56cf31 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_max.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_SHARED_CLC_MAX_H__ +#define __CLC_SHARED_CLC_MAX_H__ + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include + +#endif // __CLC_SHARED_CLC_MAX_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_max.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_max.inc new file mode 100644 index 0000000000..ca99c1264a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_max.inc @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_max(__CLC_GENTYPE a, + __CLC_GENTYPE b); + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_max(__CLC_GENTYPE a, + __CLC_SCALAR_GENTYPE b); +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_min.h b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_min.h new file mode 100644 index 0000000000..3931d4684a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_min.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_SHARED_CLC_MIN_H__ +#define __CLC_SHARED_CLC_MIN_H__ + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include + +#endif // __CLC_SHARED_CLC_MIN_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_min.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_min.inc new file mode 100644 index 0000000000..c7cfe23ec3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_min.inc @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_min(__CLC_GENTYPE a, + __CLC_GENTYPE b); + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_min(__CLC_GENTYPE a, + __CLC_SCALAR_GENTYPE b); +#endif diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vload.h b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vload.h new file mode 100644 index 0000000000..c3dbe0696c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vload.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_SHARED_CLC_VLOAD_H__ +#define __CLC_SHARED_CLC_VLOAD_H__ + +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include + +#endif // __CLC_SHARED_CLC_VLOAD_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vload.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vload.inc new file mode 100644 index 0000000000..8f3b00ec04 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vload.inc @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#define CLC_VLOAD_NAME __CLC_XCONCAT(__clc_vload, __CLC_VECSIZE) +#define CLC_VLOAD_HALF_NAME __CLC_XCONCAT(__clc_vload_half, __CLC_VECSIZE) +#define CLC_VLOADA_HALF_NAME __CLC_XCONCAT(__clc_vloada_half, __CLC_VECSIZE) + +#ifndef __CLC_SCALAR + +#define CLC_VLOAD_TY __CLC_XCONCAT(less_aligned_, __CLC_GENTYPE) + +#define CLC_VLOAD_DECL(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL CLC_VLOAD_TY CLC_VLOAD_NAME( \ + size_t offset, const ADDRSPACE __CLC_SCALAR_GENTYPE *x); + +CLC_VLOAD_DECL(__private) +CLC_VLOAD_DECL(__local) +CLC_VLOAD_DECL(__constant) +CLC_VLOAD_DECL(__global) + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +CLC_VLOAD_DECL(__generic) +#endif + +#undef CLC_VLOAD_DECL +#undef CLC_VLOAD_TY + +#endif // __CLC_SCALAR + +// vload_half and vloada_half are available even if cl_khr_fp16 is unavailable. +// Declare these functions when working on float types, which we know are +// always available. +#ifdef __CLC_FPSIZE +#if __CLC_FPSIZE == 32 + +#define CLC_VLOAD_HALF_DECL(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE CLC_VLOAD_HALF_NAME( \ + size_t offset, const ADDRSPACE half *mem); \ + \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE CLC_VLOADA_HALF_NAME( \ + size_t offset, const ADDRSPACE half *mem); + +CLC_VLOAD_HALF_DECL(__private) +CLC_VLOAD_HALF_DECL(__local) +CLC_VLOAD_HALF_DECL(__constant) +CLC_VLOAD_HALF_DECL(__global) + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +CLC_VLOAD_HALF_DECL(__generic) +#endif + +#undef CLC_VLOAD_HALF_DECL + +#endif +#endif + +#undef CLC_VLOAD_NAME +#undef CLC_VLOAD_HALF_NAME +#undef CLC_VLOADA_HALF_NAME diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vstore.h b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vstore.h new file mode 100644 index 0000000000..647dc7da1a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vstore.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_SHARED_CLC_VSTORE_H__ +#define __CLC_SHARED_CLC_VSTORE_H__ + +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include + +#endif // __CLC_SHARED_CLC_VSTORE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vstore.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vstore.inc new file mode 100644 index 0000000000..38d54b2f1b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/clc_vstore.inc @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#define CLC_VSTORE_TY __CLC_XCONCAT(less_aligned_, __CLC_GENTYPE) +#define CLC_VSTORE_NAME __CLC_XCONCAT(__clc_vstore, __CLC_VECSIZE) +#define CLC_VSTORE_HALF_NAME(x) \ + __CLC_XCONCAT(__CLC_XCONCAT(__clc_vstore_half, __CLC_VECSIZE), x) +#define CLC_VSTOREA_HALF_NAME(x) \ + __CLC_XCONCAT(__CLC_XCONCAT(__clc_vstorea_half, __CLC_VECSIZE), x) + +#ifndef __CLC_SCALAR + +#define CLC_VSTORE_DECL(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL void CLC_VSTORE_NAME( \ + CLC_VSTORE_TY data, size_t offset, ADDRSPACE __CLC_SCALAR_GENTYPE *p); + +CLC_VSTORE_DECL(__private) +CLC_VSTORE_DECL(__local) +CLC_VSTORE_DECL(__global) + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +CLC_VSTORE_DECL(__generic) +#endif + +#undef CLC_VSTORE_DECL + +#endif // __CLC_SCALAR + +// vstore_half and vstorea_half are available even if cl_khr_fp16 is +// unavailable. +#ifdef __CLC_FPSIZE +#if __CLC_FPSIZE == 32 || __CLC_FPSIZE == 64 + +#define CLC_VSTORE_HALF_DECL(ADDRSPACE, SUFFIX) \ + _CLC_OVERLOAD _CLC_DECL void CLC_VSTORE_HALF_NAME(SUFFIX)( \ + CLC_VSTORE_TY data, size_t offset, ADDRSPACE half *p); \ + \ + _CLC_OVERLOAD _CLC_DECL void CLC_VSTOREA_HALF_NAME(SUFFIX)( \ + CLC_VSTORE_TY data, size_t offset, ADDRSPACE half *p); + +#define CLC_VSTORE_HALF_DECL_ALL_MODES(ADDRSPACE) \ + CLC_VSTORE_HALF_DECL(ADDRSPACE, ) \ + CLC_VSTORE_HALF_DECL(ADDRSPACE, _rtz) \ + CLC_VSTORE_HALF_DECL(ADDRSPACE, _rtn) \ + CLC_VSTORE_HALF_DECL(ADDRSPACE, _rtp) \ + CLC_VSTORE_HALF_DECL(ADDRSPACE, _rte) + +CLC_VSTORE_HALF_DECL_ALL_MODES(__private) +CLC_VSTORE_HALF_DECL_ALL_MODES(__local) +CLC_VSTORE_HALF_DECL_ALL_MODES(__global) + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +CLC_VSTORE_HALF_DECL_ALL_MODES(__generic) +#endif + +#undef CLC_VSTORE_HALF_DECL +#undef CLC_VSTORE_HALF_DECL_ALL_MODES + +#endif +#endif + +#undef CLC_VSTORE_TY +#undef CLC_VSTORE_NAME +#undef CLC_VSTORE_HALF_NAME +#undef CLC_VSTOREA_HALF_NAME diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/ternary_decl.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/ternary_decl.inc new file mode 100644 index 0000000000..a76db1eefb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/ternary_decl.inc @@ -0,0 +1,10 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE a, __CLC_GENTYPE b, + __CLC_GENTYPE c); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/ternary_def.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/ternary_def.inc new file mode 100644 index 0000000000..92134e8cb6 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/ternary_def.inc @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE a, __CLC_GENTYPE b, + __CLC_GENTYPE c) { + return __IMPL_FUNCTION(FUNCTION)(a, b, c); +} diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/ternary_def_scalarize.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/ternary_def_scalarize.inc new file mode 100644 index 0000000000..c216fa4db4 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/ternary_def_scalarize.inc @@ -0,0 +1,153 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifdef __CLC_SCALAR + +#ifndef __CLC_MIN_VECSIZE +#define __CLC_MIN_VECSIZE 2 +#endif + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION FUNCTION +#endif + +#ifndef __CLC_DEF_SPEC +#define __CLC_DEF_SPEC _CLC_DEF +#endif + +#ifndef __CLC_RET_TYPE +#define __CLC_RET_TYPE __CLC_GENTYPE +#endif + +#ifndef __CLC_ARG1_TYPE +#define __CLC_ARG1_TYPE __CLC_GENTYPE +#endif + +#ifndef __CLC_ARG2_TYPE +#define __CLC_ARG2_TYPE __CLC_GENTYPE +#endif + +#ifndef __CLC_ARG3_TYPE +#define __CLC_ARG3_TYPE __CLC_GENTYPE +#endif + +#if __CLC_MIN_VECSIZE == 1 +_CLC_OVERLOAD __CLC_DEF_SPEC __CLC_RET_TYPE FUNCTION(__CLC_ARG1_TYPE x, + __CLC_ARG2_TYPE y, + __CLC_ARG3_TYPE z) { + return __IMPL_FUNCTION(x, y, z); +} +#endif // __CLC_MIN_VECSIZE == 1 + +#if __CLC_MIN_VECSIZE <= 2 +#define __CLC_RET_TYPE2 __CLC_XCONCAT(__CLC_RET_TYPE, 2) +#define __CLC_ARG1_TYPE2 __CLC_XCONCAT(__CLC_ARG1_TYPE, 2) +#define __CLC_ARG2_TYPE2 __CLC_XCONCAT(__CLC_ARG2_TYPE, 2) +#define __CLC_ARG3_TYPE2 __CLC_XCONCAT(__CLC_ARG3_TYPE, 2) +_CLC_OVERLOAD __CLC_DEF_SPEC __CLC_RET_TYPE2 FUNCTION(__CLC_ARG1_TYPE2 x, + __CLC_ARG2_TYPE2 y, + __CLC_ARG3_TYPE2 z) { + return (__CLC_RET_TYPE2)(__IMPL_FUNCTION(x.s0, y.s0, z.s0), + __IMPL_FUNCTION(x.s1, y.s1, z.s1)); +} +#undef __CLC_RET_TYPE2 +#undef __CLC_ARG1_TYPE2 +#undef __CLC_ARG2_TYPE2 +#undef __CLC_ARG3_TYPE2 +#endif // __CLC_MIN_VECSIZE <= 2 + +#if __CLC_MIN_VECSIZE > 3 +#error "__CLC_MIN_VECSIZE > 3 isn't implemented" +#endif + +#define __CLC_RET_TYPE3 __CLC_XCONCAT(__CLC_RET_TYPE, 3) +#define __CLC_ARG1_TYPE3 __CLC_XCONCAT(__CLC_ARG1_TYPE, 3) +#define __CLC_ARG2_TYPE3 __CLC_XCONCAT(__CLC_ARG2_TYPE, 3) +#define __CLC_ARG3_TYPE3 __CLC_XCONCAT(__CLC_ARG3_TYPE, 3) +_CLC_OVERLOAD __CLC_DEF_SPEC __CLC_RET_TYPE3 FUNCTION(__CLC_ARG1_TYPE3 x, + __CLC_ARG2_TYPE3 y, + __CLC_ARG3_TYPE3 z) { + return (__CLC_RET_TYPE3)(__IMPL_FUNCTION(x.s0, y.s0, z.s0), + __IMPL_FUNCTION(x.s1, y.s1, z.s1), + __IMPL_FUNCTION(x.s2, y.s2, z.s2)); +} +#undef __CLC_RET_TYPE3 +#undef __CLC_ARG1_TYPE3 +#undef __CLC_ARG2_TYPE3 +#undef __CLC_ARG3_TYPE3 + +#define __CLC_RET_TYPE4 __CLC_XCONCAT(__CLC_RET_TYPE, 4) +#define __CLC_ARG1_TYPE4 __CLC_XCONCAT(__CLC_ARG1_TYPE, 4) +#define __CLC_ARG2_TYPE4 __CLC_XCONCAT(__CLC_ARG2_TYPE, 4) +#define __CLC_ARG3_TYPE4 __CLC_XCONCAT(__CLC_ARG3_TYPE, 4) +_CLC_OVERLOAD __CLC_DEF_SPEC __CLC_RET_TYPE4 FUNCTION(__CLC_ARG1_TYPE4 x, + __CLC_ARG2_TYPE4 y, + __CLC_ARG3_TYPE4 z) { + return (__CLC_RET_TYPE4)(__IMPL_FUNCTION(x.s0, y.s0, z.s0), + __IMPL_FUNCTION(x.s1, y.s1, z.s1), + __IMPL_FUNCTION(x.s2, y.s2, z.s2), + __IMPL_FUNCTION(x.s3, y.s3, z.s3)); +} +#undef __CLC_RET_TYPE4 +#undef __CLC_ARG1_TYPE4 +#undef __CLC_ARG2_TYPE4 +#undef __CLC_ARG3_TYPE4 + +#define __CLC_RET_TYPE8 __CLC_XCONCAT(__CLC_RET_TYPE, 8) +#define __CLC_ARG1_TYPE8 __CLC_XCONCAT(__CLC_ARG1_TYPE, 8) +#define __CLC_ARG2_TYPE8 __CLC_XCONCAT(__CLC_ARG2_TYPE, 8) +#define __CLC_ARG3_TYPE8 __CLC_XCONCAT(__CLC_ARG3_TYPE, 8) +_CLC_OVERLOAD __CLC_DEF_SPEC __CLC_RET_TYPE8 FUNCTION(__CLC_ARG1_TYPE8 x, + __CLC_ARG2_TYPE8 y, + __CLC_ARG3_TYPE8 z) { + return (__CLC_RET_TYPE8)(__IMPL_FUNCTION(x.s0, y.s0, z.s0), + __IMPL_FUNCTION(x.s1, y.s1, z.s1), + __IMPL_FUNCTION(x.s2, y.s2, z.s2), + __IMPL_FUNCTION(x.s3, y.s3, z.s3), + __IMPL_FUNCTION(x.s4, y.s4, z.s4), + __IMPL_FUNCTION(x.s5, y.s5, z.s5), + __IMPL_FUNCTION(x.s6, y.s6, z.s6), + __IMPL_FUNCTION(x.s7, y.s7, z.s7)); +} +#undef __CLC_RET_TYPE8 +#undef __CLC_ARG1_TYPE8 +#undef __CLC_ARG2_TYPE8 +#undef __CLC_ARG3_TYPE8 + +#define __CLC_RET_TYPE16 __CLC_XCONCAT(__CLC_RET_TYPE, 16) +#define __CLC_ARG1_TYPE16 __CLC_XCONCAT(__CLC_ARG1_TYPE, 16) +#define __CLC_ARG2_TYPE16 __CLC_XCONCAT(__CLC_ARG2_TYPE, 16) +#define __CLC_ARG3_TYPE16 __CLC_XCONCAT(__CLC_ARG3_TYPE, 16) +_CLC_OVERLOAD __CLC_DEF_SPEC __CLC_RET_TYPE16 FUNCTION(__CLC_ARG1_TYPE16 x, + __CLC_ARG2_TYPE16 y, + __CLC_ARG3_TYPE16 z) { + return (__CLC_RET_TYPE16)(__IMPL_FUNCTION(x.s0, y.s0, z.s0), + __IMPL_FUNCTION(x.s1, y.s1, z.s1), + __IMPL_FUNCTION(x.s2, y.s2, z.s2), + __IMPL_FUNCTION(x.s3, y.s3, z.s3), + __IMPL_FUNCTION(x.s4, y.s4, z.s4), + __IMPL_FUNCTION(x.s5, y.s5, z.s5), + __IMPL_FUNCTION(x.s6, y.s6, z.s6), + __IMPL_FUNCTION(x.s7, y.s7, z.s7), + __IMPL_FUNCTION(x.s8, y.s8, z.s8), + __IMPL_FUNCTION(x.s9, y.s9, z.s9), + __IMPL_FUNCTION(x.sa, y.sa, z.sa), + __IMPL_FUNCTION(x.sb, y.sb, z.sb), + __IMPL_FUNCTION(x.sc, y.sc, z.sc), + __IMPL_FUNCTION(x.sd, y.sd, z.sd), + __IMPL_FUNCTION(x.se, y.se, z.se), + __IMPL_FUNCTION(x.sf, y.sf, z.sf)); +} +#undef __CLC_RET_TYPE16 +#undef __CLC_ARG1_TYPE16 +#undef __CLC_ARG2_TYPE16 +#undef __CLC_ARG3_TYPE16 + +#endif // __CLC_SCALAR diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/unary_decl.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/unary_decl.inc new file mode 100644 index 0000000000..ce1a71b828 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/unary_decl.inc @@ -0,0 +1,9 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x); diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/unary_def.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/unary_def.inc new file mode 100644 index 0000000000..e746a6bc89 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/unary_def.inc @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE a) { + return __IMPL_FUNCTION(FUNCTION)(a); +} diff --git a/local/recipes/dev/libclc/source/clc/include/clc/shared/unary_def_scalarize.inc b/local/recipes/dev/libclc/source/clc/include/clc/shared/unary_def_scalarize.inc new file mode 100644 index 0000000000..6c82babad2 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/shared/unary_def_scalarize.inc @@ -0,0 +1,97 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#ifdef __CLC_SCALAR + +#ifndef __CLC_MIN_VECSIZE +#define __CLC_MIN_VECSIZE 2 +#endif + +#ifndef __IMPL_FUNCTION +#define __IMPL_FUNCTION FUNCTION +#endif + +#ifndef __CLC_RET_TYPE +#define __CLC_RET_TYPE __CLC_GENTYPE +#endif + +#ifndef __CLC_ARG1_TYPE +#define __CLC_ARG1_TYPE __CLC_GENTYPE +#endif + +#ifndef __CLC_ARG2_TYPE +#define __CLC_ARG2_TYPE __CLC_GENTYPE +#endif + +#if __CLC_MIN_VECSIZE == 1 +_CLC_OVERLOAD _CLC_DEF __CLC_RET_TYPE FUNCTION(__CLC_ARG1_TYPE x) { + return __IMPL_FUNCTION(x); +} +#endif // __CLC_MIN_VECSIZE == 1 + +#if __CLC_MIN_VECSIZE <= 2 +#define __CLC_RET_TYPE2 __CLC_XCONCAT(__CLC_RET_TYPE, 2) +#define __CLC_ARG1_TYPE2 __CLC_XCONCAT(__CLC_ARG1_TYPE, 2) +_CLC_OVERLOAD _CLC_DEF __CLC_RET_TYPE2 FUNCTION(__CLC_ARG1_TYPE2 x) { + return (__CLC_RET_TYPE2)(__IMPL_FUNCTION(x.s0), __IMPL_FUNCTION(x.s1)); +} +#undef __CLC_RET_TYPE2 +#undef __CLC_ARG1_TYPE2 +#endif // __CLC_MIN_VECSIZE <= 2 + +#if __CLC_MIN_VECSIZE > 3 +#error "__CLC_MIN_VECSIZE > 3 isn't implemented" +#endif + +#define __CLC_RET_TYPE3 __CLC_XCONCAT(__CLC_RET_TYPE, 3) +#define __CLC_ARG1_TYPE3 __CLC_XCONCAT(__CLC_ARG1_TYPE, 3) +_CLC_OVERLOAD _CLC_DEF __CLC_RET_TYPE3 FUNCTION(__CLC_ARG1_TYPE3 x) { + return (__CLC_RET_TYPE3)(__IMPL_FUNCTION(x.s0), __IMPL_FUNCTION(x.s1), + __IMPL_FUNCTION(x.s2)); +} +#undef __CLC_RET_TYPE3 +#undef __CLC_ARG1_TYPE3 + +#define __CLC_RET_TYPE4 __CLC_XCONCAT(__CLC_RET_TYPE, 4) +#define __CLC_ARG1_TYPE4 __CLC_XCONCAT(__CLC_ARG1_TYPE, 4) +_CLC_OVERLOAD _CLC_DEF __CLC_RET_TYPE4 FUNCTION(__CLC_ARG1_TYPE4 x) { + return (__CLC_RET_TYPE4)(__IMPL_FUNCTION(x.s0), __IMPL_FUNCTION(x.s1), + __IMPL_FUNCTION(x.s2), __IMPL_FUNCTION(x.s3)); +} +#undef __CLC_RET_TYPE4 +#undef __CLC_ARG1_TYPE4 + +#define __CLC_RET_TYPE8 __CLC_XCONCAT(__CLC_RET_TYPE, 8) +#define __CLC_ARG1_TYPE8 __CLC_XCONCAT(__CLC_ARG1_TYPE, 8) +_CLC_OVERLOAD _CLC_DEF __CLC_RET_TYPE8 FUNCTION(__CLC_ARG1_TYPE8 x) { + return (__CLC_RET_TYPE8)(__IMPL_FUNCTION(x.s0), __IMPL_FUNCTION(x.s1), + __IMPL_FUNCTION(x.s2), __IMPL_FUNCTION(x.s3), + __IMPL_FUNCTION(x.s4), __IMPL_FUNCTION(x.s5), + __IMPL_FUNCTION(x.s6), __IMPL_FUNCTION(x.s7)); +} +#undef __CLC_RET_TYPE8 +#undef __CLC_ARG1_TYPE8 + +#define __CLC_RET_TYPE16 __CLC_XCONCAT(__CLC_RET_TYPE, 16) +#define __CLC_ARG1_TYPE16 __CLC_XCONCAT(__CLC_ARG1_TYPE, 16) +_CLC_OVERLOAD _CLC_DEF __CLC_RET_TYPE16 FUNCTION(__CLC_ARG1_TYPE16 x) { + return (__CLC_RET_TYPE16)(__IMPL_FUNCTION(x.s0), __IMPL_FUNCTION(x.s1), + __IMPL_FUNCTION(x.s2), __IMPL_FUNCTION(x.s3), + __IMPL_FUNCTION(x.s4), __IMPL_FUNCTION(x.s5), + __IMPL_FUNCTION(x.s6), __IMPL_FUNCTION(x.s7), + __IMPL_FUNCTION(x.s8), __IMPL_FUNCTION(x.s9), + __IMPL_FUNCTION(x.sa), __IMPL_FUNCTION(x.sb), + __IMPL_FUNCTION(x.sc), __IMPL_FUNCTION(x.sd), + __IMPL_FUNCTION(x.se), __IMPL_FUNCTION(x.sf)); +} +#undef __CLC_RET_TYPE16 +#undef __CLC_ARG1_TYPE16 + +#endif // __CLC_SCALAR diff --git a/local/recipes/dev/libclc/source/clc/include/clc/utils.h b/local/recipes/dev/libclc/source/clc/include/clc/utils.h new file mode 100644 index 0000000000..55afad0625 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/utils.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_UTILS_H__ +#define __CLC_UTILS_H__ + +#define __CLC_CONCAT(x, y) x##y +#define __CLC_XCONCAT(x, y) __CLC_CONCAT(x, y) + +#define __CLC_STR(x) #x +#define __CLC_XSTR(x) __CLC_STR(x) + +#endif // __CLC_UTILS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_global_id.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_global_id.h new file mode 100644 index 0000000000..da15ed8e53 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_global_id.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_GLOBAL_ID_H__ +#define __CLC_WORKITEM_CLC_GET_GLOBAL_ID_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL size_t __clc_get_global_id(uint dim); + +#endif // __CLC_WORKITEM_CLC_GET_GLOBAL_ID_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_global_offset.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_global_offset.h new file mode 100644 index 0000000000..639be48d0b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_global_offset.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_GLOBAL_OFFSET_H__ +#define __CLC_WORKITEM_CLC_GET_GLOBAL_OFFSET_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL size_t __clc_get_global_offset(uint dim); + +#endif // __CLC_WORKITEM_CLC_GET_GLOBAL_OFFSET_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_global_size.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_global_size.h new file mode 100644 index 0000000000..fce11f417b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_global_size.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_GLOBAL_SIZE_H__ +#define __CLC_WORKITEM_CLC_GET_GLOBAL_SIZE_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL size_t __clc_get_global_size(uint dim); + +#endif // __CLC_WORKITEM_CLC_GET_GLOBAL_SIZE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_group_id.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_group_id.h new file mode 100644 index 0000000000..3fd43cb77f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_group_id.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_GROUP_ID_H__ +#define __CLC_WORKITEM_CLC_GET_GROUP_ID_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL size_t __clc_get_group_id(uint dim); + +#endif // __CLC_WORKITEM_CLC_GET_GROUP_ID_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_local_id.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_local_id.h new file mode 100644 index 0000000000..c446127a5f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_local_id.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_LOCAL_ID_H__ +#define __CLC_WORKITEM_CLC_GET_LOCAL_ID_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL size_t __clc_get_local_id(uint dim); + +#endif // __CLC_WORKITEM_CLC_GET_LOCAL_ID_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_local_linear_id.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_local_linear_id.h new file mode 100644 index 0000000000..34c47f2afc --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_local_linear_id.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_LOCAL_LINEAR_ID_H__ +#define __CLC_WORKITEM_CLC_GET_LOCAL_LINEAR_ID_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL size_t __clc_get_local_linear_id(); + +#endif // __CLC_WORKITEM_CLC_GET_LOCAL_LINEAR_ID_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_local_size.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_local_size.h new file mode 100644 index 0000000000..7fe3c193e0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_local_size.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_LOCAL_SIZE_H__ +#define __CLC_WORKITEM_CLC_GET_LOCAL_SIZE_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL size_t __clc_get_local_size(uint dim); + +#endif // __CLC_WORKITEM_CLC_GET_LOCAL_SIZE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_max_sub_group_size.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_max_sub_group_size.h new file mode 100644 index 0000000000..8b521fe328 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_max_sub_group_size.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_MAX_SUB_GROUP_SIZE_H__ +#define __CLC_WORKITEM_CLC_GET_MAX_SUB_GROUP_SIZE_H__ + +#include + +_CLC_DEF _CLC_OVERLOAD uint __clc_get_max_sub_group_size(); + +#endif // __CLC_WORKITEM_CLC_GET_MAX_SUB_GROUP_SIZE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_num_groups.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_num_groups.h new file mode 100644 index 0000000000..f860944ad5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_num_groups.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_NUM_GROUPS_H__ +#define __CLC_WORKITEM_CLC_GET_NUM_GROUPS_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL size_t __clc_get_num_groups(uint dim); + +#endif // __CLC_WORKITEM_CLC_GET_NUM_GROUPS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_num_sub_groups.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_num_sub_groups.h new file mode 100644 index 0000000000..6965aef1bc --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_num_sub_groups.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_NUM_SUB_GROUPS_H__ +#define __CLC_WORKITEM_CLC_GET_NUM_SUB_GROUPS_H__ + +#include + +_CLC_DEF _CLC_OVERLOAD uint __clc_get_num_sub_groups(); + +#endif // __CLC_WORKITEM_CLC_GET_NUM_SUB_GROUPS_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_sub_group_id.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_sub_group_id.h new file mode 100644 index 0000000000..ac3d7bd30e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_sub_group_id.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_SUB_GROUP_ID_H__ +#define __CLC_WORKITEM_CLC_GET_SUB_GROUP_ID_H__ + +#include + +_CLC_DEF _CLC_OVERLOAD uint __clc_get_sub_group_id(); + +#endif // __CLC_WORKITEM_CLC_GET_SUB_GROUP_ID_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_sub_group_local_id.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_sub_group_local_id.h new file mode 100644 index 0000000000..06bb6f8b77 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_sub_group_local_id.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_SUB_GROUP_LOCAL_ID_H__ +#define __CLC_WORKITEM_CLC_GET_SUB_GROUP_LOCAL_ID_H__ + +#include + +_CLC_DEF _CLC_OVERLOAD uint __clc_get_sub_group_local_id(); + +#endif // __CLC_WORKITEM_CLC_GET_SUB_GROUP_LOCAL_ID_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_sub_group_size.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_sub_group_size.h new file mode 100644 index 0000000000..a6e8e49470 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_sub_group_size.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_SUB_GROUP_SIZE_H__ +#define __CLC_WORKITEM_CLC_GET_SUB_GROUP_SIZE_H__ + +#include + +_CLC_DEF _CLC_OVERLOAD uint __clc_get_sub_group_size(); + +#endif // __CLC_WORKITEM_CLC_GET_SUB_GROUP_SIZE_H__ diff --git a/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_work_dim.h b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_work_dim.h new file mode 100644 index 0000000000..7e2da4570c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/include/clc/workitem/clc_get_work_dim.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_WORKITEM_CLC_GET_WORK_DIM_H__ +#define __CLC_WORKITEM_CLC_GET_WORK_DIM_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL uint __clc_get_work_dim(); + +#endif // __CLC_WORKITEM_CLC_GET_WORK_DIM_H__ diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgcn/SOURCES b/local/recipes/dev/libclc/source/clc/lib/amdgcn/SOURCES new file mode 100644 index 0000000000..7bec1740f7 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgcn/SOURCES @@ -0,0 +1,8 @@ +math/clc_fmax.cl +math/clc_fmin.cl +math/clc_ldexp_override.cl +workitem/clc_get_global_offset.cl +workitem/clc_get_global_size.cl +workitem/clc_get_group_id.cl +workitem/clc_get_local_id.cl +workitem/clc_get_work_dim.cl diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgcn/math/clc_fmax.cl b/local/recipes/dev/libclc/source/clc/lib/amdgcn/math/clc_fmax.cl new file mode 100644 index 0000000000..cea90a7135 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgcn/math/clc_fmax.cl @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +_CLC_DEF _CLC_OVERLOAD float __clc_fmax(float x, float y) { + // fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise + // fmax instruction flushes the values for comparison, but outputs original + // denormal + x = __builtin_canonicalizef(x); + y = __builtin_canonicalizef(y); + return __builtin_fmaxf(x, y); +} + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEF _CLC_OVERLOAD double __clc_fmax(double x, double y) { + x = __builtin_canonicalize(x); + y = __builtin_canonicalize(y); + return __builtin_fmax(x, y); +} + +#endif +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_DEF _CLC_OVERLOAD half __clc_fmax(half x, half y) { + if (__clc_isnan(x)) + return y; + if (__clc_isnan(y)) + return x; + return (y < x) ? x : y; +} + +#endif + +#define FUNCTION __clc_fmax +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgcn/math/clc_fmin.cl b/local/recipes/dev/libclc/source/clc/lib/amdgcn/math/clc_fmin.cl new file mode 100644 index 0000000000..12bb0c6442 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgcn/math/clc_fmin.cl @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +_CLC_DEF _CLC_OVERLOAD float __clc_fmin(float x, float y) { + // fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise + // fmin instruction flushes the values for comparison, but outputs original + // denormal + x = __builtin_canonicalizef(x); + y = __builtin_canonicalizef(y); + return __builtin_fminf(x, y); +} + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEF _CLC_OVERLOAD double __clc_fmin(double x, double y) { + x = __builtin_canonicalize(x); + y = __builtin_canonicalize(y); + return __builtin_fmin(x, y); +} + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_DEF _CLC_OVERLOAD half __clc_fmin(half x, half y) { + if (__clc_isnan(x)) + return y; + if (__clc_isnan(y)) + return x; + return (y < x) ? y : x; +} + +#endif + +#define FUNCTION __clc_fmin +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgcn/math/clc_ldexp_override.cl b/local/recipes/dev/libclc/source/clc/lib/amdgcn/math/clc_ldexp_override.cl new file mode 100644 index 0000000000..b2990647a0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgcn/math/clc_ldexp_override.cl @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define FUNCTION __clc_ldexp +#define __CLC_ARG2_TYPE int +#define __CLC_MIN_VECSIZE 1 + +#ifdef __HAS_LDEXPF__ +// This defines all the ldexp(floatN, intN) variants. +#define __FLOAT_ONLY +#define __IMPL_FUNCTION __builtin_amdgcn_ldexpf +#define __CLC_BODY +#include +#undef __IMPL_FUNCTION +#endif + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +// This defines all the ldexp(doubleN, intN) variants. +#define __DOUBLE_ONLY +#define __IMPL_FUNCTION __builtin_amdgcn_ldexp +#define __CLC_BODY +#include +#undef __IMPL_FUNCTION +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_global_offset.cl b/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_global_offset.cl new file mode 100644 index 0000000000..24b04fb167 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_global_offset.cl @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#if __clang_major__ >= 8 +#define CONST_AS __constant +#elif __clang_major__ >= 7 +#define CONST_AS __attribute__((address_space(4))) +#else +#define CONST_AS __attribute__((address_space(2))) +#endif + +_CLC_DEF _CLC_OVERLOAD size_t __clc_get_global_offset(uint dim) { + CONST_AS uint *ptr = (CONST_AS uint *)__builtin_amdgcn_implicitarg_ptr(); + if (dim < 3) + return ptr[dim + 1]; + return 0; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_global_size.cl b/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_global_size.cl new file mode 100644 index 0000000000..b1d8f27dc6 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_global_size.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DEF _CLC_OVERLOAD size_t __clc_get_global_size(uint dim) { + switch (dim) { + case 0: + return __builtin_amdgcn_grid_size_x(); + case 1: + return __builtin_amdgcn_grid_size_y(); + case 2: + return __builtin_amdgcn_grid_size_z(); + default: + return 1; + } +} diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_group_id.cl b/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_group_id.cl new file mode 100644 index 0000000000..aea927c346 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_group_id.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DEF _CLC_OVERLOAD size_t __clc_get_group_id(uint dim) { + switch (dim) { + case 0: + return __builtin_amdgcn_workgroup_id_x(); + case 1: + return __builtin_amdgcn_workgroup_id_y(); + case 2: + return __builtin_amdgcn_workgroup_id_z(); + default: + return 1; + } +} diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_local_id.cl b/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_local_id.cl new file mode 100644 index 0000000000..b7b7a43e73 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_local_id.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DEF _CLC_OVERLOAD size_t __clc_get_local_id(uint dim) { + switch (dim) { + case 0: + return __builtin_amdgcn_workitem_id_x(); + case 1: + return __builtin_amdgcn_workitem_id_y(); + case 2: + return __builtin_amdgcn_workitem_id_z(); + default: + return 1; + } +} diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_work_dim.cl b/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_work_dim.cl new file mode 100644 index 0000000000..93cab09b41 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgcn/workitem/clc_get_work_dim.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#if __clang_major__ >= 8 +#define CONST_AS __constant +#elif __clang_major__ >= 7 +#define CONST_AS __attribute__((address_space(4))) +#else +#define CONST_AS __attribute__((address_space(2))) +#endif + +_CLC_OVERLOAD _CLC_DEF uint __clc_get_work_dim() { + CONST_AS uint *ptr = (CONST_AS uint *)__builtin_amdgcn_implicitarg_ptr(); + return ptr[0]; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/SOURCES b/local/recipes/dev/libclc/source/clc/lib/amdgpu/SOURCES new file mode 100644 index 0000000000..83b13bad9a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/SOURCES @@ -0,0 +1,13 @@ +math/clc_half_exp10.cl +math/clc_half_exp2.cl +math/clc_half_exp.cl +math/clc_half_log10.cl +math/clc_half_log2.cl +math/clc_half_log.cl +math/clc_half_recip.cl +math/clc_half_rsqrt.cl +math/clc_half_sqrt.cl +math/clc_native_exp2.cl +math/clc_native_exp.cl +math/clc_native_log10.cl +math/clc_sqrt_fp64.cl diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_exp.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_exp.cl new file mode 100644 index 0000000000..5fa9d0b9a9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_exp.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_FUNC exp +#define __FLOAT_ONLY +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_exp10.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_exp10.cl new file mode 100644 index 0000000000..5c119eb5a5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_exp10.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_FUNC exp10 +#define __FLOAT_ONLY +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_exp2.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_exp2.cl new file mode 100644 index 0000000000..9750d50089 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_exp2.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_FUNC exp2 +#define __FLOAT_ONLY +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_log.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_log.cl new file mode 100644 index 0000000000..ea19bd5a4c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_log.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_FUNC log +#define __FLOAT_ONLY +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_log10.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_log10.cl new file mode 100644 index 0000000000..af3a269539 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_log10.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_FUNC log10 +#define __FLOAT_ONLY +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_log2.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_log2.cl new file mode 100644 index 0000000000..81795f012c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_log2.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_FUNC log2 +#define __FLOAT_ONLY +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_native_unary.inc b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_native_unary.inc new file mode 100644 index 0000000000..d62343400f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_native_unary.inc @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_HALF_FUNC(x) __CLC_CONCAT(__clc_half_, x) +#define __CLC_NATIVE_FUNC(x) __CLC_CONCAT(__clc_native_, x) + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE +__CLC_HALF_FUNC(__CLC_FUNC)(__CLC_GENTYPE val) { + return __CLC_NATIVE_FUNC(__CLC_FUNC)(val); +} + +#undef __CLC_NATIVE_FUNC +#undef __CLC_HALF_FUNC diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_recip.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_recip.cl new file mode 100644 index 0000000000..edbec07e44 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_recip.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_FUNC recip +#define __FLOAT_ONLY +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_rsqrt.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_rsqrt.cl new file mode 100644 index 0000000000..c0a5489ec8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_rsqrt.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_FUNC rsqrt +#define __FLOAT_ONLY +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_sqrt.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_sqrt.cl new file mode 100644 index 0000000000..4dc6fa31f2 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_half_sqrt.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_FUNC sqrt +#define __FLOAT_ONLY +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_exp.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_exp.cl new file mode 100644 index 0000000000..591ecb0ac0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_exp.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __CLC_BODY +#define __FLOAT_ONLY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_exp.inc b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_exp.inc new file mode 100644 index 0000000000..cf2d48c405 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_exp.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_native_exp(__CLC_GENTYPE val) { + return __clc_native_exp2(val * M_LOG2E_F); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_exp2.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_exp2.cl new file mode 100644 index 0000000000..63f28921dc --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_exp2.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define __CLC_MIN_VECSIZE 1 +#define FUNCTION __clc_native_exp2 +#define __IMPL_FUNCTION __builtin_amdgcn_exp2f +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_log10.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_log10.cl new file mode 100644 index 0000000000..0668a635d2 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_log10.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __CLC_BODY +#define __FLOAT_ONLY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_log10.inc b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_log10.inc new file mode 100644 index 0000000000..c91d698609 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_native_log10.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_native_log10(__CLC_GENTYPE val) { + return __clc_native_log2(val) * (M_LN2_F / M_LN10_F); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_sqrt_fp64.cl b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_sqrt_fp64.cl new file mode 100644 index 0000000000..b7cb635a2a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/amdgpu/math/clc_sqrt_fp64.cl @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +#ifdef __AMDGCN__ +#define __clc_builtin_rsq __builtin_amdgcn_rsq +#else +#define __clc_builtin_rsq __builtin_r600_recipsqrt_ieee +#endif + +_CLC_OVERLOAD _CLC_DEF double __clc_sqrt(double x) { + uint vcc = x < 0x1p-767; + uint exp0 = vcc ? 0x100 : 0; + unsigned exp1 = vcc ? 0xffffff80 : 0; + + double v01 = __clc_ldexp(x, exp0); + double v23 = __clc_builtin_rsq(v01); + double v45 = v01 * v23; + v23 = v23 * 0.5; + + double v67 = __clc_fma(-v23, v45, 0.5); + v45 = __clc_fma(v45, v67, v45); + double v89 = __clc_fma(-v45, v45, v01); + v23 = __clc_fma(v23, v67, v23); + v45 = __clc_fma(v89, v23, v45); + v67 = __clc_fma(-v45, v45, v01); + v23 = __clc_fma(v67, v23, v45); + + v23 = __clc_ldexp(v23, exp1); + return (x == __builtin_inf() || (x == 0.0)) ? v01 : v23; +} + +#define __DOUBLE_ONLY +#define FUNCTION __clc_sqrt +#define __CLC_BODY +#include + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/clspv/SOURCES b/local/recipes/dev/libclc/source/clc/lib/clspv/SOURCES new file mode 100644 index 0000000000..b91b0e70a3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/clspv/SOURCES @@ -0,0 +1,2 @@ +math/clc_sw_fma.cl +integer/clc_mul_hi.cl diff --git a/local/recipes/dev/libclc/source/clc/lib/clspv/integer/clc_mul_hi.cl b/local/recipes/dev/libclc/source/clc/lib/clspv/integer/clc_mul_hi.cl new file mode 100644 index 0000000000..aab761736f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/clspv/integer/clc_mul_hi.cl @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// Opt-out of libclc mul_hi implementation for clspv. +// clspv has an internal implementation that does not required using a bigger +// data size. That implementation is based on OpMulExtended which is SPIR-V +// specific, thus it cannot be written in OpenCL-C. diff --git a/local/recipes/dev/libclc/source/clc/lib/clspv/math/clc_sw_fma.cl b/local/recipes/dev/libclc/source/clc/lib/clspv/math/clc_sw_fma.cl new file mode 100644 index 0000000000..2662696447 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/clspv/math/clc_sw_fma.cl @@ -0,0 +1,275 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// This version is derived from the generic fma software implementation +// (__clc_sw_fma), but avoids the use of ulong in favor of uint2. The logic has +// been updated as appropriate. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct fp { + uint2 mantissa; + int exponent; + uint sign; +}; + +static uint2 u2_set(uint hi, uint lo) { + uint2 res; + res.lo = lo; + res.hi = hi; + return res; +} + +static uint2 u2_set_u(uint val) { return u2_set(0, val); } + +static uint2 u2_mul(uint a, uint b) { + uint2 res; + res.hi = __clc_mul_hi(a, b); + res.lo = a * b; + return res; +} + +static uint2 u2_sll(uint2 val, uint shift) { + if (shift == 0) + return val; + if (shift < 32) { + val.hi <<= shift; + val.hi |= val.lo >> (32 - shift); + val.lo <<= shift; + } else { + val.hi = val.lo << (shift - 32); + val.lo = 0; + } + return val; +} + +static uint2 u2_srl(uint2 val, uint shift) { + if (shift == 0) + return val; + if (shift < 32) { + val.lo >>= shift; + val.lo |= val.hi << (32 - shift); + val.hi >>= shift; + } else { + val.lo = val.hi >> (shift - 32); + val.hi = 0; + } + return val; +} + +static uint2 u2_or(uint2 a, uint b) { + a.lo |= b; + return a; +} + +static uint2 u2_and(uint2 a, uint2 b) { + a.lo &= b.lo; + a.hi &= b.hi; + return a; +} + +static uint2 u2_add(uint2 a, uint2 b) { + uint carry = (__clc_hadd(a.lo, b.lo) >> 31) & 0x1; + a.lo += b.lo; + a.hi += b.hi + carry; + return a; +} + +static uint2 u2_add_u(uint2 a, uint b) { return u2_add(a, u2_set_u(b)); } + +static uint2 u2_inv(uint2 a) { + a.lo = ~a.lo; + a.hi = ~a.hi; + return u2_add_u(a, 1); +} + +static uint u2_clz(uint2 a) { + uint leading_zeroes = __clc_clz(a.hi); + if (leading_zeroes == 32) { + leading_zeroes += __clc_clz(a.lo); + } + return leading_zeroes; +} + +static bool u2_eq(uint2 a, uint2 b) { return a.lo == b.lo && a.hi == b.hi; } + +static bool u2_zero(uint2 a) { return u2_eq(a, u2_set_u(0)); } + +static bool u2_gt(uint2 a, uint2 b) { + return a.hi > b.hi || (a.hi == b.hi && a.lo > b.lo); +} + +_CLC_DEF _CLC_OVERLOAD float __clc_sw_fma(float a, float b, float c) { + /* special cases */ + if (__clc_isnan(a) || __clc_isnan(b) || __clc_isnan(c) || __clc_isinf(a) || + __clc_isinf(b)) { + return __clc_mad(a, b, c); + } + + /* If only c is inf, and both a,b are regular numbers, the result is c*/ + if (__clc_isinf(c)) { + return c; + } + + a = __clc_flush_denormal_if_not_supported(a); + b = __clc_flush_denormal_if_not_supported(b); + c = __clc_flush_denormal_if_not_supported(c); + + if (a == 0.0f || b == 0.0f) { + return c; + } + + if (c == 0) { + return a * b; + } + + struct fp st_a, st_b, st_c; + + st_a.exponent = a == .0f ? 0 : ((__clc_as_uint(a) & 0x7f800000) >> 23) - 127; + st_b.exponent = b == .0f ? 0 : ((__clc_as_uint(b) & 0x7f800000) >> 23) - 127; + st_c.exponent = c == .0f ? 0 : ((__clc_as_uint(c) & 0x7f800000) >> 23) - 127; + + st_a.mantissa = + u2_set_u(a == .0f ? 0 : (__clc_as_uint(a) & 0x7fffff) | 0x800000); + st_b.mantissa = + u2_set_u(b == .0f ? 0 : (__clc_as_uint(b) & 0x7fffff) | 0x800000); + st_c.mantissa = + u2_set_u(c == .0f ? 0 : (__clc_as_uint(c) & 0x7fffff) | 0x800000); + + st_a.sign = __clc_as_uint(a) & 0x80000000; + st_b.sign = __clc_as_uint(b) & 0x80000000; + st_c.sign = __clc_as_uint(c) & 0x80000000; + + // Multiplication. + // Move the product to the highest bits to maximize precision + // mantissa is 24 bits => product is 48 bits, 2bits non-fraction. + // Add one bit for future addition overflow, + // add another bit to detect subtraction underflow + struct fp st_mul; + st_mul.sign = st_a.sign ^ st_b.sign; + st_mul.mantissa = u2_sll(u2_mul(st_a.mantissa.lo, st_b.mantissa.lo), 14); + st_mul.exponent = + !u2_zero(st_mul.mantissa) ? st_a.exponent + st_b.exponent : 0; + + // FIXME: Detecting a == 0 || b == 0 above crashed GCN isel + if (st_mul.exponent == 0 && u2_zero(st_mul.mantissa)) + return c; + +// Mantissa is 23 fractional bits, shift it the same way as product mantissa +#define C_ADJUST 37ul + + // both exponents are bias adjusted + int exp_diff = st_mul.exponent - st_c.exponent; + + st_c.mantissa = u2_sll(st_c.mantissa, C_ADJUST); + uint2 cutoff_bits = u2_set_u(0); + uint2 cutoff_mask = u2_add(u2_sll(u2_set_u(1), __clc_abs(exp_diff)), + u2_set(0xffffffff, 0xffffffff)); + if (exp_diff > 0) { + cutoff_bits = + exp_diff >= 64 ? st_c.mantissa : u2_and(st_c.mantissa, cutoff_mask); + st_c.mantissa = + exp_diff >= 64 ? u2_set_u(0) : u2_srl(st_c.mantissa, exp_diff); + } else { + cutoff_bits = -exp_diff >= 64 ? st_mul.mantissa + : u2_and(st_mul.mantissa, cutoff_mask); + st_mul.mantissa = + -exp_diff >= 64 ? u2_set_u(0) : u2_srl(st_mul.mantissa, -exp_diff); + } + + struct fp st_fma; + st_fma.sign = st_mul.sign; + st_fma.exponent = __clc_max(st_mul.exponent, st_c.exponent); + if (st_c.sign == st_mul.sign) { + st_fma.mantissa = u2_add(st_mul.mantissa, st_c.mantissa); + } else { + // cutoff bits borrow one + st_fma.mantissa = + u2_add(u2_add(st_mul.mantissa, u2_inv(st_c.mantissa)), + (!u2_zero(cutoff_bits) && (st_mul.exponent > st_c.exponent) + ? u2_set(0xffffffff, 0xffffffff) + : u2_set_u(0))); + } + + // underflow: st_c.sign != st_mul.sign, and magnitude switches the sign + if (u2_gt(st_fma.mantissa, u2_set(0x7fffffff, 0xffffffff))) { + st_fma.mantissa = u2_inv(st_fma.mantissa); + st_fma.sign = st_mul.sign ^ 0x80000000; + } + + // detect overflow/underflow + int overflow_bits = 3 - u2_clz(st_fma.mantissa); + + // adjust exponent + st_fma.exponent += overflow_bits; + + // handle underflow + if (overflow_bits < 0) { + st_fma.mantissa = u2_sll(st_fma.mantissa, -overflow_bits); + overflow_bits = 0; + } + + // rounding + uint2 trunc_mask = u2_add(u2_sll(u2_set_u(1), C_ADJUST + overflow_bits), + u2_set(0xffffffff, 0xffffffff)); + uint2 trunc_bits = + u2_or(u2_and(st_fma.mantissa, trunc_mask), !u2_zero(cutoff_bits)); + uint2 last_bit = + u2_and(st_fma.mantissa, u2_sll(u2_set_u(1), C_ADJUST + overflow_bits)); + uint2 grs_bits = u2_sll(u2_set_u(4), C_ADJUST - 3 + overflow_bits); + + // round to nearest even + if (u2_gt(trunc_bits, grs_bits) || + (u2_eq(trunc_bits, grs_bits) && !u2_zero(last_bit))) { + st_fma.mantissa = + u2_add(st_fma.mantissa, u2_sll(u2_set_u(1), C_ADJUST + overflow_bits)); + } + + // Shift mantissa back to bit 23 + st_fma.mantissa = u2_srl(st_fma.mantissa, C_ADJUST + overflow_bits); + + // Detect rounding overflow + if (u2_gt(st_fma.mantissa, u2_set_u(0xffffff))) { + ++st_fma.exponent; + st_fma.mantissa = u2_srl(st_fma.mantissa, 1); + } + + if (u2_zero(st_fma.mantissa)) { + return 0.0f; + } + + // Flating point range limit + if (st_fma.exponent > 127) { + return __clc_as_float(__clc_as_uint(INFINITY) | st_fma.sign); + } + + // Flush denormals + if (st_fma.exponent <= -127) { + return __clc_as_float(st_fma.sign); + } + + return __clc_as_float(st_fma.sign | ((st_fma.exponent + 127) << 23) | + ((uint)st_fma.mantissa.lo & 0x7fffff)); +} + +#define __FLOAT_ONLY +#define FUNCTION __clc_sw_fma +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/SOURCES b/local/recipes/dev/libclc/source/clc/lib/generic/SOURCES new file mode 100644 index 0000000000..bf8736a726 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/SOURCES @@ -0,0 +1,158 @@ +async/clc_prefetch.cl +common/clc_degrees.cl +common/clc_radians.cl +common/clc_sign.cl +common/clc_smoothstep.cl +common/clc_step.cl +geometric/clc_cross.cl +geometric/clc_distance.cl +geometric/clc_dot.cl +geometric/clc_fast_distance.cl +geometric/clc_fast_length.cl +geometric/clc_fast_normalize.cl +geometric/clc_length.cl +geometric/clc_normalize.cl +integer/clc_abs.cl +integer/clc_abs_diff.cl +integer/clc_add_sat.cl +integer/clc_clz.cl +integer/clc_ctz.cl +integer/clc_hadd.cl +integer/clc_mad24.cl +integer/clc_mad_sat.cl +integer/clc_mul24.cl +integer/clc_mul_hi.cl +integer/clc_popcount.cl +integer/clc_rhadd.cl +integer/clc_rotate.cl +integer/clc_sub_sat.cl +integer/clc_upsample.cl +math/clc_acos.cl +math/clc_acosh.cl +math/clc_acospi.cl +math/clc_asin.cl +math/clc_asinh.cl +math/clc_asinpi.cl +math/clc_atan.cl +math/clc_atan2.cl +math/clc_atan2pi.cl +math/clc_atanh.cl +math/clc_atanpi.cl +math/clc_cbrt.cl +math/clc_ceil.cl +math/clc_copysign.cl +math/clc_cos.cl +math/clc_cosh.cl +math/clc_cospi.cl +math/clc_ep_log.cl +math/clc_erf.cl +math/clc_erfc.cl +math/clc_exp.cl +math/clc_exp10.cl +math/clc_exp2.cl +math/clc_expm1.cl +math/clc_exp_helper.cl +math/clc_fabs.cl +math/clc_fdim.cl +math/clc_fma.cl +math/clc_fmax.cl +math/clc_fmin.cl +math/clc_floor.cl +math/clc_fmod.cl +math/clc_fract.cl +math/clc_frexp.cl +math/clc_half_cos.cl +math/clc_half_divide.cl +math/clc_half_exp.cl +math/clc_half_exp10.cl +math/clc_half_exp2.cl +math/clc_half_log.cl +math/clc_half_log10.cl +math/clc_half_log2.cl +math/clc_half_powr.cl +math/clc_half_rsqrt.cl +math/clc_half_recip.cl +math/clc_half_sin.cl +math/clc_half_sqrt.cl +math/clc_half_tan.cl +math/clc_hypot.cl +math/clc_ilogb.cl +math/clc_ldexp.cl +math/clc_lgamma.cl +math/clc_lgamma_r.cl +math/clc_log.cl +math/clc_log10.cl +math/clc_log1p.cl +math/clc_log2.cl +math/clc_logb.cl +math/clc_mad.cl +math/clc_maxmag.cl +math/clc_minmag.cl +math/clc_modf.cl +math/clc_nan.cl +math/clc_native_cos.cl +math/clc_native_divide.cl +math/clc_native_exp.cl +math/clc_native_exp10.cl +math/clc_native_exp2.cl +math/clc_native_log.cl +math/clc_native_log10.cl +math/clc_native_log2.cl +math/clc_native_powr.cl +math/clc_native_rsqrt.cl +math/clc_native_recip.cl +math/clc_native_sin.cl +math/clc_native_sqrt.cl +math/clc_native_tan.cl +math/clc_nextafter.cl +math/clc_pow.cl +math/clc_pown.cl +math/clc_powr.cl +math/clc_remainder.cl +math/clc_remquo.cl +math/clc_rint.cl +math/clc_rootn.cl +math/clc_round.cl +math/clc_rsqrt.cl +math/clc_sin.cl +math/clc_sincos.cl +math/clc_sincos_helpers.cl +math/clc_sinh.cl +math/clc_sinpi.cl +math/clc_sqrt.cl +math/clc_sw_fma.cl +math/clc_tables.cl +math/clc_tan.cl +math/clc_tanh.cl +math/clc_tanpi.cl +math/clc_tgamma.cl +math/clc_trunc.cl +misc/clc_shuffle.cl +misc/clc_shuffle2.cl +relational/clc_all.cl +relational/clc_any.cl +relational/clc_bitselect.cl +relational/clc_isequal.cl +relational/clc_isfinite.cl +relational/clc_isgreater.cl +relational/clc_isgreaterequal.cl +relational/clc_isinf.cl +relational/clc_isless.cl +relational/clc_islessequal.cl +relational/clc_islessgreater.cl +relational/clc_isnan.cl +relational/clc_isnormal.cl +relational/clc_isnotequal.cl +relational/clc_isordered.cl +relational/clc_isunordered.cl +relational/clc_select.cl +relational/clc_signbit.cl +shared/clc_clamp.cl +shared/clc_max.cl +shared/clc_min.cl +shared/clc_vload.cl +shared/clc_vstore.cl +workitem/clc_get_local_linear_id.cl +workitem/clc_get_num_sub_groups.cl +workitem/clc_get_sub_group_id.cl +workitem/clc_get_sub_group_size.cl diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/async/clc_prefetch.cl b/local/recipes/dev/libclc/source/clc/lib/generic/async/clc_prefetch.cl new file mode 100644 index 0000000000..1b8da199eb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/async/clc_prefetch.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/async/clc_prefetch.inc b/local/recipes/dev/libclc/source/clc/lib/generic/async/clc_prefetch.inc new file mode 100644 index 0000000000..a9c6b41a8f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/async/clc_prefetch.inc @@ -0,0 +1,10 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF void __clc_prefetch(const global __CLC_GENTYPE *p, + size_t num_gentypes) {} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_degrees.cl b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_degrees.cl new file mode 100644 index 0000000000..b5b07df507 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_degrees.cl @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define DEGREES_SINGLE_DEF(TYPE, LITERAL) \ + _CLC_OVERLOAD _CLC_DEF TYPE __clc_degrees(TYPE radians) { \ + return (TYPE)LITERAL * radians; \ + } + +#define DEGREES_DEF(TYPE, LITERAL) \ + DEGREES_SINGLE_DEF(TYPE, LITERAL) \ + DEGREES_SINGLE_DEF(TYPE##2, LITERAL) \ + DEGREES_SINGLE_DEF(TYPE##3, LITERAL) \ + DEGREES_SINGLE_DEF(TYPE##4, LITERAL) \ + DEGREES_SINGLE_DEF(TYPE##8, LITERAL) \ + DEGREES_SINGLE_DEF(TYPE##16, LITERAL) + +// 180/pi = ~57.29577951308232087685 or 0x1.ca5dc1a63c1f8p+5 or 0x1.ca5dc2p+5F +DEGREES_DEF(float, 0x1.ca5dc2p+5F) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// 180/pi = ~57.29577951308232087685 or 0x1.ca5dc1a63c1f8p+5 or 0x1.ca5dc2p+5F +DEGREES_DEF(double, 0x1.ca5dc1a63c1f8p+5) + +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// 180/pi = ~57.29577951308232087685 or 0x1.ca5dc1a63c1f8p+5 or 0x1.ca5dc2p+5F +DEGREES_DEF(half, (half)0x1.ca5dc1a63c1f8p+5) + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_radians.cl b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_radians.cl new file mode 100644 index 0000000000..f8a1635ecb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_radians.cl @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define RADIANS_SINGLE_DEF(TYPE, LITERAL) \ + _CLC_OVERLOAD _CLC_DEF TYPE __clc_radians(TYPE radians) { \ + return (TYPE)LITERAL * radians; \ + } + +#define RADIANS_DEF(TYPE, LITERAL) \ + RADIANS_SINGLE_DEF(TYPE, LITERAL) \ + RADIANS_SINGLE_DEF(TYPE##2, LITERAL) \ + RADIANS_SINGLE_DEF(TYPE##3, LITERAL) \ + RADIANS_SINGLE_DEF(TYPE##4, LITERAL) \ + RADIANS_SINGLE_DEF(TYPE##8, LITERAL) \ + RADIANS_SINGLE_DEF(TYPE##16, LITERAL) + +// pi/180 = ~0.01745329251994329577 or 0x1.1df46a2529d39p-6 or 0x1.1df46ap-6F +RADIANS_DEF(float, 0x1.1df46ap-6F) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// pi/180 = ~0.01745329251994329577 or 0x1.1df46a2529d39p-6 or 0x1.1df46ap-6F +RADIANS_DEF(double, 0x1.1df46a2529d39p-6) + +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// pi/180 = ~0.01745329251994329577 or 0x1.1df46a2529d39p-6 or 0x1.1df46ap-6F +RADIANS_DEF(half, (half)0x1.1df46a2529d39p-6) + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_sign.cl b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_sign.cl new file mode 100644 index 0000000000..07cfe4bfcf --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_sign.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_sign.inc b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_sign.inc new file mode 100644 index 0000000000..3b71c0a0d8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_sign.inc @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_sign(__CLC_GENTYPE x) { + __CLC_BIT_INTN ret_zero = __clc_isnan(x) || x == __CLC_FP_LIT(0.0); + __CLC_GENTYPE ret_val = + __clc_select(__CLC_FP_LIT(1.0), __CLC_FP_LIT(0.0), ret_zero); + return __clc_copysign(ret_val, x); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_smoothstep.cl b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_smoothstep.cl new file mode 100644 index 0000000000..cf143b8fac --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_smoothstep.cl @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#include +#include +#include + +#define SMOOTHSTEP_SINGLE_DEF(edge_type, x_type, lit_suff) \ + _CLC_OVERLOAD _CLC_DEF x_type __clc_smoothstep(edge_type edge0, \ + edge_type edge1, x_type x) { \ + x_type t = __clc_clamp((x - edge0) / (edge1 - edge0), 0.0##lit_suff, \ + 1.0##lit_suff); \ + return t * t * (3.0##lit_suff - 2.0##lit_suff * t); \ + } + +#define SMOOTHSTEP_DEF(type, lit_suffix) \ + SMOOTHSTEP_SINGLE_DEF(type, type, lit_suffix) \ + SMOOTHSTEP_SINGLE_DEF(type##2, type##2, lit_suffix) \ + SMOOTHSTEP_SINGLE_DEF(type##3, type##3, lit_suffix) \ + SMOOTHSTEP_SINGLE_DEF(type##4, type##4, lit_suffix) \ + SMOOTHSTEP_SINGLE_DEF(type##8, type##8, lit_suffix) \ + SMOOTHSTEP_SINGLE_DEF(type##16, type##16, lit_suffix) + +SMOOTHSTEP_DEF(float, F) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +SMOOTHSTEP_DEF(double, ); +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +SMOOTHSTEP_DEF(half, H); +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_step.cl b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_step.cl new file mode 100644 index 0000000000..c21c27a3e9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_step.cl @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_step.inc b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_step.inc new file mode 100644 index 0000000000..627f13e82c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/common/clc_step.inc @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_step(__CLC_GENTYPE edge, + __CLC_GENTYPE x) { + return x < edge ? __CLC_FP_LIT(0.0) : __CLC_FP_LIT(1.0); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_cross.cl b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_cross.cl new file mode 100644 index 0000000000..4ed1d5797d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_cross.cl @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_cross.inc b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_cross.inc new file mode 100644 index 0000000000..5a89ed0c37 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_cross.inc @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_VECSIZE_OR_1 == 3 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cross(__CLC_GENTYPE p0, + __CLC_GENTYPE p1) { + return (__CLC_GENTYPE)(p0.y * p1.z - p0.z * p1.y, p0.z * p1.x - p0.x * p1.z, + p0.x * p1.y - p0.y * p1.x); +} + +#elif __CLC_VECSIZE_OR_1 == 4 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cross(__CLC_GENTYPE p0, + __CLC_GENTYPE p1) { + return (__CLC_GENTYPE)(p0.y * p1.z - p0.z * p1.y, p0.z * p1.x - p0.x * p1.z, + p0.x * p1.y - p0.y * p1.x, 0.0F); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_distance.cl b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_distance.cl new file mode 100644 index 0000000000..ba22c9e173 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_distance.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_distance.inc b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_distance.inc new file mode 100644 index 0000000000..89f74a6233 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_distance.inc @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if (__CLC_VECSIZE_OR_1 == 1 || __CLC_VECSIZE_OR_1 == 2 || \ + __CLC_VECSIZE_OR_1 == 3 || __CLC_VECSIZE_OR_1 == 4) + +_CLC_OVERLOAD _CLC_DEF __CLC_SCALAR_GENTYPE __clc_distance(__CLC_GENTYPE p0, + __CLC_GENTYPE p1) { + return __clc_length(p0 - p1); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_dot.cl b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_dot.cl new file mode 100644 index 0000000000..a30f9bc6e3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_dot.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_dot.inc b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_dot.inc new file mode 100644 index 0000000000..0c89493bf7 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_dot.inc @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if (__CLC_VECSIZE_OR_1 == 1 || __CLC_VECSIZE_OR_1 == 2 || \ + __CLC_VECSIZE_OR_1 == 3 || __CLC_VECSIZE_OR_1 == 4) + +_CLC_OVERLOAD _CLC_DEF __CLC_SCALAR_GENTYPE __clc_dot(__CLC_GENTYPE x, + __CLC_GENTYPE y) { +#if __CLC_VECSIZE_OR_1 == 1 + return x * y; +#elif __CLC_VECSIZE_OR_1 == 2 + return x.s0 * y.s0 + x.s1 * y.s1; +#elif __CLC_VECSIZE_OR_1 == 3 + return x.s0 * y.s0 + x.s1 * y.s1 + x.s2 * y.s2; +#else + return x.s0 * y.s0 + x.s1 * y.s1 + x.s2 * y.s2 + x.s3 * y.s3; +#endif +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_distance.cl b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_distance.cl new file mode 100644 index 0000000000..9960398984 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_distance.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_distance.inc b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_distance.inc new file mode 100644 index 0000000000..68f71d8bb3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_distance.inc @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if (__CLC_VECSIZE_OR_1 == 1 || __CLC_VECSIZE_OR_1 == 2 || \ + __CLC_VECSIZE_OR_1 == 3 || __CLC_VECSIZE_OR_1 == 4) + +_CLC_OVERLOAD _CLC_DEF __CLC_SCALAR_GENTYPE +__clc_fast_distance(__CLC_GENTYPE p0, __CLC_GENTYPE p1) { + return __clc_fast_length(p0 - p1); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_length.cl b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_length.cl new file mode 100644 index 0000000000..ce6ec5283e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_length.cl @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF float __clc_fast_length(float p) { + return __clc_fabs(p); +} + +_CLC_OVERLOAD _CLC_DEF float __clc_fast_length(float2 p) { + return __clc_half_sqrt(__clc_dot(p, p)); +} + +_CLC_OVERLOAD _CLC_DEF float __clc_fast_length(float3 p) { + return __clc_half_sqrt(__clc_dot(p, p)); +} + +_CLC_OVERLOAD _CLC_DEF float __clc_fast_length(float4 p) { + return __clc_half_sqrt(__clc_dot(p, p)); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_normalize.cl b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_normalize.cl new file mode 100644 index 0000000000..85684d0f49 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_normalize.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __FLOAT_ONLY +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_normalize.inc b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_normalize.inc new file mode 100644 index 0000000000..e4c3ab2c5a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_fast_normalize.inc @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_VECSIZE_OR_1 == 1 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fast_normalize(__CLC_GENTYPE p) { + return __clc_normalize(p); +} + +#elif (__CLC_VECSIZE_OR_1 == 2 || __CLC_VECSIZE_OR_1 == 3 || \ + __CLC_VECSIZE_OR_1 == 4) + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fast_normalize(__CLC_GENTYPE p) { + __CLC_SCALAR_GENTYPE l2 = __clc_dot(p, p); + return l2 == 0.0f ? p : p * __clc_half_rsqrt(l2); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_length.cl b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_length.cl new file mode 100644 index 0000000000..d9a9166b92 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_length.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_length.inc b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_length.inc new file mode 100644 index 0000000000..7603735478 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_length.inc @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_VECSIZE_OR_1 == 1 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_length(__CLC_GENTYPE p) { + return __clc_fabs(p); +} + +#elif (__CLC_VECSIZE_OR_1 == 2 || __CLC_VECSIZE_OR_1 == 3 || \ + __CLC_VECSIZE_OR_1 == 4) + +#if __CLC_FPSIZE == 32 +#define __CLC_GENTYPE_MIN FLT_MIN +#define __CLC_GENTYPE_MIN_SCALE_UP 0x1.0p+86F +#define __CLC_GENTYPE_MIN_SCALE_DOWN 0x1.0p-86F +#define __CLC_GENTYPE_INF_SCALE_UP 0x1.0p+65F +#define __CLC_GENTYPE_INF_SCALE_DOWN 0x1.0p-65F +#elif __CLC_FPSIZE == 64 +#define __CLC_GENTYPE_MIN DBL_MIN +#define __CLC_GENTYPE_MIN_SCALE_UP 0x1.0p+563 +#define __CLC_GENTYPE_MIN_SCALE_DOWN 0x1.0p-563 +#define __CLC_GENTYPE_INF_SCALE_UP 0x1.0p+513 +#define __CLC_GENTYPE_INF_SCALE_DOWN 0x1.0p-513 +#elif __CLC_FPSIZE == 16 +#define __CLC_GENTYPE_MIN HALF_MIN +#define __CLC_GENTYPE_MIN_SCALE_UP 0x1.0p+12H +#define __CLC_GENTYPE_MIN_SCALE_DOWN 0x1.0p-12H +#define __CLC_GENTYPE_INF_SCALE_UP 0x1.0p+7H +#define __CLC_GENTYPE_INF_SCALE_DOWN 0x1.0p-7H +#else +#error "Unsupported FP size" +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_SCALAR_GENTYPE __clc_length(__CLC_GENTYPE p) { + __CLC_SCALAR_GENTYPE l2 = __clc_dot(p, p); + + if (l2 < __CLC_GENTYPE_MIN) { + p *= __CLC_GENTYPE_MIN_SCALE_UP; + return __clc_sqrt(__clc_dot(p, p)) * __CLC_GENTYPE_MIN_SCALE_DOWN; + } + + if (l2 == INFINITY) { + p *= __CLC_GENTYPE_INF_SCALE_DOWN; + return __clc_sqrt(__clc_dot(p, p)) * __CLC_GENTYPE_INF_SCALE_UP; + } + + return __clc_sqrt(l2); +} + +#undef __CLC_GENTYPE_INF_SCALE_DOWN +#undef __CLC_GENTYPE_INF_SCALE_UP +#undef __CLC_GENTYPE_MIN_SCALE_DOWN +#undef __CLC_GENTYPE_MIN_SCALE_UP +#undef __CLC_GENTYPE_MIN + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_normalize.cl b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_normalize.cl new file mode 100644 index 0000000000..ec4a67647c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_normalize.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_normalize.inc b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_normalize.inc new file mode 100644 index 0000000000..8a47c6d482 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/geometric/clc_normalize.inc @@ -0,0 +1,84 @@ +//===----------------------------------------------------------------------===// +// + +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if (__CLC_VECSIZE_OR_1 == 1 || __CLC_VECSIZE_OR_1 == 2 || \ + __CLC_VECSIZE_OR_1 == 3 || __CLC_VECSIZE_OR_1 == 4) + +// Until we have a native FP16 implementation, go via FP32 +#if __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) { + return __CLC_CONVERT_GENTYPE(__clc_normalize(__CLC_CONVERT_FLOATN(p))); +} + +// Scalar normalize +#elif defined(__CLC_SCALAR) + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) { + return __clc_sign(p); +} + +// Vector normalize +#else + +#if __CLC_FPSIZE == 32 + +#define MIN_VAL FLT_MIN +#define MAX_SQRT 0x1.0p+86F +#if __CLC_VECSIZE_OR_1 == 2 +#define MIN_SQRT 0x1.0p-65F +#else +#define MIN_SQRT 0x1.0p-66F +#endif + +#elif __CLC_FPSIZE == 64 + +#define MIN_VAL DBL_MIN +#define MAX_SQRT 0x1.0p+563 +#if __CLC_VECSIZE_OR_1 == 2 +#define MIN_SQRT 0x1.0p-513 +#else +#define MIN_SQRT 0x1.0p-514 +#endif + +#else +#error "Invalid FP size" +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) { + if (__clc_all(p == __CLC_FP_LIT(0.0))) { + return p; + } + + __CLC_SCALAR_GENTYPE l2 = __clc_dot(p, p); + + if (l2 < MIN_VAL) { + p *= MAX_SQRT; + l2 = __clc_dot(p, p); + } else if (l2 == INFINITY) { + p *= MIN_SQRT; + l2 = __clc_dot(p, p); + if (l2 == INFINITY) { + p = __clc_copysign(__clc_select((__CLC_GENTYPE)__CLC_FP_LIT(0.0), + (__CLC_GENTYPE)__CLC_FP_LIT(1.0), + __clc_isinf(p)), + p); + l2 = __clc_dot(p, p); + } + } + return p * __clc_rsqrt(l2); +} + +#undef MIN_VAL +#undef MIN_SQRT +#undef MAX_SQRT + +#endif + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs.cl new file mode 100644 index 0000000000..c2bea5bec8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs.cl @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs.inc b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs.inc new file mode 100644 index 0000000000..26ec0b24ff --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs.inc @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_U_GENTYPE __clc_abs(__CLC_GENTYPE x) { + return __builtin_astype((__CLC_GENTYPE)(x > (__CLC_GENTYPE)(0) ? x : -x), + __CLC_U_GENTYPE); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs_diff.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs_diff.cl new file mode 100644 index 0000000000..c168b06060 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs_diff.cl @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs_diff.inc b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs_diff.inc new file mode 100644 index 0000000000..5d78982faa --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_abs_diff.inc @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_U_GENTYPE __clc_abs_diff(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + __CLC_U_GENTYPE ux = __builtin_astype(x, __CLC_U_GENTYPE); + __CLC_U_GENTYPE uy = __builtin_astype(y, __CLC_U_GENTYPE); + return x > y ? ux - uy : uy - ux; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_add_sat.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_add_sat.cl new file mode 100644 index 0000000000..8241ee5d54 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_add_sat.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define FUNCTION __clc_add_sat +#define __IMPL_FUNCTION(x) __builtin_elementwise_add_sat +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_clz.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_clz.cl new file mode 100644 index 0000000000..c6e1da680b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_clz.cl @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF char __clc_clz(char x) { + return __clc_clz((ushort)(uchar)x) - 8; +} + +_CLC_OVERLOAD _CLC_DEF uchar __clc_clz(uchar x) { + return __clc_clz((ushort)x) - 8; +} + +_CLC_OVERLOAD _CLC_DEF short __clc_clz(short x) { + return x ? __builtin_clzs(x) : 16; +} + +_CLC_OVERLOAD _CLC_DEF ushort __clc_clz(ushort x) { + return x ? __builtin_clzs(x) : 16; +} + +_CLC_OVERLOAD _CLC_DEF int __clc_clz(int x) { + return x ? __builtin_clz(x) : 32; +} + +_CLC_OVERLOAD _CLC_DEF uint __clc_clz(uint x) { + return x ? __builtin_clz(x) : 32; +} + +_CLC_OVERLOAD _CLC_DEF long __clc_clz(long x) { + return x ? __builtin_clzl(x) : 64; +} + +_CLC_OVERLOAD _CLC_DEF ulong __clc_clz(ulong x) { + return x ? __builtin_clzl(x) : 64; +} + +#define FUNCTION __clc_clz +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_ctz.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_ctz.cl new file mode 100644 index 0000000000..d82d99d539 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_ctz.cl @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF char __clc_ctz(char x) { + return __clc_ctz(__clc_as_uchar(x)); +} + +_CLC_OVERLOAD _CLC_DEF uchar __clc_ctz(uchar x) { return __builtin_ctzg(x, 8); } + +_CLC_OVERLOAD _CLC_DEF short __clc_ctz(short x) { + return __clc_ctz(__clc_as_ushort(x)); +} + +_CLC_OVERLOAD _CLC_DEF ushort __clc_ctz(ushort x) { + return __builtin_ctzg(x, 16); +} + +_CLC_OVERLOAD _CLC_DEF int __clc_ctz(int x) { + return __clc_ctz(__clc_as_uint(x)); +} + +_CLC_OVERLOAD _CLC_DEF uint __clc_ctz(uint x) { return __builtin_ctzg(x, 32); } + +_CLC_OVERLOAD _CLC_DEF long __clc_ctz(long x) { + return __clc_ctz(__clc_as_ulong(x)); +} + +_CLC_OVERLOAD _CLC_DEF ulong __clc_ctz(ulong x) { + return __builtin_ctzg(x, 64); +} + +#define FUNCTION __clc_ctz +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_hadd.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_hadd.cl new file mode 100644 index 0000000000..0f11e547c1 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_hadd.cl @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_hadd.inc b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_hadd.inc new file mode 100644 index 0000000000..379d2e8264 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_hadd.inc @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// hadd = (x+y)>>1 +// This can be simplified to x>>1 + y>>1 + (1 if both x and y have the 1s bit +// set) This saves us having to do any checks for overflow in the addition sum +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_hadd(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return (x >> (__CLC_GENTYPE)1) + (y >> (__CLC_GENTYPE)1) + + (x & y & (__CLC_GENTYPE)1); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mad24.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mad24.cl new file mode 100644 index 0000000000..12b72a20b3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mad24.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mad24.inc b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mad24.inc new file mode 100644 index 0000000000..19daacc942 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mad24.inc @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_mad24(__CLC_GENTYPE x, + __CLC_GENTYPE y, + __CLC_GENTYPE z) { + return __clc_mul24(x, y) + z; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mad_sat.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mad_sat.cl new file mode 100644 index 0000000000..7c6aaffe6c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mad_sat.cl @@ -0,0 +1,110 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_DEFINE_SIMPLE_MAD_SAT(TYPE, UP_TYPE, LIT_PREFIX) \ + _CLC_OVERLOAD _CLC_DEF TYPE __clc_mad_sat(TYPE x, TYPE y, TYPE z) { \ + UP_TYPE upscaled_mad = \ + __clc_mad24(__clc_convert_##UP_TYPE(x), __clc_convert_##UP_TYPE(y), \ + __clc_convert_##UP_TYPE(z)); \ + UP_TYPE clamped_mad = __clc_clamp(upscaled_mad, (UP_TYPE)LIT_PREFIX##_MIN, \ + (UP_TYPE)LIT_PREFIX##_MAX); \ + return __clc_convert_##TYPE(clamped_mad); \ + } + +#define __CLC_DEFINE_SIMPLE_MAD_SAT_ALL_TYS(TYPE, UP_TYPE, LIT_PREFIX) \ + __CLC_DEFINE_SIMPLE_MAD_SAT(TYPE, UP_TYPE, LIT_PREFIX) \ + __CLC_DEFINE_SIMPLE_MAD_SAT(TYPE##2, UP_TYPE##2, LIT_PREFIX) \ + __CLC_DEFINE_SIMPLE_MAD_SAT(TYPE##3, UP_TYPE##3, LIT_PREFIX) \ + __CLC_DEFINE_SIMPLE_MAD_SAT(TYPE##4, UP_TYPE##4, LIT_PREFIX) \ + __CLC_DEFINE_SIMPLE_MAD_SAT(TYPE##8, UP_TYPE##8, LIT_PREFIX) \ + __CLC_DEFINE_SIMPLE_MAD_SAT(TYPE##16, UP_TYPE##16, LIT_PREFIX) + +__CLC_DEFINE_SIMPLE_MAD_SAT_ALL_TYS(char, int, CHAR) +__CLC_DEFINE_SIMPLE_MAD_SAT_ALL_TYS(uchar, uint, UCHAR) +__CLC_DEFINE_SIMPLE_MAD_SAT_ALL_TYS(short, int, SHRT) +__CLC_DEFINE_SIMPLE_MAD_SAT_ALL_TYS(ushort, uint, USHRT) + +// Macro for defining mad_sat variants for uint/ulong +#define __CLC_DEFINE_UINTLONG_MAD_SAT(UTYPE, STYPE, ULIT_PREFIX) \ + _CLC_OVERLOAD _CLC_DEF UTYPE __clc_mad_sat(UTYPE x, UTYPE y, UTYPE z) { \ + STYPE has_mul_hi = __clc_mul_hi(x, y) != (UTYPE)0; \ + return __clc_select(__clc_add_sat(x * y, z), (UTYPE)ULIT_PREFIX##_MAX, \ + has_mul_hi); \ + } + +#define __CLC_DEFINE_UINTLONG_MAD_SAT_ALL_TYS(UTY, STY, ULIT_PREFIX) \ + __CLC_DEFINE_UINTLONG_MAD_SAT(UTY, STY, ULIT_PREFIX) \ + __CLC_DEFINE_UINTLONG_MAD_SAT(UTY##2, STY##2, ULIT_PREFIX) \ + __CLC_DEFINE_UINTLONG_MAD_SAT(UTY##3, STY##3, ULIT_PREFIX) \ + __CLC_DEFINE_UINTLONG_MAD_SAT(UTY##4, STY##4, ULIT_PREFIX) \ + __CLC_DEFINE_UINTLONG_MAD_SAT(UTY##8, STY##8, ULIT_PREFIX) \ + __CLC_DEFINE_UINTLONG_MAD_SAT(UTY##16, STY##16, ULIT_PREFIX) + +__CLC_DEFINE_UINTLONG_MAD_SAT_ALL_TYS(uint, int, UINT) +__CLC_DEFINE_UINTLONG_MAD_SAT_ALL_TYS(ulong, long, ULONG) + +// Macro for defining mad_sat variants for int +#define __CLC_DEFINE_SINT_MAD_SAT(INTTY, UINTTY, SLONGTY) \ + _CLC_OVERLOAD _CLC_DEF INTTY __clc_mad_sat(INTTY x, INTTY y, INTTY z) { \ + INTTY mhi = __clc_mul_hi(x, y); \ + UINTTY mlo = __clc_as_##UINTTY(x * y); \ + SLONGTY m = __clc_upsample(mhi, mlo); \ + m += __clc_convert_##SLONGTY(z); \ + m = __clc_clamp(m, (SLONGTY)INT_MIN, (SLONGTY)INT_MAX); \ + return __clc_convert_##INTTY(m); \ + } + +#define __CLC_DEFINE_SINT_MAD_SAT_ALL_TYS(INTTY, UINTTY, SLONGTY) \ + __CLC_DEFINE_SINT_MAD_SAT(INTTY, UINTTY, SLONGTY) \ + __CLC_DEFINE_SINT_MAD_SAT(INTTY##2, UINTTY##2, SLONGTY##2) \ + __CLC_DEFINE_SINT_MAD_SAT(INTTY##3, UINTTY##3, SLONGTY##3) \ + __CLC_DEFINE_SINT_MAD_SAT(INTTY##4, UINTTY##4, SLONGTY##4) \ + __CLC_DEFINE_SINT_MAD_SAT(INTTY##8, UINTTY##8, SLONGTY##8) \ + __CLC_DEFINE_SINT_MAD_SAT(INTTY##16, UINTTY##16, SLONGTY##16) + +__CLC_DEFINE_SINT_MAD_SAT_ALL_TYS(int, uint, long) + +// Macro for defining mad_sat variants for long +#define __CLC_DEFINE_SLONG_MAD_SAT(SLONGTY, ULONGTY) \ + _CLC_OVERLOAD _CLC_DEF SLONGTY __clc_mad_sat(SLONGTY x, SLONGTY y, \ + SLONGTY z) { \ + SLONGTY hi = __clc_mul_hi(x, y); \ + ULONGTY ulo = __clc_as_##ULONGTY(x * y); \ + SLONGTY max1 = (x < 0) == (y < 0) && hi != 0; \ + SLONGTY max2 = hi == 0 && ulo >= LONG_MAX && \ + (z > 0 || (ulo + __clc_as_##ULONGTY(z)) > LONG_MAX); \ + SLONGTY min1 = (((x < 0) != (y < 0)) && hi != -1); \ + SLONGTY min2 = \ + hi == -1 && ulo <= ((ULONGTY)LONG_MAX + 1UL) && \ + (z < 0 || __clc_as_##ULONGTY(z) < ((ULONGTY)LONG_MAX - ulo)); \ + SLONGTY ret = __clc_as_##SLONGTY(ulo + __clc_as_##ULONGTY(z)); \ + ret = __clc_select(ret, (SLONGTY)LONG_MAX, (SLONGTY)(max1 || max2)); \ + ret = __clc_select(ret, (SLONGTY)LONG_MIN, (SLONGTY)(min1 || min2)); \ + return ret; \ + } + +#define __CLC_DEFINE_SLONG_MAD_SAT_ALL_TYS(SLONGTY, ULONGTY) \ + __CLC_DEFINE_SLONG_MAD_SAT(SLONGTY, ULONGTY) \ + __CLC_DEFINE_SLONG_MAD_SAT(SLONGTY##2, ULONGTY##2) \ + __CLC_DEFINE_SLONG_MAD_SAT(SLONGTY##3, ULONGTY##3) \ + __CLC_DEFINE_SLONG_MAD_SAT(SLONGTY##4, ULONGTY##4) \ + __CLC_DEFINE_SLONG_MAD_SAT(SLONGTY##8, ULONGTY##8) \ + __CLC_DEFINE_SLONG_MAD_SAT(SLONGTY##16, ULONGTY##16) + +__CLC_DEFINE_SLONG_MAD_SAT_ALL_TYS(long, ulong) diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mul24.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mul24.cl new file mode 100644 index 0000000000..9b362af51e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mul24.cl @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mul24.inc b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mul24.inc new file mode 100644 index 0000000000..8993618618 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mul24.inc @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// We need to use shifts here in order to mantain the sign bit for signed +// integers. The compiler should optimize this to (x & 0x00FFFFFF) for +// unsigned integers. +#define CONVERT_TO_24BIT(x) (((x) << 8) >> 8) + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_mul24(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return CONVERT_TO_24BIT(x) * CONVERT_TO_24BIT(y); +} + +#undef CONVERT_TO_24BIT diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mul_hi.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mul_hi.cl new file mode 100644 index 0000000000..117d8471fb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_mul_hi.cl @@ -0,0 +1,131 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include + +// For all types EXCEPT long, which is implemented separately +#define __CLC_MUL_HI_IMPL(BGENTYPE, GENTYPE, GENSIZE) \ + _CLC_OVERLOAD _CLC_DEF GENTYPE __clc_mul_hi(GENTYPE x, GENTYPE y) { \ + BGENTYPE large_x = __clc_convert_##BGENTYPE(x); \ + BGENTYPE large_y = __clc_convert_##BGENTYPE(y); \ + BGENTYPE large_mul_hi = (large_x * large_y) >> (BGENTYPE)GENSIZE; \ + return __clc_convert_##GENTYPE(large_mul_hi); \ + } + +#define __CLC_MUL_HI_DEC_IMPL(BTYPE, TYPE, BITS) \ + __CLC_MUL_HI_IMPL(BTYPE, TYPE, BITS) \ + __CLC_MUL_HI_IMPL(BTYPE##2, TYPE##2, BITS) \ + __CLC_MUL_HI_IMPL(BTYPE##3, TYPE##3, BITS) \ + __CLC_MUL_HI_IMPL(BTYPE##4, TYPE##4, BITS) \ + __CLC_MUL_HI_IMPL(BTYPE##8, TYPE##8, BITS) \ + __CLC_MUL_HI_IMPL(BTYPE##16, TYPE##16, BITS) + +_CLC_OVERLOAD _CLC_DEF long __clc_mul_hi(long x, long y) { + long f, o, i; + ulong l; + + // Move the high/low halves of x/y into the lower 32-bits of variables so + // that we can multiply them without worrying about overflow. + long x_hi = x >> 32; + long x_lo = x & UINT_MAX; + long y_hi = y >> 32; + long y_lo = y & UINT_MAX; + + // Multiply all of the components according to FOIL method + f = x_hi * y_hi; + o = x_hi * y_lo; + i = x_lo * y_hi; + l = x_lo * y_lo; + + // Now add the components back together in the following steps: + // F: doesn't need to be modified + // O/I: Need to be added together. + // L: Shift right by 32-bits, then add into the sum of O and I + // Once O/I/L are summed up, then shift the sum by 32-bits and add to F. + // + // We use hadd to give us a bit of extra precision for the intermediate sums + // but as a result, we shift by 31 bits instead of 32 + return (long)(f + (__clc_hadd(o, (i + (long)((ulong)l >> 32))) >> 31)); +} + +_CLC_OVERLOAD _CLC_DEF ulong __clc_mul_hi(ulong x, ulong y) { + ulong f, o, i; + ulong l; + + // Move the high/low halves of x/y into the lower 32-bits of variables so + // that we can multiply them without worrying about overflow. + ulong x_hi = x >> 32; + ulong x_lo = x & UINT_MAX; + ulong y_hi = y >> 32; + ulong y_lo = y & UINT_MAX; + + // Multiply all of the components according to FOIL method + f = x_hi * y_hi; + o = x_hi * y_lo; + i = x_lo * y_hi; + l = x_lo * y_lo; + + // Now add the components back together, taking care to respect the fact that: + // F: doesn't need to be modified + // O/I: Need to be added together. + // L: Shift right by 32-bits, then add into the sum of O and I + // Once O/I/L are summed up, then shift the sum by 32-bits and add to F. + // + // We use hadd to give us a bit of extra precision for the intermediate sums + // but as a result, we shift by 31 bits instead of 32 + return (f + (__clc_hadd(o, (i + (l >> 32))) >> 31)); +} + +// Vector-based mul_hi implementation for logn/ulong. See comments in the scalar +// versions for more detail. +#define __CLC_MUL_HI_LONG_VEC_IMPL(TY, UTY) \ + _CLC_OVERLOAD _CLC_DEF TY __clc_mul_hi(TY x, TY y) { \ + TY f, o, i; \ + UTY l; \ + \ + TY x_hi = x >> 32; \ + TY x_lo = x & UINT_MAX; \ + TY y_hi = y >> 32; \ + TY y_lo = y & UINT_MAX; \ + \ + f = x_hi * y_hi; \ + o = x_hi * y_lo; \ + i = x_lo * y_hi; \ + l = __clc_convert_##UTY(x_lo * y_lo); \ + i += __clc_convert_##TY(l >> (UTY)32); \ + \ + return f + (__clc_hadd(o, i) >> (TY)31); \ + } + +#define __CLC_MUL_HI_LONG_IMPL(BTYPE, UBTYPE) \ + __CLC_MUL_HI_LONG_VEC_IMPL(BTYPE##2, UBTYPE##2) \ + __CLC_MUL_HI_LONG_VEC_IMPL(BTYPE##3, UBTYPE##3) \ + __CLC_MUL_HI_LONG_VEC_IMPL(BTYPE##4, UBTYPE##4) \ + __CLC_MUL_HI_LONG_VEC_IMPL(BTYPE##8, UBTYPE##8) \ + __CLC_MUL_HI_LONG_VEC_IMPL(BTYPE##16, UBTYPE##16) + +#define __CLC_MUL_HI_TYPES() \ + __CLC_MUL_HI_DEC_IMPL(short, char, 8) \ + __CLC_MUL_HI_DEC_IMPL(ushort, uchar, 8) \ + __CLC_MUL_HI_DEC_IMPL(int, short, 16) \ + __CLC_MUL_HI_DEC_IMPL(uint, ushort, 16) \ + __CLC_MUL_HI_DEC_IMPL(long, int, 32) \ + __CLC_MUL_HI_DEC_IMPL(ulong, uint, 32) \ + __CLC_MUL_HI_LONG_IMPL(long, ulong) \ + __CLC_MUL_HI_LONG_IMPL(ulong, ulong) + +__CLC_MUL_HI_TYPES() + +#undef __CLC_MUL_HI_TYPES +#undef __CLC_MUL_HI_LONG_IMPL +#undef __CLC_MUL_HI_LONG_VEC_IMPL +#undef __CLC_MUL_HI_DEC_IMPL +#undef __CLC_MUL_HI_IMPL diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_popcount.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_popcount.cl new file mode 100644 index 0000000000..078ceecc97 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_popcount.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define FUNCTION __clc_popcount +#define __IMPL_FUNCTION(x) __builtin_elementwise_popcount +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rhadd.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rhadd.cl new file mode 100644 index 0000000000..e7dd5c7f4b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rhadd.cl @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rhadd.inc b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rhadd.inc new file mode 100644 index 0000000000..3d55b408b6 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rhadd.inc @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// rhadd = (x+y+1)>>1 +// This can be simplified to x>>1 + y>>1 + (1 if either x or y have the 1s bit +// set) This saves us having to do any checks for overflow in the addition sums +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_rhadd(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return (x >> (__CLC_GENTYPE)1) + (y >> (__CLC_GENTYPE)1) + + ((x & (__CLC_GENTYPE)1) | (y & (__CLC_GENTYPE)1)); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rotate.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rotate.cl new file mode 100644 index 0000000000..2abf0178ce --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rotate.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rotate.inc b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rotate.inc new file mode 100644 index 0000000000..d2a22c1403 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_rotate.inc @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// The rotate(A, B) builtin left-shifts corresponding to the usual OpenCL shift +// modulo rules. These rules state that A is left-shifted by the log2(N) least +// significant bits in B when viewed as an unsigned integer value. Thus we don't +// have to worry about signed shift amounts, and can perform the computation in +// unsigned types. +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_rotate(__CLC_GENTYPE x, + __CLC_GENTYPE n) { + __CLC_U_GENTYPE x_as_u = __CLC_AS_U_GENTYPE(x); + __CLC_U_GENTYPE mask = (__CLC_U_GENTYPE)(__CLC_GENSIZE - 1); + + __CLC_U_GENTYPE lshift_amt = __CLC_AS_U_GENTYPE(n) & mask; + + __CLC_U_GENTYPE rshift_amt = + (((__CLC_U_GENTYPE)__CLC_GENSIZE - lshift_amt) & mask); + + __CLC_U_GENTYPE result = (x_as_u << lshift_amt) | (x_as_u >> rshift_amt); + + return __CLC_AS_GENTYPE(result); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_sub_sat.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_sub_sat.cl new file mode 100644 index 0000000000..e664f04b17 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_sub_sat.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define FUNCTION __clc_sub_sat +#define __IMPL_FUNCTION(x) __builtin_elementwise_sub_sat +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_upsample.cl b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_upsample.cl new file mode 100644 index 0000000000..649bc7830f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/integer/clc_upsample.cl @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_UPSAMPLE_IMPL(BGENTYPE, GENTYPE, UGENTYPE, GENSIZE) \ + _CLC_OVERLOAD _CLC_DEF BGENTYPE __clc_upsample(GENTYPE hi, UGENTYPE lo) { \ + BGENTYPE large_hi = __clc_convert_##BGENTYPE(hi); \ + BGENTYPE large_lo = __clc_convert_##BGENTYPE(lo); \ + return (large_hi << (BGENTYPE)GENSIZE) | large_lo; \ + } + +#define __CLC_UPSAMPLE_IMPL_ALL_TYS(BGENTYPE, GENTYPE, UGENTYPE, GENSIZE) \ + __CLC_UPSAMPLE_IMPL(BGENTYPE, GENTYPE, UGENTYPE, GENSIZE) \ + __CLC_UPSAMPLE_IMPL(BGENTYPE##2, GENTYPE##2, UGENTYPE##2, GENSIZE) \ + __CLC_UPSAMPLE_IMPL(BGENTYPE##3, GENTYPE##3, UGENTYPE##3, GENSIZE) \ + __CLC_UPSAMPLE_IMPL(BGENTYPE##4, GENTYPE##4, UGENTYPE##4, GENSIZE) \ + __CLC_UPSAMPLE_IMPL(BGENTYPE##8, GENTYPE##8, UGENTYPE##8, GENSIZE) \ + __CLC_UPSAMPLE_IMPL(BGENTYPE##16, GENTYPE##16, UGENTYPE##16, GENSIZE) + +#define __CLC_UPSAMPLE_TYPES() \ + __CLC_UPSAMPLE_IMPL_ALL_TYS(short, char, uchar, 8) \ + __CLC_UPSAMPLE_IMPL_ALL_TYS(ushort, uchar, uchar, 8) \ + __CLC_UPSAMPLE_IMPL_ALL_TYS(int, short, ushort, 16) \ + __CLC_UPSAMPLE_IMPL_ALL_TYS(uint, ushort, ushort, 16) \ + __CLC_UPSAMPLE_IMPL_ALL_TYS(long, int, uint, 32) \ + __CLC_UPSAMPLE_IMPL_ALL_TYS(ulong, uint, uint, 32) + +__CLC_UPSAMPLE_TYPES() + +#undef __CLC_UPSAMPLE_TYPES +#undef __CLC_UPSAMPLE_IMPL_ALL_TYS +#undef __CLC_UPSAMPLE_IMPL diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acos.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acos.cl new file mode 100644 index 0000000000..822c3f9f13 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acos.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acos.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acos.inc new file mode 100644 index 0000000000..e036a998a6 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acos.inc @@ -0,0 +1,158 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Computes arccos(x). +// +// The incoming argument is first reduced by noting that arccos(x) is invalid +// for abs(x) > 1. +// +// For denormal and small arguments arccos(x) = pi/2 to machine accuracy. +// +// Remaining argument ranges are handled as follows: +// * For abs(x) <= 0.5 use: +// arccos(x) = pi/2 - arcsin(x) = pi/2 - (x + x^3 * R(x^2)) +// where R(x^2) is a rational minimax approximation to (arcsin(x) - x)/x^3. +// * For abs(x) > 0.5 exploit the identity: +// arccos(x) = pi - 2 * arcsin(sqrt(1 - x)/2) +// together with the above rational approximation, and reconstruct the terms +// carefully. +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_acos(__CLC_GENTYPE x) { + // Some constants and split constants. + const __CLC_GENTYPE piby2 = __CLC_FP_LIT(1.5707963705e+00); + const __CLC_GENTYPE pi = __CLC_FP_LIT(3.1415926535897933e+00); + const __CLC_GENTYPE piby2_head = __CLC_FP_LIT(1.5707963267948965580e+00); + const __CLC_GENTYPE piby2_tail = __CLC_FP_LIT(6.12323399573676603587e-17); + + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_UINTN aux = ux & ~SIGNBIT_SP32; + __CLC_INTN xneg = ux != aux; + __CLC_INTN xexp = __CLC_AS_INTN(aux >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + __CLC_GENTYPE y = __CLC_AS_GENTYPE(aux); + + // transform if |x| >= 0.5 + __CLC_INTN transform = xexp >= -1; + + __CLC_GENTYPE y2 = y * y; + __CLC_GENTYPE yt = 0.5f * (1.0f - y); + __CLC_GENTYPE r = transform ? yt : y2; + + // Use a rational approximation for [0.0, 0.5] + __CLC_GENTYPE a = + __clc_mad(r, + __clc_mad(r, + __clc_mad(r, -0.00396137437848476485201154797087F, + -0.0133819288943925804214011424456F), + -0.0565298683201845211985026327361F), + 0.184161606965100694821398249421F); + + __CLC_GENTYPE b = __clc_mad(r, -0.836411276854206731913362287293F, + 1.10496961524520294485512696706F); + __CLC_GENTYPE u = r * MATH_DIVIDE(a, b); + + __CLC_GENTYPE s = __clc_sqrt(r); + y = s; + __CLC_GENTYPE s1 = __CLC_AS_GENTYPE(__CLC_AS_UINTN(s) & 0xffff0000); + __CLC_GENTYPE c = MATH_DIVIDE(__clc_mad(s1, -s1, r), s + s1); + __CLC_GENTYPE rettn = __clc_mad(s + __clc_mad(y, u, -piby2_tail), -2.0f, pi); + __CLC_GENTYPE rettp = 2.0F * (s1 + __clc_mad(y, u, c)); + __CLC_GENTYPE rett = xneg ? rettn : rettp; + __CLC_GENTYPE ret = piby2_head - (x - __clc_mad(x, -u, piby2_tail)); + + ret = transform ? rett : ret; + ret = aux > 0x3f800000U ? __CLC_GENTYPE_NAN : ret; + ret = ux == 0x3f800000U ? 0.0f : ret; + ret = ux == 0xbf800000U ? pi : ret; + ret = xexp < -26 ? piby2 : ret; + return ret; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_acos(__CLC_GENTYPE x) { + // 0x400921fb54442d18 + const __CLC_GENTYPE pi = __CLC_FP_LIT(3.1415926535897933e+00); + // 0x3ff921fb54442d18 + const __CLC_GENTYPE piby2 = __CLC_FP_LIT(1.5707963267948965580e+00); + // 0x3ff921fb54442d18 + const __CLC_GENTYPE piby2_head = __CLC_FP_LIT(1.5707963267948965580e+00); + // 0x3c91a62633145c07 + const __CLC_GENTYPE piby2_tail = __CLC_FP_LIT(6.12323399573676603587e-17); + + __CLC_GENTYPE y = __clc_fabs(x); + __CLC_LONGN xneg = x < __CLC_FP_LIT(0.0); + __CLC_INTN xexp = __CLC_CONVERT_INTN( + (__CLC_AS_ULONGN(y) >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64); + + // abs(x) >= 0.5 + __CLC_LONGN transform = __CLC_CONVERT_LONGN(xexp >= -1); + + __CLC_GENTYPE rt = __CLC_FP_LIT(0.5) * (__CLC_FP_LIT(1.0) - y); + __CLC_GENTYPE y2 = y * y; + __CLC_GENTYPE r = transform ? rt : y2; + + // Use a rational approximation for [0.0, 0.5] + __CLC_GENTYPE un = __clc_fma( + r, + __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 0.0000482901920344786991880522822991, + 0.00109242697235074662306043804220), + -0.0549989809235685841612020091328), + 0.275558175256937652532686256258), + -0.445017216867635649900123110649), + 0.227485835556935010735943483075); + + __CLC_GENTYPE ud = __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 0.105869422087204370341222318533, + -0.943639137032492685763471240072), + 2.76568859157270989520376345954), + -3.28431505720958658909889444194), + 1.36491501334161032038194214209); + + __CLC_GENTYPE u = r * MATH_DIVIDE(un, ud); + + // Reconstruct acos carefully in transformed region + __CLC_GENTYPE s = __clc_sqrt(r); + __CLC_GENTYPE ztn = __clc_fma(-2.0, (s + __clc_fma(s, u, -piby2_tail)), pi); + + __CLC_GENTYPE s1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(s) & 0xffffffff00000000UL); + __CLC_GENTYPE c = MATH_DIVIDE(__clc_fma(-s1, s1, r), s + s1); + __CLC_GENTYPE ztp = 2.0 * (s1 + __clc_fma(s, u, c)); + __CLC_GENTYPE zt = xneg ? ztn : ztp; + __CLC_GENTYPE z = piby2_head - (x - __clc_fma(-x, u, piby2_tail)); + + z = transform ? zt : z; + + z = __CLC_CONVERT_LONGN(xexp < -56) ? piby2 : z; + z = __clc_isnan(x) ? __CLC_AS_GENTYPE((__CLC_AS_ULONGN(x) | + (__CLC_ULONGN)QNANBITPATT_DP64)) + : z; + z = x == 1.0 ? 0.0 : z; + z = x == -1.0 ? pi : z; + + return z; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_acos(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_acos(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acosh.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acosh.cl new file mode 100644 index 0000000000..a46606be59 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acosh.cl @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acosh.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acosh.inc new file mode 100644 index 0000000000..2f4a58742b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acosh.inc @@ -0,0 +1,111 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_acosh(__CLC_GENTYPE x) { + __CLC_UINTN ux = __CLC_AS_UINTN(x); + + // Arguments greater than 1/sqrt(epsilon) in magnitude are approximated by + // acosh(x) = ln(2) + ln(x) + // For 2.0 <= x <= 1/sqrt(epsilon) the approximation is: + // acosh(x) = ln(x + sqrt(x * x - 1)) + __CLC_INTN high = ux > 0x46000000U; + __CLC_INTN med = ux > 0x40000000U; + + __CLC_GENTYPE w = x - 1.0f; + __CLC_GENTYPE s = w * w + 2.0f * w; + __CLC_GENTYPE t = x * x - 1.0f; + __CLC_GENTYPE r = __clc_sqrt(med ? t : s) + (med ? x : w); + __CLC_GENTYPE v = (high ? x : r) - (med ? 1.0f : 0.0f); + __CLC_GENTYPE z = __clc_log1p(v) + (high ? 0x1.62e430p-1f : 0.0f); + + z = __clc_select(z, x, __clc_isnan(x) || __clc_isinf(x)); + z = x < 1.0f ? __CLC_GENTYPE_NAN : z; + + return z; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_acosh(__CLC_GENTYPE x) { + // 1/sqrt(eps) = 9.49062656242515593767e+07 + const __CLC_GENTYPE recrteps = 0x1.6a09e667f3bcdp+26; + // log2_lead and log2_tail sum to an extra-precise version of log(2) + const __CLC_GENTYPE log2_lead = 0x1.62e42ep-1; + const __CLC_GENTYPE log2_tail = 0x1.efa39ef35793cp-25; + + // Handle x >= 128 here + __CLC_LONGN xlarge = x > recrteps; + __CLC_GENTYPE r = x + __clc_sqrt(__clc_fma(x, x, -1.0)); + r = xlarge ? x : r; + + __CLC_INTN xexp; + __CLC_GENTYPE r1, r2; + __clc_ep_log(r, &xexp, &r1, &r2); + + __CLC_GENTYPE dxexp = __CLC_CONVERT_GENTYPE( + __CLC_CONVERT_LONGN(xexp) + (xlarge ? (__CLC_LONGN)1 : (__CLC_LONGN)0)); + r1 = __clc_fma(dxexp, log2_lead, r1); + r2 = __clc_fma(dxexp, log2_tail, r2); + + __CLC_GENTYPE ret1 = r1 + r2; + + // Handle 1 < x < 128 here + // We compute the value + // t = x - 1.0 + sqrt(2.0*(x - 1.0) + (x - 1.0)*(x - 1.0)) + // using simulated quad precision. + __CLC_GENTYPE t = x - 1.0; + __CLC_GENTYPE u1 = t * 2.0; + + // (t,0) * (t,0) -> (v1, v2) + __CLC_GENTYPE v1 = t * t; + __CLC_GENTYPE v2 = __clc_fma(t, t, -v1); + + // (u1,0) + (v1,v2) -> (w1,w2) + r = u1 + v1; + __CLC_GENTYPE s = (((u1 - r) + v1) + v2); + __CLC_GENTYPE w1 = r + s; + __CLC_GENTYPE w2 = (r - w1) + s; + + // sqrt(w1,w2) -> (u1,u2) + __CLC_GENTYPE p1 = __clc_sqrt(w1); + __CLC_GENTYPE a1 = p1 * p1; + __CLC_GENTYPE a2 = __clc_fma(p1, p1, -a1); + __CLC_GENTYPE temp = (((w1 - a1) - a2) + w2); + __CLC_GENTYPE p2 = MATH_DIVIDE(temp * 0.5, p1); + u1 = p1 + p2; + __CLC_GENTYPE u2 = (p1 - u1) + p2; + + // (u1,u2) + (t,0) -> (r1,r2) + r = u1 + t; + s = ((u1 - r) + t) + u2; + // r1 = r + s; + // r2 = (r - r1) + s; + // t = r1 + r2; + t = r + s; + + // For arguments 1.13 <= x <= 1.5 the log1p function is good enough + __CLC_GENTYPE ret2 = __clc_log1p(t); + + __CLC_GENTYPE ret = x >= 128.0 ? ret1 : ret2; + + ret = (__clc_isinf(x) || __clc_isnan(x)) ? x : ret; + ret = x == 1.0 ? 0.0 : ret; + ret = x < 1.0 ? __CLC_GENTYPE_NAN : ret; + + return ret; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_acosh(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_acosh(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acospi.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acospi.cl new file mode 100644 index 0000000000..22134d3209 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acospi.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acospi.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acospi.inc new file mode 100644 index 0000000000..82d8188ca7 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_acospi.inc @@ -0,0 +1,156 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Computes arccos(x). +// +// The incoming argument is first reduced by noting that arccos(x) is invalid +// for abs(x) > 1. +// +// For denormal and small arguments arccos(x) = pi/2 to machine accuracy. +// +// Remaining argument ranges are handled as follows: +// * For abs(x) <= 0.5 use: +// arccos(x) = pi/2 - arcsin(x) = pi/2 - (x + x^3 * R(x^2)) +// where R(x^2) is a rational minimax approximation to (arcsin(x) - x)/x^3. +// * For abs(x) > 0.5 exploit the identity: +// arccos(x) = pi - 2 * arcsin(sqrt(1 - x)/2) +// together with the above rational approximation, and reconstruct the terms +// carefully. +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_acospi(__CLC_GENTYPE x) { + // Some constants and split constants. + const __CLC_GENTYPE pi = __CLC_FP_LIT(3.1415926535897933e+00); + // 0x3ff921fb54442d18 + const __CLC_GENTYPE piby2_head = __CLC_FP_LIT(1.5707963267948965580e+00); + // 0x3c91a62633145c07 + const __CLC_GENTYPE piby2_tail = __CLC_FP_LIT(6.12323399573676603587e-17); + + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_UINTN aux = ux & ~SIGNBIT_SP32; + __CLC_INTN xneg = ux != aux; + __CLC_INTN xexp = __CLC_AS_INTN(aux >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + + __CLC_GENTYPE y = __CLC_AS_GENTYPE(aux); + + // transform if |x| >= 0.5 + __CLC_INTN transform = xexp >= -1; + + __CLC_GENTYPE y2 = y * y; + __CLC_GENTYPE yt = 0.5f * (1.0f - y); + __CLC_GENTYPE r = transform ? yt : y2; + + // Use a rational approximation for [0.0, 0.5] + __CLC_GENTYPE a = + __clc_mad(r, + __clc_mad(r, + __clc_mad(r, -0.00396137437848476485201154797087F, + -0.0133819288943925804214011424456F), + -0.0565298683201845211985026327361F), + 0.184161606965100694821398249421F); + __CLC_GENTYPE b = __clc_mad(r, -0.836411276854206731913362287293F, + 1.10496961524520294485512696706F); + __CLC_GENTYPE u = r * MATH_DIVIDE(a, b); + + __CLC_GENTYPE s = __clc_sqrt(r); + y = s; + __CLC_GENTYPE s1 = __CLC_AS_GENTYPE(__CLC_AS_UINTN(s) & 0xffff0000); + __CLC_GENTYPE c = MATH_DIVIDE(r - s1 * s1, s + s1); + __CLC_GENTYPE rettn = + 1.0f - MATH_DIVIDE(2.0f * (s + __clc_mad(y, u, -piby2_tail)), pi); + __CLC_GENTYPE rettp = MATH_DIVIDE(2.0f * (s1 + __clc_mad(y, u, c)), pi); + __CLC_GENTYPE rett = xneg ? rettn : rettp; + __CLC_GENTYPE ret = + MATH_DIVIDE(piby2_head - (x - __clc_mad(x, -u, piby2_tail)), pi); + + ret = transform ? rett : ret; + ret = aux > 0x3f800000U ? __CLC_GENTYPE_NAN : ret; + ret = ux == 0x3f800000U ? 0.0f : ret; + ret = ux == 0xbf800000U ? 1.0f : ret; + ret = xexp < -26 ? 0.5f : ret; + return ret; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_acospi(__CLC_GENTYPE x) { + const __CLC_GENTYPE pi = __CLC_FP_LIT(0x1.921fb54442d18p+1); + // 0x3c91a62633145c07 + const __CLC_GENTYPE piby2_tail = __CLC_FP_LIT(6.12323399573676603587e-17); + + __CLC_GENTYPE y = __clc_fabs(x); + __CLC_LONGN xneg = x < __CLC_FP_LIT(0.0); + __CLC_INTN xexp = __CLC_CONVERT_INTN( + (__CLC_AS_ULONGN(y) >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64); + + // abs(x) >= 0.5 + __CLC_LONGN transform = __CLC_CONVERT_LONGN(xexp >= -1); + + // Transform y into the range [0,0.5) + __CLC_GENTYPE r1 = 0.5 * (1.0 - y); + __CLC_GENTYPE s = __clc_sqrt(r1); + __CLC_GENTYPE r = y * y; + r = transform ? r1 : r; + y = transform ? s : y; + + // Use a rational approximation for [0.0, 0.5] + __CLC_GENTYPE un = __clc_fma( + r, + __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 0.0000482901920344786991880522822991, + 0.00109242697235074662306043804220), + -0.0549989809235685841612020091328), + 0.275558175256937652532686256258), + -0.445017216867635649900123110649), + 0.227485835556935010735943483075); + + __CLC_GENTYPE ud = __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 0.105869422087204370341222318533, + -0.943639137032492685763471240072), + 2.76568859157270989520376345954), + -3.28431505720958658909889444194), + 1.36491501334161032038194214209); + + __CLC_GENTYPE u = r * MATH_DIVIDE(un, ud); + + // Reconstruct acos carefully in transformed region + __CLC_GENTYPE res1 = + __clc_fma(-2.0, MATH_DIVIDE(s + __clc_fma(y, u, -piby2_tail), pi), 1.0); + __CLC_GENTYPE s1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(s) & 0xffffffff00000000UL); + __CLC_GENTYPE c = MATH_DIVIDE(__clc_fma(-s1, s1, r), s + s1); + __CLC_GENTYPE res2 = + MATH_DIVIDE(__clc_fma(2.0, s1, __clc_fma(2.0, c, 2.0 * y * u)), pi); + res1 = xneg ? res1 : res2; + res2 = 0.5 - __clc_fma(x, u, x) / pi; + res1 = transform ? res1 : res2; + + res2 = x == 1.0 ? 0.0 : __CLC_GENTYPE_NAN; + res2 = x == -1.0 ? 1.0 : res2; + res1 = __CLC_CONVERT_LONGN(xexp >= 0) ? res2 : res1; + res1 = __CLC_CONVERT_LONGN(xexp < -56) ? 0.5 : res1; + + return res1; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_acospi(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_acospi(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asin.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asin.cl new file mode 100644 index 0000000000..195ede3907 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asin.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asin.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asin.inc new file mode 100644 index 0000000000..a1718b81b4 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asin.inc @@ -0,0 +1,154 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Computes arcsin(x). +// +// The incoming argument is first reduced by noting that arcsin(x) is invalid +// for abs(x) > 1 and arcsin(-x) = -arcsin(x). +// +// For denormal and small arguments, arcsin(x) = x to machine accuracy. +// +// Remaining argument ranges are handled as follows: +// * For abs(x) <= 0.5 use: +// arcsin(x) = x + x^3 * R(x^2) +// where R(x^2) is a rational minimax approximation to (arcsin(x) - x)/x^3. +// * For abs(x) > 0.5 exploit the identity: +// arcsin(x) = pi/2 - 2 * arcsin(sqrt(1 - x)/2) +// together with the above rational approximation, and reconstruct the terms +// carefully. +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_asin(__CLC_GENTYPE x) { + // 0x33a22168 + const __CLC_GENTYPE piby2_tail = __CLC_FP_LIT(7.5497894159e-08); + // 0x3f490fda + const __CLC_GENTYPE hpiby2_head = __CLC_FP_LIT(7.8539812565e-01); + // 0x3fc90fdb + const __CLC_GENTYPE piby2 = __CLC_FP_LIT(1.5707963705e+00); + + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_UINTN aux = ux & EXSIGNBIT_SP32; + __CLC_UINTN xs = ux ^ aux; + __CLC_GENTYPE spiby2 = __CLC_AS_GENTYPE(xs | __CLC_AS_UINTN(piby2)); + __CLC_INTN xexp = __CLC_AS_INTN(aux >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + __CLC_GENTYPE y = __CLC_AS_GENTYPE(aux); + + // abs(x) >= 0.5 + __CLC_INTN transform = xexp >= -1; + + __CLC_GENTYPE y2 = y * y; + __CLC_GENTYPE rt = __CLC_FP_LIT(0.5) * (__CLC_FP_LIT(1.0) - y); + __CLC_GENTYPE r = transform ? rt : y2; + + // Use a rational approximation for [0.0, 0.5] + __CLC_GENTYPE a = + __clc_mad(r, + __clc_mad(r, + __clc_mad(r, -0.00396137437848476485201154797087F, + -0.0133819288943925804214011424456F), + -0.0565298683201845211985026327361F), + 0.184161606965100694821398249421F); + + __CLC_GENTYPE b = __clc_mad(r, -0.836411276854206731913362287293F, + 1.10496961524520294485512696706F); + __CLC_GENTYPE u = r * MATH_DIVIDE(a, b); + + __CLC_GENTYPE s = __clc_sqrt(r); + __CLC_GENTYPE s1 = __CLC_AS_GENTYPE(__CLC_AS_UINTN(s) & 0xffff0000); + __CLC_GENTYPE c = MATH_DIVIDE(__clc_mad(-s1, s1, r), s + s1); + __CLC_GENTYPE p = __clc_mad(2.0f * s, u, -__clc_mad(c, -2.0f, piby2_tail)); + __CLC_GENTYPE q = __clc_mad(s1, -2.0f, hpiby2_head); + __CLC_GENTYPE vt = hpiby2_head - (p - q); + __CLC_GENTYPE v = __clc_mad(y, u, y); + v = transform ? vt : v; + + __CLC_GENTYPE ret = __CLC_AS_GENTYPE(xs | __CLC_AS_UINTN(v)); + ret = aux > 0x3f800000U ? __CLC_GENTYPE_NAN : ret; + ret = aux == 0x3f800000U ? spiby2 : ret; + ret = xexp < -14 ? x : ret; + + return ret; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_asin(__CLC_GENTYPE x) { + // 0x3c91a62633145c07 + const __CLC_GENTYPE piby2_tail = __CLC_FP_LIT(6.1232339957367660e-17); + // 0x3fe921fb54442d18 + const __CLC_GENTYPE hpiby2_head = 7.8539816339744831e-01; + // 0x3ff921fb54442d18 + const __CLC_GENTYPE piby2 = 1.5707963267948965e+00; + + __CLC_GENTYPE y = __clc_fabs(x); + __CLC_LONGN xneg = x < __CLC_FP_LIT(0.0); + __CLC_INTN xexp = __CLC_CONVERT_INTN( + (__CLC_AS_ULONGN(y) >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64); + + // abs(x) >= 0.5 + __CLC_LONGN transform = __CLC_CONVERT_LONGN(xexp >= -1); + + __CLC_GENTYPE rt = __CLC_FP_LIT(0.5) * (__CLC_FP_LIT(1.0) - y); + __CLC_GENTYPE y2 = y * y; + __CLC_GENTYPE r = transform ? rt : y2; + + // Use a rational approximation for [0.0, 0.5] + + __CLC_GENTYPE un = __clc_fma( + r, + __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 0.0000482901920344786991880522822991, + 0.00109242697235074662306043804220), + -0.0549989809235685841612020091328), + 0.275558175256937652532686256258), + -0.445017216867635649900123110649), + 0.227485835556935010735943483075); + + __CLC_GENTYPE ud = __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 0.105869422087204370341222318533, + -0.943639137032492685763471240072), + 2.76568859157270989520376345954), + -3.28431505720958658909889444194), + 1.36491501334161032038194214209); + + __CLC_GENTYPE u = r * MATH_DIVIDE(un, ud); + + // Reconstruct asin carefully in transformed region + __CLC_GENTYPE s = __clc_sqrt(r); + __CLC_GENTYPE sh = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(s) & 0xffffffff00000000UL); + __CLC_GENTYPE c = MATH_DIVIDE(__clc_fma(-sh, sh, r), s + sh); + __CLC_GENTYPE p = __clc_fma(2.0 * s, u, -__clc_fma(-2.0, c, piby2_tail)); + __CLC_GENTYPE q = __clc_fma(-2.0, sh, hpiby2_head); + __CLC_GENTYPE vt = hpiby2_head - (p - q); + __CLC_GENTYPE v = __clc_fma(y, u, y); + v = transform ? vt : v; + + v = __CLC_CONVERT_LONGN(xexp < -28) ? y : v; + v = __CLC_CONVERT_LONGN(xexp >= 0) ? __CLC_GENTYPE_NAN : v; + v = y == 1.0 ? piby2 : v; + + return xneg ? -v : v; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_asin(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_asin(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinh.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinh.cl new file mode 100644 index 0000000000..763efb4e76 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinh.cl @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinh.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinh.inc new file mode 100644 index 0000000000..5ad07dde7e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinh.inc @@ -0,0 +1,310 @@ +//===----------------------------------------------------------------------===// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_asinh(__CLC_GENTYPE x) { + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_UINTN ax = ux & EXSIGNBIT_SP32; + __CLC_UINTN xsgn = ax ^ ux; + + // |x| <= 2 + __CLC_GENTYPE t = x * x; + __CLC_GENTYPE a = + __clc_mad(t, + __clc_mad(t, + __clc_mad(t, + __clc_mad(t, -1.177198915954942694e-4f, + -4.162727710583425360e-2f), + -5.063201055468483248e-1f), + -1.480204186473758321f), + -1.152965835871758072f); + __CLC_GENTYPE b = + __clc_mad(t, + __clc_mad(t, + __clc_mad(t, + __clc_mad(t, 6.284381367285534560e-2f, + 1.260024978680227945f), + 6.582362487198468066f), + 11.99423176003939087f), + 6.917795026025976739f); + + __CLC_GENTYPE q = MATH_DIVIDE(a, b); + __CLC_GENTYPE z1 = __clc_mad(x * t, q, x); + + // |x| > 2 + + // Arguments greater than 1/sqrt(epsilon) in magnitude are + // approximated by asinh(x) = ln(2) + ln(abs(x)), with sign of x + // Arguments such that 4.0 <= abs(x) <= 1/sqrt(epsilon) are + // approximated by asinhf(x) = ln(abs(x) + sqrt(x*x+1)) + // with the sign of x (see Abramowitz and Stegun 4.6.20) + + __CLC_GENTYPE absx = __clc_fabs(x); + __CLC_INTN hi = ax > 0x46000000U; + __CLC_GENTYPE y = __clc_sqrt(absx * absx + 1.0f) + absx; + y = hi ? absx : y; + __CLC_GENTYPE r = __clc_log(y) + (hi ? 0x1.62e430p-1f : 0.0f); + __CLC_GENTYPE z2 = __CLC_AS_GENTYPE(xsgn | __CLC_AS_UINTN(r)); + + __CLC_GENTYPE z = ax <= 0x40000000 ? z1 : z2; + z = __clc_select(z, x, ax < 0x39800000U || __clc_isinf(x) || __clc_isnan(x)); + + return z; +} + +#elif __CLC_FPSIZE == 64 + +#define NA0 -0.12845379283524906084997e0 +#define NA1 -0.21060688498409799700819e0 +#define NA2 -0.10188951822578188309186e0 +#define NA3 -0.13891765817243625541799e-1 +#define NA4 -0.10324604871728082428024e-3 + +#define DA0 0.77072275701149440164511e0 +#define DA1 0.16104665505597338100747e1 +#define DA2 0.11296034614816689554875e1 +#define DA3 0.30079351943799465092429e0 +#define DA4 0.235224464765951442265117e-1 + +#define NB0 -0.12186605129448852495563e0 +#define NB1 -0.19777978436593069928318e0 +#define NB2 -0.94379072395062374824320e-1 +#define NB3 -0.12620141363821680162036e-1 +#define NB4 -0.903396794842691998748349e-4 + +#define DB0 0.73119630776696495279434e0 +#define DB1 0.15157170446881616648338e1 +#define DB2 0.10524909506981282725413e1 +#define DB3 0.27663713103600182193817e0 +#define DB4 0.21263492900663656707646e-1 + +#define NC0 -0.81210026327726247622500e-1 +#define NC1 -0.12327355080668808750232e0 +#define NC2 -0.53704925162784720405664e-1 +#define NC3 -0.63106739048128554465450e-2 +#define NC4 -0.35326896180771371053534e-4 + +#define DC0 0.48726015805581794231182e0 +#define DC1 0.95890837357081041150936e0 +#define DC2 0.62322223426940387752480e0 +#define DC3 0.15028684818508081155141e0 +#define DC4 0.10302171620320141529445e-1 + +#define ND0 -0.4638179204422665073e-1 +#define ND1 -0.7162729496035415183e-1 +#define ND2 -0.3247795155696775148e-1 +#define ND3 -0.4225785421291932164e-2 +#define ND4 -0.3808984717603160127e-4 +#define ND5 0.8023464184964125826e-6 + +#define DD0 0.2782907534642231184e0 +#define DD1 0.5549945896829343308e0 +#define DD2 0.3700732511330698879e0 +#define DD3 0.9395783438240780722e-1 +#define DD4 0.7200057974217143034e-2 + +#define NE0 -0.121224194072430701e-4 +#define NE1 -0.273145455834305218e-3 +#define NE2 -0.152866982560895737e-2 +#define NE3 -0.292231744584913045e-2 +#define NE4 -0.174670900236060220e-2 +#define NE5 -0.891754209521081538e-12 + +#define DE0 0.499426632161317606e-4 +#define DE1 0.139591210395547054e-2 +#define DE2 0.107665231109108629e-1 +#define DE3 0.325809818749873406e-1 +#define DE4 0.415222526655158363e-1 +#define DE5 0.186315628774716763e-1 + +#define NF0 -0.195436610112717345e-4 +#define NF1 -0.233315515113382977e-3 +#define NF2 -0.645380957611087587e-3 +#define NF3 -0.478948863920281252e-3 +#define NF4 -0.805234112224091742e-12 +#define NF5 0.246428598194879283e-13 + +#define DF0 0.822166621698664729e-4 +#define DF1 0.135346265620413852e-2 +#define DF2 0.602739242861830658e-2 +#define DF3 0.972227795510722956e-2 +#define DF4 0.510878800983771167e-2 + +#define NG0 -0.209689451648100728e-6 +#define NG1 -0.219252358028695992e-5 +#define NG2 -0.551641756327550939e-5 +#define NG3 -0.382300259826830258e-5 +#define NG4 -0.421182121910667329e-17 +#define NG5 0.492236019998237684e-19 + +#define DG0 0.889178444424237735e-6 +#define DG1 0.131152171690011152e-4 +#define DG2 0.537955850185616847e-4 +#define DG3 0.814966175170941864e-4 +#define DG4 0.407786943832260752e-4 + +#define NH0 -0.178284193496441400e-6 +#define NH1 -0.928734186616614974e-6 +#define NH2 -0.923318925566302615e-6 +#define NH3 -0.776417026702577552e-19 +#define NH4 0.290845644810826014e-21 + +#define DH0 0.786694697277890964e-6 +#define DH1 0.685435665630965488e-5 +#define DH2 0.153780175436788329e-4 +#define DH3 0.984873520613417917e-5 + +#define NI0 -0.538003743384069117e-10 +#define NI1 -0.273698654196756169e-9 +#define NI2 -0.268129826956403568e-9 +#define NI3 -0.804163374628432850e-29 + +#define DI0 0.238083376363471960e-9 +#define DI1 0.203579344621125934e-8 +#define DI2 0.450836980450693209e-8 +#define DI3 0.286005148753497156e-8 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_asinh(__CLC_GENTYPE x) { + const __CLC_GENTYPE rteps = 0x1.6a09e667f3bcdp-27; + const __CLC_GENTYPE recrteps = 0x1.6a09e667f3bcdp+26; + + // log2_lead and log2_tail sum to an extra-precise version of log(2) + const __CLC_GENTYPE log2_lead = 0x1.62e42ep-1; + const __CLC_GENTYPE log2_tail = 0x1.efa39ef35793cp-25; + + __CLC_GENTYPE absx = __clc_fabs(x); + + __CLC_GENTYPE t = x * x; + __CLC_GENTYPE pn, tn, pd, td; + + // XXX we are betting here that we can evaluate 8 pairs of + // polys faster than we can grab 12 coefficients from a table + // This also uses fewer registers + + // |x| >= 8 + pn = __clc_fma(t, __clc_fma(t, __clc_fma(t, NI3, NI2), NI1), NI0); + pd = __clc_fma(t, __clc_fma(t, __clc_fma(t, DI3, DI2), DI1), DI0); + + tn = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, NH4, NH3), NH2), NH1), NH0); + td = __clc_fma(t, __clc_fma(t, __clc_fma(t, DH3, DH2), DH1), DH0); + pn = absx < 8.0 ? tn : pn; + pd = absx < 8.0 ? td : pd; + + tn = __clc_fma( + t, + __clc_fma(t, __clc_fma(t, __clc_fma(t, __clc_fma(t, NG5, NG4), NG3), NG2), + NG1), + NG0); + td = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, DG4, DG3), DG2), DG1), DG0); + pn = absx < 4.0 ? tn : pn; + pd = absx < 4.0 ? td : pd; + + tn = __clc_fma( + t, + __clc_fma(t, __clc_fma(t, __clc_fma(t, __clc_fma(t, NF5, NF4), NF3), NF2), + NF1), + NF0); + td = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, DF4, DF3), DF2), DF1), DF0); + pn = absx < 2.0 ? tn : pn; + pd = absx < 2.0 ? td : pd; + + tn = __clc_fma( + t, + __clc_fma(t, __clc_fma(t, __clc_fma(t, __clc_fma(t, NE5, NE4), NE3), NE2), + NE1), + NE0); + td = __clc_fma( + t, + __clc_fma(t, __clc_fma(t, __clc_fma(t, __clc_fma(t, DE5, DE4), DE3), DE2), + DE1), + DE0); + pn = absx < 1.5 ? tn : pn; + pd = absx < 1.5 ? td : pd; + + tn = __clc_fma( + t, + __clc_fma(t, __clc_fma(t, __clc_fma(t, __clc_fma(t, ND5, ND4), ND3), ND2), + ND1), + ND0); + td = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, DD4, DD3), DD2), DD1), DD0); + pn = absx <= 1.0 ? tn : pn; + pd = absx <= 1.0 ? td : pd; + + tn = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, NC4, NC3), NC2), NC1), NC0); + td = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, DC4, DC3), DC2), DC1), DC0); + pn = absx < 0.75 ? tn : pn; + pd = absx < 0.75 ? td : pd; + + tn = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, NB4, NB3), NB2), NB1), NB0); + td = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, DB4, DB3), DB2), DB1), DB0); + pn = absx < 0.5 ? tn : pn; + pd = absx < 0.5 ? td : pd; + + tn = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, NA4, NA3), NA2), NA1), NA0); + td = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, DA4, DA3), DA2), DA1), DA0); + pn = absx < 0.25 ? tn : pn; + pd = absx < 0.25 ? td : pd; + + __CLC_GENTYPE pq = MATH_DIVIDE(pn, pd); + + // |x| <= 1 + __CLC_GENTYPE result1 = __clc_fma(absx * t, pq, absx); + + // Other ranges + __CLC_LONGN xout = absx <= 32.0 || absx > recrteps; + __CLC_GENTYPE y = absx + __clc_sqrt(__clc_fma(absx, absx, 1.0)); + y = xout ? absx : y; + + __CLC_GENTYPE r1, r2; + __CLC_INTN xexp; + __clc_ep_log(y, &xexp, &r1, &r2); + + __CLC_GENTYPE dxexp = __CLC_CONVERT_GENTYPE( + __CLC_CONVERT_LONGN(xexp) + (xout ? (__CLC_LONGN)1 : (__CLC_LONGN)0)); + r1 = __clc_fma(dxexp, log2_lead, r1); + r2 = __clc_fma(dxexp, log2_tail, r2); + + // 1 < x <= 32 + __CLC_GENTYPE v2 = (pq + 0.25) / t; + __CLC_GENTYPE r = v2 + r1; + __CLC_GENTYPE s = ((r1 - r) + v2) + r2; + __CLC_GENTYPE v1 = r + s; + v2 = (r - v1) + s; + __CLC_GENTYPE result2 = v1 + v2; + + // x > 32 + __CLC_GENTYPE result3 = r1 + r2; + + __CLC_GENTYPE ret = absx > 1.0 ? result2 : result1; + ret = absx > 32.0 ? result3 : ret; + ret = x < 0.0 ? -ret : ret; + + // NaN, +-Inf, or x small enough that asinh(x) = x + ret = __clc_select( + ret, x, + __CLC_CONVERT_LONGN(__clc_isnan(x) || __clc_isinf(x) || absx < rteps)); + return ret; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_asinh(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_asinh(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinpi.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinpi.cl new file mode 100644 index 0000000000..bc680df5f9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinpi.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinpi.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinpi.inc new file mode 100644 index 0000000000..2a47b8ed45 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_asinpi.inc @@ -0,0 +1,156 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Computes arcsin(x). +// +// The incoming argument is first reduced by noting that arcsin(x) is invalid +// for abs(x) > 1 and arcsin(-x) = -arcsin(x). +// +// For denormal and small arguments arcsin(x) = x to machine accuracy. +// +// Remaining argument ranges are handled as follows. +// +// * For abs(x) <= 0.5 use: +// arcsin(x) = x + x^3 * R(x^2) +// where R(x^2) is a rational minimax approximation to (arcsin(x) - x)/x^3. +// * For abs(x) > 0.5 exploit the identity: +// arcsin(x) = pi/2 - 2 * arcsin(sqrt(1 - x)/2) +// together with the above rational approximation, and reconstruct the terms +// carefully. +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_asinpi(__CLC_GENTYPE x) { + const __CLC_GENTYPE pi = __CLC_FP_LIT(3.1415926535897933e+00); + // 0x33a22168 + const __CLC_GENTYPE piby2_tail = __CLC_FP_LIT(7.5497894159e-08); + // 0x3f490fda + const __CLC_GENTYPE hpiby2_head = __CLC_FP_LIT(7.8539812565e-01); + + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_UINTN aux = ux & EXSIGNBIT_SP32; + __CLC_UINTN xs = ux ^ aux; + __CLC_GENTYPE shalf = + __CLC_AS_GENTYPE(xs | __CLC_AS_UINTN(__CLC_FP_LIT(0.5))); + + __CLC_INTN xexp = __CLC_AS_INTN(aux >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + + __CLC_GENTYPE y = __CLC_AS_GENTYPE(aux); + + // abs(x) >= 0.5 + __CLC_INTN transform = xexp >= -1; + + __CLC_GENTYPE y2 = y * y; + __CLC_GENTYPE rt = 0.5f * (1.0f - y); + __CLC_GENTYPE r = transform ? rt : y2; + + // Use a rational approximation for [0.0, 0.5] + __CLC_GENTYPE a = + __clc_mad(r, + __clc_mad(r, + __clc_mad(r, -0.00396137437848476485201154797087F, + -0.0133819288943925804214011424456F), + -0.0565298683201845211985026327361F), + 0.184161606965100694821398249421F); + __CLC_GENTYPE b = __clc_mad(r, -0.836411276854206731913362287293F, + 1.10496961524520294485512696706F); + __CLC_GENTYPE u = r * MATH_DIVIDE(a, b); + + __CLC_GENTYPE s = __clc_sqrt(r); + __CLC_GENTYPE s1 = __CLC_AS_GENTYPE(__CLC_AS_UINTN(s) & 0xffff0000); + __CLC_GENTYPE c = MATH_DIVIDE(__clc_mad(-s1, s1, r), s + s1); + __CLC_GENTYPE p = __clc_mad(2.0f * s, u, -__clc_mad(c, -2.0f, piby2_tail)); + __CLC_GENTYPE q = __clc_mad(s1, -2.0f, hpiby2_head); + __CLC_GENTYPE vt = hpiby2_head - (p - q); + __CLC_GENTYPE v = __clc_mad(y, u, y); + v = transform ? vt : v; + v = MATH_DIVIDE(v, pi); + __CLC_GENTYPE xbypi = MATH_DIVIDE(x, pi); + + __CLC_GENTYPE ret = __CLC_AS_GENTYPE(xs | __CLC_AS_UINTN(v)); + ret = aux > 0x3f800000U ? __CLC_GENTYPE_NAN : ret; + ret = aux == 0x3f800000U ? shalf : ret; + ret = xexp < -14 ? xbypi : ret; + + return ret; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_asinpi(__CLC_GENTYPE x) { + const __CLC_GENTYPE pi = __CLC_FP_LIT(0x1.921fb54442d18p+1); + // 0x3c91a62633145c07 + const __CLC_GENTYPE piby2_tail = __CLC_FP_LIT(6.1232339957367660e-17); + // 0x3fe921fb54442d18 + const __CLC_GENTYPE hpiby2_head = __CLC_FP_LIT(7.8539816339744831e-01); + + __CLC_GENTYPE y = __clc_fabs(x); + __CLC_LONGN xneg = x < __CLC_FP_LIT(0.0); + __CLC_INTN xexp = __CLC_CONVERT_INTN( + (__CLC_AS_ULONGN(y) >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64); + + // abs(x) >= 0.5 + __CLC_LONGN transform = __CLC_CONVERT_LONGN(xexp >= -1); + + __CLC_GENTYPE rt = 0.5 * (1.0 - y); + __CLC_GENTYPE y2 = y * y; + __CLC_GENTYPE r = transform ? rt : y2; + + // Use a rational approximation for [0.0, 0.5] + __CLC_GENTYPE un = __clc_fma( + r, + __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 0.0000482901920344786991880522822991, + 0.00109242697235074662306043804220), + -0.0549989809235685841612020091328), + 0.275558175256937652532686256258), + -0.445017216867635649900123110649), + 0.227485835556935010735943483075); + + __CLC_GENTYPE ud = __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 0.105869422087204370341222318533, + -0.943639137032492685763471240072), + 2.76568859157270989520376345954), + -3.28431505720958658909889444194), + 1.36491501334161032038194214209); + + __CLC_GENTYPE u = r * MATH_DIVIDE(un, ud); + + // Reconstruct asin carefully in transformed region + __CLC_GENTYPE s = __clc_sqrt(r); + __CLC_GENTYPE sh = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(s) & 0xffffffff00000000UL); + __CLC_GENTYPE c = MATH_DIVIDE(__clc_fma(-sh, sh, r), s + sh); + __CLC_GENTYPE p = __clc_fma(2.0 * s, u, -__clc_fma(-2.0, c, piby2_tail)); + __CLC_GENTYPE q = __clc_fma(-2.0, sh, hpiby2_head); + __CLC_GENTYPE vt = hpiby2_head - (p - q); + __CLC_GENTYPE v = __clc_fma(y, u, y); + v = transform ? vt : v; + + v = __CLC_CONVERT_LONGN(xexp < -28) ? y : v; + v = MATH_DIVIDE(v, pi); + v = __CLC_CONVERT_LONGN(xexp >= 0) ? __CLC_GENTYPE_NAN : v; + v = y == 1.0 ? 0.5 : v; + return xneg ? -v : v; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_asinpi(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_asinpi(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan.cl new file mode 100644 index 0000000000..d960f75bac --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan.inc new file mode 100644 index 0000000000..23136dbd74 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan.inc @@ -0,0 +1,168 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atan(__CLC_GENTYPE x) { + const __CLC_GENTYPE piby2 = 1.5707963267948966f; // 0x3ff921fb54442d18 + + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_UINTN aux = ux & EXSIGNBIT_SP32; + __CLC_UINTN sx = ux ^ aux; + + __CLC_GENTYPE spiby2 = __CLC_AS_GENTYPE(sx | __CLC_AS_UINTN(piby2)); + + __CLC_GENTYPE v = __CLC_AS_GENTYPE(aux); + + // Return for NaN + __CLC_GENTYPE ret = x; + + // 2^26 <= |x| <= Inf => atan(x) is close to piby2 + ret = aux <= PINFBITPATT_SP32 ? spiby2 : ret; + + // Reduce arguments 2^-19 <= |x| < 2^26 + + // 39/16 <= x < 2^26 + x = -MATH_RECIP(v); + __CLC_GENTYPE c = 1.57079632679489655800f; // atan(infinity) + + // 19/16 <= x < 39/16 + __CLC_INTN l = aux < 0x401c0000; + __CLC_GENTYPE xx = MATH_DIVIDE(v - 1.5f, __clc_mad(v, 1.5f, 1.0f)); + x = l ? xx : x; + c = l ? 9.82793723247329054082e-01f : c; // atan(1.5) + + // 11/16 <= x < 19/16 + l = aux < 0x3f980000U; + xx = MATH_DIVIDE(v - 1.0f, 1.0f + v); + x = l ? xx : x; + c = l ? 7.85398163397448278999e-01f : c; // atan(1) + + // 7/16 <= x < 11/16 + l = aux < 0x3f300000; + xx = MATH_DIVIDE(__clc_mad(v, 2.0f, -1.0f), 2.0f + v); + x = l ? xx : x; + c = l ? 4.63647609000806093515e-01f : c; // atan(0.5) + + // 2^-19 <= x < 7/16 + l = aux < 0x3ee00000; + x = l ? v : x; + c = l ? 0.0f : c; + + // Core approximation: Remez(2,2) on [-7/16,7/16] + + __CLC_GENTYPE s = x * x; + __CLC_GENTYPE a = __clc_mad(s, + __clc_mad(s, 0.470677934286149214138357545549e-2f, + 0.192324546402108583211697690500f), + 0.296528598819239217902158651186f); + + __CLC_GENTYPE b = __clc_mad(s, + __clc_mad(s, 0.299309699959659728404442796915f, + 0.111072499995399550138837673349e1f), + 0.889585796862432286486651434570f); + + __CLC_GENTYPE q = x * s * MATH_DIVIDE(a, b); + + __CLC_GENTYPE z = c - (q - x); + __CLC_GENTYPE zs = __CLC_AS_GENTYPE(sx | __CLC_AS_UINTN(z)); + + ret = aux < 0x4c800000 ? zs : ret; + + // |x| < 2^-19 + ret = aux < 0x36000000 ? __CLC_AS_GENTYPE(ux) : ret; + return ret; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atan(__CLC_GENTYPE x) { + const __CLC_GENTYPE piby2 = 1.5707963267948966e+00; // 0x3ff921fb54442d18 + + __CLC_GENTYPE v = __clc_fabs(x); + + // 2^56 > v > 39/16 + __CLC_GENTYPE a = -1.0; + __CLC_GENTYPE b = v; + // (chi + clo) = arctan(infinity) + __CLC_GENTYPE chi = 1.57079632679489655800e+00; + __CLC_GENTYPE clo = 6.12323399573676480327e-17; + + __CLC_GENTYPE ta = v - 1.5; + __CLC_GENTYPE tb = 1.0 + 1.5 * v; + __CLC_LONGN l = v <= 0x1.38p+1; // 39/16 > v > 19/16 + a = l ? ta : a; + b = l ? tb : b; + // (chi + clo) = arctan(1.5) + chi = l ? 9.82793723247329054082e-01 : chi; + clo = l ? 1.39033110312309953701e-17 : clo; + + ta = v - 1.0; + tb = 1.0 + v; + l = v <= 0x1.3p+0; // 19/16 > v > 11/16 + a = l ? ta : a; + b = l ? tb : b; + // (chi + clo) = arctan(1.) + chi = l ? 7.85398163397448278999e-01 : chi; + clo = l ? 3.06161699786838240164e-17 : clo; + + ta = 2.0 * v - 1.0; + tb = 2.0 + v; + l = v <= 0x1.6p-1; // 11/16 > v > 7/16 + a = l ? ta : a; + b = l ? tb : b; + // (chi + clo) = arctan(0.5) + chi = l ? 4.63647609000806093515e-01 : chi; + clo = l ? 2.26987774529616809294e-17 : clo; + + l = v <= 0x1.cp-2; // v < 7/16 + a = l ? v : a; + b = l ? 1.0 : b; + ; + chi = l ? 0.0 : chi; + clo = l ? 0.0 : clo; + + // Core approximation: Remez(4,4) on [-7/16,7/16] + __CLC_GENTYPE r = a / b; + __CLC_GENTYPE s = r * r; + __CLC_GENTYPE qn = + __clc_fma(s, + __clc_fma(s, + __clc_fma(s, + __clc_fma(s, 0.142316903342317766e-3, + 0.304455919504853031e-1), + 0.220638780716667420e0), + 0.447677206805497472e0), + 0.268297920532545909e0); + + __CLC_GENTYPE qd = + __clc_fma(s, + __clc_fma(s, + __clc_fma(s, + __clc_fma(s, 0.389525873944742195e-1, + 0.424602594203847109e0), + 0.141254259931958921e1), + 0.182596787737507063e1), + 0.804893761597637733e0); + + __CLC_GENTYPE q = r * s * qn / qd; + r = chi - ((q - clo) - r); + + __CLC_GENTYPE z = __clc_isnan(x) ? x : piby2; + z = v <= 0x1.0p+56 ? r : z; + z = v < 0x1.0p-26 ? v : z; + return x == v ? z : -z; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atan(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_atan(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2.cl new file mode 100644 index 0000000000..b10bf32333 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2.cl @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2.inc new file mode 100644 index 0000000000..61ffeebbc5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2.inc @@ -0,0 +1,248 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atan2(__CLC_GENTYPE y, + __CLC_GENTYPE x) { + const __CLC_GENTYPE pi = 0x1.921fb6p+1f; + const __CLC_GENTYPE piby2 = 0x1.921fb6p+0f; + const __CLC_GENTYPE piby4 = 0x1.921fb6p-1f; + const __CLC_GENTYPE threepiby4 = 0x1.2d97c8p+1f; + + __CLC_GENTYPE ax = __clc_fabs(x); + __CLC_GENTYPE ay = __clc_fabs(y); + __CLC_GENTYPE v = __clc_min(ax, ay); + __CLC_GENTYPE u = __clc_max(ax, ay); + + // Scale since u could be large, as in "regular" divide + __CLC_GENTYPE s = u > 0x1.0p+96f ? 0x1.0p-32f : 1.0f; + __CLC_GENTYPE vbyu = s * MATH_DIVIDE(v, s * u); + + __CLC_GENTYPE vbyu2 = vbyu * vbyu; + +#define USE_2_2_APPROXIMATION +#if defined USE_2_2_APPROXIMATION + __CLC_GENTYPE p = + __clc_mad(vbyu2, __clc_mad(vbyu2, -0x1.7e1f78p-9f, -0x1.7d1b98p-3f), + -0x1.5554d0p-2f) * + vbyu2 * vbyu; + __CLC_GENTYPE q = + __clc_mad(vbyu2, __clc_mad(vbyu2, 0x1.1a714cp-2f, 0x1.287c56p+0f), 1.0f); +#else + __CLC_GENTYPE p = + __clc_mad(vbyu2, __clc_mad(vbyu2, -0x1.55cd22p-5f, -0x1.26cf76p-2f), + -0x1.55554ep-2f) * + vbyu2 * vbyu; + __CLC_GENTYPE q = __clc_mad( + vbyu2, + __clc_mad(vbyu2, __clc_mad(vbyu2, 0x1.9f1304p-5f, 0x1.2656fap-1f), + 0x1.76b4b8p+0f), + 1.0f); +#endif + + // Octant 0 result + __CLC_GENTYPE a = __clc_mad(p, MATH_RECIP(q), vbyu); + + // Fix up 3 other octants + __CLC_GENTYPE at = piby2 - a; + a = ay > ax ? at : a; + at = pi - a; + a = x < 0.0F ? at : a; + + // y == 0 => 0 for x >= 0, pi for x < 0 + at = __CLC_AS_INTN(x) < 0 ? pi : 0.0f; + a = y == 0.0f ? at : a; + + // x and y are +- Inf + at = x > 0.0f ? piby4 : threepiby4; + a = __clc_select(a, at, __clc_isinf(x) && __clc_isinf(y)); + + // x or y is NaN + a = __clc_select(a, __CLC_GENTYPE_NAN, __clc_isnan(x) || __clc_isnan(y)); + + // Fixup sign and return + return __clc_copysign(a, y); +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atan2(__CLC_GENTYPE y, + __CLC_GENTYPE x) { + const __CLC_GENTYPE pi = 3.1415926535897932e+00; /* 0x400921fb54442d18 */ + const __CLC_GENTYPE piby2 = 1.5707963267948966e+00; /* 0x3ff921fb54442d18 */ + const __CLC_GENTYPE piby4 = 7.8539816339744831e-01; /* 0x3fe921fb54442d18 */ + // 0x4002d97c7f3321d2 + const __CLC_GENTYPE three_piby4 = 2.3561944901923449e+00; + const __CLC_GENTYPE pi_head = 3.1415926218032836e+00; /* 0x400921fb50000000 */ + const __CLC_GENTYPE pi_tail = 3.1786509547056392e-08; /* 0x3e6110b4611a6263 */ + // 0x3ff921fb54442d18 + const __CLC_GENTYPE piby2_head = 1.5707963267948965e+00; + // 0x3c91a62633145c07 + const __CLC_GENTYPE piby2_tail = 6.1232339957367660e-17; + + __CLC_GENTYPE x2 = x; + // Important to capture -0.0 in xneg and yneg, so comparison done as integer + __CLC_LONGN xneg = __CLC_AS_LONGN(x) < 0; + __CLC_INTN xexp = + __CLC_CONVERT_INTN(__CLC_AS_ULONGN(x) >> EXPSHIFTBITS_DP64) & 0x7ff; + + __CLC_GENTYPE y2 = y; + __CLC_LONGN yneg = __CLC_AS_LONGN(y) < 0; + __CLC_INTN yexp = + __CLC_CONVERT_INTN(__CLC_AS_ULONGN(y) >> EXPSHIFTBITS_DP64) & 0x7ff; + + __CLC_LONGN cond2 = __CLC_CONVERT_LONGN(xexp < 1021 && yexp < 1021); + __CLC_LONGN diffexp = __CLC_CONVERT_LONGN(yexp - xexp); + + // Scale up both x and y if they are both below 1/4 + __CLC_GENTYPE x1 = __clc_ldexp(x, 1024); + __CLC_INTN xexp1 = + __CLC_CONVERT_INTN(__CLC_AS_ULONGN(x1) >> EXPSHIFTBITS_DP64) & 0x7ff; + __CLC_GENTYPE y1 = __clc_ldexp(y, 1024); + __CLC_INTN yexp1 = + __CLC_CONVERT_INTN(__CLC_AS_ULONGN(y1) >> EXPSHIFTBITS_DP64) & 0x7ff; + __CLC_LONGN diffexp1 = __CLC_CONVERT_LONGN(yexp1 - xexp1); + + diffexp = __clc_select(diffexp, diffexp1, cond2); + x = cond2 ? x1 : x; + y = cond2 ? y1 : y; + + // General case: take absolute values of arguments + __CLC_GENTYPE u = __clc_fabs(x); + __CLC_GENTYPE v = __clc_fabs(y); + + // Swap u and v if necessary to obtain 0 < v < u. Compute v/u. + __CLC_LONGN swap_vu = u < v; + __CLC_GENTYPE uu = u; + u = swap_vu ? v : u; + v = swap_vu ? uu : v; + + __CLC_GENTYPE vbyu = v / u; + __CLC_GENTYPE q1, q2; + + // General values of v/u. Use a look-up table and series expansion. + + { + __CLC_GENTYPE val = vbyu > 0.0625 ? vbyu : 0.063; + __CLC_INTN index = __CLC_CONVERT_INTN(__clc_fma(256.0, val, 0.5)); + q1 = USE_TABLE(atan_jby256_tbl_head, index - 16); + q2 = USE_TABLE(atan_jby256_tbl_tail, index - 16); + __CLC_GENTYPE c = __CLC_CONVERT_GENTYPE(index) * 0x1.0p-8; + + // We're going to scale u and v by 2^(-u_exponent) to bring them close to 1 + // u_exponent could be EMAX so we have to do it in 2 steps + __CLC_INTN m = + -(__CLC_CONVERT_INTN(__CLC_AS_ULONGN(u) >> EXPSHIFTBITS_DP64) - + EXPBIAS_DP64); + __CLC_GENTYPE um = __clc_ldexp(u, m); + __CLC_GENTYPE vm = __clc_ldexp(v, m); + + // 26 leading bits of u + __CLC_GENTYPE u1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(um) & 0xfffffffff8000000UL); + __CLC_GENTYPE u2 = um - u1; + + __CLC_GENTYPE r = MATH_DIVIDE(__clc_fma(-c, u2, __clc_fma(-c, u1, vm)), + __clc_fma(c, vm, um)); + + // Polynomial approximation to atan(r) + __CLC_GENTYPE s = r * r; + q2 = q2 + __clc_fma((s * __clc_fma(-s, 0.19999918038989143496, + 0.33333333333224095522)), + -r, r); + } + + __CLC_GENTYPE q3, q4; + { + q3 = 0.0; + q4 = vbyu; + } + + __CLC_GENTYPE q5, q6; + { + __CLC_GENTYPE u1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(u) & 0xffffffff00000000UL); + __CLC_GENTYPE u2 = u - u1; + __CLC_GENTYPE vu1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(vbyu) & 0xffffffff00000000UL); + __CLC_GENTYPE vu2 = vbyu - vu1; + + q5 = 0.0; + __CLC_GENTYPE s = vbyu * vbyu; + q6 = vbyu + + __clc_fma( + -vbyu * s, + __clc_fma( + -s, + __clc_fma(-s, + __clc_fma(-s, + __clc_fma(-s, 0.90029810285449784439E-01, + 0.11110736283514525407), + 0.14285713561807169030), + 0.19999999999393223405), + 0.33333333333333170500), + MATH_DIVIDE(__clc_fma(-u, vu2, + __clc_fma(-u2, vu1, __clc_fma(-u1, vu1, v))), + u)); + } + + q3 = vbyu < 0x1.d12ed0af1a27fp-27 ? q3 : q5; + q4 = vbyu < 0x1.d12ed0af1a27fp-27 ? q4 : q6; + + q1 = vbyu > 0.0625 ? q1 : q3; + q2 = vbyu > 0.0625 ? q2 : q4; + + // Tidy-up according to which quadrant the arguments lie in + __CLC_GENTYPE res1, res2, res3, res4; + q1 = swap_vu ? piby2_head - q1 : q1; + q2 = swap_vu ? piby2_tail - q2 : q2; + q1 = xneg ? pi_head - q1 : q1; + q2 = xneg ? pi_tail - q2 : q2; + q1 = q1 + q2; + res4 = yneg ? -q1 : q1; + + res1 = yneg ? -three_piby4 : three_piby4; + res2 = yneg ? -piby4 : piby4; + res3 = xneg ? res1 : res2; + + res3 = __clc_select(res4, res3, + __CLC_CONVERT_LONGN(__clc_isinf(x2) && __clc_isinf(y2))); + res1 = yneg ? -pi : pi; + + // abs(x)/abs(y) > 2^56 and x < 0 + res3 = (diffexp < -56 && xneg) ? res1 : res3; + + res4 = MATH_DIVIDE(y, x); + // x positive and dominant over y by a factor of 2^28 + res3 = diffexp < -28 && xneg == 0 ? res4 : res3; + + // abs(y)/abs(x) > 2^56 + res4 = yneg ? -piby2 : piby2; // atan(y/x) is insignificant compared to piby2 + res3 = diffexp > 56 ? res4 : res3; + + res3 = x2 == 0.0 ? res4 : res3; // Zero x gives +- pi/2 depending on sign of y + res4 = xneg ? res1 : y2; + + // Zero y gives +-0 for positive x and +-pi for negative x + res3 = y2 == 0.0 ? res4 : res3; + res3 = __clc_isnan(y2) ? y2 : res3; + res3 = __clc_isnan(x2) ? x2 : res3; + + return res3; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atan2(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return __CLC_CONVERT_GENTYPE( + __clc_atan2(__CLC_CONVERT_FLOATN(x), __CLC_CONVERT_FLOATN(y))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2pi.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2pi.cl new file mode 100644 index 0000000000..7f75c11d15 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2pi.cl @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2pi.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2pi.inc new file mode 100644 index 0000000000..79b2551e07 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atan2pi.inc @@ -0,0 +1,227 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atan2pi(__CLC_GENTYPE y, + __CLC_GENTYPE x) { + const __CLC_GENTYPE pi = 0x1.921fb6p+1f; + + __CLC_GENTYPE ax = __clc_fabs(x); + __CLC_GENTYPE ay = __clc_fabs(y); + __CLC_GENTYPE v = __clc_min(ax, ay); + __CLC_GENTYPE u = __clc_max(ax, ay); + + // Scale since u could be large, as in "regular" divide + __CLC_GENTYPE s = u > 0x1.0p+96f ? 0x1.0p-32f : 1.0f; + __CLC_GENTYPE vbyu = s * MATH_DIVIDE(v, s * u); + + __CLC_GENTYPE vbyu2 = vbyu * vbyu; + + __CLC_GENTYPE p = + __clc_mad(vbyu2, __clc_mad(vbyu2, -0x1.7e1f78p-9f, -0x1.7d1b98p-3f), + -0x1.5554d0p-2f) * + vbyu2 * vbyu; + __CLC_GENTYPE q = + __clc_mad(vbyu2, __clc_mad(vbyu2, 0x1.1a714cp-2f, 0x1.287c56p+0f), 1.0f); + + // Octant 0 result + __CLC_GENTYPE a = MATH_DIVIDE(__clc_mad(p, MATH_RECIP(q), vbyu), pi); + + // Fix up 3 other octants + __CLC_GENTYPE at = 0.5f - a; + a = ay > ax ? at : a; + at = 1.0f - a; + a = x < 0.0F ? at : a; + + // y == 0 => 0 for x >= 0, pi for x < 0 + at = __CLC_AS_INTN(x) < 0 ? 1.0f : 0.0f; + a = y == 0.0f ? at : a; + + // x and y are +- Inf + at = x > 0.0f ? 0.25f : 0.75f; + a = __clc_select(a, at, __clc_isinf(x) && __clc_isinf(y)); + + // x or y is NaN + a = __clc_select(a, __CLC_GENTYPE_NAN, __clc_isnan(x) || __clc_isnan(y)); + + // Fixup sign and return + return __clc_copysign(a, y); +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atan2pi(__CLC_GENTYPE y, + __CLC_GENTYPE x) { + const __CLC_GENTYPE pi = 3.1415926535897932e+00; /* 0x400921fb54442d18 */ + const __CLC_GENTYPE pi_head = 3.1415926218032836e+00; /* 0x400921fb50000000 */ + const __CLC_GENTYPE pi_tail = 3.1786509547056392e-08; /* 0x3e6110b4611a6263 */ + // 0x3ff921fb54442d18 + const __CLC_GENTYPE piby2_head = 1.5707963267948965e+00; + // 0x3c91a62633145c07 + const __CLC_GENTYPE piby2_tail = 6.1232339957367660e-17; + + __CLC_GENTYPE x2 = x; + __CLC_LONGN xneg = __CLC_AS_LONGN(x) < 0; + __CLC_INTN xexp = + __CLC_CONVERT_INTN(__CLC_AS_ULONGN(x) >> EXPSHIFTBITS_DP64) & 0x7ff; + + __CLC_GENTYPE y2 = y; + __CLC_LONGN yneg = __CLC_AS_LONGN(y) < 0; + __CLC_INTN yexp = + __CLC_CONVERT_INTN(__CLC_AS_ULONGN(y) >> EXPSHIFTBITS_DP64) & 0x7ff; + + __CLC_LONGN cond2 = __CLC_CONVERT_LONGN(xexp < 1021 & yexp < 1021); + __CLC_LONGN diffexp = __CLC_CONVERT_LONGN(yexp - xexp); + + // Scale up both x and y if they are both below 1/4 + __CLC_GENTYPE x1 = __clc_ldexp(x, 1024); + __CLC_INTN xexp1 = + __CLC_CONVERT_INTN(__CLC_AS_ULONGN(x1) >> EXPSHIFTBITS_DP64) & 0x7ff; + __CLC_GENTYPE y1 = __clc_ldexp(y, 1024); + __CLC_INTN yexp1 = + __CLC_CONVERT_INTN(__CLC_AS_ULONGN(y1) >> EXPSHIFTBITS_DP64) & 0x7ff; + __CLC_LONGN diffexp1 = __CLC_CONVERT_LONGN(yexp1 - xexp1); + + diffexp = __clc_select(diffexp, diffexp1, cond2); + x = cond2 ? x1 : x; + y = cond2 ? y1 : y; + + // General case: take absolute values of arguments + __CLC_GENTYPE u = __clc_fabs(x); + __CLC_GENTYPE v = __clc_fabs(y); + + // Swap u and v if necessary to obtain 0 < v < u. Compute v/u. + __CLC_LONGN swap_vu = u < v; + __CLC_GENTYPE uu = u; + u = swap_vu ? v : u; + v = swap_vu ? uu : v; + + __CLC_GENTYPE vbyu = v / u; + __CLC_GENTYPE q1, q2; + + // General values of v/u. Use a look-up table and series expansion. + + { + __CLC_GENTYPE val = vbyu > 0.0625 ? vbyu : 0.063; + __CLC_INTN index = __CLC_CONVERT_INTN(__clc_fma(256.0, val, 0.5)); + q1 = USE_TABLE(atan_jby256_tbl_head, (index - 16)); + q2 = USE_TABLE(atan_jby256_tbl_tail, (index - 16)); + __CLC_GENTYPE c = __CLC_CONVERT_GENTYPE(index) * 0x1.0p-8; + + // We're going to scale u and v by 2^(-u_exponent) to bring them close to 1 + // u_exponent could be EMAX so we have to do it in 2 steps + __CLC_INTN m = + -(__CLC_CONVERT_INTN(__CLC_AS_ULONGN(u) >> EXPSHIFTBITS_DP64) - + EXPBIAS_DP64); + __CLC_GENTYPE um = __clc_ldexp(u, m); + __CLC_GENTYPE vm = __clc_ldexp(v, m); + + // 26 leading bits of u + __CLC_GENTYPE u1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(um) & 0xfffffffff8000000UL); + __CLC_GENTYPE u2 = um - u1; + + __CLC_GENTYPE r = MATH_DIVIDE(__clc_fma(-c, u2, __clc_fma(-c, u1, vm)), + __clc_fma(c, vm, um)); + + // Polynomial approximation to atan(r) + __CLC_GENTYPE s = r * r; + q2 = q2 + __clc_fma((s * __clc_fma(-s, 0.19999918038989143496, + 0.33333333333224095522)), + -r, r); + } + + __CLC_GENTYPE q3, q4; + { + q3 = 0.0; + q4 = vbyu; + } + + __CLC_GENTYPE q5, q6; + { + __CLC_GENTYPE u1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(u) & 0xffffffff00000000UL); + __CLC_GENTYPE u2 = u - u1; + __CLC_GENTYPE vu1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(vbyu) & 0xffffffff00000000UL); + __CLC_GENTYPE vu2 = vbyu - vu1; + + q5 = 0.0; + __CLC_GENTYPE s = vbyu * vbyu; + q6 = vbyu + + __clc_fma( + -vbyu * s, + __clc_fma( + -s, + __clc_fma(-s, + __clc_fma(-s, + __clc_fma(-s, 0.90029810285449784439E-01, + 0.11110736283514525407), + 0.14285713561807169030), + 0.19999999999393223405), + 0.33333333333333170500), + MATH_DIVIDE(__clc_fma(-u, vu2, + __clc_fma(-u2, vu1, __clc_fma(-u1, vu1, v))), + u)); + } + + q3 = vbyu < 0x1.d12ed0af1a27fp-27 ? q3 : q5; + q4 = vbyu < 0x1.d12ed0af1a27fp-27 ? q4 : q6; + + q1 = vbyu > 0.0625 ? q1 : q3; + q2 = vbyu > 0.0625 ? q2 : q4; + + // Tidy-up according to which quadrant the arguments lie in + __CLC_GENTYPE res1, res2, res3, res4; + q1 = swap_vu ? piby2_head - q1 : q1; + q2 = swap_vu ? piby2_tail - q2 : q2; + q1 = xneg ? pi_head - q1 : q1; + q2 = xneg ? pi_tail - q2 : q2; + q1 = MATH_DIVIDE(q1 + q2, pi); + res4 = yneg ? -q1 : q1; + + res1 = yneg ? -0.75 : 0.75; + res2 = yneg ? -0.25 : 0.25; + res3 = xneg ? res1 : res2; + + res3 = __clc_select(res4, res3, + __CLC_CONVERT_LONGN(__clc_isinf(y2) & __clc_isinf(x2))); + res1 = yneg ? -1.0 : 1.0; + + // abs(x)/abs(y) > 2^56 and x < 0 + res3 = diffexp < -56 && xneg ? res1 : res3; + + res4 = MATH_DIVIDE(MATH_DIVIDE(y, x), pi); + // x positive and dominant over y by a factor of 2^28 + res3 = diffexp < -28 && xneg == 0 ? res4 : res3; + + // abs(y)/abs(x) > 2^56 + res4 = yneg ? -0.5 : 0.5; // atan(y/x) is insignificant compared to piby2 + res3 = diffexp > 56 ? res4 : res3; + + res3 = x2 == 0.0 ? res4 : res3; // Zero x gives +- pi/2 depending on sign of y + res4 = xneg ? res1 : y2; + + // Zero y gives +-0 for positive x and +-pi for negative x + res3 = y2 == 0.0 ? res4 : res3; + res3 = __clc_isnan(y2) ? y2 : res3; + res3 = __clc_isnan(x2) ? x2 : res3; + + return res3; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atan2pi(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return __CLC_CONVERT_GENTYPE( + __clc_atan2pi(__CLC_CONVERT_FLOATN(x), __CLC_CONVERT_FLOATN(y))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanh.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanh.cl new file mode 100644 index 0000000000..485e72479b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanh.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanh.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanh.inc new file mode 100644 index 0000000000..e76f340d8c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanh.inc @@ -0,0 +1,105 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atanh(__CLC_GENTYPE x) { + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_UINTN ax = ux & EXSIGNBIT_SP32; + __CLC_UINTN xs = ux ^ ax; + + // |x| > 1 or NaN + __CLC_GENTYPE z = __CLC_GENTYPE_NAN; + + // |x| == 1 + __CLC_GENTYPE t = __CLC_AS_GENTYPE(xs | PINFBITPATT_SP32); + z = ax == 0x3f800000U ? t : z; + + // 1/2 <= |x| < 1 + t = __CLC_AS_GENTYPE(ax); + t = MATH_DIVIDE(2.0f * t, 1.0f - t); + t = 0.5f * __clc_log1p(t); + t = __CLC_AS_GENTYPE(xs | __CLC_AS_UINTN(t)); + z = ax < 0x3f800000U ? t : z; + + // |x| < 1/2 + t = x * x; + __CLC_GENTYPE a = __clc_mad( + __clc_mad(0.92834212715e-2f, t, -0.28120347286e0f), t, 0.39453629046e0f); + __CLC_GENTYPE b = __clc_mad(__clc_mad(0.45281890445e0f, t, -0.15537744551e1f), + t, 0.11836088638e1f); + __CLC_GENTYPE p = MATH_DIVIDE(a, b); + t = __clc_mad(x * t, p, x); + z = ax < 0x3f000000 ? t : z; + + // |x| < 2^-13 + z = ax < 0x39000000U ? x : z; + + return z; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atanh(__CLC_GENTYPE x) { + __CLC_GENTYPE absx = __clc_fabs(x); + + __CLC_GENTYPE ret = absx == 1.0 + ? __CLC_AS_GENTYPE((__CLC_ULONGN)PINFBITPATT_DP64) + : __CLC_GENTYPE_NAN; + + // |x| >= 0.5 + // Note that atanh(x) = 0.5 * ln((1+x)/(1-x)) + // For greater accuracy we use + // ln((1+x)/(1-x)) = ln(1 + 2x/(1-x)) = log1p(2x/(1-x)). + __CLC_GENTYPE r = 0.5 * __clc_log1p(2.0 * absx / (1.0 - absx)); + ret = absx < 1.0 ? r : ret; + + r = -ret; + ret = x < 0.0 ? r : ret; + + // Arguments up to 0.5 in magnitude are + // approximated by a [5,5] minimax polynomial + __CLC_GENTYPE t = x * x; + + __CLC_GENTYPE pn = __clc_fma( + t, + __clc_fma(t, + __clc_fma(t, + __clc_fma(t, + __clc_fma(t, -0.10468158892753136958e-3, + 0.28728638600548514553e-1), + -0.28180210961780814148e0), + 0.88468142536501647470e0), + -0.11028356797846341457e1), + 0.47482573589747356373e0); + + __CLC_GENTYPE pd = __clc_fma( + t, + __clc_fma(t, + __clc_fma(t, + __clc_fma(t, + __clc_fma(t, -0.35861554370169537512e-1, + 0.49561196555503101989e0), + -0.22608883748988489342e1), + 0.45414700626084508355e1), + -0.41631933639693546274e1), + 0.14244772076924206909e1); + + r = __clc_fma(x * t, pn / pd, x); + ret = absx < 0.5 ? r : ret; + + return ret; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atanh(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_atanh(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanpi.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanpi.cl new file mode 100644 index 0000000000..fee72aa7ef --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanpi.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanpi.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanpi.inc new file mode 100644 index 0000000000..fd25a586cf --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_atanpi.inc @@ -0,0 +1,172 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atanpi(__CLC_GENTYPE x) { + const __CLC_GENTYPE pi = __CLC_FP_LIT(3.1415926535897932); + + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_UINTN aux = ux & EXSIGNBIT_SP32; + __CLC_UINTN sx = ux ^ aux; + + __CLC_GENTYPE xbypi = MATH_DIVIDE(x, pi); + __CLC_GENTYPE shalf = + __CLC_AS_GENTYPE(sx | __CLC_AS_UINTN(__CLC_FP_LIT(0.5))); + + __CLC_GENTYPE v = __CLC_AS_GENTYPE(aux); + + // Return for NaN + __CLC_GENTYPE ret = x; + + // 2^26 <= |x| <= Inf => atan(x) is close to piby2 + ret = aux <= PINFBITPATT_SP32 ? shalf : ret; + + // Reduce arguments 2^-19 <= |x| < 2^26 + + // 39/16 <= x < 2^26 + x = -MATH_RECIP(v); + __CLC_GENTYPE c = 1.57079632679489655800f; // atan(infinity) + + // 19/16 <= x < 39/16 + __CLC_INTN l = aux < 0x401c0000; + __CLC_GENTYPE xx = MATH_DIVIDE(v - 1.5f, __clc_mad(v, 1.5f, 1.0f)); + x = l ? xx : x; + c = l ? 9.82793723247329054082e-01f : c; // atan(1.5) + + // 11/16 <= x < 19/16 + l = aux < 0x3f980000U; + xx = MATH_DIVIDE(v - 1.0f, 1.0f + v); + x = l ? xx : x; + c = l ? 7.85398163397448278999e-01f : c; // atan(1) + + // 7/16 <= x < 11/16 + l = aux < 0x3f300000; + xx = MATH_DIVIDE(__clc_mad(v, 2.0f, -1.0f), 2.0f + v); + x = l ? xx : x; + c = l ? 4.63647609000806093515e-01f : c; // atan(0.5) + + // 2^-19 <= x < 7/16 + l = aux < 0x3ee00000; + x = l ? v : x; + c = l ? 0.0f : c; + + // Core approximation: Remez(2,2) on [-7/16,7/16] + + __CLC_GENTYPE s = x * x; + __CLC_GENTYPE a = __clc_mad(s, + __clc_mad(s, 0.470677934286149214138357545549e-2f, + 0.192324546402108583211697690500f), + 0.296528598819239217902158651186f); + + __CLC_GENTYPE b = __clc_mad(s, + __clc_mad(s, 0.299309699959659728404442796915f, + 0.111072499995399550138837673349e1f), + 0.889585796862432286486651434570f); + + __CLC_GENTYPE q = x * s * MATH_DIVIDE(a, b); + + __CLC_GENTYPE z = c - (q - x); + z = MATH_DIVIDE(z, pi); + __CLC_GENTYPE zs = __CLC_AS_GENTYPE(sx | __CLC_AS_UINTN(z)); + + ret = aux < 0x4c800000 ? zs : ret; + + // |x| < 2^-19 + ret = aux < 0x36000000 ? xbypi : ret; + return ret; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atanpi(__CLC_GENTYPE x) { + const __CLC_GENTYPE pi = __CLC_FP_LIT(0x1.921fb54442d18p+1); + + __CLC_GENTYPE v = __clc_fabs(x); + + // 2^56 > v > 39/16 + __CLC_GENTYPE a = -1.0; + __CLC_GENTYPE b = v; + // (chi + clo) = arctan(infinity) + __CLC_GENTYPE chi = 1.57079632679489655800e+00; + __CLC_GENTYPE clo = 6.12323399573676480327e-17; + + __CLC_GENTYPE ta = v - 1.5; + __CLC_GENTYPE tb = 1.0 + 1.5 * v; + __CLC_LONGN l = v <= 0x1.38p+1; // 39/16 > v > 19/16 + a = l ? ta : a; + b = l ? tb : b; + // (chi + clo) = arctan(1.5) + chi = l ? 9.82793723247329054082e-01 : chi; + clo = l ? 1.39033110312309953701e-17 : clo; + + ta = v - 1.0; + tb = 1.0 + v; + l = v <= 0x1.3p+0; // 19/16 > v > 11/16 + a = l ? ta : a; + b = l ? tb : b; + // (chi + clo) = arctan(1.) + chi = l ? 7.85398163397448278999e-01 : chi; + clo = l ? 3.06161699786838240164e-17 : clo; + + ta = 2.0 * v - 1.0; + tb = 2.0 + v; + l = v <= 0x1.6p-1; // 11/16 > v > 7/16 + a = l ? ta : a; + b = l ? tb : b; + // (chi + clo) = arctan(0.5) + chi = l ? 4.63647609000806093515e-01 : chi; + clo = l ? 2.26987774529616809294e-17 : clo; + + l = v <= 0x1.cp-2; // v < 7/16 + a = l ? v : a; + b = l ? 1.0 : b; + ; + chi = l ? 0.0 : chi; + clo = l ? 0.0 : clo; + + // Core approximation: Remez(4,4) on [-7/16,7/16] + __CLC_GENTYPE r = a / b; + __CLC_GENTYPE s = r * r; + __CLC_GENTYPE qn = + __clc_fma(s, + __clc_fma(s, + __clc_fma(s, + __clc_fma(s, 0.142316903342317766e-3, + 0.304455919504853031e-1), + 0.220638780716667420e0), + 0.447677206805497472e0), + 0.268297920532545909e0); + + __CLC_GENTYPE qd = + __clc_fma(s, + __clc_fma(s, + __clc_fma(s, + __clc_fma(s, 0.389525873944742195e-1, + 0.424602594203847109e0), + 0.141254259931958921e1), + 0.182596787737507063e1), + 0.804893761597637733e0); + + __CLC_GENTYPE q = r * s * qn / qd; + r = (chi - ((q - clo) - r)) / pi; + __CLC_GENTYPE vp = v / pi; + + __CLC_GENTYPE z = __clc_isnan(x) ? x : 0.5; + z = v <= 0x1.0p+56 ? r : z; + z = v < 0x1.0p-26 ? vp : z; + return x == v ? z : -z; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atanpi(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_atanpi(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cbrt.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cbrt.cl new file mode 100644 index 0000000000..2686908593 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cbrt.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cbrt.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cbrt.inc new file mode 100644 index 0000000000..2aba2484e3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cbrt.inc @@ -0,0 +1,135 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cbrt(__CLC_GENTYPE x) { + __CLC_UINTN xi = __CLC_AS_UINTN(x); + __CLC_UINTN axi = __CLC_AS_UINTN(__clc_fabs(x)); + __CLC_UINTN xsign = axi ^ xi; + xi = axi; + + __CLC_INTN m = __CLC_AS_INTN(xi >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + + // Treat subnormals + __CLC_UINTN xisub = __CLC_AS_UINTN(__CLC_AS_GENTYPE(xi | 0x3f800000) - 1.0f); + __CLC_INTN msub = __CLC_AS_INTN(xisub >> EXPSHIFTBITS_SP32) - 253; + __CLC_INTN c = m == -127; + xi = c ? xisub : xi; + m = c ? msub : m; + + __CLC_INTN m3 = m / 3; + __CLC_INTN rem = m - m3 * 3; + __CLC_GENTYPE mf = __CLC_AS_GENTYPE((m3 + EXPBIAS_SP32) << EXPSHIFTBITS_SP32); + + __CLC_UINTN indx = (xi & 0x007f0000) + ((xi & 0x00008000) << 1); + __CLC_GENTYPE f = __CLC_AS_GENTYPE((xi & MANTBITS_SP32) | 0x3f000000) - + __CLC_AS_GENTYPE(indx | 0x3f000000); + + indx >>= 16; + __CLC_GENTYPE r = f * USE_TABLE(log_inv_tbl, __CLC_AS_INTN(indx)); + __CLC_GENTYPE poly = __clc_mad(__clc_mad(r, 0x1.f9add4p-5f, -0x1.c71c72p-4f), + r * r, r * 0x1.555556p-2f); + + // This could also be done with a 5-element table + __CLC_GENTYPE remH = 0x1.428000p-1f; + __CLC_GENTYPE remT = 0x1.45f31ap-14f; + + remH = rem == -1 ? 0x1.964000p-1f : remH; + remT = rem == -1 ? 0x1.fea53ep-13f : remT; + + remH = rem == 0 ? 0x1.000000p+0f : remH; + remT = rem == 0 ? 0x0.000000p+0f : remT; + + remH = rem == 1 ? 0x1.428000p+0f : remH; + remT = rem == 1 ? 0x1.45f31ap-13f : remT; + + remH = rem == 2 ? 0x1.964000p+0f : remH; + remT = rem == 2 ? 0x1.fea53ep-12f : remT; + + __CLC_GENTYPE cbrtH = USE_TABLE(cbrt_tbl_head, __CLC_AS_INTN(indx)); + __CLC_GENTYPE cbrtT = USE_TABLE(cbrt_tbl_tail, __CLC_AS_INTN(indx)); + + __CLC_GENTYPE bH = cbrtH * remH; + __CLC_GENTYPE bT = + __clc_mad(cbrtH, remT, __clc_mad(cbrtT, remH, cbrtT * remT)); + + __CLC_GENTYPE z = __clc_mad(poly, bH, __clc_mad(poly, bT, bT)) + bH; + z *= mf; + z = __CLC_AS_GENTYPE(__CLC_AS_UINTN(z) | xsign); + c = axi >= EXPBITS_SP32 || axi == 0; + z = c ? x : z; + return z; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cbrt(__CLC_GENTYPE x) { + __CLC_LONGN return_x = __clc_isinf(x) || __clc_isnan(x) || x == 0.0; + __CLC_ULONGN ux = __CLC_AS_ULONGN(__clc_fabs(x)); + __CLC_INTN m = __CLC_CONVERT_INTN(ux >> EXPSHIFTBITS_DP64) - 1023; + + // Treat subnormals + __CLC_ULONGN uxs = + __CLC_AS_ULONGN(__CLC_AS_GENTYPE(0x3ff0000000000000UL | ux) - 1.0); + __CLC_INTN ms = m + __CLC_CONVERT_INTN(uxs >> EXPSHIFTBITS_DP64) - 1022; + + __CLC_INTN c = m == -1023; + ux = __CLC_CONVERT_LONGN(c) ? uxs : ux; + m = c ? ms : m; + + __CLC_INTN mby3 = m / 3; + __CLC_INTN rem = m - 3 * mby3; + + __CLC_GENTYPE mf = __CLC_AS_GENTYPE(__CLC_CONVERT_ULONGN(mby3 + 1023) << 52); + + ux &= 0x000fffffffffffffUL; + __CLC_GENTYPE Y = __CLC_AS_GENTYPE(0x3fe0000000000000UL | ux); + + // nearest integer + __CLC_INTN index = __CLC_CONVERT_INTN(ux >> 43); + index = (0x100 | (index >> 1)) + (index & 1); + __CLC_GENTYPE F = __CLC_CONVERT_GENTYPE(index) * 0x1.0p-9; + + __CLC_GENTYPE f = Y - F; + __CLC_GENTYPE r = f * USE_TABLE(cbrt_inv_tbl, index - 256); + + __CLC_GENTYPE z = + r * __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, -0x1.8090d6221a247p-6, + 0x1.ee7113506ac13p-6), + -0x1.511e8d2b3183bp-5), + 0x1.f9add3c0ca458p-5), + -0x1.c71c71c71c71cp-4), + 0x1.5555555555555p-2); + + __CLC_GENTYPE Rem_h = USE_TABLE(cbrt_rem_tbl_head, rem + 2); + __CLC_GENTYPE Rem_t = USE_TABLE(cbrt_rem_tbl_tail, rem + 2); + + __CLC_GENTYPE F_h = USE_TABLE(cbrt_dbl_tbl_head, index - 256); + __CLC_GENTYPE F_t = USE_TABLE(cbrt_dbl_tbl_tail, index - 256); + + __CLC_GENTYPE b_h = F_h * Rem_h; + __CLC_GENTYPE b_t = __clc_fma(Rem_t, F_h, __clc_fma(F_t, Rem_h, F_t * Rem_t)); + + __CLC_GENTYPE ans = __clc_fma(z, b_h, __clc_fma(z, b_t, b_t)) + b_h; + ans = __clc_copysign(ans * mf, x); + return return_x ? x : ans; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cbrt(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_cbrt(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ceil.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ceil.cl new file mode 100644 index 0000000000..b06cb364b5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ceil.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define FUNCTION __clc_ceil +#define __IMPL_FUNCTION(x) __builtin_elementwise_ceil +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_copysign.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_copysign.cl new file mode 100644 index 0000000000..06f126b16d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_copysign.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define FUNCTION __clc_copysign +#define __IMPL_FUNCTION(x) __builtin_elementwise_copysign +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cos.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cos.cl new file mode 100644 index 0000000000..0c9dc287aa --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cos.cl @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cos.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cos.inc new file mode 100644 index 0000000000..4b8108c086 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cos.inc @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_FLOATN __clc_cos(__CLC_FLOATN x) { + __CLC_FLOATN absx = __clc_fabs(x); + + __CLC_FLOATN r0, r1; + __CLC_INTN regn = __clc_argReductionS(&r0, &r1, absx); + + __CLC_FLOATN ss = -__clc_sinf_piby4(r0, r1); + __CLC_FLOATN cc = __clc_cosf_piby4(r0, r1); + + __CLC_FLOATN c = (regn & 1) != 0 ? ss : cc; + c = __CLC_AS_FLOATN(__CLC_AS_INTN(c) ^ ((regn > 1) << 31)); + + c = __clc_select(c, __CLC_GENTYPE_NAN, __clc_isnan(x) || __clc_isinf(x)); + + return c; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cos(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_cos(__CLC_CONVERT_FLOATN(x))); +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cos(__CLC_GENTYPE x) { + __CLC_GENTYPE absx = __clc_fabs(x); + + __CLC_BIT_INTN is_medium = absx < 0x1.0p+47; + + __CLC_INTN regn_m, regn_l; + __CLC_GENTYPE r_m, r_l, rr_m, rr_l; + + __clc_remainder_piby2_medium(absx, &r_m, &rr_m, ®n_m); + __clc_remainder_piby2_large(absx, &r_l, &rr_l, ®n_l); + + __CLC_GENTYPE r = is_medium ? r_m : r_l; + __CLC_GENTYPE rr = is_medium ? rr_m : rr_l; + __CLC_INTN regn = __CLC_CONVERT_INTN(is_medium) ? regn_m : regn_l; + + __CLC_GENTYPE sinval, cosval; + __clc_sincos_piby4(r, rr, &sinval, &cosval); + sinval = -sinval; + + __CLC_LONGN c = + __CLC_AS_LONGN(__CLC_CONVERT_BIT_INTN((regn & 1) != 0) ? sinval : cosval); + c ^= __CLC_CONVERT_BIT_INTN(regn > 1) << 63; + + return __clc_isnan(absx) | __clc_isinf(absx) ? __CLC_GENTYPE_NAN + : __CLC_AS_GENTYPE(c); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cosh.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cosh.cl new file mode 100644 index 0000000000..4da78de271 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cosh.cl @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cosh.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cosh.inc new file mode 100644 index 0000000000..a9fa1bb141 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cosh.inc @@ -0,0 +1,199 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cosh(__CLC_GENTYPE x) { + // After dealing with special cases the computation is split into regions as + // follows. abs(x) >= max_cosh_arg: cosh(x) = sign(x)*Inf abs(x) >= + // small_threshold: cosh(x) = sign(x)*exp(abs(x))/2 computed using the + // splitexp and scaleDouble functions as for exp_amd(). + // abs(x) < small_threshold: + // compute p = exp(y) - 1 and then z = 0.5*(p+(p/(p+1.0))) + // cosh(x) is then z. + + const __CLC_GENTYPE max_cosh_arg = 0x1.65a9fap+6f; + const __CLC_GENTYPE small_threshold = 0x1.0a2b24p+3f; + + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_GENTYPE y = __clc_fabs(x); + __CLC_UINTN aux = __CLC_AS_UINTN(y); + + // Find the integer part y0 of y and the increment dy = y - y0. We then + // compute z = sinh(y) = sinh(y0)cosh(dy) + cosh(y0)sinh(dy) z = cosh(y) = + // cosh(y0)cosh(dy) + sinh(y0)sinh(dy) where sinh(y0) and cosh(y0) are + // tabulated above. + + __CLC_INTN ind = __CLC_CONVERT_INTN(y); + ind = __CLC_CONVERT_UINTN(ind) > 36U ? 0 : ind; + + __CLC_GENTYPE dy = y - __CLC_CONVERT_GENTYPE(ind); + __CLC_GENTYPE dy2 = dy * dy; + + __CLC_GENTYPE sdy = __clc_mad( + dy2, + __clc_mad( + dy2, + __clc_mad( + dy2, + __clc_mad( + dy2, + __clc_mad(dy2, + __clc_mad(dy2, 0.7746188980094184251527126e-12f, + 0.160576793121939886190847e-9f), + 0.250521176994133472333666e-7f), + 0.275573191913636406057211e-5f), + 0.198412698413242405162014e-3f), + 0.833333333333329931873097e-2f), + 0.166666666666666667013899e0f); + sdy = __clc_mad(sdy, dy * dy2, dy); + + __CLC_GENTYPE cdy = __clc_mad( + dy2, + __clc_mad( + dy2, + __clc_mad( + dy2, + __clc_mad( + dy2, + __clc_mad(dy2, + __clc_mad(dy2, 0.1163921388172173692062032e-10f, + 0.208744349831471353536305e-8f), + 0.275573350756016588011357e-6f), + 0.248015872460622433115785e-4f), + 0.138888888889814854814536e-2f), + 0.416666666666660876512776e-1f), + 0.500000000000000005911074e0f); + cdy = __clc_mad(cdy, dy2, 1.0f); + + __CLC_GENTYPE sinhcoshh = USE_TABLE(sinhcosh_tbl_head, ind); + __CLC_GENTYPE sinhcosht = USE_TABLE(sinhcosh_tbl_tail, ind); + __CLC_GENTYPE z = __clc_mad(sinhcoshh, sdy, sinhcosht * cdy); + + // When exp(-x) is insignificant compared to exp(x), return exp(x)/2 + __CLC_GENTYPE t = __clc_exp(y - 0x1.62e500p-1f); + __CLC_GENTYPE zsmall = __clc_mad(0x1.a0210ep-18f, t, t); + z = y >= small_threshold ? zsmall : z; + + // Corner cases + z = y >= max_cosh_arg ? __CLC_AS_GENTYPE((__CLC_UINTN)PINFBITPATT_SP32) : z; + z = aux > PINFBITPATT_SP32 ? __CLC_GENTYPE_NAN : z; + z = aux < 0x38800000 ? 1.0f : z; + + return z; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cosh(__CLC_GENTYPE x) { + // After dealing with special cases the computation is split into + // regions as follows: + // + // abs(x) >= max_cosh_arg: + // cosh(x) = sign(x)*Inf + // + // abs(x) >= small_threshold: + // cosh(x) = sign(x)*exp(abs(x))/2 computed using the + // splitexp and scaleDouble functions as for exp_amd(). + // + // abs(x) < small_threshold: + // compute p = exp(y) - 1 and then z = 0.5*(p+(p/(p+1.0))) + // cosh(x) is then sign(x)*z. + + // This is ln(2^1025) = 0x408633ce8fb9f87e + const __CLC_GENTYPE max_cosh_arg = 7.10475860073943977113e+02; + + // This is where exp(-x) is insignificant compared to exp(x) = ln(2^27) + const __CLC_GENTYPE small_threshold = 0x1.2b708872320e2p+4; + + __CLC_GENTYPE y = __clc_fabs(x); + + // In this range we find the integer part y0 of y + // and the increment dy = y - y0. We then compute + // z = cosh(y) = cosh(y0)cosh(dy) + sinh(y0)sinh(dy) + // where sinh(y0) and cosh(y0) are tabulated above. + + __CLC_INTN ind = __clc_min(__CLC_CONVERT_INTN(y), 36); + __CLC_GENTYPE dy = y - __CLC_CONVERT_GENTYPE(ind); + __CLC_GENTYPE dy2 = dy * dy; + + __CLC_GENTYPE sdy = + dy * dy2 * + __clc_fma( + dy2, + __clc_fma( + dy2, + __clc_fma( + dy2, + __clc_fma( + dy2, + __clc_fma(dy2, + __clc_fma(dy2, 0.7746188980094184251527126e-12, + 0.160576793121939886190847e-9), + 0.250521176994133472333666e-7), + 0.275573191913636406057211e-5), + 0.198412698413242405162014e-3), + 0.833333333333329931873097e-2), + 0.166666666666666667013899e0); + + __CLC_GENTYPE cdy = + dy2 * + __clc_fma( + dy2, + __clc_fma( + dy2, + __clc_fma( + dy2, + __clc_fma( + dy2, + __clc_fma(dy2, + __clc_fma(dy2, 0.1163921388172173692062032e-10, + 0.208744349831471353536305e-8), + 0.275573350756016588011357e-6), + 0.248015872460622433115785e-4), + 0.138888888889814854814536e-2), + 0.416666666666660876512776e-1), + 0.500000000000000005911074e0); + + // At this point sinh(dy) is approximated by dy + sdy, + // and cosh(dy) is approximated by 1 + cdy. + __CLC_GENTYPE cl = USE_TABLE(cosh_tbl_head, ind); + __CLC_GENTYPE ct = USE_TABLE(cosh_tbl_tail, ind); + __CLC_GENTYPE sl = USE_TABLE(sinh_tbl_head, ind); + __CLC_GENTYPE st = USE_TABLE(sinh_tbl_tail, ind); + + __CLC_GENTYPE z = + __clc_fma( + sl, dy, + __clc_fma(sl, sdy, + __clc_fma(cl, cdy, + __clc_fma(st, dy, __clc_fma(st, sdy, ct * cdy)) + + ct))) + + cl; + + // Other cases + z = y < 0x1.0p-28 ? 1.0 : z; + + __CLC_GENTYPE t = __clc_exp(y - 0x1.62e42fefa3800p-1); + t = __clc_fma(t, -0x1.ef35793c76641p-45, t); + z = y >= small_threshold ? t : z; + + z = y >= max_cosh_arg ? __CLC_AS_GENTYPE((__CLC_ULONGN)PINFBITPATT_DP64) : z; + + z = __clc_isinf(x) || __clc_isnan(x) ? y : z; + + return z; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cosh(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_cosh(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cospi.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cospi.cl new file mode 100644 index 0000000000..07e1b49cc9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cospi.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cospi.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cospi.inc new file mode 100644 index 0000000000..b037f82872 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_cospi.inc @@ -0,0 +1,116 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cospi(__CLC_GENTYPE x) { + __CLC_GENTYPE absx = __clc_fabs(x); + __CLC_INTN ix = __CLC_AS_INTN(absx); + __CLC_INTN iax = __CLC_CONVERT_INTN(absx); + __CLC_GENTYPE r = absx - __CLC_CONVERT_GENTYPE(iax); + __CLC_INTN xodd = (iax & 0x1) != 0 ? (__CLC_INTN)0x80000000 : (__CLC_INTN)0; + + // Initialize with return for +-Inf and NaN + __CLC_INTN ir = QNANBITPATT_SP32; + + // 2^24 <= |x| < Inf, the result is always even integer + ir = ix < PINFBITPATT_SP32 ? 0x3f800000 : ir; + + // 2^23 <= |x| < 2^24, the result is always integer + ir = ix < 0x4b800000 ? xodd | 0x3f800000 : ir; + + // 0x1.0p-7 <= |x| < 2^23, result depends on which 0.25 interval + + // r < 1.0 + __CLC_GENTYPE a = 1.0f - r; + __CLC_INTN e = 1; + __CLC_INTN s = xodd ^ (__CLC_INTN)0x80000000; + + // r <= 0.75 + __CLC_INTN c = r <= 0.75f; + a = c ? r - 0.5f : a; + e = c ? 0 : e; + + // r < 0.5 + c = r < 0.5f; + a = c ? 0.5f - r : a; + s = c ? xodd : s; + + // r <= 0.25 + c = r <= 0.25f; + a = c ? r : a; + e = c ? 1 : e; + + __CLC_GENTYPE sinval, cosval; + __clc_sincos_piby4(a * M_PI_F, &sinval, &cosval); + __CLC_INTN jr = s ^ __CLC_AS_INTN(e != 0 ? cosval : sinval); + + ir = ix < 0x4b000000 ? jr : ir; + + return __CLC_AS_GENTYPE(ir); +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cospi(__CLC_GENTYPE x) { + __CLC_GENTYPE absx = __clc_fabs(x); + __CLC_LONGN ix = __CLC_AS_LONGN(absx); + __CLC_LONGN iax = __CLC_CONVERT_LONGN(absx); + __CLC_GENTYPE r = absx - __CLC_CONVERT_GENTYPE(iax); + __CLC_LONGN xodd = + (iax & 0x1L) != 0 ? (__CLC_LONGN)0x8000000000000000L : (__CLC_LONGN)0L; + + // Initialize with return for +-Inf and NaN + __CLC_LONGN ir = QNANBITPATT_DP64; + + // 2^53 <= |x| < Inf, the result is always even integer + ir = ix < PINFBITPATT_DP64 ? 0x3ff0000000000000L : ir; + + // 2^52 <= |x| < 2^53, the result is always integer + ir = absx < 0x1.0p+53 ? xodd | 0x3ff0000000000000L : ir; + + // 0x1.0p-7 <= |x| < 2^52, result depends on which 0.25 interval + + // r < 1.0 + __CLC_GENTYPE a = 1.0 - r; + __CLC_LONGN e = 1; + __CLC_LONGN s = xodd ^ (__CLC_LONGN)0x8000000000000000L; + + // r <= 0.75 + __CLC_LONGN c = r <= 0.75; + __CLC_GENTYPE t = r - 0.5; + a = c ? t : a; + e = c ? 0 : e; + + // r < 0.5 + c = r < 0.5; + t = 0.5 - r; + a = c ? t : a; + s = c ? xodd : s; + + // r <= 0.25 + c = r <= 0.25; + a = c ? r : a; + e = c ? 1 : e; + + __CLC_GENTYPE sinval, cosval; + __clc_sincos_piby4(a * M_PI, 0.0, &sinval, &cosval); + __CLC_LONGN jr = s ^ __CLC_AS_LONGN(e != 0 ? cosval : sinval); + + ir = absx < 0x1.0p+52 ? jr : ir; + + return __CLC_AS_GENTYPE(ir); +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_cospi(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_cospi(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ep_log.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ep_log.cl new file mode 100644 index 0000000000..c6782f77a1 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ep_log.cl @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifdef cl_khr_fp64 + +#include +#include +#include +#include +#include +#include + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +#define __CLC_BODY +#include + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ep_log.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ep_log.inc new file mode 100644 index 0000000000..f51e487bed --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ep_log.inc @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Computes natural log(x). Algorithm based on: +// Ping-Tak Peter Tang +// "Table-driven implementation of the logarithm function in IEEE floating-point +// arithmetic" +// ACM Transactions on Mathematical Software (TOMS) Volume 16, Issue 4 (December +// 1990) +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 64 + +#define LN0 8.33333333333317923934e-02 +#define LN1 1.25000000037717509602e-02 +#define LN2 2.23213998791944806202e-03 +#define LN3 4.34887777707614552256e-04 + +#define LF0 8.33333333333333593622e-02 +#define LF1 1.24999999978138668903e-02 +#define LF2 2.23219810758559851206e-03 + +_CLC_DEF _CLC_OVERLOAD void __clc_ep_log(__CLC_GENTYPE x, + private __CLC_INTN *xexp, + private __CLC_GENTYPE *r1, + private __CLC_GENTYPE *r2) { + __CLC_LONGN near_one = x >= 0x1.e0faap-1 && x <= 0x1.1082cp+0; + + __CLC_ULONGN ux = __CLC_AS_ULONGN(x); + __CLC_ULONGN uxs = + __CLC_AS_ULONGN(__CLC_AS_GENTYPE(0x03d0000000000000UL | ux) - 0x1.0p-962); + __CLC_LONGN c = ux < IMPBIT_DP64; + ux = c ? uxs : ux; + __CLC_INTN expadjust = + __CLC_CONVERT_INTN(c ? (__CLC_LONGN)60 : (__CLC_LONGN)0); + + // Store the exponent of x in xexp and put f into the range [0.5,1) + __CLC_INTN xexp1 = __CLC_CONVERT_INTN((ux >> EXPSHIFTBITS_DP64) & 0x7ff) - + EXPBIAS_DP64 - expadjust; + __CLC_GENTYPE f = __CLC_AS_GENTYPE(HALFEXPBITS_DP64 | (ux & MANTBITS_DP64)); + *xexp = __CLC_CONVERT_INTN(near_one) ? 0 : xexp1; + + __CLC_GENTYPE r = x - 1.0; + __CLC_GENTYPE u1 = MATH_DIVIDE(r, 2.0 + r); + __CLC_GENTYPE ru1 = -r * u1; + u1 = u1 + u1; + + __CLC_INTN index = __CLC_CONVERT_INTN(ux >> 45); + index = ((0x80 | (index & 0x7e)) >> 1) + (index & 0x1); + + __CLC_GENTYPE f1 = __CLC_CONVERT_GENTYPE(index) * 0x1.0p-7; + __CLC_GENTYPE f2 = f - f1; + __CLC_GENTYPE u2 = MATH_DIVIDE(f2, __clc_fma(0.5, f2, f1)); + + __CLC_GENTYPE z1 = USE_TABLE(ln_tbl_lo, (index - 64)); + __CLC_GENTYPE q = USE_TABLE(ln_tbl_hi, (index - 64)); + + z1 = near_one ? r : z1; + q = near_one ? 0.0 : q; + __CLC_GENTYPE u = near_one ? u1 : u2; + __CLC_GENTYPE v = u * u; + + __CLC_GENTYPE cc = near_one ? ru1 : u2; + + __CLC_GENTYPE z21 = + __clc_fma(v, __clc_fma(v, __clc_fma(v, LN3, LN2), LN1), LN0); + __CLC_GENTYPE z22 = __clc_fma(v, __clc_fma(v, LF2, LF1), LF0); + __CLC_GENTYPE z2 = near_one ? z21 : z22; + z2 = __clc_fma(u * v, z2, cc) + q; + + *r1 = z1; + *r2 = z2; +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_erf.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_erf.cl new file mode 100644 index 0000000000..17fee3e8d1 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_erf.cl @@ -0,0 +1,523 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#define erx 8.4506291151e-01f /* 0x3f58560b */ + +// Coefficients for approximation to erf on [0, 0.84375] + +#define efx 1.2837916613e-01f /* 0x3e0375d4 */ +#define efx8 1.0270333290e+00f /* 0x3f8375d4 */ + +#define pp0 1.2837916613e-01f /* 0x3e0375d4 */ +#define pp1 -3.2504209876e-01f /* 0xbea66beb */ +#define pp2 -2.8481749818e-02f /* 0xbce9528f */ +#define pp3 -5.7702702470e-03f /* 0xbbbd1489 */ +#define pp4 -2.3763017452e-05f /* 0xb7c756b1 */ +#define qq1 3.9791721106e-01f /* 0x3ecbbbce */ +#define qq2 6.5022252500e-02f /* 0x3d852a63 */ +#define qq3 5.0813062117e-03f /* 0x3ba68116 */ +#define qq4 1.3249473704e-04f /* 0x390aee49 */ +#define qq5 -3.9602282413e-06f /* 0xb684e21a */ + +// Coefficients for approximation to erf in [0.84375, 1.25] + +#define pa0 -2.3621185683e-03f /* 0xbb1acdc6 */ +#define pa1 4.1485610604e-01f /* 0x3ed46805 */ +#define pa2 -3.7220788002e-01f /* 0xbebe9208 */ +#define pa3 3.1834661961e-01f /* 0x3ea2fe54 */ +#define pa4 -1.1089469492e-01f /* 0xbde31cc2 */ +#define pa5 3.5478305072e-02f /* 0x3d1151b3 */ +#define pa6 -2.1663755178e-03f /* 0xbb0df9c0 */ +#define qa1 1.0642088205e-01f /* 0x3dd9f331 */ +#define qa2 5.4039794207e-01f /* 0x3f0a5785 */ +#define qa3 7.1828655899e-02f /* 0x3d931ae7 */ +#define qa4 1.2617121637e-01f /* 0x3e013307 */ +#define qa5 1.3637083583e-02f /* 0x3c5f6e13 */ +#define qa6 1.1984500103e-02f /* 0x3c445aa3 */ + +// Coefficients for approximation to erfc in [1.25, 1/0.35] + +#define ra0 -9.8649440333e-03f /* 0xbc21a093 */ +#define ra1 -6.9385856390e-01f /* 0xbf31a0b7 */ +#define ra2 -1.0558626175e+01f /* 0xc128f022 */ +#define ra3 -6.2375331879e+01f /* 0xc2798057 */ +#define ra4 -1.6239666748e+02f /* 0xc322658c */ +#define ra5 -1.8460508728e+02f /* 0xc3389ae7 */ +#define ra6 -8.1287437439e+01f /* 0xc2a2932b */ +#define ra7 -9.8143291473e+00f /* 0xc11d077e */ +#define sa1 1.9651271820e+01f /* 0x419d35ce */ +#define sa2 1.3765776062e+02f /* 0x4309a863 */ +#define sa3 4.3456588745e+02f /* 0x43d9486f */ +#define sa4 6.4538726807e+02f /* 0x442158c9 */ +#define sa5 4.2900814819e+02f /* 0x43d6810b */ +#define sa6 1.0863500214e+02f /* 0x42d9451f */ +#define sa7 6.5702495575e+00f /* 0x40d23f7c */ +#define sa8 -6.0424413532e-02f /* 0xbd777f97 */ + +// Coefficients for approximation to erfc in [1/0.35, 28] + +#define rb0 -9.8649431020e-03f /* 0xbc21a092 */ +#define rb1 -7.9928326607e-01f /* 0xbf4c9dd4 */ +#define rb2 -1.7757955551e+01f /* 0xc18e104b */ +#define rb3 -1.6063638306e+02f /* 0xc320a2ea */ +#define rb4 -6.3756646729e+02f /* 0xc41f6441 */ +#define rb5 -1.0250950928e+03f /* 0xc480230b */ +#define rb6 -4.8351919556e+02f /* 0xc3f1c275 */ +#define sb1 3.0338060379e+01f /* 0x41f2b459 */ +#define sb2 3.2579251099e+02f /* 0x43a2e571 */ +#define sb3 1.5367296143e+03f /* 0x44c01759 */ +#define sb4 3.1998581543e+03f /* 0x4547fdbb */ +#define sb5 2.5530502930e+03f /* 0x451f90ce */ +#define sb6 4.7452853394e+02f /* 0x43ed43a7 */ +#define sb7 -2.2440952301e+01f /* 0xc1b38712 */ + +_CLC_OVERLOAD _CLC_DEF float __clc_erf(float x) { + int hx = __clc_as_uint(x); + float absx = __clc_fabs(x); + int ix = __clc_as_uint(absx); + + float x2 = absx * absx; + float t = 1.0f / x2; + float tt = absx - 1.0f; + t = absx < 1.25f ? tt : t; + t = absx < 0.84375f ? x2 : t; + + float u, v, tu, tv; + + // |x| < 6 + u = __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, __clc_mad(t, __clc_mad(t, __clc_mad(t, rb6, rb5), rb4), rb3), + rb2), + rb1), + rb0); + v = __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, __clc_mad(t, __clc_mad(t, __clc_mad(t, sb7, sb6), sb5), sb4), + sb3), + sb2), + sb1); + + tu = __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, + __clc_mad(t, __clc_mad(t, __clc_mad(t, ra7, ra6), ra5), ra4), + ra3), + ra2), + ra1), + ra0); + tv = __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, + __clc_mad(t, __clc_mad(t, __clc_mad(t, sa8, sa7), sa6), sa5), + sa4), + sa3), + sa2), + sa1); + u = absx < 0x1.6db6dcp+1f ? tu : u; + v = absx < 0x1.6db6dcp+1f ? tv : v; + + tu = __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, __clc_mad(t, __clc_mad(t, __clc_mad(t, pa6, pa5), pa4), pa3), + pa2), + pa1), + pa0); + tv = __clc_mad( + t, + __clc_mad(t, __clc_mad(t, __clc_mad(t, __clc_mad(t, qa6, qa5), qa4), qa3), + qa2), + qa1); + u = absx < 1.25f ? tu : u; + v = absx < 1.25f ? tv : v; + + tu = __clc_mad( + t, __clc_mad(t, __clc_mad(t, __clc_mad(t, pp4, pp3), pp2), pp1), pp0); + tv = __clc_mad( + t, __clc_mad(t, __clc_mad(t, __clc_mad(t, qq5, qq4), qq3), qq2), qq1); + u = absx < 0.84375f ? tu : u; + v = absx < 0.84375f ? tv : v; + + v = __clc_mad(t, v, 1.0f); + float q = MATH_DIVIDE(u, v); + + float ret = 1.0f; + + // |x| < 6 + float z = __clc_as_float(ix & 0xfffff000); + float r = __clc_exp(-z * z) * __clc_exp(__clc_mad(z - absx, z + absx, q)); + r *= 0x1.23ba94p-1f; // exp(-0.5625) + r = 1.0f - MATH_DIVIDE(r, absx); + ret = absx < 6.0f ? r : ret; + + r = erx + q; + ret = absx < 1.25f ? r : ret; + + ret = __clc_as_float((hx & 0x80000000) | __clc_as_int(ret)); + + r = __clc_mad(x, q, x); + ret = absx < 0.84375f ? r : ret; + + // Prevent underflow + r = 0.125f * __clc_mad(8.0f, x, efx8 * x); + ret = absx < 0x1.0p-28f ? r : ret; + + ret = __clc_isnan(x) ? x : ret; + + return ret; +} + +#define __FLOAT_ONLY +#define FUNCTION __clc_erf +#define __CLC_BODY +#include +#undef FUNCTION + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* double erf(double x) + * double erfc(double x) + * x + * 2 |\ + * erf(x) = --------- | exp(-t*t)dt + * sqrt(pi) \| + * 0 + * + * erfc(x) = 1-erf(x) + * Note that + * erf(-x) = -erf(x) + * erfc(-x) = 2 - erfc(x) + * + * Method: + * 1. For |x| in [0, 0.84375] + * erf(x) = x + x*R(x^2) + * erfc(x) = 1 - erf(x) if x in [-.84375,0.25] + * = 0.5 + ((0.5-x)-x*R) if x in [0.25,0.84375] + * where R = P/Q where P is an odd poly of degree 8 and + * Q is an odd poly of degree 10. + * -57.90 + * | R - (erf(x)-x)/x | <= 2 + * + * + * Remark. The formula is derived by noting + * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....) + * and that + * 2/sqrt(pi) = 1.128379167095512573896158903121545171688 + * is close to one. The interval is chosen because the fix + * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is + * near 0.6174), and by some experiment, 0.84375 is chosen to + * guarantee the error is less than one ulp for erf. + * + * 2. For |x| in [0.84375,1.25], let s = |x| - 1, and + * c = 0.84506291151 rounded to single (24 bits) + * erf(x) = sign(x) * (c + P1(s)/Q1(s)) + * erfc(x) = (1-c) - P1(s)/Q1(s) if x > 0 + * 1+(c+P1(s)/Q1(s)) if x < 0 + * |P1/Q1 - (erf(|x|)-c)| <= 2**-59.06 + * Remark: here we use the taylor series expansion at x=1. + * erf(1+s) = erf(1) + s*Poly(s) + * = 0.845.. + P1(s)/Q1(s) + * That is, we use rational approximation to approximate + * erf(1+s) - (c = (single)0.84506291151) + * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25] + * where + * P1(s) = degree 6 poly in s + * Q1(s) = degree 6 poly in s + * + * 3. For x in [1.25,1/0.35(~2.857143)], + * erfc(x) = (1/x)*exp(-x*x-0.5625+R1/S1) + * erf(x) = 1 - erfc(x) + * where + * R1(z) = degree 7 poly in z, (z=1/x^2) + * S1(z) = degree 8 poly in z + * + * 4. For x in [1/0.35,28] + * erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0 + * = 2.0 - (1/x)*exp(-x*x-0.5625+R2/S2) if -6 x >= 28 + * erf(x) = sign(x) *(1 - tiny) (raise inexact) + * erfc(x) = tiny*tiny (raise underflow) if x > 0 + * = 2 - tiny if x<0 + * + * 7. Special case: + * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1, + * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2, + * erfc/erf(NaN) is NaN + */ + +#define AU0 -9.86494292470009928597e-03 +#define AU1 -7.99283237680523006574e-01 +#define AU2 -1.77579549177547519889e+01 +#define AU3 -1.60636384855821916062e+02 +#define AU4 -6.37566443368389627722e+02 +#define AU5 -1.02509513161107724954e+03 +#define AU6 -4.83519191608651397019e+02 + +#define AV1 3.03380607434824582924e+01 +#define AV2 3.25792512996573918826e+02 +#define AV3 1.53672958608443695994e+03 +#define AV4 3.19985821950859553908e+03 +#define AV5 2.55305040643316442583e+03 +#define AV6 4.74528541206955367215e+02 +#define AV7 -2.24409524465858183362e+01 + +#define BU0 -9.86494403484714822705e-03 +#define BU1 -6.93858572707181764372e-01 +#define BU2 -1.05586262253232909814e+01 +#define BU3 -6.23753324503260060396e+01 +#define BU4 -1.62396669462573470355e+02 +#define BU5 -1.84605092906711035994e+02 +#define BU6 -8.12874355063065934246e+01 +#define BU7 -9.81432934416914548592e+00 + +#define BV1 1.96512716674392571292e+01 +#define BV2 1.37657754143519042600e+02 +#define BV3 4.34565877475229228821e+02 +#define BV4 6.45387271733267880336e+02 +#define BV5 4.29008140027567833386e+02 +#define BV6 1.08635005541779435134e+02 +#define BV7 6.57024977031928170135e+00 +#define BV8 -6.04244152148580987438e-02 + +#define CU0 -2.36211856075265944077e-03 +#define CU1 4.14856118683748331666e-01 +#define CU2 -3.72207876035701323847e-01 +#define CU3 3.18346619901161753674e-01 +#define CU4 -1.10894694282396677476e-01 +#define CU5 3.54783043256182359371e-02 +#define CU6 -2.16637559486879084300e-03 + +#define CV1 1.06420880400844228286e-01 +#define CV2 5.40397917702171048937e-01 +#define CV3 7.18286544141962662868e-02 +#define CV4 1.26171219808761642112e-01 +#define CV5 1.36370839120290507362e-02 +#define CV6 1.19844998467991074170e-02 + +#define DU0 1.28379167095512558561e-01 +#define DU1 -3.25042107247001499370e-01 +#define DU2 -2.84817495755985104766e-02 +#define DU3 -5.77027029648944159157e-03 +#define DU4 -2.37630166566501626084e-05 + +#define DV1 3.97917223959155352819e-01 +#define DV2 6.50222499887672944485e-02 +#define DV3 5.08130628187576562776e-03 +#define DV4 1.32494738004321644526e-04 +#define DV5 -3.96022827877536812320e-06 + +_CLC_OVERLOAD _CLC_DEF double __clc_erf(double y) { + double x = __clc_fabs(y); + double x2 = x * x; + double xm1 = x - 1.0; + + // Poly variable + double t = 1.0 / x2; + t = x < 1.25 ? xm1 : t; + t = x < 0.84375 ? x2 : t; + + double u, ut, v, vt; + + // Evaluate rational poly + // XXX We need to see of we can grab 16 coefficents from a table + // faster than evaluating 3 of the poly pairs + // if (x < 6.0) + u = __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, AU6, AU5), AU4), AU3), + AU2), + AU1), + AU0); + v = __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, AV7, AV6), AV5), AV4), + AV3), + AV2), + AV1); + + ut = __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, + __clc_fma(t, __clc_fma(t, __clc_fma(t, BU7, BU6), BU5), BU4), + BU3), + BU2), + BU1), + BU0); + vt = __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, + __clc_fma(t, __clc_fma(t, __clc_fma(t, BV8, BV7), BV6), BV5), + BV4), + BV3), + BV2), + BV1); + u = x < 0x1.6db6ep+1 ? ut : u; + v = x < 0x1.6db6ep+1 ? vt : v; + + ut = __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, CU6, CU5), CU4), CU3), + CU2), + CU1), + CU0); + vt = __clc_fma( + t, + __clc_fma(t, __clc_fma(t, __clc_fma(t, __clc_fma(t, CV6, CV5), CV4), CV3), + CV2), + CV1); + u = x < 1.25 ? ut : u; + v = x < 1.25 ? vt : v; + + ut = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, DU4, DU3), DU2), DU1), DU0); + vt = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, DV5, DV4), DV3), DV2), DV1); + u = x < 0.84375 ? ut : u; + v = x < 0.84375 ? vt : v; + + v = __clc_fma(t, v, 1.0); + + // Compute rational approximation + double q = u / v; + + // Compute results + double z = __clc_as_double(__clc_as_long(x) & 0xffffffff00000000L); + double r = __clc_exp(-z * z - 0.5625) * __clc_exp((z - x) * (z + x) + q); + r = 1.0 - r / x; + + double ret = x < 6.0 ? r : 1.0; + + r = 8.45062911510467529297e-01 + q; + ret = x < 1.25 ? r : ret; + + q = x < 0x1.0p-28 ? 1.28379167095512586316e-01 : q; + + r = __clc_fma(x, q, x); + ret = x < 0.84375 ? r : ret; + + ret = __clc_isnan(x) ? x : ret; + + return y < 0.0 ? -ret : ret; +} + +#define __DOUBLE_ONLY +#define FUNCTION __clc_erf +#define __CLC_BODY +#include +#undef FUNCTION + +#endif + +#ifdef cl_khr_fp16 + +#include + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// Forward the half version of this builtin onto the float one +#define __HALF_ONLY +#define FUNCTION __clc_erf +#define __CLC_BODY +#include + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_erfc.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_erfc.cl new file mode 100644 index 0000000000..77f8959831 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_erfc.cl @@ -0,0 +1,532 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#define erx_f 8.4506291151e-01f /* 0x3f58560b */ + +// Coefficients for approximation to erf on [0, 0.84375] + +#define efx 1.2837916613e-01f /* 0x3e0375d4 */ +#define efx8 1.0270333290e+00f /* 0x3f8375d4 */ + +#define pp0 1.2837916613e-01f /* 0x3e0375d4 */ +#define pp1 -3.2504209876e-01f /* 0xbea66beb */ +#define pp2 -2.8481749818e-02f /* 0xbce9528f */ +#define pp3 -5.7702702470e-03f /* 0xbbbd1489 */ +#define pp4 -2.3763017452e-05f /* 0xb7c756b1 */ +#define qq1 3.9791721106e-01f /* 0x3ecbbbce */ +#define qq2 6.5022252500e-02f /* 0x3d852a63 */ +#define qq3 5.0813062117e-03f /* 0x3ba68116 */ +#define qq4 1.3249473704e-04f /* 0x390aee49 */ +#define qq5 -3.9602282413e-06f /* 0xb684e21a */ + +// Coefficients for approximation to erf in [0.84375, 1.25] + +#define pa0 -2.3621185683e-03f /* 0xbb1acdc6 */ +#define pa1 4.1485610604e-01f /* 0x3ed46805 */ +#define pa2 -3.7220788002e-01f /* 0xbebe9208 */ +#define pa3 3.1834661961e-01f /* 0x3ea2fe54 */ +#define pa4 -1.1089469492e-01f /* 0xbde31cc2 */ +#define pa5 3.5478305072e-02f /* 0x3d1151b3 */ +#define pa6 -2.1663755178e-03f /* 0xbb0df9c0 */ +#define qa1 1.0642088205e-01f /* 0x3dd9f331 */ +#define qa2 5.4039794207e-01f /* 0x3f0a5785 */ +#define qa3 7.1828655899e-02f /* 0x3d931ae7 */ +#define qa4 1.2617121637e-01f /* 0x3e013307 */ +#define qa5 1.3637083583e-02f /* 0x3c5f6e13 */ +#define qa6 1.1984500103e-02f /* 0x3c445aa3 */ + +// Coefficients for approximation to erfc in [1.25, 1/0.35] + +#define ra0 -9.8649440333e-03f /* 0xbc21a093 */ +#define ra1 -6.9385856390e-01f /* 0xbf31a0b7 */ +#define ra2 -1.0558626175e+01f /* 0xc128f022 */ +#define ra3 -6.2375331879e+01f /* 0xc2798057 */ +#define ra4 -1.6239666748e+02f /* 0xc322658c */ +#define ra5 -1.8460508728e+02f /* 0xc3389ae7 */ +#define ra6 -8.1287437439e+01f /* 0xc2a2932b */ +#define ra7 -9.8143291473e+00f /* 0xc11d077e */ +#define sa1 1.9651271820e+01f /* 0x419d35ce */ +#define sa2 1.3765776062e+02f /* 0x4309a863 */ +#define sa3 4.3456588745e+02f /* 0x43d9486f */ +#define sa4 6.4538726807e+02f /* 0x442158c9 */ +#define sa5 4.2900814819e+02f /* 0x43d6810b */ +#define sa6 1.0863500214e+02f /* 0x42d9451f */ +#define sa7 6.5702495575e+00f /* 0x40d23f7c */ +#define sa8 -6.0424413532e-02f /* 0xbd777f97 */ + +// Coefficients for approximation to erfc in [1/0.35, 28] + +#define rb0 -9.8649431020e-03f /* 0xbc21a092 */ +#define rb1 -7.9928326607e-01f /* 0xbf4c9dd4 */ +#define rb2 -1.7757955551e+01f /* 0xc18e104b */ +#define rb3 -1.6063638306e+02f /* 0xc320a2ea */ +#define rb4 -6.3756646729e+02f /* 0xc41f6441 */ +#define rb5 -1.0250950928e+03f /* 0xc480230b */ +#define rb6 -4.8351919556e+02f /* 0xc3f1c275 */ +#define sb1 3.0338060379e+01f /* 0x41f2b459 */ +#define sb2 3.2579251099e+02f /* 0x43a2e571 */ +#define sb3 1.5367296143e+03f /* 0x44c01759 */ +#define sb4 3.1998581543e+03f /* 0x4547fdbb */ +#define sb5 2.5530502930e+03f /* 0x451f90ce */ +#define sb6 4.7452853394e+02f /* 0x43ed43a7 */ +#define sb7 -2.2440952301e+01f /* 0xc1b38712 */ + +_CLC_OVERLOAD _CLC_DEF float __clc_erfc(float x) { + float absx = __clc_fabs(x); + int ix = __clc_as_uint(absx); + + // Argument for polys + float x2 = absx * absx; + float t = 1.0f / x2; + float tt = absx - 1.0f; + t = absx < 1.25f ? tt : t; + t = absx < 0.84375f ? x2 : t; + + // Evaluate polys + float tu, tv, u, v; + + u = __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, __clc_mad(t, __clc_mad(t, __clc_mad(t, rb6, rb5), rb4), rb3), + rb2), + rb1), + rb0); + v = __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, __clc_mad(t, __clc_mad(t, __clc_mad(t, sb7, sb6), sb5), sb4), + sb3), + sb2), + sb1); + + tu = __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, + __clc_mad(t, __clc_mad(t, __clc_mad(t, ra7, ra6), ra5), ra4), + ra3), + ra2), + ra1), + ra0); + tv = __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, + __clc_mad(t, __clc_mad(t, __clc_mad(t, sa8, sa7), sa6), sa5), + sa4), + sa3), + sa2), + sa1); + u = absx < 0x1.6db6dap+1f ? tu : u; + v = absx < 0x1.6db6dap+1f ? tv : v; + + tu = __clc_mad( + t, + __clc_mad( + t, + __clc_mad( + t, __clc_mad(t, __clc_mad(t, __clc_mad(t, pa6, pa5), pa4), pa3), + pa2), + pa1), + pa0); + tv = __clc_mad( + t, + __clc_mad(t, __clc_mad(t, __clc_mad(t, __clc_mad(t, qa6, qa5), qa4), qa3), + qa2), + qa1); + u = absx < 1.25f ? tu : u; + v = absx < 1.25f ? tv : v; + + tu = __clc_mad( + t, __clc_mad(t, __clc_mad(t, __clc_mad(t, pp4, pp3), pp2), pp1), pp0); + tv = __clc_mad( + t, __clc_mad(t, __clc_mad(t, __clc_mad(t, qq5, qq4), qq3), qq2), qq1); + u = absx < 0.84375f ? tu : u; + v = absx < 0.84375f ? tv : v; + + v = __clc_mad(t, v, 1.0f); + + float q = MATH_DIVIDE(u, v); + + float ret = 0.0f; + + float z = __clc_as_float(ix & 0xfffff000); + float r = __clc_exp(-z * z) * __clc_exp(__clc_mad(z - absx, z + absx, q)); + r *= 0x1.23ba94p-1f; // exp(-0.5625) + r = MATH_DIVIDE(r, absx); + t = 2.0f - r; + r = x < 0.0f ? t : r; + ret = absx < 28.0f ? r : ret; + + r = 1.0f - erx_f - q; + t = erx_f + q + 1.0f; + r = x < 0.0f ? t : r; + ret = absx < 1.25f ? r : ret; + + r = 0.5f - __clc_mad(x, q, x - 0.5f); + ret = absx < 0.84375f ? r : ret; + + ret = x < -6.0f ? 2.0f : ret; + + ret = __clc_isnan(x) ? x : ret; + + return ret; +} + +#define __FLOAT_ONLY +#define FUNCTION __clc_erfc +#define __CLC_BODY +#include +#undef FUNCTION + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* double erf(double x) + * double erfc(double x) + * x + * 2 |\ + * erf(x) = --------- | exp(-t*t)dt + * sqrt(pi) \| + * 0 + * + * erfc(x) = 1-erf(x) + * Note that + * erf(-x) = -erf(x) + * erfc(-x) = 2 - erfc(x) + * + * Method: + * 1. For |x| in [0, 0.84375] + * erf(x) = x + x*R(x^2) + * erfc(x) = 1 - erf(x) if x in [-.84375,0.25] + * = 0.5 + ((0.5-x)-x*R) if x in [0.25,0.84375] + * where R = P/Q where P is an odd poly of degree 8 and + * Q is an odd poly of degree 10. + * -57.90 + * | R - (erf(x)-x)/x | <= 2 + * + * + * Remark. The formula is derived by noting + * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....) + * and that + * 2/sqrt(pi) = 1.128379167095512573896158903121545171688 + * is close to one. The interval is chosen because the fix + * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is + * near 0.6174), and by some experiment, 0.84375 is chosen to + * guarantee the error is less than one ulp for erf. + * + * 2. For |x| in [0.84375,1.25], let s = |x| - 1, and + * c = 0.84506291151 rounded to single (24 bits) + * erf(x) = sign(x) * (c + P1(s)/Q1(s)) + * erfc(x) = (1-c) - P1(s)/Q1(s) if x > 0 + * 1+(c+P1(s)/Q1(s)) if x < 0 + * |P1/Q1 - (erf(|x|)-c)| <= 2**-59.06 + * Remark: here we use the taylor series expansion at x=1. + * erf(1+s) = erf(1) + s*Poly(s) + * = 0.845.. + P1(s)/Q1(s) + * That is, we use rational approximation to approximate + * erf(1+s) - (c = (single)0.84506291151) + * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25] + * where + * P1(s) = degree 6 poly in s + * Q1(s) = degree 6 poly in s + * + * 3. For x in [1.25,1/0.35(~2.857143)], + * erfc(x) = (1/x)*exp(-x*x-0.5625+R1/S1) + * erf(x) = 1 - erfc(x) + * where + * R1(z) = degree 7 poly in z, (z=1/x^2) + * S1(z) = degree 8 poly in z + * + * 4. For x in [1/0.35,28] + * erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0 + * = 2.0 - (1/x)*exp(-x*x-0.5625+R2/S2) if -6 x >= 28 + * erf(x) = sign(x) *(1 - tiny) (raise inexact) + * erfc(x) = tiny*tiny (raise underflow) if x > 0 + * = 2 - tiny if x<0 + * + * 7. Special case: + * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1, + * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2, + * erfc/erf(NaN) is NaN + */ + +#define AU0 -9.86494292470009928597e-03 +#define AU1 -7.99283237680523006574e-01 +#define AU2 -1.77579549177547519889e+01 +#define AU3 -1.60636384855821916062e+02 +#define AU4 -6.37566443368389627722e+02 +#define AU5 -1.02509513161107724954e+03 +#define AU6 -4.83519191608651397019e+02 + +#define AV0 3.03380607434824582924e+01 +#define AV1 3.25792512996573918826e+02 +#define AV2 1.53672958608443695994e+03 +#define AV3 3.19985821950859553908e+03 +#define AV4 2.55305040643316442583e+03 +#define AV5 4.74528541206955367215e+02 +#define AV6 -2.24409524465858183362e+01 + +#define BU0 -9.86494403484714822705e-03 +#define BU1 -6.93858572707181764372e-01 +#define BU2 -1.05586262253232909814e+01 +#define BU3 -6.23753324503260060396e+01 +#define BU4 -1.62396669462573470355e+02 +#define BU5 -1.84605092906711035994e+02 +#define BU6 -8.12874355063065934246e+01 +#define BU7 -9.81432934416914548592e+00 + +#define BV0 1.96512716674392571292e+01 +#define BV1 1.37657754143519042600e+02 +#define BV2 4.34565877475229228821e+02 +#define BV3 6.45387271733267880336e+02 +#define BV4 4.29008140027567833386e+02 +#define BV5 1.08635005541779435134e+02 +#define BV6 6.57024977031928170135e+00 +#define BV7 -6.04244152148580987438e-02 + +#define CU0 -2.36211856075265944077e-03 +#define CU1 4.14856118683748331666e-01 +#define CU2 -3.72207876035701323847e-01 +#define CU3 3.18346619901161753674e-01 +#define CU4 -1.10894694282396677476e-01 +#define CU5 3.54783043256182359371e-02 +#define CU6 -2.16637559486879084300e-03 + +#define CV0 1.06420880400844228286e-01 +#define CV1 5.40397917702171048937e-01 +#define CV2 7.18286544141962662868e-02 +#define CV3 1.26171219808761642112e-01 +#define CV4 1.36370839120290507362e-02 +#define CV5 1.19844998467991074170e-02 + +#define DU0 1.28379167095512558561e-01 +#define DU1 -3.25042107247001499370e-01 +#define DU2 -2.84817495755985104766e-02 +#define DU3 -5.77027029648944159157e-03 +#define DU4 -2.37630166566501626084e-05 + +#define DV0 3.97917223959155352819e-01 +#define DV1 6.50222499887672944485e-02 +#define DV2 5.08130628187576562776e-03 +#define DV3 1.32494738004321644526e-04 +#define DV4 -3.96022827877536812320e-06 + +_CLC_OVERLOAD _CLC_DEF double __clc_erfc(double x) { + long lx = __clc_as_long(x); + long ax = lx & 0x7fffffffffffffffL; + double absx = __clc_as_double(ax); + int xneg = lx != ax; + + // Poly arg + double x2 = x * x; + double xm1 = absx - 1.0; + double t = 1.0 / x2; + t = absx < 1.25 ? xm1 : t; + t = absx < 0.84375 ? x2 : t; + + // Evaluate rational poly + // XXX Need to evaluate if we can grab the 14 coefficients from a + // table faster than evaluating 3 pairs of polys + double tu, tv, u, v; + + // |x| < 28 + u = __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, AU6, AU5), AU4), AU3), + AU2), + AU1), + AU0); + v = __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, AV6, AV5), AV4), AV3), + AV2), + AV1), + AV0); + + tu = __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, + __clc_fma(t, __clc_fma(t, __clc_fma(t, BU7, BU6), BU5), BU4), + BU3), + BU2), + BU1), + BU0); + tv = __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, + __clc_fma(t, __clc_fma(t, __clc_fma(t, BV7, BV6), BV5), BV4), + BV3), + BV2), + BV1), + BV0); + u = absx < 0x1.6db6dp+1 ? tu : u; + v = absx < 0x1.6db6dp+1 ? tv : v; + + tu = __clc_fma( + t, + __clc_fma( + t, + __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, CU6, CU5), CU4), CU3), + CU2), + CU1), + CU0); + tv = __clc_fma( + t, + __clc_fma(t, __clc_fma(t, __clc_fma(t, __clc_fma(t, CV5, CV4), CV3), CV2), + CV1), + CV0); + u = absx < 1.25 ? tu : u; + v = absx < 1.25 ? tv : v; + + tu = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, DU4, DU3), DU2), DU1), DU0); + tv = __clc_fma( + t, __clc_fma(t, __clc_fma(t, __clc_fma(t, DV4, DV3), DV2), DV1), DV0); + u = absx < 0.84375 ? tu : u; + v = absx < 0.84375 ? tv : v; + + v = __clc_fma(t, v, 1.0); + double q = u / v; + + // Evaluate return value + + // |x| < 28 + double z = __clc_as_double(ax & 0xffffffff00000000UL); + double ret = __clc_exp(-z * z - 0.5625) * + __clc_exp((z - absx) * (z + absx) + q) / absx; + t = 2.0 - ret; + ret = xneg ? t : ret; + + const double erx = 8.45062911510467529297e-01; + z = erx + q + 1.0; + t = 1.0 - erx - q; + t = xneg ? z : t; + ret = absx < 1.25 ? t : ret; + + // z = 1.0 - fma(x, q, x); + // t = 0.5 - fma(x, q, x - 0.5); + // t = xneg == 1 | absx < 0.25 ? z : t; + t = __clc_fma(-x, q, 1.0 - x); + ret = absx < 0.84375 ? t : ret; + + ret = x >= 28.0 ? 0.0 : ret; + ret = x <= -6.0 ? 2.0 : ret; + ret = ax > 0x7ff0000000000000UL ? x : ret; + + return ret; +} + +#define __DOUBLE_ONLY +#define FUNCTION __clc_erfc +#define __CLC_BODY +#include +#undef FUNCTION + +#endif + +#ifdef cl_khr_fp16 + +#include + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// Forward the half version of this builtin onto the float one +#define __HALF_ONLY +#define FUNCTION __clc_erfc +#define __CLC_BODY +#include + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp.cl new file mode 100644 index 0000000000..6ff4527218 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp.inc new file mode 100644 index 0000000000..5057bf8034 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp.inc @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_exp(__CLC_GENTYPE x) { + // Reduce x + const __CLC_GENTYPE ln2HI = 0x1.62e300p-1f; + const __CLC_GENTYPE ln2LO = 0x1.2fefa2p-17f; + const __CLC_GENTYPE invln2 = 0x1.715476p+0f; + + __CLC_GENTYPE fhalF = x < 0.0f ? -0.5f : 0.5f; + __CLC_INTN p = __CLC_CONVERT_INTN(__clc_mad(x, invln2, fhalF)); + __CLC_GENTYPE fp = __CLC_CONVERT_GENTYPE(p); + __CLC_GENTYPE hi = __clc_mad(fp, -ln2HI, x); // t*ln2HI is exact here + __CLC_GENTYPE lo = -fp * ln2LO; + + // Evaluate poly + __CLC_GENTYPE t = hi + lo; + __CLC_GENTYPE tt = t * t; + __CLC_GENTYPE v = __clc_mad( + tt, + -__clc_mad( + tt, + __clc_mad(tt, + __clc_mad(tt, + __clc_mad(tt, 0x1.637698p-25f, -0x1.bbd41cp-20f), + 0x1.1566aap-14f), + -0x1.6c16c2p-9f), + 0x1.555556p-3f), + t); + + __CLC_GENTYPE y = 1.0f - (((-lo) - MATH_DIVIDE(t * v, 2.0f - v)) - hi); + + // Scale by 2^p + __CLC_GENTYPE r = __CLC_AS_GENTYPE(__CLC_AS_INTN(y) + (p << 23)); + + // ln(largest_normal) = 88.72283905206835305366 + const __CLC_GENTYPE ulim = 0x1.62e430p+6f; + // ln(smallest_normal) = -87.33654475055310898657 + const __CLC_GENTYPE llim = -0x1.5d589ep+6f; + + r = x < llim ? 0.0f : r; + r = x < ulim ? r : __CLC_AS_GENTYPE((__CLC_UINTN)0x7f800000); + return __clc_isnan(x) ? x : r; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_exp(__CLC_GENTYPE x) { + + const __CLC_GENTYPE X_MIN = -0x1.74910d52d3051p+9; // -1075*ln(2) + const __CLC_GENTYPE X_MAX = 0x1.62e42fefa39efp+9; // 1024*ln(2) + const __CLC_GENTYPE R_64_BY_LOG2 = 0x1.71547652b82fep+6; // 64/ln(2) + const __CLC_GENTYPE R_LOG2_BY_64_LD = 0x1.62e42fefa0000p-7; // head ln(2)/64 + const __CLC_GENTYPE R_LOG2_BY_64_TL = 0x1.cf79abc9e3b39p-46; // tail ln(2)/64 + + __CLC_INTN n = __CLC_CONVERT_INTN(x * R_64_BY_LOG2); + __CLC_GENTYPE r = + __clc_fma(-R_LOG2_BY_64_TL, __CLC_CONVERT_GENTYPE(n), + __clc_fma(-R_LOG2_BY_64_LD, __CLC_CONVERT_GENTYPE(n), x)); + return __clc_exp_helper(x, X_MIN, X_MAX, r, n); +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_exp(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_exp(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp10.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp10.cl new file mode 100644 index 0000000000..04e912ed98 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp10.cl @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp10.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp10.inc new file mode 100644 index 0000000000..96bc5331fe --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp10.inc @@ -0,0 +1,155 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Algorithm: +// +// e^x = 2^(x/ln(2)) = 2^(x*(64/ln(2))/64) +// +// x*(64/ln(2)) = n + f, |f| <= 0.5, n is integer +// n = 64*m + j, 0 <= j < 64 +// +// e^x = 2^((64*m + j + f)/64) +// = (2^m) * (2^(j/64)) * 2^(f/64) +// = (2^m) * (2^(j/64)) * e^(f*(ln(2)/64)) +// +// f = x*(64/ln(2)) - n +// r = f*(ln(2)/64) = x - n*(ln(2)/64) +// +// e^x = (2^m) * (2^(j/64)) * e^r +// +// (2^(j/64)) is precomputed +// +// e^r = 1 + r + (r^2)/2! + (r^3)/3! + (r^4)/4! + (r^5)/5! +// e^r = 1 + q +// +// q = r + (r^2)/2! + (r^3)/3! + (r^4)/4! + (r^5)/5! +// +// e^x = (2^m) * ( (2^(j/64)) + q*(2^(j/64)) ) +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_exp10(__CLC_GENTYPE x) { + // 128*log2/log10 : 38.53183944498959 + const __CLC_GENTYPE X_MAX = 0x1.344134p+5f; + // -149*log2/log10 : -44.8534693539332 + const __CLC_GENTYPE X_MIN = -0x1.66d3e8p+5f; + // 64*log10/log2 : 212.6033980727912 + const __CLC_GENTYPE R_64_BY_LOG10_2 = 0x1.a934f0p+7f; + // log2/(64 * log10) lead : 0.004699707 + const __CLC_GENTYPE R_LOG10_2_BY_64_LD = 0x1.340000p-8f; + // log2/(64 * log10) tail : 0.00000388665057 + const __CLC_GENTYPE R_LOG10_2_BY_64_TL = 0x1.04d426p-18f; + const __CLC_GENTYPE R_LN10 = 0x1.26bb1cp+1f; + + __CLC_INTN return_nan = __clc_isnan(x); + __CLC_INTN return_inf = x > X_MAX; + __CLC_INTN return_zero = x < X_MIN; + + __CLC_INTN n = __CLC_CONVERT_INTN(x * R_64_BY_LOG10_2); + + __CLC_GENTYPE fn = __CLC_CONVERT_GENTYPE(n); + __CLC_INTN j = n & 0x3f; + __CLC_INTN m = n >> 6; + __CLC_INTN m2 = m << EXPSHIFTBITS_SP32; + __CLC_GENTYPE r; + + r = R_LN10 * + __clc_mad(fn, -R_LOG10_2_BY_64_TL, __clc_mad(fn, -R_LOG10_2_BY_64_LD, x)); + + // Truncated Taylor series for e^r + __CLC_GENTYPE z2 = + __clc_mad(__clc_mad(__clc_mad(r, 0x1.555556p-5f, 0x1.555556p-3f), r, + 0x1.000000p-1f), + r * r, r); + + __CLC_GENTYPE two_to_jby64 = USE_TABLE(exp_tbl, j); + z2 = __clc_mad(two_to_jby64, z2, two_to_jby64); + + __CLC_GENTYPE z2s = z2 * __CLC_AS_GENTYPE((__CLC_UINTN)0x1 << (m + 149)); + __CLC_GENTYPE z2n = __CLC_AS_GENTYPE(__CLC_AS_INTN(z2) + m2); + z2 = m <= -126 ? z2s : z2n; + + z2 = return_inf ? __CLC_AS_GENTYPE((__CLC_UINTN)PINFBITPATT_SP32) : z2; + z2 = return_zero ? 0.0f : z2; + z2 = return_nan ? x : z2; + return z2; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_exp10(__CLC_GENTYPE x) { + // 1024*ln(2)/ln(10) + const __CLC_GENTYPE X_MAX = 0x1.34413509f79ffp+8; + // -1074*ln(2)/ln(10) + const __CLC_GENTYPE X_MIN = -0x1.434e6420f4374p+8; + // 64*ln(10)/ln(2) + const __CLC_GENTYPE R_64_BY_LOG10_2 = 0x1.a934f0979a371p+7; + // head ln(2)/(64*ln(10)) + const __CLC_GENTYPE R_LOG10_2_BY_64_LD = 0x1.3441350000000p-8; + // tail ln(2)/(64*ln(10)) + const __CLC_GENTYPE R_LOG10_2_BY_64_TL = 0x1.3ef3fde623e25p-37; + // ln(10) + const __CLC_GENTYPE R_LN10 = 0x1.26bb1bbb55516p+1; + + __CLC_INTN n = __CLC_CONVERT_INTN(x * R_64_BY_LOG10_2); + + __CLC_GENTYPE dn = __CLC_CONVERT_GENTYPE(n); + + __CLC_INTN j = n & 0x3f; + __CLC_INTN m = n >> 6; + + __CLC_GENTYPE r = R_LN10 * __clc_fma(-R_LOG10_2_BY_64_TL, dn, + __clc_fma(-R_LOG10_2_BY_64_LD, dn, x)); + + // 6 term tail of Taylor expansion of e^r + __CLC_GENTYPE z2 = + r * __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 0x1.6c16c16c16c17p-10, + 0x1.1111111111111p-7), + 0x1.5555555555555p-5), + 0x1.5555555555555p-3), + 0x1.0000000000000p-1), + 1.0); + + __CLC_GENTYPE tv0 = USE_TABLE(two_to_jby64_ep_tbl_head, j); + __CLC_GENTYPE tv1 = USE_TABLE(two_to_jby64_ep_tbl_tail, j); + z2 = __clc_fma(tv0 + tv1, z2, tv1) + tv0; + + __CLC_INTN small_value = + (m < -1022) || ((m == -1022) && __CLC_CONVERT_INTN(z2 < 1.0)); + + __CLC_INTN n1 = m >> 2; + __CLC_INTN n2 = m - n1; + __CLC_GENTYPE z3 = + z2 * __CLC_AS_GENTYPE((__CLC_CONVERT_LONGN(n1) + 1023) << 52); + z3 *= __CLC_AS_GENTYPE((__CLC_CONVERT_LONGN(n2) + 1023) << 52); + + z2 = __clc_ldexp(z2, m); + z2 = __CLC_CONVERT_LONGN(small_value) ? z3 : z2; + + z2 = __clc_isnan(x) ? x : z2; + + z2 = x > X_MAX ? __CLC_AS_GENTYPE((__CLC_ULONGN)PINFBITPATT_DP64) : z2; + z2 = x < X_MIN ? 0.0 : z2; + + return z2; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_exp10(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_exp10(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp2.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp2.cl new file mode 100644 index 0000000000..9635f84e5a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp2.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp2.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp2.inc new file mode 100644 index 0000000000..6da361a43e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp2.inc @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_exp2(__CLC_GENTYPE x) { + // Reduce x + const __CLC_GENTYPE ln2HI = 0x1.62e300p-1f; + const __CLC_GENTYPE ln2LO = 0x1.2fefa2p-17f; + + __CLC_GENTYPE t = __clc_rint(x); + __CLC_INTN p = __CLC_CONVERT_INTN(t); + __CLC_GENTYPE tt = x - t; + __CLC_GENTYPE hi = tt * ln2HI; + __CLC_GENTYPE lo = tt * ln2LO; + + // Evaluate poly + t = hi + lo; + tt = t * t; + __CLC_GENTYPE v = __clc_mad( + tt, + -__clc_mad( + tt, + __clc_mad(tt, + __clc_mad(tt, + __clc_mad(tt, 0x1.637698p-25f, -0x1.bbd41cp-20f), + 0x1.1566aap-14f), + -0x1.6c16c2p-9f), + 0x1.555556p-3f), + t); + + __CLC_GENTYPE y = 1.0f - (((-lo) - MATH_DIVIDE(t * v, 2.0f - v)) - hi); + + // Scale by 2^p + __CLC_GENTYPE r = __CLC_AS_FLOATN(__CLC_AS_INTN(y) + (p << 23)); + + const __CLC_GENTYPE ulim = 128.0f; + const __CLC_GENTYPE llim = -126.0f; + + r = x < llim ? 0.0f : r; + r = x < ulim ? r : __CLC_AS_FLOATN((__CLC_UINTN)0x7f800000); + return __clc_isnan(x) ? x : r; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_exp2(__CLC_GENTYPE x) { + const __CLC_GENTYPE R_LN2 = 0x1.62e42fefa39efp-1; // ln(2) + const __CLC_GENTYPE R_1_BY_64 = 1.0 / 64.0; + + __CLC_INTN n = __CLC_CONVERT_INTN(x * 64.0); + __CLC_GENTYPE r = R_LN2 * __clc_fma(-R_1_BY_64, __CLC_CONVERT_GENTYPE(n), x); + + return __clc_exp_helper(x, -1074.0, 1024.0, r, n); +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_exp2(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_exp2(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp_helper.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp_helper.cl new file mode 100644 index 0000000000..92ff8f7fe4 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp_helper.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include + +#define __DOUBLE_ONLY +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp_helper.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp_helper.inc new file mode 100644 index 0000000000..70ced7e9ea --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_exp_helper.inc @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_exp_helper(__CLC_GENTYPE x, + __CLC_GENTYPE x_min, + __CLC_GENTYPE x_max, + __CLC_GENTYPE r, + __CLC_INTN n) { + + __CLC_INTN j = n & 0x3f; + __CLC_INTN m = n >> 6; + + // 6 term tail of Taylor expansion of e^r + __CLC_GENTYPE z2 = + r * __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 0x1.6c16c16c16c17p-10, + 0x1.1111111111111p-7), + 0x1.5555555555555p-5), + 0x1.5555555555555p-3), + 0x1.0000000000000p-1), + 1.0); + + __CLC_GENTYPE tv0 = USE_TABLE(two_to_jby64_ep_tbl_head, j); + __CLC_GENTYPE tv1 = USE_TABLE(two_to_jby64_ep_tbl_tail, j); + z2 = __clc_fma(tv0 + tv1, z2, tv1) + tv0; + + __CLC_INTN small_value = + (m < -1022) || ((m == -1022) && __CLC_CONVERT_INTN(z2 < 1.0)); + + __CLC_INTN n1 = m >> 2; + __CLC_INTN n2 = m - n1; + __CLC_GENTYPE z3 = + z2 * __CLC_AS_GENTYPE((__CLC_CONVERT_LONGN(n1) + 1023) << 52); + z3 *= __CLC_AS_GENTYPE((__CLC_CONVERT_LONGN(n2) + 1023) << 52); + + z2 = __clc_ldexp(z2, m); + z2 = __CLC_CONVERT_LONGN(small_value) ? z3 : z2; + + z2 = __clc_isnan(x) ? x : z2; + + z2 = x > x_max ? __CLC_AS_GENTYPE((__CLC_ULONGN)PINFBITPATT_DP64) : z2; + z2 = x < x_min ? 0.0 : z2; + + return z2; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_expm1.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_expm1.cl new file mode 100644 index 0000000000..8695b46eb9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_expm1.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_expm1.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_expm1.inc new file mode 100644 index 0000000000..6abee9b3f0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_expm1.inc @@ -0,0 +1,169 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +/* Refer to the exp routine for the underlying algorithm */ +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_expm1(__CLC_GENTYPE x) { + // 128*log2 : 88.722839111673 + const __CLC_GENTYPE X_MAX = 0x1.62e42ep+6f; + // -149*log2 : -103.27892990343184 + const __CLC_GENTYPE X_MIN = -0x1.9d1da0p+6f; + // 64/log2 : 92.332482616893657 + const __CLC_GENTYPE R_64_BY_LOG2 = 0x1.715476p+6f; + // log2/64 lead: 0.0108032227 + const __CLC_GENTYPE R_LOG2_BY_64_LD = 0x1.620000p-7f; + // log2/64 tail: 0.0000272020388 + const __CLC_GENTYPE R_LOG2_BY_64_TL = 0x1.c85fdep-16f; + + __CLC_UINTN xi = __CLC_AS_UINTN(x); + __CLC_INTN n = __CLC_CONVERT_INTN(x * R_64_BY_LOG2); + __CLC_GENTYPE fn = __CLC_CONVERT_GENTYPE(n); + + __CLC_INTN j = n & 0x3f; + __CLC_INTN m = n >> 6; + + __CLC_GENTYPE r = + __clc_mad(fn, -R_LOG2_BY_64_TL, __clc_mad(fn, -R_LOG2_BY_64_LD, x)); + + // Truncated Taylor series + __CLC_GENTYPE z2 = __clc_mad( + r * r, __clc_mad(r, __clc_mad(r, 0x1.555556p-5f, 0x1.555556p-3f), 0.5f), + r); + + __CLC_GENTYPE m2 = __CLC_AS_GENTYPE((m + EXPBIAS_SP32) << EXPSHIFTBITS_SP32); + __CLC_GENTYPE exp_head = USE_TABLE(exp_tbl_ep_head, j); + __CLC_GENTYPE exp_tail = USE_TABLE(exp_tbl_ep_tail, j); + + __CLC_GENTYPE two_to_jby64_h = exp_head * m2; + __CLC_GENTYPE two_to_jby64_t = exp_tail * m2; + __CLC_GENTYPE two_to_jby64 = two_to_jby64_h + two_to_jby64_t; + + z2 = __clc_mad(z2, two_to_jby64, two_to_jby64_t) + (two_to_jby64_h - 1.0f); + // Make subnormals work + z2 = x == 0.f ? x : z2; + z2 = x < X_MIN || m < -24 ? -1.0f : z2; + z2 = x > X_MAX ? __CLC_AS_GENTYPE((__CLC_UINTN)PINFBITPATT_SP32) : z2; + z2 = __clc_isnan(x) ? x : z2; + + return z2; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_expm1(__CLC_GENTYPE x) { + const __CLC_GENTYPE max_expm1_arg = 709.8; + const __CLC_GENTYPE min_expm1_arg = -37.42994775023704; + // 0x3FCC8FF7C79A9A22 = log(1+1/4) + const __CLC_GENTYPE log_OnePlus_OneByFour = 0.22314355131420976; + // 0xBFD269621134DB93 = log(1-1/4) + const __CLC_GENTYPE log_OneMinus_OneByFour = -0.28768207245178096; + const __CLC_GENTYPE sixtyfour_by_lnof2 = + 92.33248261689366; // 0x40571547652b82fe + const __CLC_GENTYPE lnof2_by_64_head = + 0.010830424696223417; // 0x3f862e42fefa0000 + const __CLC_GENTYPE lnof2_by_64_tail = + 2.5728046223276688e-14; // 0x3d1cf79abc9e3b39 + + // First, assume log(1-1/4) < x < log(1+1/4) i.e -0.28768 < x < 0.22314 + __CLC_GENTYPE u = __CLC_AS_GENTYPE(__CLC_AS_ULONGN(x) & 0xffffffffff000000UL); + __CLC_GENTYPE v = x - u; + __CLC_GENTYPE y = u * u * 0.5; + __CLC_GENTYPE z = v * (x + u) * 0.5; + + __CLC_GENTYPE q = __clc_fma( + x, + __clc_fma( + x, + __clc_fma( + x, + __clc_fma( + x, + __clc_fma( + x, + __clc_fma(x, + __clc_fma(x, + __clc_fma(x, 2.4360682937111612e-8, + 2.7582184028154370e-7), + 2.7558212415361945e-6), + 2.4801576918453420e-5), + 1.9841269447671544e-4), + 1.3888888890687830e-3), + 8.3333333334012270e-3), + 4.1666666666665560e-2), + 1.6666666666666632e-1); + q *= x * x * x; + + __CLC_GENTYPE z1g = (u + y) + (q + (v + z)); + __CLC_GENTYPE z1 = x + (y + (q + z)); + z1 = y >= 0x1.0p-7 ? z1g : z1; + + // Now assume outside interval around 0 + __CLC_INTN n = __CLC_CONVERT_INTN(x * sixtyfour_by_lnof2); + __CLC_INTN j = n & 0x3f; + __CLC_INTN m = n >> 6; + + __CLC_GENTYPE f1 = USE_TABLE(two_to_jby64_ep_tbl_head, j); + __CLC_GENTYPE f2 = USE_TABLE(two_to_jby64_ep_tbl_tail, j); + __CLC_GENTYPE f = f1 + f2; + + __CLC_GENTYPE dn = __CLC_CONVERT_GENTYPE(-n); + __CLC_GENTYPE r = + __clc_fma(dn, lnof2_by_64_tail, __clc_fma(dn, lnof2_by_64_head, x)); + + q = __clc_fma(r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 1.38889490863777199667e-03, + 8.33336798434219616221e-03), + 4.16666666662260795726e-02), + 1.66666666665260878863e-01), + 5.00000000000000008883e-01); + q = __clc_fma(r * r, q, r); + + __CLC_GENTYPE twopm = __CLC_AS_GENTYPE(__CLC_CONVERT_LONGN(m + EXPBIAS_DP64) + << EXPSHIFTBITS_DP64); + __CLC_GENTYPE twopmm = __CLC_AS_GENTYPE(__CLC_CONVERT_LONGN(EXPBIAS_DP64 - m) + << EXPSHIFTBITS_DP64); + + // Computations for m > 52, including where result is close to Inf + __CLC_ULONGN uval = __CLC_AS_ULONGN(0x1.0p+1023 * (f1 + (f * q + (f2)))); + __CLC_INTN e = __CLC_CONVERT_INTN(uval >> EXPSHIFTBITS_DP64) + 1; + + __CLC_GENTYPE zme1024 = __CLC_AS_GENTYPE( + (__CLC_CONVERT_ULONGN(e) << EXPSHIFTBITS_DP64) | (uval & MANTBITS_DP64)); + zme1024 = __CLC_CONVERT_LONGN(e == 2047) + ? __CLC_AS_GENTYPE((__CLC_ULONGN)PINFBITPATT_DP64) + : zme1024; + + __CLC_GENTYPE zmg52 = twopm * (f1 + __clc_fma(f, q, f2 - twopmm)); + zmg52 = __CLC_CONVERT_LONGN(m == 1024) ? zme1024 : zmg52; + + // For m < 53 + __CLC_GENTYPE zml53 = + twopm * ((f1 - twopmm) + __clc_fma(f1, q, f2 * (1.0 + q))); + + // For m < -7 + __CLC_GENTYPE zmln7 = __clc_fma(twopm, f1 + __clc_fma(f, q, f2), -1.0); + + z = __CLC_CONVERT_LONGN(m < 53) ? zml53 : zmg52; + z = __CLC_CONVERT_LONGN(m < -7) ? zmln7 : z; + z = x > log_OneMinus_OneByFour && x < log_OnePlus_OneByFour ? z1 : z; + z = x > max_expm1_arg ? __CLC_AS_GENTYPE((__CLC_ULONGN)PINFBITPATT_DP64) : z; + z = x < min_expm1_arg ? -1.0 : z; + + return z; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_expm1(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_expm1(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fabs.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fabs.cl new file mode 100644 index 0000000000..a0f0f3af07 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fabs.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define FUNCTION __clc_fabs +#define __IMPL_FUNCTION(x) __builtin_elementwise_abs +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fdim.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fdim.cl new file mode 100644 index 0000000000..4e76448cde --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fdim.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fdim.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fdim.inc new file mode 100644 index 0000000000..d34ee8c39a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fdim.inc @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fdim(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return __clc_select(__builtin_elementwise_max(x - y, __CLC_FP_LIT(0.0)), + __CLC_GENTYPE_NAN, + __CLC_CONVERT_BIT_INTN(__clc_isnan(x) || __clc_isnan(y))); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_floor.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_floor.cl new file mode 100644 index 0000000000..a14adb9829 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_floor.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define FUNCTION __clc_floor +#define __IMPL_FUNCTION(x) __builtin_elementwise_floor +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fma.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fma.cl new file mode 100644 index 0000000000..e69ef614e7 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fma.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fma.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fma.inc new file mode 100644 index 0000000000..b23b6433d2 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fma.inc @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_fma(__CLC_GENTYPE a, __CLC_GENTYPE b, + __CLC_GENTYPE c) { +#if __CLC_FPSIZE == 32 + if (!__CLC_HAVE_HW_FMA32()) + return __clc_sw_fma(a, b, c); +#endif + return __builtin_elementwise_fma(a, b, c); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fmax.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fmax.cl new file mode 100644 index 0000000000..5ebbf1b28d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fmax.cl @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __FLOAT_ONLY +#define __CLC_MIN_VECSIZE 1 +#define FUNCTION __clc_fmax +#define __IMPL_FUNCTION __builtin_fmaxf +#define __CLC_BODY +#include +#undef __CLC_MIN_VECSIZE +#undef FUNCTION +#undef __IMPL_FUNCTION + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +#define __DOUBLE_ONLY +#define __CLC_MIN_VECSIZE 1 +#define FUNCTION __clc_fmax +#define __IMPL_FUNCTION __builtin_fmax +#define __CLC_BODY +#include +#undef __CLC_MIN_VECSIZE +#undef FUNCTION +#undef __IMPL_FUNCTION + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_DEF _CLC_OVERLOAD half __clc_fmax(half x, half y) { + if (__clc_isnan(x)) + return y; + if (__clc_isnan(y)) + return x; + return (x < y) ? y : x; +} + +#define __HALF_ONLY +#define __CLC_SUPPORTED_VECSIZE_OR_1 2 +#define FUNCTION __clc_fmax +#define __CLC_BODY +#include +#undef FUNCTION + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fmin.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fmin.cl new file mode 100644 index 0000000000..5bddbb8634 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fmin.cl @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __FLOAT_ONLY +#define __CLC_MIN_VECSIZE 1 +#define FUNCTION __clc_fmin +#define __IMPL_FUNCTION __builtin_fminf +#define __CLC_BODY +#include +#undef __CLC_MIN_VECSIZE +#undef FUNCTION +#undef __IMPL_FUNCTION + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +#define __DOUBLE_ONLY +#define __CLC_MIN_VECSIZE 1 +#define FUNCTION __clc_fmin +#define __IMPL_FUNCTION __builtin_fmin +#define __CLC_BODY +#include +#undef __CLC_MIN_VECSIZE +#undef FUNCTION +#undef __IMPL_FUNCTION + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_DEF _CLC_OVERLOAD half __clc_fmin(half x, half y) { + if (__clc_isnan(x)) + return y; + if (__clc_isnan(y)) + return x; + return (y < x) ? y : x; +} + +#define __HALF_ONLY +#define __CLC_SUPPORTED_VECSIZE_OR_1 2 +#define FUNCTION __clc_fmin +#define __CLC_BODY +#include + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fmod.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fmod.cl new file mode 100644 index 0000000000..3162ef60d4 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fmod.cl @@ -0,0 +1,197 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +_CLC_DEF _CLC_OVERLOAD float __clc_fmod(float x, float y) { + int ux = __clc_as_int(x); + int ax = ux & EXSIGNBIT_SP32; + float xa = __clc_as_float(ax); + int sx = ux ^ ax; + int ex = ax >> EXPSHIFTBITS_SP32; + + int uy = __clc_as_int(y); + int ay = uy & EXSIGNBIT_SP32; + float ya = __clc_as_float(ay); + int ey = ay >> EXPSHIFTBITS_SP32; + + float xr = __clc_as_float(0x3f800000 | (ax & 0x007fffff)); + float yr = __clc_as_float(0x3f800000 | (ay & 0x007fffff)); + int c; + int k = ex - ey; + + while (k > 0) { + c = xr >= yr; + xr -= c ? yr : 0.0f; + xr += xr; + --k; + } + + c = xr >= yr; + xr -= c ? yr : 0.0f; + + int lt = ex < ey; + + xr = lt ? xa : xr; + yr = lt ? ya : yr; + + float s = __clc_as_float(ey << EXPSHIFTBITS_SP32); + xr *= lt ? 1.0f : s; + + c = ax == ay; + xr = c ? 0.0f : xr; + + xr = __clc_as_float(sx ^ __clc_as_int(xr)); + + c = ax > PINFBITPATT_SP32 | ay > PINFBITPATT_SP32 | ax == PINFBITPATT_SP32 | + ay == 0; + xr = c ? __clc_as_float(QNANBITPATT_SP32) : xr; + + return xr; +} + +#define __FLOAT_ONLY +#define FUNCTION __clc_fmod +#define __CLC_BODY +#include +#undef FUNCTION + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEF _CLC_OVERLOAD double __clc_fmod(double x, double y) { + ulong ux = __clc_as_ulong(x); + ulong ax = ux & ~SIGNBIT_DP64; + ulong xsgn = ux ^ ax; + double dx = __clc_as_double(ax); + int xexp = __clc_convert_int(ax >> EXPSHIFTBITS_DP64); + int xexp1 = 11 - (int)__clc_clz(ax & MANTBITS_DP64); + xexp1 = xexp < 1 ? xexp1 : xexp; + + ulong uy = __clc_as_ulong(y); + ulong ay = uy & ~SIGNBIT_DP64; + double dy = __clc_as_double(ay); + int yexp = __clc_convert_int(ay >> EXPSHIFTBITS_DP64); + int yexp1 = 11 - (int)__clc_clz(ay & MANTBITS_DP64); + yexp1 = yexp < 1 ? yexp1 : yexp; + + // First assume |x| > |y| + + // Set ntimes to the number of times we need to do a + // partial remainder. If the exponent of x is an exact multiple + // of 53 larger than the exponent of y, and the mantissa of x is + // less than the mantissa of y, ntimes will be one too large + // but it doesn't matter - it just means that we'll go round + // the loop below one extra time. + int ntimes = __clc_max(0, (xexp1 - yexp1) / 53); + double w = __clc_ldexp(dy, ntimes * 53); + w = ntimes == 0 ? dy : w; + double scale = ntimes == 0 ? 1.0 : 0x1.0p-53; + + // Each time round the loop we compute a partial remainder. + // This is done by subtracting a large multiple of w + // from x each time, where w is a scaled up version of y. + // The subtraction must be performed exactly in quad + // precision, though the result at each stage can + // fit exactly in a double precision number. + int i; + double t, v, p, pp; + + for (i = 0; i < ntimes; i++) { + // Compute integral multiplier + t = __clc_trunc(dx / w); + + // Compute w * t in quad precision + p = w * t; + pp = __clc_fma(w, t, -p); + + // Subtract w * t from dx + v = dx - p; + dx = v + (((dx - v) - p) - pp); + + // If t was one too large, dx will be negative. Add back one w. + dx += dx < 0.0 ? w : 0.0; + + // Scale w down by 2^(-53) for the next iteration + w *= scale; + } + + // One more time + // Variable todd says whether the integer t is odd or not + t = __clc_floor(dx / w); + long lt = (long)t; + int todd = lt & 1; + + p = w * t; + pp = __clc_fma(w, t, -p); + v = dx - p; + dx = v + (((dx - v) - p) - pp); + i = dx < 0.0; + todd ^= i; + dx += i ? w : 0.0; + + // At this point, dx lies in the range [0,dy) + double ret = __clc_as_double(xsgn ^ __clc_as_ulong(dx)); + dx = __clc_as_double(ax); + + // Now handle |x| == |y| + int c = dx == dy; + t = __clc_as_double(xsgn); + ret = c ? t : ret; + + // Next, handle |x| < |y| + c = dx < dy; + ret = c ? x : ret; + + // We don't need anything special for |x| == 0 + + // |y| is 0 + c = dy == 0.0; + ret = c ? __clc_as_double(QNANBITPATT_DP64) : ret; + + // y is +-Inf, NaN + c = yexp > BIASEDEMAX_DP64; + t = y == y ? x : y; + ret = c ? t : ret; + + // x is +=Inf, NaN + c = xexp > BIASEDEMAX_DP64; + ret = c ? __clc_as_double(QNANBITPATT_DP64) : ret; + + return ret; +} + +#define __DOUBLE_ONLY +#define FUNCTION __clc_fmod +#define __CLC_BODY +#include +#undef FUNCTION + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// Forward the half version of this builtin onto the float one +#define __HALF_ONLY +#define FUNCTION __clc_fmod +#define __CLC_BODY +#include + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fract.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fract.cl new file mode 100644 index 0000000000..7db43ef878 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fract.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fract.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fract.inc new file mode 100644 index 0000000000..f0466e339b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_fract.inc @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 64 +#define MIN_CONSTANT 0x1.fffffffffffffp-1 +#elif __CLC_FPSIZE == 32 +#define MIN_CONSTANT 0x1.fffffep-1f +#elif __CLC_FPSIZE == 16 +#define MIN_CONSTANT 0x1.ffcp-1h +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fract(__CLC_GENTYPE x, + private __CLC_GENTYPE *iptr) { + *iptr = __clc_floor(x); + __CLC_GENTYPE r = __clc_fmin(x - *iptr, MIN_CONSTANT); + r = __clc_isinf(x) ? __CLC_FP_LIT(0.0) : r; + r = __clc_isnan(x) ? x : r; + return r; +} + +#define FRACT_DEF(addrspace) \ + _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fract( \ + __CLC_GENTYPE x, addrspace __CLC_GENTYPE *iptr) { \ + __CLC_GENTYPE private_iptr; \ + __CLC_GENTYPE ret = __clc_fract(x, &private_iptr); \ + *iptr = private_iptr; \ + return ret; \ + } + +FRACT_DEF(local); +FRACT_DEF(global); +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +FRACT_DEF(generic); +#endif + +#undef MIN_CONSTANT diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_frexp.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_frexp.cl new file mode 100644 index 0000000000..7ff292ebb7 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_frexp.cl @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#define __CLC_ADDRESS_SPACE private +#include +#undef __CLC_ADDRESS_SPACE + +#define __CLC_BODY +#define __CLC_ADDRESS_SPACE global +#include +#undef __CLC_ADDRESS_SPACE + +#define __CLC_BODY +#define __CLC_ADDRESS_SPACE local +#include +#undef __CLC_ADDRESS_SPACE + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +#define __CLC_BODY +#define __CLC_ADDRESS_SPACE generic +#include +#undef __CLC_ADDRESS_SPACE +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_frexp.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_frexp.inc new file mode 100644 index 0000000000..d212b6a1b3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_frexp.inc @@ -0,0 +1,67 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#if __CLC_FPSIZE == 32 +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE +__clc_frexp(__CLC_GENTYPE x, __CLC_ADDRESS_SPACE __CLC_INTN *ep) { + __CLC_INTN i = __CLC_AS_INTN(x); + __CLC_INTN ai = i & EXSIGNBIT_SP32; + + // Scale subnormal by 2^26 without multiplying + __CLC_INTN is_subnormal = ai > 0 && ai < 0x00800000; + __CLC_GENTYPE s = __CLC_AS_GENTYPE(ai | 0x0d800000) - 0x1.0p-100f; + ai = __clc_select(ai, __CLC_AS_INTN(s), is_subnormal); + __CLC_INTN e = (ai >> EXPSHIFTBITS_SP32) - 126 - + __clc_select((__CLC_INTN)0, (__CLC_INTN)26, is_subnormal); + + i = (i & (__CLC_INTN)SIGNBIT_SP32) | (__CLC_INTN)HALFEXPBITS_SP32 | + (ai & (__CLC_INTN)MANTBITS_SP32); + + __CLC_INTN is_inf_nan_or_zero = + ai == (__CLC_INTN)0 || __clc_isinf(x) || __clc_isnan(x); + *ep = __clc_select(e, (__CLC_INTN)0, is_inf_nan_or_zero); + return __clc_select(__CLC_AS_GENTYPE(i), x, is_inf_nan_or_zero); +} +#endif + +#if __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE +__clc_frexp(__CLC_GENTYPE x, __CLC_ADDRESS_SPACE __CLC_INTN *ep) { + return __CLC_CONVERT_HALFN(__clc_frexp(__CLC_CONVERT_FLOATN(x), ep)); +} + +#endif + +#if __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE +__clc_frexp(__CLC_GENTYPE x, __CLC_ADDRESS_SPACE __CLC_INTN *ep) { + __CLC_LONGN i = __CLC_AS_LONGN(x); + __CLC_LONGN ai = i & EXSIGNBIT_DP64; + + // Scale subnormal by 2^54 without multiplying + __CLC_LONGN is_subnormal = ai > 0 && ai < 0x0010000000000000L; + __CLC_GENTYPE s = __CLC_AS_GENTYPE(ai | 0x0370000000000000L) - 0x1.0p-968; + ai = __clc_select(ai, __CLC_AS_LONGN(s), is_subnormal); + __CLC_LONGN e = (ai >> EXPSHIFTBITS_DP64) - (__CLC_LONGN)1022 - + __clc_select((__CLC_LONGN)0, (__CLC_LONGN)54, is_subnormal); + + i = (i & (__CLC_LONGN)SIGNBIT_DP64) | (__CLC_LONGN)HALFEXPBITS_DP64 | + (ai & (__CLC_LONGN)MANTBITS_DP64); + + __CLC_LONGN is_inf_nan_or_zero = + x == __CLC_FP_LIT(0.0) || __clc_isinf(x) || __clc_isnan(x); + *ep = __CLC_CONVERT_INTN(__clc_select(e, 0L, is_inf_nan_or_zero)); + return __clc_select(__CLC_AS_GENTYPE(i), x, is_inf_nan_or_zero); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_cos.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_cos.cl new file mode 100644 index 0000000000..79a7ee7b48 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_cos.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_cos +#define __IMPL_FUNCTION(x) __clc_cos +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_divide.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_divide.cl new file mode 100644 index 0000000000..88676a4ac7 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_divide.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_divide.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_divide.inc new file mode 100644 index 0000000000..27fdb183dd --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_divide.inc @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_half_divide(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return x / y; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_exp.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_exp.cl new file mode 100644 index 0000000000..b53454580e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_exp.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_exp +#define __IMPL_FUNCTION(x) __clc_exp +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_exp10.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_exp10.cl new file mode 100644 index 0000000000..7bd107bf59 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_exp10.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_exp10 +#define __IMPL_FUNCTION(x) __clc_exp10 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_exp2.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_exp2.cl new file mode 100644 index 0000000000..a20d79bfff --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_exp2.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_exp2 +#define __IMPL_FUNCTION(x) __clc_exp2 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_log.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_log.cl new file mode 100644 index 0000000000..26b2c756c9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_log.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_log +#define __IMPL_FUNCTION(x) __clc_log +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_log10.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_log10.cl new file mode 100644 index 0000000000..36f5bf55bb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_log10.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_log10 +#define __IMPL_FUNCTION(x) __clc_log10 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_log2.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_log2.cl new file mode 100644 index 0000000000..cbf1d350dd --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_log2.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_log2 +#define __IMPL_FUNCTION(x) __clc_log2 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_powr.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_powr.cl new file mode 100644 index 0000000000..f7ef2074b8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_powr.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_powr +#define __IMPL_FUNCTION(x) __clc_powr +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_recip.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_recip.cl new file mode 100644 index 0000000000..0ae1e922d4 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_recip.cl @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#define __FLOAT_ONLY +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_recip.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_recip.inc new file mode 100644 index 0000000000..24ededc8e5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_recip.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_half_recip(__CLC_GENTYPE val) { + return 1.0f / val; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_rsqrt.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_rsqrt.cl new file mode 100644 index 0000000000..7e5d9e0526 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_rsqrt.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_rsqrt +#define __IMPL_FUNCTION(x) __clc_rsqrt +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_sin.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_sin.cl new file mode 100644 index 0000000000..ef333dae37 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_sin.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_sin +#define __IMPL_FUNCTION(x) __clc_sin +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_sqrt.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_sqrt.cl new file mode 100644 index 0000000000..293eb81196 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_sqrt.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_sqrt +#define __IMPL_FUNCTION(x) __clc_sqrt +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_tan.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_tan.cl new file mode 100644 index 0000000000..ecc9f8f328 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_half_tan.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_half_tan +#define __IMPL_FUNCTION(x) __clc_tan +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_hypot.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_hypot.cl new file mode 100644 index 0000000000..6990be3083 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_hypot.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_hypot.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_hypot.inc new file mode 100644 index 0000000000..2fa91620b1 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_hypot.inc @@ -0,0 +1,94 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// Returns sqrt(x*x + y*y) with no overflow or underflow unless the result +// warrants it + +#if __CLC_FPSIZE == 32 +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_hypot(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_UINTN aux = ux & EXSIGNBIT_SP32; + __CLC_UINTN uy = __CLC_AS_UINTN(y); + __CLC_UINTN auy = uy & EXSIGNBIT_SP32; + __CLC_INTN c = aux > auy; + ux = c ? aux : auy; + uy = c ? auy : aux; + + __CLC_INTN xexp = __clc_clamp( + __CLC_AS_INTN(ux >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32, -126, 126); + __CLC_GENTYPE fx_exp = + __CLC_AS_GENTYPE((xexp + EXPBIAS_SP32) << EXPSHIFTBITS_SP32); + __CLC_GENTYPE fi_exp = + __CLC_AS_GENTYPE((-xexp + EXPBIAS_SP32) << EXPSHIFTBITS_SP32); + __CLC_GENTYPE fx = __CLC_AS_GENTYPE(ux) * fi_exp; + __CLC_GENTYPE fy = __CLC_AS_GENTYPE(uy) * fi_exp; + + __CLC_GENTYPE retval = __clc_sqrt(__clc_mad(fx, fx, fy * fy)) * fx_exp; + + retval = (ux > PINFBITPATT_SP32 || uy == 0) ? __CLC_AS_GENTYPE(ux) : retval; + retval = (ux == PINFBITPATT_SP32 || uy == PINFBITPATT_SP32) + ? __CLC_AS_GENTYPE((__CLC_UINTN)PINFBITPATT_SP32) + : retval; + return retval; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_hypot(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + __CLC_ULONGN ux = __CLC_AS_ULONGN(x) & ~SIGNBIT_DP64; + __CLC_INTN xexp = __CLC_CONVERT_INTN(ux >> EXPSHIFTBITS_DP64); + x = __CLC_AS_GENTYPE(ux); + + __CLC_ULONGN uy = __CLC_AS_ULONGN(y) & ~SIGNBIT_DP64; + __CLC_INTN yexp = __CLC_CONVERT_INTN(uy >> EXPSHIFTBITS_DP64); + y = __CLC_AS_GENTYPE(uy); + + __CLC_LONGN c = __CLC_CONVERT_LONGN(xexp > EXPBIAS_DP64 + 500 || + yexp > EXPBIAS_DP64 + 500); + __CLC_GENTYPE preadjust = c ? 0x1.0p-600 : 1.0; + __CLC_GENTYPE postadjust = c ? 0x1.0p+600 : 1.0; + + c = __CLC_CONVERT_LONGN(xexp < EXPBIAS_DP64 - 500 || + yexp < EXPBIAS_DP64 - 500); + preadjust = c ? 0x1.0p+600 : preadjust; + postadjust = c ? 0x1.0p-600 : postadjust; + + __CLC_GENTYPE ax = x * preadjust; + __CLC_GENTYPE ay = y * preadjust; + + // The post adjust may overflow, but this can't be avoided in any case + __CLC_GENTYPE r = __clc_sqrt(__clc_fma(ax, ax, ay * ay)) * postadjust; + + // If the difference in exponents between x and y is large + __CLC_GENTYPE s = x + y; + c = __CLC_CONVERT_LONGN(__clc_abs(xexp - yexp) > MANTLENGTH_DP64 + 1); + r = c ? s : r; + + // Check for NaN + c = __clc_isnan(x) || __clc_isnan(y); + r = c ? __CLC_AS_GENTYPE((__CLC_ULONGN)QNANBITPATT_DP64) : r; + + // If either is Inf, we must return Inf + c = x == __CLC_AS_GENTYPE((__CLC_ULONGN)PINFBITPATT_DP64) || + y == __CLC_AS_GENTYPE((__CLC_ULONGN)PINFBITPATT_DP64); + r = c ? __CLC_AS_GENTYPE((__CLC_ULONGN)PINFBITPATT_DP64) : r; + + return r; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_hypot(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return __CLC_CONVERT_GENTYPE( + __clc_hypot(__CLC_CONVERT_FLOATN(x), __CLC_CONVERT_FLOATN(y))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ilogb.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ilogb.cl new file mode 100644 index 0000000000..c33ed9fe9b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ilogb.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ilogb.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ilogb.inc new file mode 100644 index 0000000000..acbc70a9d1 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ilogb.inc @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_INTN __clc_ilogb(__CLC_GENTYPE x) { + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_UINTN ax = ux & EXSIGNBIT_SP32; + __CLC_INTN rs = (__CLC_INTN)LOG_MAGIC_NUM_SP32 - + __CLC_AS_INTN(__clc_clz(ux & MANTBITS_SP32)); + __CLC_INTN r = __CLC_AS_INTN(ax >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + r = ax < 0x00800000U ? rs : r; + r = ax == 0 ? FP_ILOGB0 : r; + + // We could merge those 2 tests and have: + // + // r = ax >= EXPBITS_SP32 ? 0x7fffffff : r + // + // since FP_ILOGBNAN is set to INT_MAX, but it's clearer this way and + // FP_ILOGBNAN can change without requiring changes to __clc_ilogb() code. + r = ax > EXPBITS_SP32 ? FP_ILOGBNAN : r; + r = ax == EXPBITS_SP32 ? 0x7fffffff : r; + return r; +} + +#endif + +#if __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_INTN __clc_ilogb(__CLC_GENTYPE x) { + __CLC_ULONGN ux = __CLC_AS_ULONGN(x); + __CLC_ULONGN ax = ux & ~SIGNBIT_DP64; + __CLC_INTN rs = (__CLC_INTN)LOG_MAGIC_NUM_DP64 - + __CLC_CONVERT_INTN(__clc_clz(ax & MANTBITS_DP64)); + __CLC_INTN r = __CLC_CONVERT_INTN(ax >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64; + r = __CLC_CONVERT_INTN(ax < 0x0010000000000000UL) ? rs : r; + r = __CLC_CONVERT_INTN(ax == 0UL) ? (__CLC_INTN)FP_ILOGB0 : r; + + // We could merge those 2 tests and have: + // + // r = ax >= 0x7ff0000000000000UL ? 0x7fffffff : r + // + // since FP_ILOGBNAN is set to INT_MAX, but it's clearer this way and + // FP_ILOGBNAN can change without requiring changes to __clc_ilogb() code. + r = __CLC_CONVERT_INTN(ax > 0x7ff0000000000000UL) ? FP_ILOGBNAN : r; + r = __CLC_CONVERT_INTN(ax == 0x7ff0000000000000UL) ? 0x7fffffff : r; + return r; +} + +#endif + +#if __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_INTN __clc_ilogb(__CLC_GENTYPE x) { + __CLC_USHORTN ux = __CLC_AS_USHORTN(x); + __CLC_USHORTN ax = ux & (__CLC_USHORTN)EXSIGNBIT_FP16; + __CLC_USHORTN mantx = ux & (__CLC_USHORTN)MANTBITS_FP16; + __CLC_INTN rs = + (__CLC_INTN)LOG_MAGIC_NUM_FP16 - __CLC_CONVERT_INTN(__clc_clz(mantx)); + __CLC_INTN r = + __CLC_CONVERT_INTN(ax >> (__CLC_USHORTN)EXPSHIFTBITS_FP16) - EXPBIAS_FP16; + r = __CLC_CONVERT_INTN(ax < (__CLC_USHORTN)0x0400U) ? rs : r; + r = __CLC_CONVERT_INTN(ax == (__CLC_USHORTN)0) ? (__CLC_INTN)FP_ILOGB0 : r; + + // We could merge those 2 tests and have: + // + // r = ax >= EXPBITS_FP16 ? 0x7fffffff : r + // + // since FP_ILOGBNAN is set to INT_MAX, but it's clearer this way and + // FP_ILOGBNAN can change without requiring changes to __clc_ilogb() code. + r = __CLC_CONVERT_INTN(ax > (__CLC_USHORTN)EXPBITS_FP16) ? FP_ILOGBNAN : r; + r = __CLC_CONVERT_INTN(ax == (__CLC_USHORTN)EXPBITS_FP16) ? 0x7fffffff : r; + return r; +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ldexp.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ldexp.cl new file mode 100644 index 0000000000..cb4185d89c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_ldexp.cl @@ -0,0 +1,138 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define _CLC_DEF_ldexp _CLC_DEF __attribute__((weak)) + +_CLC_DEF_ldexp _CLC_OVERLOAD float __clc_ldexp(float x, int n) { + + if (!__clc_fp32_subnormals_supported()) { + // This treats subnormals as zeros + int i = __clc_as_int(x); + int e = (i >> 23) & 0xff; + int m = i & 0x007fffff; + int s = i & 0x80000000; + int v = __clc_add_sat(e, n); + v = __clc_clamp(v, 0, 0xff); + int mr = (e == 0 || v == 0 || v == 0xff) ? 0 : m; + int c = e == 0xff; + mr = c ? m : mr; + int er = c ? e : v; + er = e ? er : e; + return __clc_as_float(s | (er << 23) | mr); + } + + /* supports denormal values */ + const int multiplier = 24; + float val_f; + uint val_ui; + uint sign; + int exponent; + val_ui = __clc_as_uint(x); + sign = val_ui & 0x80000000; + val_ui = val_ui & 0x7fffffff; /* remove the sign bit */ + int val_x = val_ui; + + exponent = val_ui >> 23; /* get the exponent */ + int dexp = exponent; + + /* denormal support */ + int fbh = + 127 - + (__clc_as_uint((float)(__clc_as_float(val_ui | 0x3f800000) - 1.0f)) >> + 23); + int dexponent = 25 - fbh; + uint dval_ui = (((val_ui << fbh) & 0x007fffff) | (dexponent << 23)); + int ex = dexponent + n - multiplier; + dexponent = ex; + uint val = sign | (ex << 23) | (dval_ui & 0x007fffff); + int ex1 = dexponent + multiplier; + ex1 = -ex1 + 25; + dval_ui = (((dval_ui & 0x007fffff) | 0x800000) >> ex1); + dval_ui = dexponent > 0 ? val : dval_ui; + dval_ui = dexponent > 254 ? 0x7f800000 : dval_ui; /*overflow*/ + dval_ui = dexponent < -multiplier ? 0 : dval_ui; /*underflow*/ + dval_ui = dval_ui | sign; + val_f = __clc_as_float(dval_ui); + + exponent += n; + + val = sign | (exponent << 23) | (val_ui & 0x007fffff); + ex1 = exponent + multiplier; + ex1 = -ex1 + 25; + val_ui = (((val_ui & 0x007fffff) | 0x800000) >> ex1); + val_ui = exponent > 0 ? val : val_ui; + val_ui = exponent > 254 ? 0x7f800000 : val_ui; /*overflow*/ + val_ui = exponent < -multiplier ? 0 : val_ui; /*underflow*/ + val_ui = val_ui | sign; + + val_ui = dexp == 0 ? dval_ui : val_ui; + val_f = __clc_as_float(val_ui); + + val_f = (__clc_isnan(x) || __clc_isinf(x) || val_x == 0) ? x : val_f; + return val_f; +} + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEF_ldexp _CLC_OVERLOAD double __clc_ldexp(double x, int n) { + long l = __clc_as_ulong(x); + int e = (l >> 52) & 0x7ff; + long s = l & 0x8000000000000000; + + ulong ux = __clc_as_ulong(x * 0x1.0p+53); + int de = ((int)(ux >> 52) & 0x7ff) - 53; + int c = e == 0; + e = c ? de : e; + + ux = c ? ux : l; + + int v = e + n; + v = __clc_clamp(v, -0x7ff, 0x7ff); + + ux &= ~EXPBITS_DP64; + + double mr = __clc_as_double(ux | ((ulong)(v + 53) << 52)); + mr = mr * 0x1.0p-53; + + mr = v > 0 ? __clc_as_double(ux | ((ulong)v << 52)) : mr; + + mr = v == 0x7ff ? __clc_as_double(s | PINFBITPATT_DP64) : mr; + mr = v < -53 ? __clc_as_double(s) : mr; + + mr = ((n == 0) | __clc_isinf(x) | (x == 0)) ? x : mr; + return mr; +} + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DEF_ldexp half __clc_ldexp(half x, int n) { + return (half)__clc_ldexp((float)x, n); +} + +#endif + +#define FUNCTION __clc_ldexp +#define __CLC_DEF_SPEC _CLC_DEF_ldexp +#define __CLC_ARG2_TYPE int +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma.cl new file mode 100644 index 0000000000..ca8f589c3b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma.inc new file mode 100644 index 0000000000..9aea86ed73 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma.inc @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_lgamma(__CLC_GENTYPE x) { + __CLC_INTN s; + return __clc_lgamma_r(x, &s); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma_r.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma_r.cl new file mode 100644 index 0000000000..ffacfc17a4 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma_r.cl @@ -0,0 +1,620 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ==================================================== +// Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +// +// Developed at SunPro, a Sun Microsystems, Inc. business. +// Permission to use, copy, modify, and distribute this +// software is freely granted, provided that this notice +// is preserved. +// ==================================================== + +#define pi_f 3.1415927410e+00f /* 0x40490fdb */ + +#define a0_f 7.7215664089e-02f /* 0x3d9e233f */ +#define a1_f 3.2246702909e-01f /* 0x3ea51a66 */ +#define a2_f 6.7352302372e-02f /* 0x3d89f001 */ +#define a3_f 2.0580807701e-02f /* 0x3ca89915 */ +#define a4_f 7.3855509982e-03f /* 0x3bf2027e */ +#define a5_f 2.8905137442e-03f /* 0x3b3d6ec6 */ +#define a6_f 1.1927076848e-03f /* 0x3a9c54a1 */ +#define a7_f 5.1006977446e-04f /* 0x3a05b634 */ +#define a8_f 2.2086278477e-04f /* 0x39679767 */ +#define a9_f 1.0801156895e-04f /* 0x38e28445 */ +#define a10_f 2.5214456400e-05f /* 0x37d383a2 */ +#define a11_f 4.4864096708e-05f /* 0x383c2c75 */ + +#define tc_f 1.4616321325e+00f /* 0x3fbb16c3 */ + +#define tf_f -1.2148628384e-01f /* 0xbdf8cdcd */ +/* tt -(tail of tf) */ +#define tt_f 6.6971006518e-09f /* 0x31e61c52 */ + +#define t0_f 4.8383611441e-01f /* 0x3ef7b95e */ +#define t1_f -1.4758771658e-01f /* 0xbe17213c */ +#define t2_f 6.4624942839e-02f /* 0x3d845a15 */ +#define t3_f -3.2788541168e-02f /* 0xbd064d47 */ +#define t4_f 1.7970675603e-02f /* 0x3c93373d */ +#define t5_f -1.0314224288e-02f /* 0xbc28fcfe */ +#define t6_f 6.1005386524e-03f /* 0x3bc7e707 */ +#define t7_f -3.6845202558e-03f /* 0xbb7177fe */ +#define t8_f 2.2596477065e-03f /* 0x3b141699 */ +#define t9_f -1.4034647029e-03f /* 0xbab7f476 */ +#define t10_f 8.8108185446e-04f /* 0x3a66f867 */ +#define t11_f -5.3859531181e-04f /* 0xba0d3085 */ +#define t12_f 3.1563205994e-04f /* 0x39a57b6b */ +#define t13_f -3.1275415677e-04f /* 0xb9a3f927 */ +#define t14_f 3.3552918467e-04f /* 0x39afe9f7 */ + +#define u0_f -7.7215664089e-02f /* 0xbd9e233f */ +#define u1_f 6.3282704353e-01f /* 0x3f2200f4 */ +#define u2_f 1.4549225569e+00f /* 0x3fba3ae7 */ +#define u3_f 9.7771751881e-01f /* 0x3f7a4bb2 */ +#define u4_f 2.2896373272e-01f /* 0x3e6a7578 */ +#define u5_f 1.3381091878e-02f /* 0x3c5b3c5e */ + +#define v1_f 2.4559779167e+00f /* 0x401d2ebe */ +#define v2_f 2.1284897327e+00f /* 0x4008392d */ +#define v3_f 7.6928514242e-01f /* 0x3f44efdf */ +#define v4_f 1.0422264785e-01f /* 0x3dd572af */ +#define v5_f 3.2170924824e-03f /* 0x3b52d5db */ + +#define s0_f -7.7215664089e-02f /* 0xbd9e233f */ +#define s1_f 2.1498242021e-01f /* 0x3e5c245a */ +#define s2_f 3.2577878237e-01f /* 0x3ea6cc7a */ +#define s3_f 1.4635047317e-01f /* 0x3e15dce6 */ +#define s4_f 2.6642270386e-02f /* 0x3cda40e4 */ +#define s5_f 1.8402845599e-03f /* 0x3af135b4 */ +#define s6_f 3.1947532989e-05f /* 0x3805ff67 */ + +#define r1_f 1.3920053244e+00f /* 0x3fb22d3b */ +#define r2_f 7.2193557024e-01f /* 0x3f38d0c5 */ +#define r3_f 1.7193385959e-01f /* 0x3e300f6e */ +#define r4_f 1.8645919859e-02f /* 0x3c98bf54 */ +#define r5_f 7.7794247773e-04f /* 0x3a4beed6 */ +#define r6_f 7.3266842264e-06f /* 0x36f5d7bd */ + +#define w0_f 4.1893854737e-01f /* 0x3ed67f1d */ +#define w1_f 8.3333335817e-02f /* 0x3daaaaab */ +#define w2_f -2.7777778450e-03f /* 0xbb360b61 */ +#define w3_f 7.9365057172e-04f /* 0x3a500cfd */ +#define w4_f -5.9518753551e-04f /* 0xba1c065c */ +#define w5_f 8.3633989561e-04f /* 0x3a5b3dd2 */ +#define w6_f -1.6309292987e-03f /* 0xbad5c4e8 */ + +_CLC_OVERLOAD _CLC_DEF float __clc_lgamma_r(float x, private int *signp) { + int hx = __clc_as_int(x); + float absx = __clc_fabs(x); + int ix = __clc_as_int(absx); + + if (ix >= 0x7f800000) { + *signp = 1; + return x; + } + + if (absx < 0x1.0p-70f) { + *signp = hx < 0 ? -1 : 1; + return -__clc_log(absx); + } + + float r; + + if (absx == 1.0f | absx == 2.0f) + r = 0.0f; + + else if (absx < 2.0f) { + float y = 2.0f - absx; + int i = 0; + + int c = absx < 0x1.bb4c30p+0f; + float yt = absx - tc_f; + y = c ? yt : y; + i = c ? 1 : i; + + c = absx < 0x1.3b4c40p+0f; + yt = absx - 1.0f; + y = c ? yt : y; + i = c ? 2 : i; + + r = -__clc_log(absx); + yt = 1.0f - absx; + c = absx <= 0x1.ccccccp-1f; + r = c ? r : 0.0f; + y = c ? yt : y; + i = c ? 0 : i; + + c = absx < 0x1.769440p-1f; + yt = absx - (tc_f - 1.0f); + y = c ? yt : y; + i = c ? 1 : i; + + c = absx < 0x1.da6610p-3f; + y = c ? absx : y; + i = c ? 2 : i; + + float z, w, p1, p2, p3, p; + switch (i) { + case 0: + z = y * y; + p1 = __clc_mad( + z, + __clc_mad( + z, + __clc_mad(z, __clc_mad(z, __clc_mad(z, a10_f, a8_f), a6_f), a4_f), + a2_f), + a0_f); + p2 = z * + __clc_mad( + z, + __clc_mad( + z, + __clc_mad(z, __clc_mad(z, __clc_mad(z, a11_f, a9_f), a7_f), + a5_f), + a3_f), + a1_f); + p = __clc_mad(y, p1, p2); + r += __clc_mad(y, -0.5f, p); + break; + case 1: + z = y * y; + w = z * y; + p1 = __clc_mad( + w, __clc_mad(w, __clc_mad(w, __clc_mad(w, t12_f, t9_f), t6_f), t3_f), + t0_f); + p2 = __clc_mad( + w, __clc_mad(w, __clc_mad(w, __clc_mad(w, t13_f, t10_f), t7_f), t4_f), + t1_f); + p3 = __clc_mad( + w, __clc_mad(w, __clc_mad(w, __clc_mad(w, t14_f, t11_f), t8_f), t5_f), + t2_f); + p = __clc_mad(z, p1, -__clc_mad(w, -__clc_mad(y, p3, p2), tt_f)); + r += tf_f + p; + break; + case 2: + p1 = y * + __clc_mad( + y, + __clc_mad(y, + __clc_mad(y, + __clc_mad(y, __clc_mad(y, u5_f, u4_f), u3_f), + u2_f), + u1_f), + u0_f); + p2 = __clc_mad( + y, + __clc_mad( + y, + __clc_mad(y, __clc_mad(y, __clc_mad(y, v5_f, v4_f), v3_f), v2_f), + v1_f), + 1.0f); + r += __clc_mad(y, -0.5f, MATH_DIVIDE(p1, p2)); + break; + } + } else if (absx < 8.0f) { + int i = (int)absx; + float y = absx - (float)i; + float p = + y * + __clc_mad( + y, + __clc_mad( + y, + __clc_mad( + y, + __clc_mad(y, __clc_mad(y, __clc_mad(y, s6_f, s5_f), s4_f), + s3_f), + s2_f), + s1_f), + s0_f); + float q = __clc_mad( + y, + __clc_mad( + y, + __clc_mad(y, + __clc_mad(y, __clc_mad(y, __clc_mad(y, r6_f, r5_f), r4_f), + r3_f), + r2_f), + r1_f), + 1.0f); + r = __clc_mad(y, 0.5f, MATH_DIVIDE(p, q)); + + float y6 = y + 6.0f; + float y5 = y + 5.0f; + float y4 = y + 4.0f; + float y3 = y + 3.0f; + float y2 = y + 2.0f; + + float z = 1.0f; + z *= i > 6 ? y6 : 1.0f; + z *= i > 5 ? y5 : 1.0f; + z *= i > 4 ? y4 : 1.0f; + z *= i > 3 ? y3 : 1.0f; + z *= i > 2 ? y2 : 1.0f; + + r += __clc_log(z); + } else if (absx < 0x1.0p+58f) { + float z = 1.0f / absx; + float y = z * z; + float w = __clc_mad( + z, + __clc_mad( + y, + __clc_mad(y, + __clc_mad(y, __clc_mad(y, __clc_mad(y, w6_f, w5_f), w4_f), + w3_f), + w2_f), + w1_f), + w0_f); + r = __clc_mad(absx - 0.5f, __clc_log(absx) - 1.0f, w); + } else + // 2**58 <= x <= Inf + r = absx * (__clc_log(absx) - 1.0f); + + int s = 1; + + if (x < 0.0f) { + float t = __clc_sinpi(x); + r = __clc_log(pi_f / __clc_fabs(t * x)) - r; + r = t == 0.0f ? INFINITY : r; + s = t < 0.0f ? -1 : s; + } + + *signp = s; + return r; +} + +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, __clc_lgamma_r, float, + private, int) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +// ==================================================== +// Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +// +// Developed at SunPro, a Sun Microsystems, Inc. business. +// Permission to use, copy, modify, and distribute this +// software is freely granted, provided that this notice +// is preserved. +// ==================================================== + +// lgamma_r(x, i) +// Reentrant version of the logarithm of the Gamma function +// with user provide pointer for the sign of Gamma(x). +// +// Method: +// 1. Argument Reduction for 0 < x <= 8 +// Since gamma(1+s)=s*gamma(s), for x in [0,8], we may +// reduce x to a number in [1.5,2.5] by +// lgamma(1+s) = log(s) + lgamma(s) +// for example, +// lgamma(7.3) = log(6.3) + lgamma(6.3) +// = log(6.3*5.3) + lgamma(5.3) +// = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3) +// 2. Polynomial approximation of lgamma around its +// minimun ymin=1.461632144968362245 to maintain monotonicity. +// On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use +// Let z = x-ymin; +// lgamma(x) = -1.214862905358496078218 + z^2*poly(z) +// where +// poly(z) is a 14 degree polynomial. +// 2. Rational approximation in the primary interval [2,3] +// We use the following approximation: +// s = x-2.0; +// lgamma(x) = 0.5*s + s*P(s)/Q(s) +// with accuracy +// |P/Q - (lgamma(x)-0.5s)| < 2**-61.71 +// Our algorithms are based on the following observation +// +// zeta(2)-1 2 zeta(3)-1 3 +// lgamma(2+s) = s*(1-Euler) + --------- * s - --------- * s + ... +// 2 3 +// +// where Euler = 0.5771... is the Euler constant, which is very +// close to 0.5. +// +// 3. For x>=8, we have +// lgamma(x)~(x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+.... +// (better formula: +// lgamma(x)~(x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...) +// Let z = 1/x, then we approximation +// f(z) = lgamma(x) - (x-0.5)(log(x)-1) +// by +// 3 5 11 +// w = w0 + w1*z + w2*z + w3*z + ... + w6*z +// where +// |w - f(z)| < 2**-58.74 +// +// 4. For negative x, since (G is gamma function) +// -x*G(-x)*G(x) = pi/sin(pi*x), +// we have +// G(x) = pi/(sin(pi*x)*(-x)*G(-x)) +// since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0 +// Hence, for x<0, signgam = sign(sin(pi*x)) and +// lgamma(x) = log(|Gamma(x)|) +// = log(pi/(|x*sin(pi*x)|)) - lgamma(-x); +// Note: one should avoid compute pi*(-x) directly in the +// computation of sin(pi*(-x)). +// +// 5. Special Cases +// lgamma(2+s) ~ s*(1-Euler) for tiny s +// lgamma(1)=lgamma(2)=0 +// lgamma(x) ~ -log(x) for tiny x +// lgamma(0) = lgamma(inf) = inf +// lgamma(-integer) = +-inf +// +#define pi 3.14159265358979311600e+00 /* 0x400921FB, 0x54442D18 */ + +#define a0 7.72156649015328655494e-02 /* 0x3FB3C467, 0xE37DB0C8 */ +#define a1 3.22467033424113591611e-01 /* 0x3FD4A34C, 0xC4A60FAD */ +#define a2 6.73523010531292681824e-02 /* 0x3FB13E00, 0x1A5562A7 */ +#define a3 2.05808084325167332806e-02 /* 0x3F951322, 0xAC92547B */ +#define a4 7.38555086081402883957e-03 /* 0x3F7E404F, 0xB68FEFE8 */ +#define a5 2.89051383673415629091e-03 /* 0x3F67ADD8, 0xCCB7926B */ +#define a6 1.19270763183362067845e-03 /* 0x3F538A94, 0x116F3F5D */ +#define a7 5.10069792153511336608e-04 /* 0x3F40B6C6, 0x89B99C00 */ +#define a8 2.20862790713908385557e-04 /* 0x3F2CF2EC, 0xED10E54D */ +#define a9 1.08011567247583939954e-04 /* 0x3F1C5088, 0x987DFB07 */ +#define a10 2.52144565451257326939e-05 /* 0x3EFA7074, 0x428CFA52 */ +#define a11 4.48640949618915160150e-05 /* 0x3F07858E, 0x90A45837 */ + +#define tc 1.46163214496836224576e+00 /* 0x3FF762D8, 0x6356BE3F */ +#define tf -1.21486290535849611461e-01 /* 0xBFBF19B9, 0xBCC38A42 */ +#define tt -3.63867699703950536541e-18 /* 0xBC50C7CA, 0xA48A971F */ + +#define t0 4.83836122723810047042e-01 /* 0x3FDEF72B, 0xC8EE38A2 */ +#define t1 -1.47587722994593911752e-01 /* 0xBFC2E427, 0x8DC6C509 */ +#define t2 6.46249402391333854778e-02 /* 0x3FB08B42, 0x94D5419B */ +#define t3 -3.27885410759859649565e-02 /* 0xBFA0C9A8, 0xDF35B713 */ +#define t4 1.79706750811820387126e-02 /* 0x3F9266E7, 0x970AF9EC */ +#define t5 -1.03142241298341437450e-02 /* 0xBF851F9F, 0xBA91EC6A */ +#define t6 6.10053870246291332635e-03 /* 0x3F78FCE0, 0xE370E344 */ +#define t7 -3.68452016781138256760e-03 /* 0xBF6E2EFF, 0xB3E914D7 */ +#define t8 2.25964780900612472250e-03 /* 0x3F6282D3, 0x2E15C915 */ +#define t9 -1.40346469989232843813e-03 /* 0xBF56FE8E, 0xBF2D1AF1 */ +#define t10 8.81081882437654011382e-04 /* 0x3F4CDF0C, 0xEF61A8E9 */ +#define t11 -5.38595305356740546715e-04 /* 0xBF41A610, 0x9C73E0EC */ +#define t12 3.15632070903625950361e-04 /* 0x3F34AF6D, 0x6C0EBBF7 */ +#define t13 -3.12754168375120860518e-04 /* 0xBF347F24, 0xECC38C38 */ +#define t14 3.35529192635519073543e-04 /* 0x3F35FD3E, 0xE8C2D3F4 */ + +#define u0 -7.72156649015328655494e-02 /* 0xBFB3C467, 0xE37DB0C8 */ +#define u1 6.32827064025093366517e-01 /* 0x3FE4401E, 0x8B005DFF */ +#define u2 1.45492250137234768737e+00 /* 0x3FF7475C, 0xD119BD6F */ +#define u3 9.77717527963372745603e-01 /* 0x3FEF4976, 0x44EA8450 */ +#define u4 2.28963728064692451092e-01 /* 0x3FCD4EAE, 0xF6010924 */ +#define u5 1.33810918536787660377e-02 /* 0x3F8B678B, 0xBF2BAB09 */ + +#define v1 2.45597793713041134822e+00 /* 0x4003A5D7, 0xC2BD619C */ +#define v2 2.12848976379893395361e+00 /* 0x40010725, 0xA42B18F5 */ +#define v3 7.69285150456672783825e-01 /* 0x3FE89DFB, 0xE45050AF */ +#define v4 1.04222645593369134254e-01 /* 0x3FBAAE55, 0xD6537C88 */ +#define v5 3.21709242282423911810e-03 /* 0x3F6A5ABB, 0x57D0CF61 */ + +#define s0_d -7.72156649015328655494e-02 /* 0xBFB3C467, 0xE37DB0C8 */ +#define s1_d 2.14982415960608852501e-01 /* 0x3FCB848B, 0x36E20878 */ +#define s2_d 3.25778796408930981787e-01 /* 0x3FD4D98F, 0x4F139F59 */ +#define s3_d 1.46350472652464452805e-01 /* 0x3FC2BB9C, 0xBEE5F2F7 */ +#define s4_d 2.66422703033638609560e-02 /* 0x3F9B481C, 0x7E939961 */ +#define s5_d 1.84028451407337715652e-03 /* 0x3F5E26B6, 0x7368F239 */ +#define s6_d 3.19475326584100867617e-05 /* 0x3F00BFEC, 0xDD17E945 */ + +#define r1 1.39200533467621045958e+00 /* 0x3FF645A7, 0x62C4AB74 */ +#define r2 7.21935547567138069525e-01 /* 0x3FE71A18, 0x93D3DCDC */ +#define r3 1.71933865632803078993e-01 /* 0x3FC601ED, 0xCCFBDF27 */ +#define r4 1.86459191715652901344e-02 /* 0x3F9317EA, 0x742ED475 */ +#define r5 7.77942496381893596434e-04 /* 0x3F497DDA, 0xCA41A95B */ +#define r6 7.32668430744625636189e-06 /* 0x3EDEBAF7, 0xA5B38140 */ + +#define w0 4.18938533204672725052e-01 /* 0x3FDACFE3, 0x90C97D69 */ +#define w1 8.33333333333329678849e-02 /* 0x3FB55555, 0x5555553B */ +#define w2 -2.77777777728775536470e-03 /* 0xBF66C16C, 0x16B02E5C */ +#define w3 7.93650558643019558500e-04 /* 0x3F4A019F, 0x98CF38B6 */ +#define w4 -5.95187557450339963135e-04 /* 0xBF4380CB, 0x8C0FE741 */ +#define w5 8.36339918996282139126e-04 /* 0x3F4B67BA, 0x4CDAD5D1 */ +#define w6 -1.63092934096575273989e-03 /* 0xBF5AB89D, 0x0B9E43E4 */ + +_CLC_OVERLOAD _CLC_DEF double __clc_lgamma_r(double x, private int *ip) { + ulong ux = __clc_as_ulong(x); + double absx = __clc_fabs(x); + ulong ax = __clc_as_ulong(absx); + + if (ax >= 0x7ff0000000000000UL) { + // +-Inf, NaN + *ip = 1; + return absx; + } + + if (absx < 0x1.0p-70) { + *ip = ax == ux ? 1 : -1; + return -__clc_log(absx); + } + + // Handle rest of range + double r; + + if (absx < 2.0) { + int i = 0; + double y = 2.0 - absx; + + int c = absx < 0x1.bb4c3p+0; + double t = absx - tc; + i = c ? 1 : i; + y = c ? t : y; + + c = absx < 0x1.3b4c4p+0; + t = absx - 1.0; + i = c ? 2 : i; + y = c ? t : y; + + c = absx <= 0x1.cccccp-1; + t = -__clc_log(absx); + r = c ? t : 0.0; + t = 1.0 - absx; + i = c ? 0 : i; + y = c ? t : y; + + c = absx < 0x1.76944p-1; + t = absx - (tc - 1.0); + i = c ? 1 : i; + y = c ? t : y; + + c = absx < 0x1.da661p-3; + i = c ? 2 : i; + y = c ? absx : y; + + double p, q; + + switch (i) { + case 0: + p = __clc_fma( + y, __clc_fma(y, __clc_fma(y, __clc_fma(y, a11, a10), a9), a8), a7); + p = __clc_fma(y, __clc_fma(y, __clc_fma(y, __clc_fma(y, p, a6), a5), a4), + a3); + p = __clc_fma(y, __clc_fma(y, __clc_fma(y, p, a2), a1), a0); + r = __clc_fma(y, p - 0.5, r); + break; + case 1: + p = __clc_fma( + y, __clc_fma(y, __clc_fma(y, __clc_fma(y, t14, t13), t12), t11), t10); + p = __clc_fma( + y, + __clc_fma(y, __clc_fma(y, __clc_fma(y, __clc_fma(y, p, t9), t8), t7), + t6), + t5); + p = __clc_fma( + y, + __clc_fma(y, __clc_fma(y, __clc_fma(y, __clc_fma(y, p, t4), t3), t2), + t1), + t0); + p = __clc_fma(y * y, p, -tt); + r += (tf + p); + break; + case 2: + p = y * + __clc_fma( + y, + __clc_fma( + y, __clc_fma(y, __clc_fma(y, __clc_fma(y, u5, u4), u3), u2), + u1), + u0); + q = __clc_fma( + y, + __clc_fma(y, __clc_fma(y, __clc_fma(y, __clc_fma(y, v5, v4), v3), v2), + v1), + 1.0); + r += __clc_fma(-0.5, y, p / q); + } + } else if (absx < 8.0) { + int i = absx; + double y = absx - (double)i; + double p = + y * + __clc_fma( + y, + __clc_fma( + y, + __clc_fma( + y, + __clc_fma(y, __clc_fma(y, __clc_fma(y, s6_d, s5_d), s4_d), + s3_d), + s2_d), + s1_d), + s0_d); + double q = __clc_fma( + y, + __clc_fma( + y, + __clc_fma(y, + __clc_fma(y, __clc_fma(y, __clc_fma(y, r6, r5), r4), r3), + r2), + r1), + 1.0); + r = __clc_fma(0.5, y, p / q); + double z = 1.0; + // lgamma(1+s) = log(s) + lgamma(s) + double y6 = y + 6.0; + double y5 = y + 5.0; + double y4 = y + 4.0; + double y3 = y + 3.0; + double y2 = y + 2.0; + z *= i > 6 ? y6 : 1.0; + z *= i > 5 ? y5 : 1.0; + z *= i > 4 ? y4 : 1.0; + z *= i > 3 ? y3 : 1.0; + z *= i > 2 ? y2 : 1.0; + r += __clc_log(z); + } else { + double z = 1.0 / absx; + double z2 = z * z; + double w = __clc_fma( + z, + __clc_fma( + z2, + __clc_fma( + z2, __clc_fma(z2, __clc_fma(z2, __clc_fma(z2, w6, w5), w4), w3), + w2), + w1), + w0); + r = (absx - 0.5) * (__clc_log(absx) - 1.0) + w; + } + + if (x < 0.0) { + double t = __clc_sinpi(x); + r = __clc_log(pi / __clc_fabs(t * x)) - r; + r = t == 0.0 ? INFINITY : r; + *ip = t < 0.0 ? -1 : 1; + } else + *ip = 1; + + return r; +} + +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, __clc_lgamma_r, double, + private, int) +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DEF half __clc_lgamma_r(half x, private int *iptr) { + return (half)__clc_lgamma_r((float)x, iptr); +} + +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __clc_lgamma_r, half, + private, int); + +#endif + +#define __CLC_ADDRSPACE global +#define __CLC_BODY +#include +#undef __CLC_ADDRSPACE + +#define __CLC_ADDRSPACE local +#define __CLC_BODY +#include +#undef __CLC_ADDRSPACE + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +#define __CLC_ADDRSPACE generic +#define __CLC_BODY +#include +#undef __CLC_ADDRSPACE +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma_r.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma_r.inc new file mode 100644 index 0000000000..87891efd44 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_lgamma_r.inc @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE +__clc_lgamma_r(__CLC_GENTYPE x, __CLC_ADDRSPACE __CLC_INTN *iptr) { + __CLC_INTN private_iptr; + __CLC_GENTYPE ret = __clc_lgamma_r(x, &private_iptr); + *iptr = private_iptr; + return ret; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log.cl new file mode 100644 index 0000000000..cf5628f206 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log.cl @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include + +/* + *log(x) = log2(x) * (1/log2(e)) + */ + +_CLC_OVERLOAD _CLC_DEF float __clc_log(float x) { + return __clc_log2(x) * (1.0f / M_LOG2E_F); +} + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF double __clc_log(double x) { + return __clc_log2(x) * (1.0 / M_LOG2E); +} + +#endif // cl_khr_fp64 + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DEF half __clc_log(half x) { + return (half)__clc_log2((float)x) * (1.0h / M_LOG2E_H); +} + +#endif // cl_khr_fp16 + +#define FUNCTION __clc_log +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log10.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log10.cl new file mode 100644 index 0000000000..f5f0e8cc70 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log10.cl @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#endif // cl_khr_fp64 + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#endif // cl_khr_fp16 + +#define COMPILING_LOG10 +#include "clc_log_base.h" +#undef COMPILING_LOG10 + +#define FUNCTION __clc_log10 +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log1p.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log1p.cl new file mode 100644 index 0000000000..71ccba79a7 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log1p.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log1p.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log1p.inc new file mode 100644 index 0000000000..8c7dcfc48c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log1p.inc @@ -0,0 +1,170 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Computes natural log(1+x). Algorithm based on: +// Ping-Tak Peter Tang +// "Table-driven implementation of the logarithm function in IEEE floating-point +// arithmetic" ACM Transactions on Mathematical Software (TOMS) Volume 16, Issue +// 4 (December 1990) +// +// Note that we use a lookup table of size 64 rather than 128, and compensate by +// having extra terms in the minimax polynomial for the kernel approximation. +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_log1p(__CLC_GENTYPE x) { + __CLC_GENTYPE w = x; + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_UINTN ax = ux & EXSIGNBIT_SP32; + + // |x| < 2^-4 + __CLC_GENTYPE u2 = MATH_DIVIDE(x, 2.0f + x); + __CLC_GENTYPE u = u2 + u2; + __CLC_GENTYPE v = u * u; + // 2/(5 * 2^5), 2/(3 * 2^3) + __CLC_GENTYPE zsmall = + __clc_mad(-u2, x, __clc_mad(v, 0x1.99999ap-7f, 0x1.555556p-4f) * v * u) + + x; + + // |x| >= 2^-4 + ux = __CLC_AS_UINTN(x + 1.0f); + + __CLC_INTN m = __CLC_AS_INTN((ux >> EXPSHIFTBITS_SP32) & 0xff) - EXPBIAS_SP32; + __CLC_GENTYPE mf = __CLC_CONVERT_GENTYPE(m); + __CLC_UINTN indx = (ux & 0x007f0000) + ((ux & 0x00008000) << 1); + __CLC_GENTYPE F = __CLC_AS_GENTYPE(indx | 0x3f000000); + + // x > 2^24 + __CLC_GENTYPE fg24 = F - __CLC_AS_GENTYPE(0x3f000000 | (ux & MANTBITS_SP32)); + + // x <= 2^24 + __CLC_UINTN xhi = ux & 0xffff8000; + __CLC_GENTYPE xh = __CLC_AS_GENTYPE(xhi); + __CLC_GENTYPE xt = (1.0f - xh) + w; + __CLC_UINTN xnm = ((~(xhi & 0x7f800000)) - 0x00800000) & 0x7f800000; + xt = xt * __CLC_AS_GENTYPE(xnm) * 0.5f; + __CLC_GENTYPE fl24 = + F - __CLC_AS_GENTYPE(0x3f000000 | (xhi & MANTBITS_SP32)) - xt; + + __CLC_GENTYPE f = mf > 24.0f ? fg24 : fl24; + + indx = indx >> 16; + __CLC_GENTYPE r = f * USE_TABLE(log_inv_tbl, __CLC_CONVERT_INTN(indx)); + + // 1/3, 1/2 + __CLC_GENTYPE poly = + __clc_mad(__clc_mad(r, 0x1.555556p-2f, 0x1.0p-1f), r * r, r); + + const __CLC_GENTYPE LOG2_HEAD = 0x1.62e000p-1f; // 0.693115234 + const __CLC_GENTYPE LOG2_TAIL = 0x1.0bfbe8p-15f; // 0.0000319461833 + + __CLC_GENTYPE tv0 = USE_TABLE(loge_tbl_lo, __CLC_AS_INTN(indx)); + __CLC_GENTYPE tv1 = USE_TABLE(loge_tbl_hi, __CLC_AS_INTN(indx)); + __CLC_GENTYPE z1 = __clc_mad(mf, LOG2_HEAD, tv0); + __CLC_GENTYPE z2 = __clc_mad(mf, LOG2_TAIL, -poly) + tv1; + __CLC_GENTYPE z = z1 + z2; + + z = ax < 0x3d800000U ? zsmall : z; + + // Edge cases + z = ax >= PINFBITPATT_SP32 ? w : z; + z = w < -1.0f ? __CLC_GENTYPE_NAN : z; + z = w == -1.0f ? __CLC_AS_GENTYPE((__CLC_UINTN)NINFBITPATT_SP32) : z; + // Fix subnormals + z = ax < 0x33800000 ? x : z; + + return z; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_log1p(__CLC_GENTYPE x) { + // Process Inside the threshold now + __CLC_ULONGN ux = __CLC_AS_ULONGN((__CLC_GENTYPE)1.0 + x); + __CLC_INTN xexp = + __CLC_CONVERT_INTN((ux >> EXPSHIFTBITS_DP64) & 0x7ff) - EXPBIAS_DP64; + __CLC_GENTYPE f = + __CLC_AS_GENTYPE((__CLC_ULONGN)ONEEXPBITS_DP64 | (ux & MANTBITS_DP64)); + + __CLC_INTN j = __CLC_CONVERT_INTN(ux >> 45); + j = ((0x80 | (j & 0x7e)) >> 1) + (j & 0x1); + __CLC_GENTYPE f1 = __CLC_CONVERT_GENTYPE(j) * 0x1.0p-6; + j -= 64; + + __CLC_GENTYPE f2temp = f - f1; + __CLC_GENTYPE m2 = + __CLC_AS_GENTYPE(__CLC_CONVERT_ULONGN(0x3ff - xexp) << EXPSHIFTBITS_DP64); + __CLC_GENTYPE f2l = __clc_fma(m2, x, m2 - f1); + __CLC_GENTYPE f2g = __clc_fma(m2, x, -f1) + m2; + __CLC_GENTYPE f2 = + __CLC_CONVERT_LONGN(xexp <= MANTLENGTH_DP64 - 1) ? f2l : f2g; + f2 = __CLC_CONVERT_LONGN(xexp <= -2 || (xexp >= MANTLENGTH_DP64 + 8)) ? f2temp + : f2; + + __CLC_GENTYPE z1 = USE_TABLE(ln_tbl_lo, j); + __CLC_GENTYPE q = USE_TABLE(ln_tbl_hi, j); + + __CLC_GENTYPE u = MATH_DIVIDE(f2, __clc_fma(0.5, f2, f1)); + __CLC_GENTYPE v = u * u; + + __CLC_GENTYPE poly = v * __clc_fma(v, + __clc_fma(v, 2.23219810758559851206e-03, + 1.24999999978138668903e-02), + 8.33333333333333593622e-02); + + // log2_lead and log2_tail sum to an extra-precise version of log(2) + // 0x3fe62e42e0000000 + const __CLC_GENTYPE log2_lead = 6.93147122859954833984e-01; + // 0x3e6efa39ef35793c + const __CLC_GENTYPE log2_tail = 5.76999904754328540596e-08; + + __CLC_GENTYPE z2 = q + __clc_fma(u, poly, u); + __CLC_GENTYPE dxexp = __CLC_CONVERT_GENTYPE(xexp); + __CLC_GENTYPE r1 = __clc_fma(dxexp, log2_lead, z1); + __CLC_GENTYPE r2 = __clc_fma(dxexp, log2_tail, z2); + __CLC_GENTYPE result1 = r1 + r2; + + // Process Outside the threshold now + __CLC_GENTYPE r = x; + u = r / (2.0 + r); + __CLC_GENTYPE correction = r * u; + u = u + u; + v = u * u; + r1 = r; + + poly = __clc_fma(v, + __clc_fma(v, + __clc_fma(v, 4.34887777707614552256e-04, + 2.23213998791944806202e-03), + 1.25000000037717509602e-02), + 8.33333333333317923934e-02); + + r2 = __clc_fma(u * v, poly, -correction); + + // The values exp(-1/16)-1 and exp(1/16)-1 + const __CLC_GENTYPE log1p_thresh1 = -0x1.f0540438fd5c3p-5; + const __CLC_GENTYPE log1p_thresh2 = 0x1.082b577d34ed8p-4; + __CLC_GENTYPE result2 = r1 + r2; + result2 = x < log1p_thresh1 || x > log1p_thresh2 ? result1 : result2; + + result2 = __clc_isinf(x) ? x : result2; + result2 = x < -1.0 ? __CLC_GENTYPE_NAN : result2; + result2 = + x == -1.0 ? __CLC_AS_GENTYPE((__CLC_ULONGN)NINFBITPATT_DP64) : result2; + return result2; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_log1p(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_log1p(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log2.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log2.cl new file mode 100644 index 0000000000..335488af2f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log2.cl @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#endif // cl_khr_fp64 + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#endif // cl_khr_fp16 + +#define COMPILING_LOG2 +#include "clc_log_base.h" +#undef COMPILING_LOG2 + +#define FUNCTION __clc_log2 +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log_base.h b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log_base.h new file mode 100644 index 0000000000..9418535db8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_log_base.h @@ -0,0 +1,324 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include + +/* + Algorithm: + + Based on: + Ping-Tak Peter Tang + "Table-driven implementation of the logarithm function in IEEE + floating-point arithmetic" + ACM Transactions on Mathematical Software (TOMS) + Volume 16, Issue 4 (December 1990) + + + x very close to 1.0 is handled differently, for x everywhere else + a brief explanation is given below + + x = (2^m)*A + x = (2^m)*(G+g) with (1 <= G < 2) and (g <= 2^(-8)) + x = (2^m)*2*(G/2+g/2) + x = (2^m)*2*(F+f) with (0.5 <= F < 1) and (f <= 2^(-9)) + + Y = (2^(-1))*(2^(-m))*(2^m)*A + Now, range of Y is: 0.5 <= Y < 1 + + F = 0x80 + (first 7 mantissa bits) + (8th mantissa bit) + Now, range of F is: 128 <= F <= 256 + F = F / 256 + Now, range of F is: 0.5 <= F <= 1 + + f = -(Y-F), with (f <= 2^(-9)) + + log(x) = m*log(2) + log(2) + log(F-f) + log(x) = m*log(2) + log(2) + log(F) + log(1-(f/F)) + log(x) = m*log(2) + log(2*F) + log(1-r) + + r = (f/F), with (r <= 2^(-8)) + r = f*(1/F) with (1/F) precomputed to avoid division + + log(x) = m*log(2) + log(G) - poly + + log(G) is precomputed + poly = (r + (r^2)/2 + (r^3)/3 + (r^4)/4) + (r^5)/5)) + + log(2) and log(G) need to be maintained in extra precision + to avoid losing precision in the calculations + + + For x close to 1.0, we employ the following technique to + ensure faster convergence. + + log(x) = log((1+s)/(1-s)) = 2*s + (2/3)*s^3 + (2/5)*s^5 + (2/7)*s^7 + x = ((1+s)/(1-s)) + x = 1 + r + s = r/(2+r) + +*/ + +_CLC_OVERLOAD _CLC_DEF float +#if defined(COMPILING_LOG2) +__clc_log2(float x) +#elif defined(COMPILING_LOG10) +__clc_log10(float x) +#else +__clc_log(float x) +#endif +{ + +#if defined(COMPILING_LOG2) + const float LOG2E = 0x1.715476p+0f; // 1.4426950408889634 + const float LOG2E_HEAD = 0x1.700000p+0f; // 1.4375 + const float LOG2E_TAIL = 0x1.547652p-8f; // 0.00519504072 +#elif defined(COMPILING_LOG10) + const float LOG10E = 0x1.bcb7b2p-2f; // 0.43429448190325182 + const float LOG10E_HEAD = 0x1.bc0000p-2f; // 0.43359375 + const float LOG10E_TAIL = 0x1.6f62a4p-11f; // 0.0007007319 + const float LOG10_2_HEAD = 0x1.340000p-2f; // 0.30078125 + const float LOG10_2_TAIL = 0x1.04d426p-12f; // 0.000248745637 +#else + const float LOG2_HEAD = 0x1.62e000p-1f; // 0.693115234 + const float LOG2_TAIL = 0x1.0bfbe8p-15f; // 0.0000319461833 +#endif + + uint xi = __clc_as_uint(x); + uint ax = xi & EXSIGNBIT_SP32; + + // Calculations for |x-1| < 2^-4 + float r = x - 1.0f; + int near1 = __clc_fabs(r) < 0x1.0p-4f; + float u2 = MATH_DIVIDE(r, 2.0f + r); + float corr = u2 * r; + float u = u2 + u2; + float v = u * u; + float znear1, z1, z2; + + // 2/(5 * 2^5), 2/(3 * 2^3) + z2 = __clc_mad(u, __clc_mad(v, 0x1.99999ap-7f, 0x1.555556p-4f) * v, -corr); + +#if defined(COMPILING_LOG2) + z1 = __clc_as_float(__clc_as_int(r) & 0xffff0000); + z2 = z2 + (r - z1); + znear1 = __clc_mad( + z1, LOG2E_HEAD, + __clc_mad(z2, LOG2E_HEAD, __clc_mad(z1, LOG2E_TAIL, z2 * LOG2E_TAIL))); +#elif defined(COMPILING_LOG10) + z1 = __clc_as_float(__clc_as_int(r) & 0xffff0000); + z2 = z2 + (r - z1); + znear1 = __clc_mad( + z1, LOG10E_HEAD, + __clc_mad(z2, LOG10E_HEAD, __clc_mad(z1, LOG10E_TAIL, z2 * LOG10E_TAIL))); +#else + znear1 = z2 + r; +#endif + + // Calculations for x not near 1 + int m = (int)(xi >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + + // Normalize subnormal + uint xis = __clc_as_uint(__clc_as_float(xi | 0x3f800000) - 1.0f); + int ms = (int)(xis >> EXPSHIFTBITS_SP32) - 253; + int c = m == -127; + m = c ? ms : m; + uint xin = c ? xis : xi; + + float mf = (float)m; + uint indx = (xin & 0x007f0000) + ((xin & 0x00008000) << 1); + + // F - Y + float f = __clc_as_float(0x3f000000 | indx) - + __clc_as_float(0x3f000000 | (xin & MANTBITS_SP32)); + + indx = indx >> 16; + r = f * USE_TABLE(log_inv_tbl, indx); + + // 1/3, 1/2 + float poly = __clc_mad(__clc_mad(r, 0x1.555556p-2f, 0.5f), r * r, r); + +#if defined(COMPILING_LOG2) + float2 tv = USE_TABLE(log2_tbl, indx); + z1 = tv.s0 + mf; + z2 = __clc_mad(poly, -LOG2E, tv.s1); +#elif defined(COMPILING_LOG10) + float2 tv = USE_TABLE(log10_tbl, indx); + z1 = __clc_mad(mf, LOG10_2_HEAD, tv.s0); + z2 = __clc_mad(poly, -LOG10E, mf * LOG10_2_TAIL) + tv.s1; +#else + float2 tv = USE_TABLE(log_tbl, indx); + z1 = __clc_mad(mf, LOG2_HEAD, tv.s0); + z2 = __clc_mad(mf, LOG2_TAIL, -poly) + tv.s1; +#endif + + float z = z1 + z2; + z = near1 ? znear1 : z; + + // Corner cases + z = ax >= PINFBITPATT_SP32 ? x : z; + z = xi != ax ? __clc_as_float(QNANBITPATT_SP32) : z; + z = ax == 0 ? __clc_as_float(NINFBITPATT_SP32) : z; + + return z; +} + +#ifdef cl_khr_fp64 + +_CLC_OVERLOAD _CLC_DEF double +#if defined(COMPILING_LOG2) +__clc_log2(double x) +#elif defined(COMPILING_LOG10) +__clc_log10(double x) +#else +__clc_log(double x) +#endif +{ + +#ifndef COMPILING_LOG2 + // log2_lead and log2_tail sum to an extra-precise version of ln(2) + const double log2_lead = 6.93147122859954833984e-01; /* 0x3fe62e42e0000000 */ + const double log2_tail = 5.76999904754328540596e-08; /* 0x3e6efa39ef35793c */ +#endif + +#if defined(COMPILING_LOG10) + // log10e_lead and log10e_tail sum to an extra-precision version of log10(e) + // (19 bits in lead) + const double log10e_lead = + 4.34293746948242187500e-01; /* 0x3fdbcb7800000000 */ + const double log10e_tail = + 7.3495500964015109100644e-7; /* 0x3ea8a93728719535 */ +#elif defined(COMPILING_LOG2) + // log2e_lead and log2e_tail sum to an extra-precision version of log2(e) (19 + // bits in lead) + const double log2e_lead = 1.44269180297851562500E+00; /* 0x3FF7154400000000 */ + const double log2e_tail = 3.23791044778235969970E-06; /* 0x3ECB295C17F0BBBE */ +#endif + + // log_thresh1 = 9.39412117004394531250e-1 = 0x3fee0faa00000000 + // log_thresh2 = 1.06449508666992187500 = 0x3ff1082c00000000 + const double log_thresh1 = 0x1.e0faap-1; + const double log_thresh2 = 0x1.1082cp+0; + + bool is_near = x >= log_thresh1 && x <= log_thresh2; + + // Near 1 code + double r = x - 1.0; + double u = r / (2.0 + r); + double correction = r * u; + u = u + u; + double v = u * u; + double r1 = r; + + const double ca_1 = 8.33333333333317923934e-02; /* 0x3fb55555555554e6 */ + const double ca_2 = 1.25000000037717509602e-02; /* 0x3f89999999bac6d4 */ + const double ca_3 = 2.23213998791944806202e-03; /* 0x3f62492307f1519f */ + const double ca_4 = 4.34887777707614552256e-04; /* 0x3f3c8034c85dfff0 */ + + double r2 = __clc_fma( + u * v, __clc_fma(v, __clc_fma(v, __clc_fma(v, ca_4, ca_3), ca_2), ca_1), + -correction); + +#if defined(COMPILING_LOG10) + r = r1; + r1 = __clc_as_double(__clc_as_ulong(r1) & 0xffffffff00000000); + r2 = r2 + (r - r1); + double ret_near = __clc_fma( + log10e_lead, r1, + __clc_fma(log10e_lead, r2, __clc_fma(log10e_tail, r1, log10e_tail * r2))); +#elif defined(COMPILING_LOG2) + r = r1; + r1 = __clc_as_double(__clc_as_ulong(r1) & 0xffffffff00000000); + r2 = r2 + (r - r1); + double ret_near = __clc_fma( + log2e_lead, r1, + __clc_fma(log2e_lead, r2, __clc_fma(log2e_tail, r1, log2e_tail * r2))); +#else + double ret_near = r1 + r2; +#endif + + // This is the far from 1 code + + // Deal with subnormal + ulong ux = __clc_as_ulong(x); + ulong uxs = + __clc_as_ulong(__clc_as_double(0x03d0000000000000UL | ux) - 0x1.0p-962); + int c = ux < IMPBIT_DP64; + ux = c ? uxs : ux; + int expadjust = c ? 60 : 0; + + int xexp = ((__clc_as_int2(ux).hi >> 20) & 0x7ff) - EXPBIAS_DP64 - expadjust; + double f = __clc_as_double(HALFEXPBITS_DP64 | (ux & MANTBITS_DP64)); + int index = __clc_as_int2(ux).hi >> 13; + index = ((0x80 | (index & 0x7e)) >> 1) + (index & 0x1); + + double z1 = USE_TABLE(ln_tbl_lo, index - 64); + double q = USE_TABLE(ln_tbl_hi, index - 64); + + double f1 = index * 0x1.0p-7; + double f2 = f - f1; + u = f2 / __clc_fma(f2, 0.5, f1); + v = u * u; + + const double cb_1 = 8.33333333333333593622e-02; /* 0x3fb5555555555557 */ + const double cb_2 = 1.24999999978138668903e-02; /* 0x3f89999999865ede */ + const double cb_3 = 2.23219810758559851206e-03; /* 0x3f6249423bd94741 */ + + double poly = v * __clc_fma(v, __clc_fma(v, cb_3, cb_2), cb_1); + double z2 = q + __clc_fma(u, poly, u); + + double dxexp = (double)xexp; +#if defined(COMPILING_LOG10) + // Add xexp * log(2) to z1,z2 to get log(x) + r1 = __clc_fma(dxexp, log2_lead, z1); + r2 = __clc_fma(dxexp, log2_tail, z2); + double ret_far = __clc_fma( + log10e_lead, r1, + __clc_fma(log10e_lead, r2, __clc_fma(log10e_tail, r1, log10e_tail * r2))); +#elif defined(COMPILING_LOG2) + r1 = __clc_fma(log2e_lead, z1, dxexp); + r2 = __clc_fma(log2e_lead, z2, __clc_fma(log2e_tail, z1, log2e_tail * z2)); + double ret_far = r1 + r2; +#else + r1 = __clc_fma(dxexp, log2_lead, z1); + r2 = __clc_fma(dxexp, log2_tail, z2); + double ret_far = r1 + r2; +#endif + + double ret = is_near ? ret_near : ret_far; + + ret = __clc_isinf(x) ? __clc_as_double(PINFBITPATT_DP64) : ret; + ret = (__clc_isnan(x) | (x < 0.0)) ? __clc_as_double(QNANBITPATT_DP64) : ret; + ret = x == 0.0 ? __clc_as_double(NINFBITPATT_DP64) : ret; + return ret; +} + +#endif // cl_khr_fp64 + +#ifdef cl_khr_fp16 + +_CLC_OVERLOAD _CLC_DEF half +#if defined(COMPILING_LOG2) +__clc_log2(half x) { + return (half)__clc_log2((float)x); +} +#elif defined(COMPILING_LOG10) +__clc_log10(half x) { + return (half)__clc_log10((float)x); +} +#else +__clc_log(half x) { + return (half)__clc_log((float)x); +} +#endif + +#endif // cl_khr_fp16 diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_logb.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_logb.cl new file mode 100644 index 0000000000..f571a11d0c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_logb.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_logb.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_logb.inc new file mode 100644 index 0000000000..dde394886d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_logb.inc @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_logb(__CLC_GENTYPE x) { + __CLC_INTN ax = __CLC_AS_INTN(x) & EXSIGNBIT_SP32; + __CLC_GENTYPE s = __CLC_CONVERT_GENTYPE(LOG_MAGIC_NUM_SP32 - __clc_clz(ax)); + __CLC_GENTYPE r = + __CLC_CONVERT_GENTYPE((ax >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32); + r = ax >= PINFBITPATT_SP32 ? __CLC_AS_GENTYPE(ax) : r; + r = ax < 0x00800000 ? s : r; + r = ax == 0 ? __CLC_AS_GENTYPE((__CLC_INTN)NINFBITPATT_SP32) : r; + return r; +} + +#endif + +#if __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_logb(__CLC_GENTYPE x) { + __CLC_LONGN ax = __CLC_AS_LONGN(x) & EXSIGNBIT_DP64; + __CLC_GENTYPE s = __CLC_CONVERT_GENTYPE(LOG_MAGIC_NUM_DP64 - __clc_clz(ax)); + __CLC_GENTYPE r = + __CLC_CONVERT_GENTYPE((ax >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64); + r = ax >= PINFBITPATT_DP64 ? __CLC_AS_GENTYPE(ax) : r; + r = ax < 0x0010000000000000L ? s : r; + r = ax == 0L ? __CLC_AS_GENTYPE((__CLC_LONGN)NINFBITPATT_DP64) : r; + return r; +} + +#endif + +#if __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_logb(__CLC_GENTYPE x) { + __CLC_SHORTN ax = __CLC_AS_SHORTN(x) & (__CLC_SHORTN)EXSIGNBIT_FP16; + __CLC_GENTYPE s = __CLC_CONVERT_GENTYPE((__CLC_SHORTN)LOG_MAGIC_NUM_FP16 - + (__CLC_SHORTN)__clc_clz(ax)); + __CLC_GENTYPE r = __CLC_CONVERT_GENTYPE( + (ax >> (__CLC_SHORTN)EXPSHIFTBITS_FP16) - (__CLC_SHORTN)EXPBIAS_FP16); + r = ax >= (__CLC_SHORTN)PINFBITPATT_FP16 ? __CLC_AS_GENTYPE(ax) : r; + r = ax < (__CLC_SHORTN)0x0400 ? s : r; + r = ax == (__CLC_SHORTN)0 ? __CLC_AS_GENTYPE((__CLC_SHORTN)NINFBITPATT_FP16) + : r; + return r; +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_mad.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_mad.cl new file mode 100644 index 0000000000..f8b04f90c8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_mad.cl @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_mad.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_mad.inc new file mode 100644 index 0000000000..d8fd5b51bf --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_mad.inc @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_mad(__CLC_GENTYPE a, __CLC_GENTYPE b, + __CLC_GENTYPE c) { +#pragma OPENCL FP_CONTRACT ON + return a * b + c; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_maxmag.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_maxmag.cl new file mode 100644 index 0000000000..e34fd5613c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_maxmag.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_maxmag.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_maxmag.inc new file mode 100644 index 0000000000..0c346eeac8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_maxmag.inc @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_maxmag(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + const __CLC_GENTYPE res = __clc_select( + y, x, + __CLC_CONVERT_BIT_INTN(__clc_isgreater(__clc_fabs(x), __clc_fabs(y)))); + return __clc_select( + res, __clc_fmax(x, y), + __CLC_CONVERT_BIT_INTN(__clc_isnan(x) || __clc_isnan(y) || + __clc_isequal(__clc_fabs(x), __clc_fabs(y)))); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_minmag.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_minmag.cl new file mode 100644 index 0000000000..8529beb8d8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_minmag.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_minmag.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_minmag.inc new file mode 100644 index 0000000000..2b9236fedf --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_minmag.inc @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_minmag(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + const __CLC_GENTYPE res = __clc_select( + y, x, __CLC_CONVERT_BIT_INTN(__clc_isless(__clc_fabs(x), __clc_fabs(y)))); + return __clc_select( + res, __clc_fmin(x, y), + __CLC_CONVERT_BIT_INTN(__clc_isnan(x) || __clc_isnan(y) || + __clc_isequal(__clc_fabs(x), __clc_fabs(y)))); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_modf.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_modf.cl new file mode 100644 index 0000000000..dd8ac493dd --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_modf.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_modf.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_modf.inc new file mode 100644 index 0000000000..962d859ce9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_modf.inc @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_modf(__CLC_GENTYPE x, + private __CLC_GENTYPE *iptr) { + *iptr = __clc_trunc(x); + return __clc_copysign(__clc_isinf(x) ? __CLC_FP_LIT(0.0) : x - *iptr, x); +} + +#define CLC_MODF_DEF(addrspace) \ + _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_modf( \ + __CLC_GENTYPE x, addrspace __CLC_GENTYPE *iptr) { \ + __CLC_GENTYPE private_iptr; \ + __CLC_GENTYPE ret = __clc_modf(x, &private_iptr); \ + *iptr = private_iptr; \ + return ret; \ + } + +CLC_MODF_DEF(local); +CLC_MODF_DEF(global); + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +CLC_MODF_DEF(generic); +#endif + +#undef CLC_MODF_DEF diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_nan.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_nan.cl new file mode 100644 index 0000000000..0d480175b9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_nan.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_nan.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_nan.inc new file mode 100644 index 0000000000..46e828ba48 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_nan.inc @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 64 +#define NAN_MASK 0x7ff0000000000000ul +#elif __CLC_FPSIZE == 32 +#define NAN_MASK 0x7fc00000 +#elif __CLC_FPSIZE == 16 +#define NAN_MASK 0x7e00 +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_nan(__CLC_U_GENTYPE code) { + const __CLC_U_GENTYPE mask = NAN_MASK; + const __CLC_U_GENTYPE res = code | mask; + return __CLC_AS_GENTYPE(res); +} + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_nan(__CLC_S_GENTYPE code) { + return __clc_nan(__CLC_AS_U_GENTYPE(code)); +} + +#undef NAN_MASK diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_cos.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_cos.cl new file mode 100644 index 0000000000..2e63e9c949 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_cos.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_cos +#define __IMPL_FUNCTION(x) __builtin_elementwise_cos +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_divide.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_divide.cl new file mode 100644 index 0000000000..005089b1ba --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_divide.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_divide.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_divide.inc new file mode 100644 index 0000000000..fdf1794812 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_divide.inc @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_native_divide(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return x / y; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp.cl new file mode 100644 index 0000000000..2f50a0aefa --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_exp +#define __IMPL_FUNCTION(x) __builtin_elementwise_exp +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp10.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp10.cl new file mode 100644 index 0000000000..7ca5d1992c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp10.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __FLOAT_ONLY +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp10.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp10.inc new file mode 100644 index 0000000000..c002b5444f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp10.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_native_exp10(__CLC_GENTYPE val) { + return __clc_native_exp2(val * M_LOG210_F); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp2.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp2.cl new file mode 100644 index 0000000000..25f557306c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_exp2.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_exp2 +#define __IMPL_FUNCTION(x) __builtin_elementwise_exp2 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_log.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_log.cl new file mode 100644 index 0000000000..b9b9d274f8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_log.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_log +#define __IMPL_FUNCTION(x) __builtin_elementwise_log +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_log10.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_log10.cl new file mode 100644 index 0000000000..221aa40646 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_log10.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_log10 +#define __IMPL_FUNCTION(x) __builtin_elementwise_log10 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_log2.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_log2.cl new file mode 100644 index 0000000000..c3008ce242 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_log2.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_log2 +#define __IMPL_FUNCTION(x) __builtin_elementwise_log2 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_powr.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_powr.cl new file mode 100644 index 0000000000..7c7dcaf8c5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_powr.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __FLOAT_ONLY +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_powr.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_powr.inc new file mode 100644 index 0000000000..51bd8b5ceb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_powr.inc @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_native_powr(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + // x^y == 2^{log2 x^y} == 2^{y * log2 x} + // for x < 0 propagate nan created by log2 + return __clc_native_exp2(y * __clc_native_log2(x)); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_recip.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_recip.cl new file mode 100644 index 0000000000..4377f10b15 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_recip.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_recip.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_recip.inc new file mode 100644 index 0000000000..57eb35a952 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_recip.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_native_recip(__CLC_GENTYPE val) { + return 1.0f / val; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_rsqrt.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_rsqrt.cl new file mode 100644 index 0000000000..d5e6fcdae4 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_rsqrt.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#define __FLOAT_ONLY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_rsqrt.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_rsqrt.inc new file mode 100644 index 0000000000..7a3b0b2af2 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_rsqrt.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_native_rsqrt(__CLC_GENTYPE val) { + return 1.0f / __clc_native_sqrt(val); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_sin.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_sin.cl new file mode 100644 index 0000000000..533f8d726d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_sin.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_sin +#define __IMPL_FUNCTION(x) __builtin_elementwise_sin +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_sqrt.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_sqrt.cl new file mode 100644 index 0000000000..e0f028e988 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_sqrt.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_sqrt +#define __IMPL_FUNCTION(x) __builtin_elementwise_sqrt +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_tan.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_tan.cl new file mode 100644 index 0000000000..a9ac46688c --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_tan.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __FLOAT_ONLY +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_tan.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_tan.inc new file mode 100644 index 0000000000..f61a78968a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_native_tan.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_native_tan(__CLC_GENTYPE val) { + return __clc_native_sin(val) / __clc_native_cos(val); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_nextafter.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_nextafter.cl new file mode 100644 index 0000000000..6fc699ce71 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_nextafter.cl @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include + +// This file provides OpenCL C implementations of __clc_nextafter for +// targets that don't support the clang builtin. + +#define CLC_AS_TYPE(x) __clc_as_##x + +#define NEXTAFTER(FLOAT_TYPE, UINT_TYPE, INT_TYPE, INT_TYPE_SCALAR) \ + _CLC_OVERLOAD _CLC_DEF FLOAT_TYPE __clc_nextafter(FLOAT_TYPE x, \ + FLOAT_TYPE y) { \ + const UINT_TYPE sign_bit = (UINT_TYPE)1 \ + << (sizeof(INT_TYPE_SCALAR) * 8 - 1); \ + UINT_TYPE ix = CLC_AS_TYPE(UINT_TYPE)(x); \ + FLOAT_TYPE absx = __clc_fabs(x); \ + UINT_TYPE mxu = sign_bit - ix; \ + INT_TYPE mx = CLC_AS_TYPE(INT_TYPE)(mxu); \ + mx = CLC_AS_TYPE(INT_TYPE)(ix) < (INT_TYPE)0 ? mx \ + : CLC_AS_TYPE(INT_TYPE)(ix); \ + UINT_TYPE iy = CLC_AS_TYPE(UINT_TYPE)(y); \ + FLOAT_TYPE absy = __clc_fabs(y); \ + UINT_TYPE myu = sign_bit - iy; \ + INT_TYPE my = CLC_AS_TYPE(INT_TYPE)(myu); \ + my = CLC_AS_TYPE(INT_TYPE)(iy) < (INT_TYPE)0 ? my \ + : CLC_AS_TYPE(INT_TYPE)(iy); \ + INT_TYPE t = mx + (mx < my ? (INT_TYPE)1 : (INT_TYPE)-1); \ + UINT_TYPE r = sign_bit - CLC_AS_TYPE(UINT_TYPE)(t); \ + r = (t < (INT_TYPE)0 || (t == (INT_TYPE)0 && mx < my)) \ + ? r \ + : CLC_AS_TYPE(UINT_TYPE)(t); \ + r = __clc_isnan(x) ? ix : r; \ + r = __clc_isnan(y) ? iy : r; \ + r = ((CLC_AS_TYPE(UINT_TYPE)(absx) | CLC_AS_TYPE(UINT_TYPE)(absy)) == \ + (UINT_TYPE)0 || \ + ix == iy) \ + ? iy \ + : r; \ + return CLC_AS_TYPE(FLOAT_TYPE)(r); \ + } + +NEXTAFTER(float, uint, int, int) +NEXTAFTER(float2, uint2, int2, int) +NEXTAFTER(float3, uint3, int3, int) +NEXTAFTER(float4, uint4, int4, int) +NEXTAFTER(float8, uint8, int8, int) +NEXTAFTER(float16, uint16, int16, int) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +NEXTAFTER(double, ulong, long, long) +NEXTAFTER(double2, ulong2, long2, long) +NEXTAFTER(double3, ulong3, long3, long) +NEXTAFTER(double4, ulong4, long4, long) +NEXTAFTER(double8, ulong8, long8, long) +NEXTAFTER(double16, ulong16, long16, long) + +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +NEXTAFTER(half, ushort, short, short) +NEXTAFTER(half2, ushort2, short2, short) +NEXTAFTER(half3, ushort3, short3, short) +NEXTAFTER(half4, ushort4, short4, short) +NEXTAFTER(half8, ushort8, short8, short) +NEXTAFTER(half16, ushort16, short16, short) + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pow.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pow.cl new file mode 100644 index 0000000000..3d371938e4 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pow.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pow.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pow.inc new file mode 100644 index 0000000000..8b1f820268 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pow.inc @@ -0,0 +1,438 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Computes pow using log and exp +// +// x^y = exp(y * log(x)) +// +// We take care not to lose precision in the intermediate steps +// +// When computing log, calculate it in splits: +// +// r = f * (p_invead + p_inv_tail) +// r = rh + rt +// +// Calculate log polynomial using r, in end addition, do: +// +// poly = poly + ((rh-r) + rt) +// +// lth = -r +// ltt = ((xexp * log2_t) - poly) + logT +// lt = lth + ltt +// +// lh = (xexp * log2_h) + logH +// l = lh + lt +// +// Calculate final log answer as gh and gt: +// +// gh = l & higher-half bits +// gt = (((ltt - (lt - lth)) + ((lh - l) + lt)) + (l - gh)) +// +// yh = y & higher-half bits +// yt = y - yh +// +// Before entering computation of exp: +// +// vs = ((yt*gt + yt*gh) + yh*gt) +// v = vs + yh*gh +// vt = ((yh*gh - v) + vs) +// +// In calculation of exp, add vt to r that is used for poly. +// +// At the end of exp, do +// +// ((((expT * poly) + expT) + expH*poly) + expH) +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_pow(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + __CLC_GENTYPE absx = __clc_fabs(x); + __CLC_INTN ix = __CLC_AS_INTN(x); + __CLC_INTN ax = __CLC_AS_INTN(absx); + __CLC_INTN xpos = ix == ax; + + __CLC_INTN iy = __CLC_AS_INTN(y); + __CLC_INTN ay = __CLC_AS_INTN(__clc_fabs(y)); + __CLC_INTN ypos = iy == ay; + + /* Extra precise log calculation + * First handle case that x is close to 1 + */ + __CLC_GENTYPE r = 1.0f - absx; + __CLC_INTN near1 = __clc_fabs(r) < 0x1.0p-4f; + __CLC_GENTYPE r2 = r * r; + + /* Coefficients are just 1/3, 1/4, 1/5 and 1/6 */ + __CLC_GENTYPE poly = __clc_mad( + r, + __clc_mad(r, + __clc_mad(r, __clc_mad(r, 0x1.24924ap-3f, 0x1.555556p-3f), + 0x1.99999ap-3f), + 0x1.000000p-2f), + 0x1.555556p-2f); + + poly *= r2 * r; + + __CLC_GENTYPE lth_near1 = -r2 * 0.5f; + __CLC_GENTYPE ltt_near1 = -poly; + __CLC_GENTYPE lt_near1 = lth_near1 + ltt_near1; + __CLC_GENTYPE lh_near1 = -r; + __CLC_GENTYPE l_near1 = lh_near1 + lt_near1; + + /* Computations for x not near 1 */ + __CLC_INTN m = __CLC_CONVERT_INTN(ax >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + __CLC_GENTYPE mf = __CLC_CONVERT_GENTYPE(m); + __CLC_INTN ixs = __CLC_AS_INTN(__CLC_AS_GENTYPE(ax | 0x3f800000) - 1.0f); + __CLC_GENTYPE mfs = __CLC_CONVERT_GENTYPE((ixs >> EXPSHIFTBITS_SP32) - 253); + __CLC_INTN c = m == -127; + __CLC_INTN ixn = c ? ixs : ax; + __CLC_GENTYPE mfn = c ? mfs : mf; + + __CLC_INTN indx = (ixn & 0x007f0000) + ((ixn & 0x00008000) << 1); + + /* F - Y */ + __CLC_GENTYPE f = __CLC_AS_GENTYPE(0x3f000000 | indx) - + __CLC_AS_GENTYPE(0x3f000000 | (ixn & MANTBITS_SP32)); + + indx = indx >> 16; + __CLC_GENTYPE rh = f * USE_TABLE(log_inv_tbl_ep_head, indx); + __CLC_GENTYPE rt = f * USE_TABLE(log_inv_tbl_ep_tail, indx); + r = rh + rt; + + poly = __clc_mad(r, __clc_mad(r, 0x1.0p-2f, 0x1.555556p-2f), 0x1.0p-1f) * + (r * r); + poly += (rh - r) + rt; + + const __CLC_GENTYPE LOG2_HEAD = 0x1.62e000p-1f; /* 0.693115234 */ + const __CLC_GENTYPE LOG2_TAIL = 0x1.0bfbe8p-15f; /* 0.0000319461833 */ + __CLC_GENTYPE logel = USE_TABLE(loge_tbl_lo, indx); + __CLC_GENTYPE logeh = USE_TABLE(loge_tbl_hi, indx); + __CLC_GENTYPE lth = -r; + __CLC_GENTYPE ltt = __clc_mad(mfn, LOG2_TAIL, -poly) + logeh; + __CLC_GENTYPE lt = lth + ltt; + __CLC_GENTYPE lh = __clc_mad(mfn, LOG2_HEAD, logel); + __CLC_GENTYPE l = lh + lt; + + /* Select near 1 or not */ + lth = near1 ? lth_near1 : lth; + ltt = near1 ? ltt_near1 : ltt; + lt = near1 ? lt_near1 : lt; + lh = near1 ? lh_near1 : lh; + l = near1 ? l_near1 : l; + + __CLC_GENTYPE gh = __CLC_AS_GENTYPE(__CLC_AS_UINTN(l) & 0xfffff000); + __CLC_GENTYPE gt = ((ltt - (lt - lth)) + ((lh - l) + lt)) + (l - gh); + + __CLC_GENTYPE yh = __CLC_AS_GENTYPE(__CLC_AS_UINTN(iy) & 0xfffff000); + + __CLC_GENTYPE yt = y - yh; + + __CLC_GENTYPE ylogx_s = __clc_mad(gt, yh, __clc_mad(gh, yt, yt * gt)); + __CLC_GENTYPE ylogx = __clc_mad(yh, gh, ylogx_s); + __CLC_GENTYPE ylogx_t = __clc_mad(yh, gh, -ylogx) + ylogx_s; + + /* Extra precise exp of ylogx */ + /* 64/log2 : 92.332482616893657 */ + const __CLC_GENTYPE R_64_BY_LOG2 = 0x1.715476p+6f; + __CLC_INTN n = __CLC_CONVERT_INTN(ylogx * R_64_BY_LOG2); + __CLC_GENTYPE nf = __CLC_CONVERT_GENTYPE(n); + + __CLC_INTN j = n & 0x3f; + m = n >> 6; + __CLC_INTN m2 = m << EXPSHIFTBITS_SP32; + + /* log2/64 lead: 0.0108032227 */ + const __CLC_GENTYPE R_LOG2_BY_64_LD = 0x1.620000p-7f; + /* log2/64 tail: 0.0000272020388 */ + const __CLC_GENTYPE R_LOG2_BY_64_TL = 0x1.c85fdep-16f; + r = __clc_mad(nf, -R_LOG2_BY_64_TL, __clc_mad(nf, -R_LOG2_BY_64_LD, ylogx)) + + ylogx_t; + + /* Truncated Taylor series for e^r */ + poly = __clc_mad(__clc_mad(__clc_mad(r, 0x1.555556p-5f, 0x1.555556p-3f), r, + 0x1.000000p-1f), + r * r, r); + + __CLC_GENTYPE exp_head = USE_TABLE(exp_tbl_ep_head, j); + __CLC_GENTYPE exp_tail = USE_TABLE(exp_tbl_ep_tail, j); + + __CLC_GENTYPE expylogx = + __clc_mad(exp_head, poly, __clc_mad(exp_tail, poly, exp_tail)) + exp_head; + __CLC_GENTYPE sexpylogx = + expylogx * __CLC_AS_GENTYPE((__CLC_UINTN)0x1 << (m + 149)); + __CLC_GENTYPE texpylogx = __CLC_AS_GENTYPE(__CLC_AS_INTN(expylogx) + m2); + expylogx = m < -125 ? sexpylogx : texpylogx; + + /* Result is +-Inf if (ylogx + ylogx_t) > 128*log2 */ + expylogx = + __clc_select(expylogx, __CLC_AS_GENTYPE((__CLC_UINTN)PINFBITPATT_SP32), + ylogx > 0x1.62e430p+6f || + (ylogx == 0x1.62e430p+6f && ylogx_t > -0x1.05c610p-22f)); + + /* Result is 0 if ylogx < -149*log2 */ + expylogx = ylogx < -0x1.9d1da0p+6f ? 0.0f : expylogx; + + /* Classify y: + * inty = 0 means not an integer. + * inty = 1 means odd integer. + * inty = 2 means even integer. + */ + + __CLC_INTN yexp = + __CLC_CONVERT_INTN(ay >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32 + 1; + __CLC_INTN mask = ((__CLC_INTN)1 << (24 - yexp)) - 1; + __CLC_INTN yodd = ((iy >> (24 - yexp)) & 0x1) != 0; + __CLC_INTN inty = yodd ? 1 : 2; + inty = (iy & mask) != 0 ? 0 : inty; + inty = yexp < 1 ? 0 : inty; + inty = yexp > 24 ? 2 : inty; + + __CLC_GENTYPE signval = + __CLC_AS_GENTYPE((__CLC_AS_UINTN(expylogx) ^ SIGNBIT_SP32)); + expylogx = ((inty == 1) && !xpos) ? signval : expylogx; + __CLC_INTN ret = __CLC_AS_INTN(expylogx); + + /* Corner case handling */ + ret = (!xpos && (inty == 0)) ? QNANBITPATT_SP32 : ret; + ret = ax < 0x3f800000 && iy == (__CLC_INTN)NINFBITPATT_SP32 ? PINFBITPATT_SP32 + : ret; + ret = ax > 0x3f800000 && iy == (__CLC_INTN)NINFBITPATT_SP32 ? 0 : ret; + ret = ax < 0x3f800000 && iy == (__CLC_INTN)PINFBITPATT_SP32 ? 0 : ret; + ret = ax > 0x3f800000 && iy == (__CLC_INTN)PINFBITPATT_SP32 ? PINFBITPATT_SP32 + : ret; + __CLC_BIT_INTN x_is_ninf = ix == (__CLC_INTN)NINFBITPATT_SP32; + __CLC_BIT_INTN x_is_pinf = ix == (__CLC_INTN)PINFBITPATT_SP32; + __CLC_INTN xinf = + xpos ? (__CLC_INTN)PINFBITPATT_SP32 : (__CLC_INTN)NINFBITPATT_SP32; + + ret = ((ax == 0) && !ypos && (inty == 1)) ? xinf : ret; + ret = ((ax == 0) && !ypos && (inty != 1)) ? PINFBITPATT_SP32 : ret; + __CLC_INTN xzero = xpos ? (__CLC_INTN)0 : (__CLC_INTN)0x80000000; + ret = ((ax == 0) && ypos && (inty == 1)) ? xzero : ret; + ret = ((ax == 0) && ypos && (inty != 1)) ? 0 : ret; + ret = ((ax == 0) && (iy == (__CLC_INTN)NINFBITPATT_SP32)) ? PINFBITPATT_SP32 + : ret; + ret = (ix == (__CLC_INTN)0xbf800000 && ay == PINFBITPATT_SP32) ? 0x3f800000 + : ret; + ret = (x_is_ninf && !ypos && (inty == 1)) ? (__CLC_INTN)0x80000000 : ret; + ret = (x_is_ninf && !ypos && (inty != 1)) ? 0 : ret; + ret = (x_is_ninf && ypos && (inty == 1)) ? (__CLC_INTN)NINFBITPATT_SP32 : ret; + ret = (x_is_ninf && ypos && (inty != 1)) ? (__CLC_INTN)PINFBITPATT_SP32 : ret; + ret = (x_is_pinf && !ypos) ? 0 : ret; + ret = (x_is_pinf && ypos) ? PINFBITPATT_SP32 : ret; + ret = (ax > PINFBITPATT_SP32) ? ix : ret; + ret = (ay > PINFBITPATT_SP32) ? iy : ret; + ret = ay == 0 ? 0x3f800000 : ret; + ret = ix == 0x3f800000 ? 0x3f800000 : ret; + + return __CLC_AS_GENTYPE(ret); +} + +#elif __CLC_FPSIZE == 64 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_pow(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + const __CLC_GENTYPE real_log2_tail = 5.76999904754328540596e-08; + const __CLC_GENTYPE real_log2_lead = 6.93147122859954833984e-01; + + __CLC_LONGN ux = __CLC_AS_LONGN(x); + __CLC_LONGN ax = __CLC_AS_LONGN(__clc_fabs(x)); + __CLC_BIT_INTN xpos = ax == ux; + + __CLC_LONGN uy = __CLC_AS_LONGN(y); + __CLC_LONGN ay = __CLC_AS_LONGN(__clc_fabs(y)); + __CLC_BIT_INTN ypos = ay == uy; + + // Extended precision log + __CLC_GENTYPE v, vt; + { + __CLC_INTN exp = __CLC_CONVERT_INTN(ax >> 52) - 1023; + __CLC_INTN mask_exp_1023 = exp == (__CLC_INTN)-1023; + __CLC_GENTYPE xexp = __CLC_CONVERT_GENTYPE(exp); + __CLC_LONGN mantissa = ax & 0x000FFFFFFFFFFFFFL; + + __CLC_LONGN temp_ux = + __CLC_AS_LONGN(__CLC_AS_GENTYPE(0x3ff0000000000000L | mantissa) - 1.0); + exp = __CLC_CONVERT_INTN((temp_ux & 0x7FF0000000000000L) >> 52) - 2045; + __CLC_GENTYPE xexp1 = __CLC_CONVERT_GENTYPE(exp); + __CLC_LONGN mantissa1 = temp_ux & 0x000FFFFFFFFFFFFFL; + + xexp = __CLC_CONVERT_LONGN(mask_exp_1023) ? xexp1 : xexp; + mantissa = __CLC_CONVERT_LONGN(mask_exp_1023) ? mantissa1 : mantissa; + + __CLC_LONGN rax = (mantissa & 0x000ff00000000000) + + ((mantissa & 0x0000080000000000) << 1); + __CLC_INTN index = __CLC_CONVERT_INTN(rax >> 44); + + __CLC_GENTYPE F = __CLC_AS_GENTYPE(rax | 0x3FE0000000000000L); + __CLC_GENTYPE Y = __CLC_AS_GENTYPE(mantissa | 0x3FE0000000000000L); + __CLC_GENTYPE f = F - Y; + __CLC_GENTYPE log_h = USE_TABLE(log_f_inv_tbl_head, index); + __CLC_GENTYPE log_t = USE_TABLE(log_f_inv_tbl_tail, index); + __CLC_GENTYPE f_inv = (log_h + log_t) * f; + __CLC_GENTYPE r1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(f_inv) & 0xfffffffff8000000L); + __CLC_GENTYPE r2 = __clc_fma(-F, r1, f) * (log_h + log_t); + __CLC_GENTYPE r = r1 + r2; + + __CLC_GENTYPE poly = __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, __clc_fma(r, 1.0 / 7.0, 1.0 / 6.0), 1.0 / 5.0), + 1.0 / 4.0), + 1.0 / 3.0); + poly = poly * r * r * r; + + __CLC_GENTYPE hr1r1 = 0.5 * r1 * r1; + __CLC_GENTYPE poly0h = r1 + hr1r1; + __CLC_GENTYPE poly0t = r1 - poly0h + hr1r1; + poly = __clc_fma(r1, r2, __clc_fma(0.5 * r2, r2, poly)) + r2 + poly0t; + + log_h = USE_TABLE(powlog_tbl_head, index); + log_t = USE_TABLE(powlog_tbl_tail, index); + + __CLC_GENTYPE resT_t = __clc_fma(xexp, real_log2_tail, +log_t) - poly; + __CLC_GENTYPE resT = resT_t - poly0h; + __CLC_GENTYPE resH = __clc_fma(xexp, real_log2_lead, log_h); + __CLC_GENTYPE resT_h = poly0h; + + __CLC_GENTYPE H = resT + resH; + __CLC_GENTYPE H_h = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(H) & 0xfffffffff8000000L); + __CLC_GENTYPE T = + (resH - H + resT) + (resT_t - (resT + resT_h)) + (H - H_h); + H = H_h; + + __CLC_GENTYPE y_head = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(uy) & 0xfffffffff8000000L); + __CLC_GENTYPE y_tail = y - y_head; + + __CLC_GENTYPE temp = __clc_fma(y_tail, H, __clc_fma(y_head, T, y_tail * T)); + v = __clc_fma(y_head, H, temp); + vt = __clc_fma(y_head, H, -v) + temp; + } + + // Now calculate exp of (v,vt) + + __CLC_GENTYPE expv; + { + const __CLC_GENTYPE max_exp_arg = 709.782712893384; + const __CLC_GENTYPE min_exp_arg = -745.1332191019411; + const __CLC_GENTYPE sixtyfour_by_lnof2 = 92.33248261689366; + const __CLC_GENTYPE lnof2_by_64_head = 0.010830424260348081; + const __CLC_GENTYPE lnof2_by_64_tail = -4.359010638708991e-10; + + // If v is so large that we need to return INFINITY, or so small that we + // need to return 0, set v to known values that will produce that result. Do + // not try to continue the computation with the original v and patch it up + // afterwards because v may be so large that temp is out of range of int, in + // which case that conversion, and a value based on that conversion being + // passed to __clc_ldexp, results in undefined behavior. + v = v > max_exp_arg ? 1000.0 : v; + v = v < min_exp_arg ? -1000.0 : v; + + __CLC_GENTYPE temp = v * sixtyfour_by_lnof2; + __CLC_INTN n = __CLC_CONVERT_INTN(temp); + __CLC_GENTYPE dn = __CLC_CONVERT_GENTYPE(n); + __CLC_INTN j = n & 0x0000003f; + __CLC_INTN m = n >> 6; + + __CLC_GENTYPE f1 = USE_TABLE(two_to_jby64_ep_tbl_head, j); + __CLC_GENTYPE f2 = USE_TABLE(two_to_jby64_ep_tbl_tail, j); + __CLC_GENTYPE f = f1 + f2; + + __CLC_GENTYPE r1 = __clc_fma(dn, -lnof2_by_64_head, v); + __CLC_GENTYPE r2 = dn * lnof2_by_64_tail; + __CLC_GENTYPE r = (r1 + r2) + vt; + + __CLC_GENTYPE q = + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 1.38889490863777199667e-03, + 8.33336798434219616221e-03), + 4.16666666662260795726e-02), + 1.66666666665260878863e-01), + 5.00000000000000008883e-01); + q = __clc_fma(r * r, q, r); + + expv = __clc_fma(f, q, f2) + f1; + expv = __clc_ldexp(expv, m); + } + + // See whether y is an integer. + // inty = 0 means not an integer. + // inty = 1 means odd integer. + // inty = 2 means even integer. + + __CLC_LONGN inty; + { + __CLC_INTN yexp = + __CLC_CONVERT_INTN(ay >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64 + 1; + inty = __CLC_CONVERT_LONGN(yexp < 1 ? 0 : 2); + inty = __CLC_CONVERT_LONGN(yexp > 53) ? 2 : inty; + __CLC_LONGN mask = ((__CLC_LONGN)1L << (53 - yexp)) - 1L; + __CLC_LONGN inty1 = (((ay & ~mask) >> (53 - yexp)) & 1L) == 1L ? 1L : 2L; + inty1 = (ay & mask) != 0 ? 0 : inty1; + inty = __CLC_CONVERT_LONGN(!(yexp < 1) && !(yexp > 53)) ? inty1 : inty; + } + + expv *= (inty == 1) && !xpos ? -1.0 : 1.0; + + __CLC_LONGN ret = __CLC_AS_LONGN(expv); + + // Now all the edge cases + __CLC_BIT_INTN x_is_ninf = ux == (__CLC_LONGN)NINFBITPATT_DP64; + __CLC_BIT_INTN x_is_pinf = ux == (__CLC_LONGN)PINFBITPATT_DP64; + __CLC_BIT_INTN y_is_ninf = uy == (__CLC_LONGN)NINFBITPATT_DP64; + __CLC_BIT_INTN y_is_pinf = uy == (__CLC_LONGN)PINFBITPATT_DP64; + ret = !xpos && (inty == 0) ? QNANBITPATT_DP64 : ret; + ret = ax < 0x3ff0000000000000L && y_is_ninf ? PINFBITPATT_DP64 : ret; + ret = ax > 0x3ff0000000000000L && y_is_ninf ? 0L : ret; + ret = ax < 0x3ff0000000000000L && y_is_pinf ? 0L : ret; + ret = ax > 0x3ff0000000000000L && y_is_pinf ? PINFBITPATT_DP64 : ret; + __CLC_LONGN xinf = + xpos ? (__CLC_LONGN)PINFBITPATT_DP64 : (__CLC_LONGN)NINFBITPATT_DP64; + ret = ((ax == 0L) && !ypos && (inty == 1)) ? xinf : ret; + ret = ((ax == 0L) && !ypos && (inty != 1)) ? PINFBITPATT_DP64 : ret; + __CLC_LONGN xzero = xpos ? (__CLC_LONGN)0L : (__CLC_LONGN)0x8000000000000000L; + ret = ((ax == 0L) && ypos && (inty == 1)) ? xzero : ret; + ret = ((ax == 0L) && ypos && (inty != 1)) ? 0L : ret; + ret = ((ax == 0L) && y_is_ninf) ? PINFBITPATT_DP64 : ret; + ret = ((ux == (__CLC_LONGN)0xbff0000000000000L) && (ay == PINFBITPATT_DP64)) + ? 0x3ff0000000000000L + : ret; + ret = (x_is_ninf && !ypos && (inty == 1)) ? (__CLC_LONGN)0x8000000000000000L + : ret; + ret = (x_is_ninf && !ypos && (inty != 1)) ? 0L : ret; + ret = + (x_is_ninf && ypos && (inty == 1)) ? (__CLC_LONGN)NINFBITPATT_DP64 : ret; + ret = + (x_is_ninf && ypos && (inty != 1)) ? (__CLC_LONGN)PINFBITPATT_DP64 : ret; + ret = x_is_pinf && !ypos ? 0L : ret; + ret = x_is_pinf && ypos ? PINFBITPATT_DP64 : ret; + ret = ax > PINFBITPATT_DP64 ? ux : ret; + ret = ay > PINFBITPATT_DP64 ? uy : ret; + ret = ay == 0L ? 0x3ff0000000000000L : ret; + ret = ux == 0x3ff0000000000000L ? 0x3ff0000000000000L : ret; + + return __CLC_AS_GENTYPE(ret); +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_pow(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return __CLC_CONVERT_GENTYPE( + __clc_pow(__CLC_CONVERT_FLOATN(x), __CLC_CONVERT_FLOATN(y))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pown.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pown.cl new file mode 100644 index 0000000000..074f212a31 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pown.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pown.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pown.inc new file mode 100644 index 0000000000..483fd2faf2 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_pown.inc @@ -0,0 +1,402 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Computes pow using log and exp +// +// x^y = exp(y * log(x)) +// +// We take care not to lose precision in the intermediate steps. +// +// When computing log, calculate it in splits: +// +// r = f * (p_invead + p_inv_tail) +// r = rh + rt +// +// Calculate log polynomial using r, in end addition, do: +// +// poly = poly + ((rh-r) + rt) +// +// lth = -r +// ltt = ((xexp * log2_t) - poly) + logT +// lt = lth + ltt +// +// lh = (xexp * log2_h) + logH +// l = lh + lt +// +// Calculate final log answer as gh and gt: +// +// gh = l & higher-half bits +// gt = (((ltt - (lt - lth)) + ((lh - l) + lt)) + (l - gh)) +// +// yh = y & higher-half bits +// yt = y - yh +// +// Before entering computation of exp: +// +// vs = ((yt*gt + yt*gh) + yh*gt) +// v = vs + yh*gh +// vt = ((yh*gh - v) + vs) +// +// In calculation of exp, add vt to r that is used for poly. +// +// At the end of exp, do: +// +// ((((expT * poly) + expT) + expH*poly) + expH) +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_pown(__CLC_GENTYPE x, + __CLC_INTN ny) { + __CLC_GENTYPE y = __CLC_CONVERT_GENTYPE(ny); + + __CLC_GENTYPE absx = __clc_fabs(x); + __CLC_INTN ix = __CLC_AS_INTN(x); + __CLC_INTN ax = __CLC_AS_INTN(absx); + __CLC_INTN xpos = ix == ax; + + __CLC_INTN iy = __CLC_AS_INTN(y); + __CLC_INTN ay = __CLC_AS_INTN(__clc_fabs(y)); + __CLC_INTN ypos = iy == ay; + + // Extra precise log calculation + // First handle case that x is close to 1 + __CLC_GENTYPE r = 1.0f - absx; + __CLC_INTN near1 = __clc_fabs(r) < 0x1.0p-4f; + __CLC_GENTYPE r2 = r * r; + + // Coefficients are just 1/3, 1/4, 1/5 and 1/6 + __CLC_GENTYPE poly = __clc_mad( + r, + __clc_mad(r, + __clc_mad(r, __clc_mad(r, 0x1.24924ap-3f, 0x1.555556p-3f), + 0x1.99999ap-3f), + 0x1.000000p-2f), + 0x1.555556p-2f); + + poly *= r2 * r; + + __CLC_GENTYPE lth_near1 = -r2 * 0.5f; + __CLC_GENTYPE ltt_near1 = -poly; + __CLC_GENTYPE lt_near1 = lth_near1 + ltt_near1; + __CLC_GENTYPE lh_near1 = -r; + __CLC_GENTYPE l_near1 = lh_near1 + lt_near1; + + // Computations for x not near 1 + __CLC_INTN m = __CLC_CONVERT_INTN(ax >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + __CLC_GENTYPE mf = __CLC_CONVERT_GENTYPE(m); + __CLC_INTN ixs = __CLC_AS_INTN(__CLC_AS_GENTYPE(ax | 0x3f800000) - 1.0f); + __CLC_GENTYPE mfs = __CLC_CONVERT_GENTYPE((ixs >> EXPSHIFTBITS_SP32) - 253); + __CLC_INTN c = m == -127; + __CLC_INTN ixn = c ? ixs : ax; + __CLC_GENTYPE mfn = c ? mfs : mf; + + __CLC_INTN indx = (ixn & 0x007f0000) + ((ixn & 0x00008000) << 1); + + // F - Y + __CLC_GENTYPE f = __CLC_AS_GENTYPE(0x3f000000 | indx) - + __CLC_AS_GENTYPE(0x3f000000 | (ixn & MANTBITS_SP32)); + + indx = indx >> 16; + __CLC_GENTYPE rh = f * USE_TABLE(log_inv_tbl_ep_head, indx); + __CLC_GENTYPE rt = f * USE_TABLE(log_inv_tbl_ep_tail, indx); + r = rh + rt; + + poly = __clc_mad(r, __clc_mad(r, 0x1.0p-2f, 0x1.555556p-2f), 0x1.0p-1f) * + (r * r); + poly += (rh - r) + rt; + + const __CLC_GENTYPE LOG2_HEAD = 0x1.62e000p-1f; // 0.693115234 + const __CLC_GENTYPE LOG2_TAIL = 0x1.0bfbe8p-15f; // 0.0000319461833 + __CLC_GENTYPE logel = USE_TABLE(loge_tbl_lo, indx); + __CLC_GENTYPE logeh = USE_TABLE(loge_tbl_hi, indx); + __CLC_GENTYPE lth = -r; + __CLC_GENTYPE ltt = __clc_mad(mfn, LOG2_TAIL, -poly) + logeh; + __CLC_GENTYPE lt = lth + ltt; + __CLC_GENTYPE lh = __clc_mad(mfn, LOG2_HEAD, logel); + __CLC_GENTYPE l = lh + lt; + + // Select near 1 or not + lth = near1 ? lth_near1 : lth; + ltt = near1 ? ltt_near1 : ltt; + lt = near1 ? lt_near1 : lt; + lh = near1 ? lh_near1 : lh; + l = near1 ? l_near1 : l; + + __CLC_GENTYPE gh = __CLC_AS_GENTYPE(__CLC_AS_UINTN(l) & 0xfffff000); + __CLC_GENTYPE gt = ((ltt - (lt - lth)) + ((lh - l) + lt)) + (l - gh); + + __CLC_GENTYPE yh = __CLC_AS_GENTYPE(__CLC_AS_UINTN(iy) & 0xfffff000); + + __CLC_GENTYPE yt = __CLC_CONVERT_GENTYPE(ny - __CLC_CONVERT_INTN(yh)); + + __CLC_GENTYPE ylogx_s = __clc_mad(gt, yh, __clc_mad(gh, yt, yt * gt)); + __CLC_GENTYPE ylogx = __clc_mad(yh, gh, ylogx_s); + __CLC_GENTYPE ylogx_t = __clc_mad(yh, gh, -ylogx) + ylogx_s; + + // Extra precise exp of ylogx + // 64/log2 : 92.332482616893657 + const __CLC_GENTYPE R_64_BY_LOG2 = 0x1.715476p+6f; + __CLC_INTN n = __CLC_CONVERT_INTN(ylogx * R_64_BY_LOG2); + __CLC_GENTYPE nf = __CLC_CONVERT_GENTYPE(n); + + __CLC_INTN j = n & 0x3f; + m = n >> 6; + __CLC_INTN m2 = m << EXPSHIFTBITS_SP32; + + // log2/64 lead: 0.0108032227 + const __CLC_GENTYPE R_LOG2_BY_64_LD = 0x1.620000p-7f; + // log2/64 tail: 0.0000272020388 + const __CLC_GENTYPE R_LOG2_BY_64_TL = 0x1.c85fdep-16f; + r = __clc_mad(nf, -R_LOG2_BY_64_TL, __clc_mad(nf, -R_LOG2_BY_64_LD, ylogx)) + + ylogx_t; + + // Truncated Taylor series for e^r + poly = __clc_mad(__clc_mad(__clc_mad(r, 0x1.555556p-5f, 0x1.555556p-3f), r, + 0x1.000000p-1f), + r * r, r); + + __CLC_GENTYPE exp_head = USE_TABLE(exp_tbl_ep_head, j); + __CLC_GENTYPE exp_tail = USE_TABLE(exp_tbl_ep_tail, j); + + __CLC_GENTYPE expylogx = + __clc_mad(exp_head, poly, __clc_mad(exp_tail, poly, exp_tail)) + exp_head; + __CLC_GENTYPE sexpylogx = + expylogx * __CLC_AS_GENTYPE((__CLC_INTN)0x1 << (m + 149)); + __CLC_GENTYPE texpylogx = __CLC_AS_GENTYPE(__CLC_AS_INTN(expylogx) + m2); + expylogx = m < -125 ? sexpylogx : texpylogx; + + // Result is +-Inf if (ylogx + ylogx_t) > 128*log2 + expylogx = + __clc_select(expylogx, __CLC_AS_GENTYPE((__CLC_UINTN)PINFBITPATT_SP32), + ylogx > 0x1.62e430p+6f || + (ylogx == 0x1.62e430p+6f && ylogx_t > -0x1.05c610p-22f)); + + // Result is 0 if ylogx < -149*log2 + expylogx = ylogx < -0x1.9d1da0p+6f ? 0.0f : expylogx; + + // Classify y: + // inty = 0 means not an integer. + // inty = 1 means odd integer. + // inty = 2 means even integer. + + __CLC_INTN inty = 2 - (ny & 1); + + __CLC_GENTYPE signval = + __CLC_AS_GENTYPE((__CLC_AS_UINTN(expylogx) ^ SIGNBIT_SP32)); + expylogx = ((inty == 1) && !xpos) ? signval : expylogx; + __CLC_INTN ret = __CLC_AS_INTN(expylogx); + + // Corner case handling + __CLC_BIT_INTN x_is_ninf = ix == (__CLC_INTN)NINFBITPATT_SP32; + + __CLC_INTN xinf = + xpos ? (__CLC_INTN)PINFBITPATT_SP32 : (__CLC_INTN)NINFBITPATT_SP32; + ret = ((ax == 0) && !ypos && (inty == 1)) ? xinf : ret; + ret = ((ax == 0) && !ypos && (inty == 2)) ? PINFBITPATT_SP32 : ret; + ret = ((ax == 0) && ypos && (inty == 2)) ? 0 : ret; + __CLC_INTN xzero = !xpos ? (__CLC_INTN)0x80000000 : (__CLC_INTN)0; + ret = ((ax == 0) && ypos && (inty == 1)) ? xzero : ret; + ret = (x_is_ninf && !ypos && (inty == 1)) ? (__CLC_INTN)0x80000000 : ret; + ret = (x_is_ninf && !ypos && (inty != 1)) ? 0 : ret; + ret = (x_is_ninf && ypos && (inty == 1)) ? (__CLC_INTN)NINFBITPATT_SP32 : ret; + ret = (x_is_ninf && ypos && (inty != 1)) ? (__CLC_INTN)PINFBITPATT_SP32 : ret; + ret = ((ix == PINFBITPATT_SP32) && !ypos) ? 0 : ret; + ret = ((ix == PINFBITPATT_SP32) && ypos) ? (__CLC_INTN)PINFBITPATT_SP32 : ret; + ret = ax > PINFBITPATT_SP32 ? ix : ret; + ret = ny == 0 ? 0x3f800000 : ret; + + return __CLC_AS_GENTYPE(ret); +} + +#elif __CLC_FPSIZE == 64 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_pown(__CLC_GENTYPE x, + __CLC_INTN ny) { + const __CLC_GENTYPE real_log2_tail = 5.76999904754328540596e-08; + const __CLC_GENTYPE real_log2_lead = 6.93147122859954833984e-01; + + __CLC_GENTYPE y = __CLC_CONVERT_GENTYPE(ny); + + __CLC_LONGN ux = __CLC_AS_LONGN(x); + __CLC_LONGN ax = __CLC_AS_LONGN(__clc_fabs(x)); + __CLC_BIT_INTN xpos = ax == ux; + + __CLC_LONGN uy = __CLC_AS_LONGN(y); + __CLC_LONGN ay = __CLC_AS_LONGN(__clc_fabs(y)); + __CLC_BIT_INTN ypos = ay == uy; + + // Extended precision log + __CLC_GENTYPE v, vt; + { + __CLC_INTN exp = __CLC_CONVERT_INTN(ax >> 52) - 1023; + __CLC_INTN mask_exp_1023 = exp == -1023; + __CLC_GENTYPE xexp = __CLC_CONVERT_GENTYPE(exp); + __CLC_LONGN mantissa = ax & 0x000FFFFFFFFFFFFFL; + + __CLC_LONGN temp_ux = + __CLC_AS_LONGN(__CLC_AS_GENTYPE(0x3ff0000000000000L | mantissa) - 1.0); + exp = __CLC_CONVERT_INTN((temp_ux & 0x7FF0000000000000L) >> 52) - 2045; + __CLC_GENTYPE xexp1 = __CLC_CONVERT_GENTYPE(exp); + __CLC_LONGN mantissa1 = temp_ux & 0x000FFFFFFFFFFFFFL; + + xexp = __CLC_CONVERT_LONGN(mask_exp_1023) ? xexp1 : xexp; + mantissa = __CLC_CONVERT_LONGN(mask_exp_1023) ? mantissa1 : mantissa; + + __CLC_LONGN rax = (mantissa & 0x000ff00000000000) + + ((mantissa & 0x0000080000000000) << 1); + __CLC_INTN index = __CLC_CONVERT_INTN(rax >> 44); + + __CLC_GENTYPE F = __CLC_AS_GENTYPE(rax | 0x3FE0000000000000L); + __CLC_GENTYPE Y = __CLC_AS_GENTYPE(mantissa | 0x3FE0000000000000L); + __CLC_GENTYPE f = F - Y; + __CLC_GENTYPE log_h = USE_TABLE(log_f_inv_tbl_head, index); + __CLC_GENTYPE log_t = USE_TABLE(log_f_inv_tbl_tail, index); + __CLC_GENTYPE f_inv = (log_h + log_t) * f; + __CLC_GENTYPE r1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(f_inv) & 0xfffffffff8000000L); + __CLC_GENTYPE r2 = __clc_fma(-F, r1, f) * (log_h + log_t); + __CLC_GENTYPE r = r1 + r2; + + __CLC_GENTYPE poly = __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, __clc_fma(r, 1.0 / 7.0, 1.0 / 6.0), 1.0 / 5.0), + 1.0 / 4.0), + 1.0 / 3.0); + poly = poly * r * r * r; + + __CLC_GENTYPE hr1r1 = 0.5 * r1 * r1; + __CLC_GENTYPE poly0h = r1 + hr1r1; + __CLC_GENTYPE poly0t = r1 - poly0h + hr1r1; + poly = __clc_fma(r1, r2, __clc_fma(0.5 * r2, r2, poly)) + r2 + poly0t; + + log_h = USE_TABLE(powlog_tbl_head, index); + log_t = USE_TABLE(powlog_tbl_tail, index); + + __CLC_GENTYPE resT_t = __clc_fma(xexp, real_log2_tail, +log_t) - poly; + __CLC_GENTYPE resT = resT_t - poly0h; + __CLC_GENTYPE resH = __clc_fma(xexp, real_log2_lead, log_h); + __CLC_GENTYPE resT_h = poly0h; + + __CLC_GENTYPE H = resT + resH; + __CLC_GENTYPE H_h = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(H) & 0xfffffffff8000000L); + __CLC_GENTYPE T = + (resH - H + resT) + (resT_t - (resT + resT_h)) + (H - H_h); + H = H_h; + + __CLC_GENTYPE y_head = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(uy) & 0xfffffffff8000000L); + __CLC_GENTYPE y_tail = y - y_head; + + __CLC_BIT_INTN mask_2_24 = ay > 0x4170000000000000; // 2^24 + __CLC_INTN nyh = __CLC_CONVERT_INTN(y_head); + __CLC_INTN nyt = ny - nyh; + __CLC_GENTYPE y_tail1 = __CLC_CONVERT_GENTYPE(nyt); + y_tail = mask_2_24 ? y_tail1 : y_tail; + + __CLC_GENTYPE temp = __clc_fma(y_tail, H, __clc_fma(y_head, T, y_tail * T)); + v = __clc_fma(y_head, H, temp); + vt = __clc_fma(y_head, H, -v) + temp; + } + + // Now calculate exp of (v,vt) + + __CLC_GENTYPE expv; + { + const __CLC_GENTYPE max_exp_arg = 709.782712893384; + const __CLC_GENTYPE min_exp_arg = -745.1332191019411; + const __CLC_GENTYPE sixtyfour_by_lnof2 = 92.33248261689366; + const __CLC_GENTYPE lnof2_by_64_head = 0.010830424260348081; + const __CLC_GENTYPE lnof2_by_64_tail = -4.359010638708991e-10; + + // If v is so large that we need to return INFINITY, or so small that we + // need to return 0, set v to known values that will produce that result. Do + // not try to continue the computation with the original v and patch it up + // afterwards because v may be so large that temp is out of range of int, in + // which case that conversion, and a value based on that conversion being + // passed to __clc_ldexp, results in undefined behavior. + v = v > max_exp_arg ? 1000.0 : v; + v = v < min_exp_arg ? -1000.0 : v; + + __CLC_GENTYPE temp = v * sixtyfour_by_lnof2; + __CLC_INTN n = __CLC_CONVERT_INTN(temp); + __CLC_GENTYPE dn = __CLC_CONVERT_GENTYPE(n); + __CLC_INTN j = n & 0x0000003f; + __CLC_INTN m = n >> 6; + + __CLC_GENTYPE f1 = USE_TABLE(two_to_jby64_ep_tbl_head, j); + __CLC_GENTYPE f2 = USE_TABLE(two_to_jby64_ep_tbl_tail, j); + __CLC_GENTYPE f = f1 + f2; + + __CLC_GENTYPE r1 = __clc_fma(dn, -lnof2_by_64_head, v); + __CLC_GENTYPE r2 = dn * lnof2_by_64_tail; + __CLC_GENTYPE r = (r1 + r2) + vt; + + __CLC_GENTYPE q = + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 1.38889490863777199667e-03, + 8.33336798434219616221e-03), + 4.16666666662260795726e-02), + 1.66666666665260878863e-01), + 5.00000000000000008883e-01); + q = __clc_fma(r * r, q, r); + + expv = __clc_fma(f, q, f2) + f1; + expv = __clc_ldexp(expv, m); + } + + // See whether y is an integer. + // inty = 0 means not an integer. + // inty = 1 means odd integer. + // inty = 2 means even integer. + + __CLC_LONGN inty = __CLC_CONVERT_LONGN(2 - (ny & 1)); + + expv *= ((inty == 1) && !xpos) ? -1.0 : 1.0; + + __CLC_LONGN ret = __CLC_AS_LONGN(expv); + + // Now all the edge cases + __CLC_BIT_INTN x_is_ninf = ux == (__CLC_LONGN)NINFBITPATT_DP64; + __CLC_BIT_INTN x_is_pinf = ux == (__CLC_LONGN)PINFBITPATT_DP64; + __CLC_LONGN xinf = + xpos ? (__CLC_LONGN)PINFBITPATT_DP64 : (__CLC_LONGN)NINFBITPATT_DP64; + + ret = ((ax == 0L) && !ypos && (inty == 1)) ? xinf : ret; + ret = ((ax == 0L) && !ypos && (inty == 2)) ? (__CLC_LONGN)PINFBITPATT_DP64 + : ret; + ret = ((ax == 0L) && ypos && (inty == 2)) ? 0L : ret; + __CLC_LONGN xzero = !xpos ? (__CLC_LONGN)0x8000000000000000L : 0L; + ret = ((ax == 0L) && ypos && (inty == 1)) ? xzero : ret; + ret = (x_is_ninf && !ypos && (inty == 1)) ? (__CLC_LONGN)0x8000000000000000L + : ret; + ret = (x_is_ninf && !ypos && (inty != 1)) ? 0L : ret; + ret = + (x_is_ninf && ypos && (inty == 1)) ? (__CLC_LONGN)NINFBITPATT_DP64 : ret; + ret = + (x_is_ninf && ypos && (inty != 1)) ? (__CLC_LONGN)PINFBITPATT_DP64 : ret; + ret = (x_is_pinf && !ypos) ? 0L : ret; + ret = (x_is_pinf && ypos) ? (__CLC_LONGN)PINFBITPATT_DP64 : ret; + ret = ax > (__CLC_LONGN)PINFBITPATT_DP64 ? ux : ret; + ret = __CLC_CONVERT_LONGN(ny == 0) ? (__CLC_LONGN)0x3ff0000000000000L : ret; + + return __CLC_AS_GENTYPE(ret); +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_pown(__CLC_GENTYPE x, __CLC_INTN y) { + return __CLC_CONVERT_GENTYPE(__clc_pown(__CLC_CONVERT_FLOATN(x), y)); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_powr.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_powr.cl new file mode 100644 index 0000000000..c596a552f0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_powr.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_powr.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_powr.inc new file mode 100644 index 0000000000..1244f7f6ac --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_powr.inc @@ -0,0 +1,414 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Computes pow using log and exp +// +// x^y = exp(y * log(x)) +// +// We take care not to lose precision in the intermediate steps +// +// When computing log, calculate it in splits: +// +// r = f * (p_invead + p_inv_tail) +// r = rh + rt +// +// Calculate log polynomial using r, in end addition, do: +// +// poly = poly + ((rh-r) + rt) +// +// lth = -r +// ltt = ((xexp * log2_t) - poly) + logT +// lt = lth + ltt +// +// lh = (xexp * log2_h) + logH +// l = lh + lt +// +// Calculate final log answer as gh and gt: +// +// gh = l & higher-half bits +// gt = (((ltt - (lt - lth)) + ((lh - l) + lt)) + (l - gh)) +// +// yh = y & higher-half bits +// yt = y - yh +// +// Before entering computation of exp: +// +// vs = ((yt*gt + yt*gh) + yh*gt) +// v = vs + yh*gh +// vt = ((yh*gh - v) + vs) +// +// In calculation of exp, add vt to r that is used for poly. +// +// At the end of exp, do +// +// ((((expT * poly) + expT) + expH*poly) + expH) +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_powr(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + __CLC_GENTYPE absx = __clc_fabs(x); + __CLC_INTN ix = __CLC_AS_INTN(x); + __CLC_INTN ax = __CLC_AS_INTN(absx); + __CLC_INTN xpos = ix == ax; + + __CLC_INTN iy = __CLC_AS_INTN(y); + __CLC_INTN ay = __CLC_AS_INTN(__clc_fabs(y)); + __CLC_INTN ypos = iy == ay; + + // Extra precise log calculation + // First handle case that x is close to 1 + __CLC_GENTYPE r = 1.0f - absx; + __CLC_INTN near1 = __clc_fabs(r) < 0x1.0p-4f; + __CLC_GENTYPE r2 = r * r; + + // Coefficients are just 1/3, 1/4, 1/5 and 1/6 + __CLC_GENTYPE poly = __clc_mad( + r, + __clc_mad(r, + __clc_mad(r, __clc_mad(r, 0x1.24924ap-3f, 0x1.555556p-3f), + 0x1.99999ap-3f), + 0x1.000000p-2f), + 0x1.555556p-2f); + + poly *= r2 * r; + + __CLC_GENTYPE lth_near1 = -r2 * 0.5f; + __CLC_GENTYPE ltt_near1 = -poly; + __CLC_GENTYPE lt_near1 = lth_near1 + ltt_near1; + __CLC_GENTYPE lh_near1 = -r; + __CLC_GENTYPE l_near1 = lh_near1 + lt_near1; + + // Computations for x not near 1 + __CLC_INTN m = __CLC_CONVERT_INTN(ax >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + __CLC_GENTYPE mf = __CLC_CONVERT_GENTYPE(m); + __CLC_INTN ixs = __CLC_AS_INTN(__CLC_AS_GENTYPE(ax | 0x3f800000) - 1.0f); + __CLC_GENTYPE mfs = __CLC_CONVERT_GENTYPE((ixs >> EXPSHIFTBITS_SP32) - 253); + __CLC_INTN c = m == -127; + __CLC_INTN ixn = c ? ixs : ax; + __CLC_GENTYPE mfn = c ? mfs : mf; + + __CLC_INTN indx = (ixn & 0x007f0000) + ((ixn & 0x00008000) << 1); + + // F - Y + __CLC_GENTYPE f = __CLC_AS_GENTYPE(0x3f000000 | indx) - + __CLC_AS_GENTYPE(0x3f000000 | (ixn & MANTBITS_SP32)); + + indx = indx >> 16; + __CLC_GENTYPE rh = f * USE_TABLE(log_inv_tbl_ep_head, indx); + __CLC_GENTYPE rt = f * USE_TABLE(log_inv_tbl_ep_tail, indx); + r = rh + rt; + + poly = __clc_mad(r, __clc_mad(r, 0x1.0p-2f, 0x1.555556p-2f), 0x1.0p-1f) * + (r * r); + poly += (rh - r) + rt; + + const __CLC_GENTYPE LOG2_HEAD = 0x1.62e000p-1f; // 0.693115234 + const __CLC_GENTYPE LOG2_TAIL = 0x1.0bfbe8p-15f; // 0.0000319461833 + __CLC_GENTYPE logel = USE_TABLE(loge_tbl_lo, indx); + __CLC_GENTYPE logeh = USE_TABLE(loge_tbl_hi, indx); + __CLC_GENTYPE lth = -r; + __CLC_GENTYPE ltt = __clc_mad(mfn, LOG2_TAIL, -poly) + logeh; + __CLC_GENTYPE lt = lth + ltt; + __CLC_GENTYPE lh = __clc_mad(mfn, LOG2_HEAD, logel); + __CLC_GENTYPE l = lh + lt; + + // Select near 1 or not + lth = near1 ? lth_near1 : lth; + ltt = near1 ? ltt_near1 : ltt; + lt = near1 ? lt_near1 : lt; + lh = near1 ? lh_near1 : lh; + l = near1 ? l_near1 : l; + + __CLC_GENTYPE gh = __CLC_AS_GENTYPE(__CLC_AS_UINTN(l) & 0xfffff000); + __CLC_GENTYPE gt = ((ltt - (lt - lth)) + ((lh - l) + lt)) + (l - gh); + + __CLC_GENTYPE yh = __CLC_AS_GENTYPE(__CLC_AS_UINTN(iy) & 0xfffff000); + + __CLC_GENTYPE yt = y - yh; + + __CLC_GENTYPE ylogx_s = __clc_mad(gt, yh, __clc_mad(gh, yt, yt * gt)); + __CLC_GENTYPE ylogx = __clc_mad(yh, gh, ylogx_s); + __CLC_GENTYPE ylogx_t = __clc_mad(yh, gh, -ylogx) + ylogx_s; + + // Extra precise exp of ylogx + // 64/log2 : 92.332482616893657 + const __CLC_GENTYPE R_64_BY_LOG2 = 0x1.715476p+6f; + __CLC_INTN n = __CLC_CONVERT_INTN(ylogx * R_64_BY_LOG2); + __CLC_GENTYPE nf = __CLC_CONVERT_GENTYPE(n); + + __CLC_INTN j = n & 0x3f; + m = n >> 6; + __CLC_INTN m2 = m << EXPSHIFTBITS_SP32; + // log2/64 lead: 0.0108032227 + const __CLC_GENTYPE R_LOG2_BY_64_LD = 0x1.620000p-7f; + // log2/64 tail: 0.0000272020388 + const __CLC_GENTYPE R_LOG2_BY_64_TL = 0x1.c85fdep-16f; + r = __clc_mad(nf, -R_LOG2_BY_64_TL, __clc_mad(nf, -R_LOG2_BY_64_LD, ylogx)) + + ylogx_t; + + // Truncated Taylor series for e^r + poly = __clc_mad(__clc_mad(__clc_mad(r, 0x1.555556p-5f, 0x1.555556p-3f), r, + 0x1.000000p-1f), + r * r, r); + + __CLC_GENTYPE exp_head = USE_TABLE(exp_tbl_ep_head, j); + __CLC_GENTYPE exp_tail = USE_TABLE(exp_tbl_ep_tail, j); + + __CLC_GENTYPE expylogx = + __clc_mad(exp_head, poly, __clc_mad(exp_tail, poly, exp_tail)) + exp_head; + __CLC_GENTYPE sexpylogx = + expylogx * __CLC_AS_GENTYPE((__CLC_INTN)0x1 << (m + 149)); + __CLC_GENTYPE texpylogx = __CLC_AS_GENTYPE(__CLC_AS_INTN(expylogx) + m2); + expylogx = m < -125 ? sexpylogx : texpylogx; + + // Result is +-Inf if (ylogx + ylogx_t) > 128*log2 + expylogx = + __clc_select(expylogx, __CLC_AS_GENTYPE((__CLC_UINTN)PINFBITPATT_SP32), + (ylogx > 0x1.62e430p+6f) || + (ylogx == 0x1.62e430p+6f && ylogx_t > -0x1.05c610p-22f)); + + // Result is 0 if ylogx < -149*log2 + expylogx = ylogx < -0x1.9d1da0p+6f ? 0.0f : expylogx; + + // Classify y: + // inty = 0 means not an integer. + // inty = 1 means odd integer. + // inty = 2 means even integer. + + __CLC_INTN yexp = (__CLC_INTN)(ay >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32 + 1; + __CLC_INTN mask = ((__CLC_INTN)1 << (24 - yexp)) - 1; + __CLC_INTN yodd = ((iy >> (24 - yexp)) & 0x1) != 0; + __CLC_INTN inty = yodd ? 1 : 2; + inty = (iy & mask) != 0 ? 0 : inty; + inty = yexp < 1 ? 0 : inty; + inty = yexp > 24 ? 2 : inty; + + __CLC_GENTYPE signval = + __CLC_AS_GENTYPE((__CLC_AS_UINTN(expylogx) ^ SIGNBIT_SP32)); + expylogx = ((inty == 1) && !xpos) ? signval : expylogx; + __CLC_INTN ret = __CLC_AS_INTN(expylogx); + + // Corner case handling + __CLC_BIT_INTN y_is_ninf = iy == (__CLC_INTN)NINFBITPATT_SP32; + __CLC_BIT_INTN y_is_pinf = iy == (__CLC_INTN)PINFBITPATT_SP32; + __CLC_BIT_INTN x_is_inf = ax == (__CLC_INTN)PINFBITPATT_SP32; + + ret = ax < 0x3f800000 && y_is_ninf ? PINFBITPATT_SP32 : ret; + ret = ax < 0x3f800000 && y_is_pinf ? 0 : ret; + ret = ax == 0x3f800000 && ay < PINFBITPATT_SP32 ? 0x3f800000 : ret; + ret = ax == 0x3f800000 && ay == PINFBITPATT_SP32 ? QNANBITPATT_SP32 : ret; + ret = ax > 0x3f800000 && y_is_ninf ? 0 : ret; + ret = ax > 0x3f800000 && y_is_pinf ? PINFBITPATT_SP32 : ret; + ret = ((ix < PINFBITPATT_SP32) && (ay == 0)) ? 0x3f800000 : ret; + ret = (x_is_inf && !ypos) ? 0 : ret; + ret = (x_is_inf && ypos) ? PINFBITPATT_SP32 : ret; + ret = (x_is_inf && y_is_pinf) ? PINFBITPATT_SP32 : ret; + ret = (x_is_inf && (ay == 0)) ? QNANBITPATT_SP32 : ret; + ret = ((ax == 0) && !ypos) ? PINFBITPATT_SP32 : ret; + ret = ((ax == 0) && ypos) ? 0 : ret; + ret = ((ax == 0) && (ay == 0)) ? QNANBITPATT_SP32 : ret; + ret = ((ax != 0) && !xpos) ? QNANBITPATT_SP32 : ret; + ret = ax > PINFBITPATT_SP32 ? ix : ret; + ret = ay > PINFBITPATT_SP32 ? iy : ret; + + return __CLC_AS_GENTYPE(ret); +} + +#elif __CLC_FPSIZE == 64 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_powr(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + const __CLC_GENTYPE real_log2_tail = 5.76999904754328540596e-08; + const __CLC_GENTYPE real_log2_lead = 6.93147122859954833984e-01; + + __CLC_LONGN ux = __CLC_AS_LONGN(x); + __CLC_LONGN ax = __CLC_AS_LONGN(__clc_fabs(x)); + __CLC_BIT_INTN xpos = ax == ux; + + __CLC_LONGN uy = __CLC_AS_LONGN(y); + __CLC_LONGN ay = __CLC_AS_LONGN(__clc_fabs(y)); + __CLC_BIT_INTN ypos = ay == uy; + + // Extended precision log + __CLC_GENTYPE v, vt; + { + __CLC_INTN exp = __CLC_CONVERT_INTN(ax >> 52) - 1023; + __CLC_INTN mask_exp_1023 = exp == (__CLC_INTN)-1023; + __CLC_GENTYPE xexp = __CLC_CONVERT_GENTYPE(exp); + __CLC_LONGN mantissa = ax & 0x000FFFFFFFFFFFFFL; + + __CLC_LONGN temp_ux = + __CLC_AS_LONGN(__CLC_AS_GENTYPE(0x3ff0000000000000L | mantissa) - 1.0); + exp = __CLC_CONVERT_INTN((temp_ux & 0x7FF0000000000000L) >> 52) - 2045; + __CLC_GENTYPE xexp1 = __CLC_CONVERT_GENTYPE(exp); + __CLC_LONGN mantissa1 = temp_ux & 0x000FFFFFFFFFFFFFL; + + xexp = __CLC_CONVERT_LONGN(mask_exp_1023) ? xexp1 : xexp; + mantissa = __CLC_CONVERT_LONGN(mask_exp_1023) ? mantissa1 : mantissa; + + __CLC_LONGN rax = (mantissa & 0x000ff00000000000) + + ((mantissa & 0x0000080000000000) << 1); + __CLC_INTN index = __CLC_CONVERT_INTN(rax >> 44); + + __CLC_GENTYPE F = __CLC_AS_GENTYPE(rax | 0x3FE0000000000000L); + __CLC_GENTYPE Y = __CLC_AS_GENTYPE(mantissa | 0x3FE0000000000000L); + __CLC_GENTYPE f = F - Y; + __CLC_GENTYPE log_h = USE_TABLE(log_f_inv_tbl_head, index); + __CLC_GENTYPE log_t = USE_TABLE(log_f_inv_tbl_tail, index); + __CLC_GENTYPE f_inv = (log_h + log_t) * f; + __CLC_GENTYPE r1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(f_inv) & 0xfffffffff8000000L); + __CLC_GENTYPE r2 = __clc_fma(-F, r1, f) * (log_h + log_t); + __CLC_GENTYPE r = r1 + r2; + + __CLC_GENTYPE poly = __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, __clc_fma(r, 1.0 / 7.0, 1.0 / 6.0), 1.0 / 5.0), + 1.0 / 4.0), + 1.0 / 3.0); + poly = poly * r * r * r; + + __CLC_GENTYPE hr1r1 = 0.5 * r1 * r1; + __CLC_GENTYPE poly0h = r1 + hr1r1; + __CLC_GENTYPE poly0t = r1 - poly0h + hr1r1; + poly = __clc_fma(r1, r2, __clc_fma(0.5 * r2, r2, poly)) + r2 + poly0t; + + log_h = USE_TABLE(powlog_tbl_head, index); + log_t = USE_TABLE(powlog_tbl_tail, index); + + __CLC_GENTYPE resT_t = __clc_fma(xexp, real_log2_tail, +log_t) - poly; + __CLC_GENTYPE resT = resT_t - poly0h; + __CLC_GENTYPE resH = __clc_fma(xexp, real_log2_lead, log_h); + __CLC_GENTYPE resT_h = poly0h; + + __CLC_GENTYPE H = resT + resH; + __CLC_GENTYPE H_h = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(H) & 0xfffffffff8000000L); + __CLC_GENTYPE T = + (resH - H + resT) + (resT_t - (resT + resT_h)) + (H - H_h); + H = H_h; + + __CLC_GENTYPE y_head = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(uy) & 0xfffffffff8000000L); + __CLC_GENTYPE y_tail = y - y_head; + + __CLC_GENTYPE temp = __clc_fma(y_tail, H, __clc_fma(y_head, T, y_tail * T)); + v = __clc_fma(y_head, H, temp); + vt = __clc_fma(y_head, H, -v) + temp; + } + + // Now calculate exp of (v,vt) + + __CLC_GENTYPE expv; + { + const __CLC_GENTYPE max_exp_arg = 709.782712893384; + const __CLC_GENTYPE min_exp_arg = -745.1332191019411; + const __CLC_GENTYPE sixtyfour_by_lnof2 = 92.33248261689366; + const __CLC_GENTYPE lnof2_by_64_head = 0.010830424260348081; + const __CLC_GENTYPE lnof2_by_64_tail = -4.359010638708991e-10; + + // If v is so large that we need to return INFINITY, or so small that we + // need to return 0, set v to known values that will produce that result. Do + // not try to continue the computation with the original v and patch it up + // afterwards because v may be so large that temp is out of range of int, in + // which case that conversion, and a value based on that conversion being + // passed to __clc_ldexp, results in undefined behavior. + v = v > max_exp_arg ? 1000.0 : v; + v = v < min_exp_arg ? -1000.0 : v; + + __CLC_GENTYPE temp = v * sixtyfour_by_lnof2; + __CLC_INTN n = __CLC_CONVERT_INTN(temp); + __CLC_GENTYPE dn = __CLC_CONVERT_GENTYPE(n); + __CLC_INTN j = n & 0x0000003f; + __CLC_INTN m = n >> 6; + + __CLC_GENTYPE f1 = USE_TABLE(two_to_jby64_ep_tbl_head, j); + __CLC_GENTYPE f2 = USE_TABLE(two_to_jby64_ep_tbl_tail, j); + __CLC_GENTYPE f = f1 + f2; + + __CLC_GENTYPE r1 = __clc_fma(dn, -lnof2_by_64_head, v); + __CLC_GENTYPE r2 = dn * lnof2_by_64_tail; + __CLC_GENTYPE r = (r1 + r2) + vt; + + __CLC_GENTYPE q = + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 1.38889490863777199667e-03, + 8.33336798434219616221e-03), + 4.16666666662260795726e-02), + 1.66666666665260878863e-01), + 5.00000000000000008883e-01); + q = __clc_fma(r * r, q, r); + + expv = __clc_fma(f, q, f2) + f1; + expv = __clc_ldexp(expv, m); + } + + // See whether y is an integer. + // inty = 0 means not an integer. + // inty = 1 means odd integer. + // inty = 2 means even integer. + + __CLC_LONGN inty; + { + __CLC_INTN yexp = + __CLC_CONVERT_INTN(ay >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64 + 1; + inty = __CLC_CONVERT_LONGN(yexp < 1 ? 0 : 2); + inty = __CLC_CONVERT_LONGN(yexp > 53) ? 2 : inty; + __CLC_LONGN mask = ((__CLC_LONGN)1L << (53 - yexp)) - 1L; + __CLC_LONGN inty1 = (((ay & ~mask) >> (53 - yexp)) & 1L) == 1L ? 1L : 2L; + inty1 = (ay & mask) != 0 ? 0 : inty1; + inty = __CLC_CONVERT_LONGN(!(yexp < 1) && !(yexp > 53)) ? inty1 : inty; + } + + expv *= ((inty == 1) && !xpos) ? -1.0 : 1.0; + + __CLC_LONGN ret = __CLC_AS_LONGN(expv); + + // Now all the edge cases + __CLC_BIT_INTN y_is_ninf = uy == (__CLC_LONGN)NINFBITPATT_DP64; + __CLC_BIT_INTN y_is_pinf = uy == (__CLC_LONGN)PINFBITPATT_DP64; + __CLC_BIT_INTN x_is_inf = ax == (__CLC_LONGN)PINFBITPATT_DP64; + + ret = ax < 0x3ff0000000000000L && y_is_ninf ? PINFBITPATT_DP64 : ret; + ret = ax < 0x3ff0000000000000L && y_is_pinf ? 0L : ret; + ret = ax == 0x3ff0000000000000L && ay < PINFBITPATT_DP64 ? 0x3ff0000000000000L + : ret; + ret = ax == 0x3ff0000000000000L && ay == PINFBITPATT_DP64 ? QNANBITPATT_DP64 + : ret; + ret = ax > 0x3ff0000000000000L && y_is_ninf ? 0L : ret; + ret = ax > 0x3ff0000000000000L && y_is_pinf ? PINFBITPATT_DP64 : ret; + ret = ux < PINFBITPATT_DP64 && ay == 0L ? 0x3ff0000000000000L : ret; + ret = (x_is_inf && !ypos) ? 0L : ret; + ret = (x_is_inf && ypos) ? PINFBITPATT_DP64 : ret; + ret = (x_is_inf && y_is_pinf) ? PINFBITPATT_DP64 : ret; + ret = ((ax == PINFBITPATT_DP64) && (ay == 0L)) ? QNANBITPATT_DP64 : ret; + ret = ((ax == 0L) && !ypos) ? PINFBITPATT_DP64 : ret; + ret = ((ax == 0L) && ypos) ? 0L : ret; + ret = ((ax == 0L) && (ay == 0L)) ? QNANBITPATT_DP64 : ret; + ret = ((ax != 0L) && !xpos) ? QNANBITPATT_DP64 : ret; + ret = ax > PINFBITPATT_DP64 ? ux : ret; + ret = ay > PINFBITPATT_DP64 ? uy : ret; + + return __CLC_AS_GENTYPE(ret); +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_powr(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return __CLC_CONVERT_GENTYPE( + __clc_powr(__CLC_CONVERT_FLOATN(x), __CLC_CONVERT_FLOATN(y))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_remainder.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_remainder.cl new file mode 100644 index 0000000000..2b3d185a8b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_remainder.cl @@ -0,0 +1,233 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +_CLC_DEF _CLC_OVERLOAD float __clc_remainder(float x, float y) { + int ux = __clc_as_int(x); + int ax = ux & EXSIGNBIT_SP32; + float xa = __clc_as_float(ax); + int sx = ux ^ ax; + int ex = ax >> EXPSHIFTBITS_SP32; + + int uy = __clc_as_int(y); + int ay = uy & EXSIGNBIT_SP32; + float ya = __clc_as_float(ay); + int ey = ay >> EXPSHIFTBITS_SP32; + + float xr = __clc_as_float(0x3f800000 | (ax & 0x007fffff)); + float yr = __clc_as_float(0x3f800000 | (ay & 0x007fffff)); + int c; + int k = ex - ey; + + uint q = 0; + + while (k > 0) { + c = xr >= yr; + q = (q << 1) | c; + xr -= c ? yr : 0.0f; + xr += xr; + --k; + } + + c = xr > yr; + q = (q << 1) | c; + xr -= c ? yr : 0.0f; + + int lt = ex < ey; + + q = lt ? 0 : q; + xr = lt ? xa : xr; + yr = lt ? ya : yr; + + c = (yr < 2.0f * xr) | ((yr == 2.0f * xr) & ((q & 0x1) == 0x1)); + xr -= c ? yr : 0.0f; + q += c; + + float s = __clc_as_float(ey << EXPSHIFTBITS_SP32); + xr *= lt ? 1.0f : s; + + c = ax == ay; + xr = c ? 0.0f : xr; + + xr = __clc_as_float(sx ^ __clc_as_int(xr)); + + c = ax > PINFBITPATT_SP32 | ay > PINFBITPATT_SP32 | ax == PINFBITPATT_SP32 | + ay == 0; + xr = c ? __clc_as_float(QNANBITPATT_SP32) : xr; + + return xr; +} + +#define __FLOAT_ONLY +#define FUNCTION __clc_remainder +#define __CLC_BODY +#include +#undef FUNCTION + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEF _CLC_OVERLOAD double __clc_remainder(double x, double y) { + ulong ux = __clc_as_ulong(x); + ulong ax = ux & ~SIGNBIT_DP64; + ulong xsgn = ux ^ ax; + double dx = __clc_as_double(ax); + int xexp = __clc_convert_int(ax >> EXPSHIFTBITS_DP64); + int xexp1 = 11 - (int)__clc_clz(ax & MANTBITS_DP64); + xexp1 = xexp < 1 ? xexp1 : xexp; + + ulong uy = __clc_as_ulong(y); + ulong ay = uy & ~SIGNBIT_DP64; + double dy = __clc_as_double(ay); + int yexp = __clc_convert_int(ay >> EXPSHIFTBITS_DP64); + int yexp1 = 11 - (int)__clc_clz(ay & MANTBITS_DP64); + yexp1 = yexp < 1 ? yexp1 : yexp; + + int qsgn = ((ux ^ uy) & SIGNBIT_DP64) == 0UL ? 1 : -1; + + // First assume |x| > |y| + + // Set ntimes to the number of times we need to do a + // partial remainder. If the exponent of x is an exact multiple + // of 53 larger than the exponent of y, and the mantissa of x is + // less than the mantissa of y, ntimes will be one too large + // but it doesn't matter - it just means that we'll go round + // the loop below one extra time. + int ntimes = __clc_max(0, (xexp1 - yexp1) / 53); + double w = __clc_ldexp(dy, ntimes * 53); + w = ntimes == 0 ? dy : w; + double scale = ntimes == 0 ? 1.0 : 0x1.0p-53; + + // Each time round the loop we compute a partial remainder. + // This is done by subtracting a large multiple of w + // from x each time, where w is a scaled up version of y. + // The subtraction must be performed exactly in quad + // precision, though the result at each stage can + // fit exactly in a double precision number. + int i; + double t, v, p, pp; + + for (i = 0; i < ntimes; i++) { + // Compute integral multiplier + t = __clc_trunc(dx / w); + + // Compute w * t in quad precision + p = w * t; + pp = __clc_fma(w, t, -p); + + // Subtract w * t from dx + v = dx - p; + dx = v + (((dx - v) - p) - pp); + + // If t was one too large, dx will be negative. Add back one w. + dx += dx < 0.0 ? w : 0.0; + + // Scale w down by 2^(-53) for the next iteration + w *= scale; + } + + // One more time + // Variable todd says whether the integer t is odd or not + t = __clc_floor(dx / w); + long lt = (long)t; + int todd = lt & 1; + + p = w * t; + pp = __clc_fma(w, t, -p); + v = dx - p; + dx = v + (((dx - v) - p) - pp); + i = dx < 0.0; + todd ^= i; + dx += i ? w : 0.0; + + // At this point, dx lies in the range [0,dy) + + // For the fmod function, we're done apart from setting the correct sign. + // + // For the remainder function, we need to adjust dx + // so that it lies in the range (-y/2, y/2] by carefully + // subtracting w (== dy == y) if necessary. The rigmarole + // with todd is to get the correct sign of the result + // when x/y lies exactly half way between two integers, + // when we need to choose the even integer. + + int al = (2.0 * dx > w) | (todd & (2.0 * dx == w)); + double dxl = dx - (al ? w : 0.0); + + int ag = (dx > 0.5 * w) | (todd & (dx == 0.5 * w)); + double dxg = dx - (ag ? w : 0.0); + + dx = dy < 0x1.0p+1022 ? dxl : dxg; + + double ret = __clc_as_double(xsgn ^ __clc_as_ulong(dx)); + dx = __clc_as_double(ax); + + // Now handle |x| == |y| + int c = dx == dy; + t = __clc_as_double(xsgn); + ret = c ? t : ret; + + // Next, handle |x| < |y| + c = dx < dy; + ret = c ? x : ret; + + c &= (yexp<1023 & 2.0 * dx> dy) | (dx > 0.5 * dy); + // we could use a conversion here instead since qsgn = +-1 + p = qsgn == 1 ? -1.0 : 1.0; + t = __clc_fma(y, p, x); + ret = c ? t : ret; + + // We don't need anything special for |x| == 0 + + // |y| is 0 + c = dy == 0.0; + ret = c ? __clc_as_double(QNANBITPATT_DP64) : ret; + + // y is +-Inf, NaN + c = yexp > BIASEDEMAX_DP64; + t = y == y ? x : y; + ret = c ? t : ret; + + // x is +=Inf, NaN + c = xexp > BIASEDEMAX_DP64; + ret = c ? __clc_as_double(QNANBITPATT_DP64) : ret; + + return ret; +} + +#define __DOUBLE_ONLY +#define FUNCTION __clc_remainder +#define __CLC_BODY +#include +#undef FUNCTION + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// Forward the half version of this builtin onto the float one +#define __HALF_ONLY +#define FUNCTION __clc_remainder +#define __CLC_BODY +#include + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_remquo.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_remquo.cl new file mode 100644 index 0000000000..1505d1c3fb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_remquo.cl @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_ADDRESS_SPACE private +#include +#undef __CLC_ADDRESS_SPACE + +#define __CLC_ADDRESS_SPACE global +#include +#undef __CLC_ADDRESS_SPACE + +#define __CLC_ADDRESS_SPACE local +#include +#undef __CLC_ADDRESS_SPACE + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +#define __CLC_ADDRESS_SPACE generic +#include +#undef __CLC_ADDRESS_SPACE +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_remquo.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_remquo.inc new file mode 100644 index 0000000000..28f51c4e2f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_remquo.inc @@ -0,0 +1,271 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_DEF _CLC_OVERLOAD float __clc_remquo(float x, float y, + __CLC_ADDRESS_SPACE int *quo) { + x = __clc_flush_denormal_if_not_supported(x); + y = __clc_flush_denormal_if_not_supported(y); + int ux = __clc_as_int(x); + int ax = ux & EXSIGNBIT_SP32; + float xa = __clc_as_float(ax); + int sx = ux ^ ax; + int ex = ax >> EXPSHIFTBITS_SP32; + + int uy = __clc_as_int(y); + int ay = uy & EXSIGNBIT_SP32; + float ya = __clc_as_float(ay); + int sy = uy ^ ay; + int ey = ay >> EXPSHIFTBITS_SP32; + + float xr = __clc_as_float(0x3f800000 | (ax & 0x007fffff)); + float yr = __clc_as_float(0x3f800000 | (ay & 0x007fffff)); + int c; + int k = ex - ey; + + uint q = 0; + + while (k > 0) { + c = xr >= yr; + q = (q << 1) | c; + xr -= c ? yr : 0.0f; + xr += xr; + --k; + } + + c = xr > yr; + q = (q << 1) | c; + xr -= c ? yr : 0.0f; + + int lt = ex < ey; + + q = lt ? 0 : q; + xr = lt ? xa : xr; + yr = lt ? ya : yr; + + c = (yr < 2.0f * xr) | ((yr == 2.0f * xr) & ((q & 0x1) == 0x1)); + xr -= c ? yr : 0.0f; + q += c; + + float s = __clc_as_float(ey << EXPSHIFTBITS_SP32); + xr *= lt ? 1.0f : s; + + int qsgn = sx == sy ? 1 : -1; + int quot = (q & 0x7f) * qsgn; + + c = ax == ay; + quot = c ? qsgn : quot; + xr = c ? 0.0f : xr; + + xr = __clc_as_float(sx ^ __clc_as_int(xr)); + + c = ax > PINFBITPATT_SP32 | ay > PINFBITPATT_SP32 | ax == PINFBITPATT_SP32 | + ay == 0; + quot = c ? 0 : quot; + xr = c ? __clc_as_float(QNANBITPATT_SP32) : xr; + + *quo = quot; + + return xr; +} + +// remquo signature is special, we don't have macro for this +#define __VEC_REMQUO(TYPE, VEC_SIZE, HALF_VEC_SIZE) \ + _CLC_DEF _CLC_OVERLOAD TYPE##VEC_SIZE __clc_remquo( \ + TYPE##VEC_SIZE x, TYPE##VEC_SIZE y, \ + __CLC_ADDRESS_SPACE int##VEC_SIZE *quo) { \ + int##HALF_VEC_SIZE lo, hi; \ + TYPE##VEC_SIZE ret; \ + ret.lo = __clc_remquo(x.lo, y.lo, &lo); \ + ret.hi = __clc_remquo(x.hi, y.hi, &hi); \ + (*quo).lo = lo; \ + (*quo).hi = hi; \ + return ret; \ + } + +#define __VEC3_REMQUO(TYPE) \ + _CLC_DEF _CLC_OVERLOAD TYPE##3 __clc_remquo( \ + TYPE##3 x, TYPE##3 y, __CLC_ADDRESS_SPACE int##3 * quo) { \ + int2 lo; \ + int hi; \ + TYPE##3 ret; \ + ret.s01 = __clc_remquo(x.s01, y.s01, &lo); \ + ret.s2 = __clc_remquo(x.s2, y.s2, &hi); \ + (*quo).s01 = lo; \ + (*quo).s2 = hi; \ + return ret; \ + } +__VEC_REMQUO(float, 2, ) +__VEC3_REMQUO(float) +__VEC_REMQUO(float, 4, 2) +__VEC_REMQUO(float, 8, 4) +__VEC_REMQUO(float, 16, 8) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEF _CLC_OVERLOAD double __clc_remquo(double x, double y, + __CLC_ADDRESS_SPACE int *pquo) { + ulong ux = __clc_as_ulong(x); + ulong ax = ux & ~SIGNBIT_DP64; + ulong xsgn = ux ^ ax; + double dx = __clc_as_double(ax); + int xexp = __clc_convert_int(ax >> EXPSHIFTBITS_DP64); + int xexp1 = 11 - (int)__clc_clz(ax & MANTBITS_DP64); + xexp1 = xexp < 1 ? xexp1 : xexp; + + ulong uy = __clc_as_ulong(y); + ulong ay = uy & ~SIGNBIT_DP64; + double dy = __clc_as_double(ay); + int yexp = __clc_convert_int(ay >> EXPSHIFTBITS_DP64); + int yexp1 = 11 - (int)__clc_clz(ay & MANTBITS_DP64); + yexp1 = yexp < 1 ? yexp1 : yexp; + + int qsgn = ((ux ^ uy) & SIGNBIT_DP64) == 0UL ? 1 : -1; + + // First assume |x| > |y| + + // Set ntimes to the number of times we need to do a + // partial remainder. If the exponent of x is an exact multiple + // of 53 larger than the exponent of y, and the mantissa of x is + // less than the mantissa of y, ntimes will be one too large + // but it doesn't matter - it just means that we'll go round + // the loop below one extra time. + int ntimes = __clc_max(0, (xexp1 - yexp1) / 53); + double w = __clc_ldexp(dy, ntimes * 53); + w = ntimes == 0 ? dy : w; + double scale = ntimes == 0 ? 1.0 : 0x1.0p-53; + + // Each time round the loop we compute a partial remainder. + // This is done by subtracting a large multiple of w + // from x each time, where w is a scaled up version of y. + // The subtraction must be performed exactly in quad + // precision, though the result at each stage can + // fit exactly in a double precision number. + int i; + double t, v, p, pp; + + for (i = 0; i < ntimes; i++) { + // Compute integral multiplier + t = __clc_trunc(dx / w); + + // Compute w * t in quad precision + p = w * t; + pp = __clc_fma(w, t, -p); + + // Subtract w * t from dx + v = dx - p; + dx = v + (((dx - v) - p) - pp); + + // If t was one too large, dx will be negative. Add back one w. + dx += dx < 0.0 ? w : 0.0; + + // Scale w down by 2^(-53) for the next iteration + w *= scale; + } + + // One more time + // Variable todd says whether the integer t is odd or not + t = __clc_floor(dx / w); + long lt = (long)t; + int todd = lt & 1; + + p = w * t; + pp = __clc_fma(w, t, -p); + v = dx - p; + dx = v + (((dx - v) - p) - pp); + i = dx < 0.0; + todd ^= i; + dx += i ? w : 0.0; + + lt -= i; + + // At this point, dx lies in the range [0,dy) + + // For the remainder function, we need to adjust dx + // so that it lies in the range (-y/2, y/2] by carefully + // subtracting w (== dy == y) if necessary. The rigmarole + // with todd is to get the correct sign of the result + // when x/y lies exactly half way between two integers, + // when we need to choose the even integer. + + int al = (2.0 * dx > w) | (todd & (2.0 * dx == w)); + double dxl = dx - (al ? w : 0.0); + + int ag = (dx > 0.5 * w) | (todd & (dx == 0.5 * w)); + double dxg = dx - (ag ? w : 0.0); + + dx = dy < 0x1.0p+1022 ? dxl : dxg; + lt += dy < 0x1.0p+1022 ? al : ag; + int quo = ((int)lt & 0x7f) * qsgn; + + double ret = __clc_as_double(xsgn ^ __clc_as_ulong(dx)); + dx = __clc_as_double(ax); + + // Now handle |x| == |y| + int c = dx == dy; + t = __clc_as_double(xsgn); + quo = c ? qsgn : quo; + ret = c ? t : ret; + + // Next, handle |x| < |y| + c = dx < dy; + quo = c ? 0 : quo; + ret = c ? x : ret; + + c &= (yexp < 1023 & 2.0 * dx > dy) | (dx > 0.5 * dy); + quo = c ? qsgn : quo; + // we could use a conversion here instead since qsgn = +-1 + p = qsgn == 1 ? -1.0 : 1.0; + t = __clc_fma(y, p, x); + ret = c ? t : ret; + + // We don't need anything special for |x| == 0 + + // |y| is 0 + c = dy == 0.0; + quo = c ? 0 : quo; + ret = c ? __clc_as_double(QNANBITPATT_DP64) : ret; + + // y is +-Inf, NaN + c = yexp > BIASEDEMAX_DP64; + quo = c ? 0 : quo; + t = y == y ? x : y; + ret = c ? t : ret; + + // x is +=Inf, NaN + c = xexp > BIASEDEMAX_DP64; + quo = c ? 0 : quo; + ret = c ? __clc_as_double(QNANBITPATT_DP64) : ret; + + *pquo = quo; + return ret; +} +__VEC_REMQUO(double, 2, ) +__VEC3_REMQUO(double) +__VEC_REMQUO(double, 4, 2) +__VEC_REMQUO(double, 8, 4) +__VEC_REMQUO(double, 16, 8) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DEF half __clc_remquo(half x, half y, + __CLC_ADDRESS_SPACE int *pquo) { + return (half)__clc_remquo((float)x, (float)y, pquo); +} +__VEC_REMQUO(half, 2, ) +__VEC3_REMQUO(half) +__VEC_REMQUO(half, 4, 2) +__VEC_REMQUO(half, 8, 4) +__VEC_REMQUO(half, 16, 8) + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rint.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rint.cl new file mode 100644 index 0000000000..b3f94490e3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rint.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define FUNCTION __clc_rint +#define __IMPL_FUNCTION(x) __builtin_elementwise_rint +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rootn.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rootn.cl new file mode 100644 index 0000000000..da397cf66d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rootn.cl @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rootn.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rootn.inc new file mode 100644 index 0000000000..996f88f145 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rootn.inc @@ -0,0 +1,404 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Computes pow using log and exp +// +// x^y = exp(y * log(x)) +// +// We take care not to lose precision in the intermediate steps. +// +// When computing log, calculate it in splits: +// +// r = f * (p_invead + p_inv_tail) +// r = rh + rt +// +// Calculate log polynomial using r, in end addition, do: +// +// poly = poly + ((rh-r) + rt) +// +// lth = -r +// ltt = ((xexp * log2_t) - poly) + logT +// lt = lth + ltt +// +// lh = (xexp * log2_h) + logH +// l = lh + lt +// +// Calculate final log answer as gh and gt: +// +// gh = l & higher-half bits +// gt = (((ltt - (lt - lth)) + ((lh - l) + lt)) + (l - gh)) +// +// yh = y & higher-half bits +// yt = y - yh +// +// Before entering computation of exp: +// +// vs = ((yt*gt + yt*gh) + yh*gt) +// v = vs + yh*gh +// vt = ((yh*gh - v) + vs) +// +// In calculation of exp, add vt to r that is used for poly. +// +// At the end of exp, do: +// +// ((((expT * poly) + expT) + expH*poly) + expH) +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_rootn(__CLC_GENTYPE x, + __CLC_INTN ny) { + __CLC_GENTYPE y = MATH_RECIP(__CLC_CONVERT_GENTYPE(ny)); + + __CLC_INTN ix = __CLC_AS_INTN(x); + __CLC_INTN ax = ix & EXSIGNBIT_SP32; + __CLC_INTN xpos = ix == ax; + + __CLC_INTN iy = __CLC_AS_INTN(y); + __CLC_INTN ay = iy & EXSIGNBIT_SP32; + __CLC_INTN ypos = iy == ay; + + // Extra precise log calculation + // First handle case that x is close to 1 + __CLC_GENTYPE r = 1.0f - __CLC_AS_GENTYPE(ax); + __CLC_INTN near1 = __clc_fabs(r) < 0x1.0p-4f; + __CLC_GENTYPE r2 = r * r; + + // Coefficients are just 1/3, 1/4, 1/5 and 1/6 + __CLC_GENTYPE poly = __clc_mad( + r, + __clc_mad(r, + __clc_mad(r, __clc_mad(r, 0x1.24924ap-3f, 0x1.555556p-3f), + 0x1.99999ap-3f), + 0x1.000000p-2f), + 0x1.555556p-2f); + + poly *= r2 * r; + + __CLC_GENTYPE lth_near1 = -r2 * 0.5f; + __CLC_GENTYPE ltt_near1 = -poly; + __CLC_GENTYPE lt_near1 = lth_near1 + ltt_near1; + __CLC_GENTYPE lh_near1 = -r; + __CLC_GENTYPE l_near1 = lh_near1 + lt_near1; + + // Computations for x not near 1 + __CLC_INTN m = __CLC_CONVERT_INTN(ax >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + __CLC_GENTYPE mf = __CLC_CONVERT_GENTYPE(m); + __CLC_INTN ixs = __CLC_AS_INTN(__CLC_AS_GENTYPE(ax | 0x3f800000) - 1.0f); + __CLC_GENTYPE mfs = __CLC_CONVERT_GENTYPE((ixs >> EXPSHIFTBITS_SP32) - 253); + __CLC_INTN c = m == -127; + __CLC_INTN ixn = c ? ixs : ax; + __CLC_GENTYPE mfn = c ? mfs : mf; + + __CLC_INTN indx = (ixn & 0x007f0000) + ((ixn & 0x00008000) << 1); + + // F - Y + __CLC_GENTYPE f = __CLC_AS_GENTYPE(0x3f000000 | indx) - + __CLC_AS_GENTYPE(0x3f000000 | (ixn & MANTBITS_SP32)); + + indx = indx >> 16; + __CLC_GENTYPE rh = f * USE_TABLE(log_inv_tbl_ep_head, indx); + __CLC_GENTYPE rt = f * USE_TABLE(log_inv_tbl_ep_tail, indx); + ; + r = rh + rt; + + poly = __clc_mad(r, __clc_mad(r, 0x1.0p-2f, 0x1.555556p-2f), 0x1.0p-1f) * + (r * r); + poly += (rh - r) + rt; + + const __CLC_GENTYPE LOG2_HEAD = 0x1.62e000p-1f; // 0.693115234 + const __CLC_GENTYPE LOG2_TAIL = 0x1.0bfbe8p-15f; // 0.0000319461833 + __CLC_GENTYPE lth = -r; + __CLC_GENTYPE ltt = + __clc_mad(mfn, LOG2_TAIL, -poly) + USE_TABLE(loge_tbl_hi, indx); + __CLC_GENTYPE lt = lth + ltt; + __CLC_GENTYPE lh = __clc_mad(mfn, LOG2_HEAD, USE_TABLE(loge_tbl_lo, indx)); + __CLC_GENTYPE l = lh + lt; + + // Select near 1 or not + lth = near1 ? lth_near1 : lth; + ltt = near1 ? ltt_near1 : ltt; + lt = near1 ? lt_near1 : lt; + lh = near1 ? lh_near1 : lh; + l = near1 ? l_near1 : l; + + __CLC_GENTYPE gh = __CLC_AS_GENTYPE(__CLC_AS_UINTN(l) & 0xfffff000); + __CLC_GENTYPE gt = ((ltt - (lt - lth)) + ((lh - l) + lt)) + (l - gh); + + __CLC_GENTYPE yh = __CLC_AS_GENTYPE(__CLC_AS_UINTN(iy) & 0xfffff000); + + __CLC_GENTYPE fny = __CLC_CONVERT_GENTYPE(ny); + __CLC_GENTYPE fnyh = __CLC_AS_GENTYPE(__CLC_AS_UINTN(fny) & 0xfffff000); + __CLC_GENTYPE fnyt = __CLC_CONVERT_GENTYPE(ny - __CLC_CONVERT_INTN(fnyh)); + __CLC_GENTYPE yt = + MATH_DIVIDE(__clc_mad(-fnyt, yh, __clc_mad(-fnyh, yh, 1.0f)), fny); + + __CLC_GENTYPE ylogx_s = __clc_mad(gt, yh, __clc_mad(gh, yt, yt * gt)); + __CLC_GENTYPE ylogx = __clc_mad(yh, gh, ylogx_s); + __CLC_GENTYPE ylogx_t = __clc_mad(yh, gh, -ylogx) + ylogx_s; + + // Extra precise exp of ylogx + const __CLC_GENTYPE R_64_BY_LOG2 = + 0x1.715476p+6f; // 64/log2 : 92.332482616893657 + __CLC_INTN n = __CLC_CONVERT_INTN(ylogx * R_64_BY_LOG2); + __CLC_GENTYPE nf = __CLC_CONVERT_GENTYPE(n); + + __CLC_INTN j = n & 0x3f; + m = n >> 6; + __CLC_INTN m2 = m << EXPSHIFTBITS_SP32; + + // log2/64 lead: 0.0108032227 + const __CLC_GENTYPE R_LOG2_BY_64_LD = 0x1.620000p-7f; + // log2/64 tail: 0.0000272020388 + const __CLC_GENTYPE R_LOG2_BY_64_TL = 0x1.c85fdep-16f; + r = __clc_mad(nf, -R_LOG2_BY_64_TL, __clc_mad(nf, -R_LOG2_BY_64_LD, ylogx)) + + ylogx_t; + + // Truncated Taylor series for e^r + poly = __clc_mad(__clc_mad(__clc_mad(r, 0x1.555556p-5f, 0x1.555556p-3f), r, + 0x1.000000p-1f), + r * r, r); + + __CLC_GENTYPE exph = USE_TABLE(exp_tbl_ep_head, j); + __CLC_GENTYPE expt = USE_TABLE(exp_tbl_ep_tail, j); + + __CLC_GENTYPE expylogx = + __clc_mad(exph, poly, __clc_mad(expt, poly, expt)) + exph; + __CLC_GENTYPE sexpylogx = + __clc_fp32_subnormals_supported() + ? expylogx * __CLC_AS_GENTYPE((__CLC_INTN)0x1 << (m + 149)) + : 0.0f; + + __CLC_GENTYPE texpylogx = __CLC_AS_GENTYPE(__CLC_AS_INTN(expylogx) + m2); + expylogx = m < -125 ? sexpylogx : texpylogx; + + // Result is +-Inf if (ylogx + ylogx_t) > 128*log2 + expylogx = ((ylogx > 0x1.62e430p+6f) | + (ylogx == 0x1.62e430p+6f & ylogx_t > -0x1.05c610p-22f)) + ? __CLC_AS_GENTYPE((__CLC_UINTN)PINFBITPATT_SP32) + : expylogx; + + // Result is 0 if ylogx < -149*log2 + expylogx = ylogx < -0x1.9d1da0p+6f ? 0.0f : expylogx; + + // Classify y: + // inty = 0 means not an integer. + // inty = 1 means odd integer. + // inty = 2 means even integer. + + __CLC_INTN inty = 2 - (ny & 1); + + __CLC_GENTYPE signval = + __CLC_AS_GENTYPE((__CLC_AS_UINTN(expylogx) ^ SIGNBIT_SP32)); + expylogx = ((inty == 1) & !xpos) ? signval : expylogx; + __CLC_INTN ret = __CLC_AS_INTN(expylogx); + + // Corner case handling + __CLC_BIT_INTN x_is_ninf = ix == (__CLC_INTN)NINFBITPATT_SP32; + __CLC_BIT_INTN x_is_pinf = ix == (__CLC_INTN)PINFBITPATT_SP32; + + ret = (!xpos & (inty == 2)) ? __CLC_AS_INTN(__CLC_GENTYPE_NAN) : ret; + __CLC_INTN xinf = + xpos ? (__CLC_INTN)PINFBITPATT_SP32 : (__CLC_INTN)NINFBITPATT_SP32; + ret = ((ax == 0) & !ypos & (inty == 1)) ? xinf : ret; + ret = ((ax == 0) & !ypos & (inty == 2)) ? PINFBITPATT_SP32 : ret; + ret = ((ax == 0) & ypos & (inty == 2)) ? 0 : ret; + __CLC_INTN xzero = xpos ? 0 : (__CLC_INTN)0x80000000; + ret = ((ax == 0) & ypos & (inty == 1)) ? xzero : ret; + ret = (x_is_ninf & ypos & (inty == 1)) ? (__CLC_INTN)NINFBITPATT_SP32 : ret; + ret = (x_is_ninf & !ypos & (inty == 1)) ? (__CLC_INTN)0x80000000 : ret; + ret = (x_is_pinf & !ypos) ? 0 : ret; + ret = (x_is_pinf & ypos) ? PINFBITPATT_SP32 : ret; + ret = ax > PINFBITPATT_SP32 ? ix : ret; + ret = ny == 0 ? __CLC_AS_INTN(__CLC_GENTYPE_NAN) : ret; + + return __CLC_AS_GENTYPE(ret); +} + +#elif __CLC_FPSIZE == 64 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_rootn(__CLC_GENTYPE x, + __CLC_INTN ny) { + const __CLC_GENTYPE real_log2_tail = 5.76999904754328540596e-08; + const __CLC_GENTYPE real_log2_lead = 6.93147122859954833984e-01; + + __CLC_GENTYPE dny = __CLC_CONVERT_GENTYPE(ny); + __CLC_GENTYPE y = 1.0 / dny; + + __CLC_LONGN ux = __CLC_AS_LONGN(x); + __CLC_LONGN ax = __CLC_AS_LONGN(__clc_fabs(x)); + __CLC_BIT_INTN xpos = ax == ux; + + __CLC_LONGN uy = __CLC_AS_LONGN(y); + __CLC_LONGN ay = __CLC_AS_LONGN(__clc_fabs(y)); + __CLC_BIT_INTN ypos = ay == uy; + + // Extended precision log + __CLC_GENTYPE v, vt; + { + __CLC_INTN exp = __CLC_CONVERT_INTN(ax >> 52) - 1023; + __CLC_INTN mask_exp_1023 = exp == -1023; + __CLC_GENTYPE xexp = __CLC_CONVERT_GENTYPE(exp); + __CLC_LONGN mantissa = ax & 0x000FFFFFFFFFFFFFL; + + __CLC_LONGN temp_ux = + __CLC_AS_LONGN(__CLC_AS_GENTYPE(0x3ff0000000000000L | mantissa) - 1.0); + exp = __CLC_CONVERT_INTN((temp_ux & 0x7FF0000000000000L) >> 52) - 2045; + __CLC_GENTYPE xexp1 = __CLC_CONVERT_GENTYPE(exp); + __CLC_LONGN mantissa1 = temp_ux & 0x000FFFFFFFFFFFFFL; + + xexp = __CLC_CONVERT_LONGN(mask_exp_1023) ? xexp1 : xexp; + mantissa = __CLC_CONVERT_LONGN(mask_exp_1023) ? mantissa1 : mantissa; + + __CLC_LONGN rax = (mantissa & 0x000ff00000000000) + + ((mantissa & 0x0000080000000000) << 1); + __CLC_INTN index = __CLC_CONVERT_INTN(rax >> 44); + + __CLC_GENTYPE F = __CLC_AS_GENTYPE(rax | 0x3FE0000000000000L); + __CLC_GENTYPE Y = __CLC_AS_GENTYPE(mantissa | 0x3FE0000000000000L); + __CLC_GENTYPE f = F - Y; + __CLC_GENTYPE log_h = USE_TABLE(log_f_inv_tbl_head, index); + __CLC_GENTYPE log_t = USE_TABLE(log_f_inv_tbl_tail, index); + __CLC_GENTYPE f_inv = (log_h + log_t) * f; + __CLC_GENTYPE r1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(f_inv) & 0xfffffffff8000000L); + __CLC_GENTYPE r2 = __clc_fma(-F, r1, f) * (log_h + log_t); + __CLC_GENTYPE r = r1 + r2; + + __CLC_GENTYPE poly = __clc_fma( + r, + __clc_fma(r, + __clc_fma(r, __clc_fma(r, 1.0 / 7.0, 1.0 / 6.0), 1.0 / 5.0), + 1.0 / 4.0), + 1.0 / 3.0); + poly = poly * r * r * r; + + __CLC_GENTYPE hr1r1 = 0.5 * r1 * r1; + __CLC_GENTYPE poly0h = r1 + hr1r1; + __CLC_GENTYPE poly0t = r1 - poly0h + hr1r1; + poly = __clc_fma(r1, r2, __clc_fma(0.5 * r2, r2, poly)) + r2 + poly0t; + + log_h = USE_TABLE(powlog_tbl_head, index); + log_t = USE_TABLE(powlog_tbl_tail, index); + + __CLC_GENTYPE resT_t = __clc_fma(xexp, real_log2_tail, +log_t) - poly; + __CLC_GENTYPE resT = resT_t - poly0h; + __CLC_GENTYPE resH = __clc_fma(xexp, real_log2_lead, log_h); + __CLC_GENTYPE resT_h = poly0h; + + __CLC_GENTYPE H = resT + resH; + __CLC_GENTYPE H_h = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(H) & 0xfffffffff8000000L); + __CLC_GENTYPE T = + (resH - H + resT) + (resT_t - (resT + resT_h)) + (H - H_h); + H = H_h; + + __CLC_GENTYPE y_head = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(uy) & 0xfffffffff8000000L); + __CLC_GENTYPE y_tail = y - y_head; + + __CLC_GENTYPE fnyh = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(dny) & 0xfffffffffff00000); + __CLC_GENTYPE fnyt = __CLC_CONVERT_GENTYPE(ny - __CLC_CONVERT_INTN(fnyh)); + y_tail = __clc_fma(-fnyt, y_head, __clc_fma(-fnyh, y_head, 1.0)) / dny; + + __CLC_GENTYPE temp = __clc_fma(y_tail, H, __clc_fma(y_head, T, y_tail * T)); + v = __clc_fma(y_head, H, temp); + vt = __clc_fma(y_head, H, -v) + temp; + } + + // Now calculate exp of (v,vt) + + __CLC_GENTYPE expv; + { + const __CLC_GENTYPE max_exp_arg = 709.782712893384; + const __CLC_GENTYPE min_exp_arg = -745.1332191019411; + const __CLC_GENTYPE sixtyfour_by_lnof2 = 92.33248261689366; + const __CLC_GENTYPE lnof2_by_64_head = 0.010830424260348081; + const __CLC_GENTYPE lnof2_by_64_tail = -4.359010638708991e-10; + + // If v is so large that we need to return INFINITY, or so small that we + // need to return 0, set v to known values that will produce that result. Do + // not try to continue the computation with the original v and patch it up + // afterwards because v may be so large that temp is out of range of int, in + // which case that conversion, and a value based on that conversion being + // passed to __clc_ldexp, results in undefined behavior. + v = v > max_exp_arg ? 1000.0 : v; + v = v < min_exp_arg ? -1000.0 : v; + + __CLC_GENTYPE temp = v * sixtyfour_by_lnof2; + __CLC_INTN n = __CLC_CONVERT_INTN(temp); + __CLC_GENTYPE dn = __CLC_CONVERT_GENTYPE(n); + __CLC_INTN j = n & 0x0000003f; + __CLC_INTN m = n >> 6; + + __CLC_GENTYPE f1 = USE_TABLE(two_to_jby64_ep_tbl_head, j); + __CLC_GENTYPE f2 = USE_TABLE(two_to_jby64_ep_tbl_tail, j); + __CLC_GENTYPE f = f1 + f2; + + __CLC_GENTYPE r1 = __clc_fma(dn, -lnof2_by_64_head, v); + __CLC_GENTYPE r2 = dn * lnof2_by_64_tail; + __CLC_GENTYPE r = (r1 + r2) + vt; + + __CLC_GENTYPE q = + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, + __clc_fma(r, 1.38889490863777199667e-03, + 8.33336798434219616221e-03), + 4.16666666662260795726e-02), + 1.66666666665260878863e-01), + 5.00000000000000008883e-01); + q = __clc_fma(r * r, q, r); + + expv = __clc_fma(f, q, f2) + f1; + expv = __clc_ldexp(expv, m); + } + + // See whether y is an integer. + // inty = 0 means not an integer. + // inty = 1 means odd integer. + // inty = 2 means even integer. + + __CLC_LONGN inty = __CLC_CONVERT_LONGN(2 - (ny & 1)); + + expv *= ((inty == 1) & !xpos) ? -1.0 : 1.0; + + __CLC_LONGN ret = __CLC_AS_LONGN(expv); + + // Now all the edge cases + __CLC_BIT_INTN x_is_ninf = ux == (__CLC_LONGN)NINFBITPATT_DP64; + __CLC_BIT_INTN x_is_pinf = ux == (__CLC_LONGN)PINFBITPATT_DP64; + ret = (!xpos & (inty == 2)) ? __CLC_AS_LONGN(__CLC_GENTYPE_NAN) : ret; + __CLC_LONGN xinf = + xpos ? (__CLC_LONGN)PINFBITPATT_DP64 : (__CLC_LONGN)NINFBITPATT_DP64; + ret = ((ax == 0L) & !ypos & (inty == 1)) ? xinf : ret; + ret = + ((ax == 0L) & !ypos & (inty == 2)) ? (__CLC_LONGN)PINFBITPATT_DP64 : ret; + ret = ((ax == 0L) & ypos & (inty == 2)) ? 0L : ret; + __CLC_LONGN xzero = xpos ? 0L : (__CLC_LONGN)0x8000000000000000L; + ret = ((ax == 0L) & ypos & (inty == 1)) ? xzero : ret; + ret = (x_is_ninf & ypos & (inty == 1)) ? (__CLC_LONGN)NINFBITPATT_DP64 : ret; + ret = (x_is_ninf & !ypos & (inty == 1)) ? (__CLC_LONGN)0x8000000000000000L + : ret; + ret = (x_is_pinf & !ypos) ? 0L : ret; + ret = (x_is_pinf & ypos) ? (__CLC_LONGN)PINFBITPATT_DP64 : ret; + ret = ax > (__CLC_LONGN)PINFBITPATT_DP64 ? ux : ret; + ret = __CLC_CONVERT_LONGN(ny == 0) ? __CLC_AS_LONGN(__CLC_GENTYPE_NAN) : ret; + return __CLC_AS_GENTYPE(ret); +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_rootn(__CLC_GENTYPE x, + __CLC_INTN y) { + return __CLC_CONVERT_GENTYPE(__clc_rootn(__CLC_CONVERT_FLOATN(x), y)); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_round.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_round.cl new file mode 100644 index 0000000000..8c298d8c34 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_round.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define FUNCTION __clc_round +#define __IMPL_FUNCTION(x) __builtin_elementwise_round +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rsqrt.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rsqrt.cl new file mode 100644 index 0000000000..92a3d06f46 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rsqrt.cl @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rsqrt.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rsqrt.inc new file mode 100644 index 0000000000..4c04155a93 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_rsqrt.inc @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +__attribute__((weak)) _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE +__clc_rsqrt(__CLC_GENTYPE val) { +#pragma clang fp contract(fast) + return __CLC_FP_LIT(1.0) / __builtin_elementwise_sqrt(val); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sin.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sin.cl new file mode 100644 index 0000000000..0ff9739c6a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sin.cl @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sin.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sin.inc new file mode 100644 index 0000000000..b4f72eb625 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sin.inc @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_FLOATN __clc_sin(__CLC_FLOATN x) { + __CLC_FLOATN absx = __clc_fabs(x); + + __CLC_FLOATN r0, r1; + __CLC_INTN regn = __clc_argReductionS(&r0, &r1, absx); + + __CLC_FLOATN ss = __clc_sinf_piby4(r0, r1); + __CLC_FLOATN cc = __clc_cosf_piby4(r0, r1); + + __CLC_FLOATN s = (regn & 1) != 0 ? cc : ss; + s = __CLC_AS_FLOATN(__CLC_AS_INTN(s) ^ ((regn > 1) << 31) ^ + (__CLC_AS_INTN(x) ^ __CLC_AS_INTN(absx))); + + s = __clc_select(s, __CLC_GENTYPE_NAN, __clc_isnan(x) || __clc_isinf(x)); + + // Subnormals + s = x == 0.0f ? x : s; + + return s; +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_sin(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_sin(__CLC_CONVERT_FLOATN(x))); +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_sin(__CLC_GENTYPE x) { + __CLC_GENTYPE absx = __clc_fabs(x); + + __CLC_BIT_INTN is_medium = absx < 0x1.0p+47; + + __CLC_INTN regn_m, regn_l; + __CLC_GENTYPE r_m, r_l, rr_m, rr_l; + + __clc_remainder_piby2_medium(absx, &r_m, &rr_m, ®n_m); + __clc_remainder_piby2_large(absx, &r_l, &rr_l, ®n_l); + + __CLC_GENTYPE r = is_medium ? r_m : r_l; + __CLC_GENTYPE rr = is_medium ? rr_m : rr_l; + __CLC_INTN regn = __CLC_CONVERT_INTN(is_medium) ? regn_m : regn_l; + + __CLC_GENTYPE sinval, cosval; + __clc_sincos_piby4(r, rr, &sinval, &cosval); + + __CLC_LONGN s = + __CLC_AS_LONGN(__CLC_CONVERT_BIT_INTN((regn & 1) != 0) ? cosval : sinval); + + s ^= (__CLC_CONVERT_BIT_INTN(regn > 1) << 63) ^ + (__CLC_CONVERT_BIT_INTN(x < 0.0) << 63); + + return __clc_isinf(x) | __clc_isnan(x) ? __CLC_GENTYPE_NAN + : __CLC_AS_GENTYPE(s); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos.cl new file mode 100644 index 0000000000..2209a41593 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos.inc new file mode 100644 index 0000000000..da5059bfe7 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos.inc @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#define __CLC_DECLARE_SINCOS(ADDRSPACE, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE __clc_sincos(TYPE x, ADDRSPACE TYPE *cosval) { \ + *cosval = __clc_cos(x); \ + return __clc_sin(x); \ + } + +__CLC_DECLARE_SINCOS(global, __CLC_GENTYPE) +__CLC_DECLARE_SINCOS(local, __CLC_GENTYPE) +__CLC_DECLARE_SINCOS(private, __CLC_GENTYPE) +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +__CLC_DECLARE_SINCOS(generic, __CLC_GENTYPE) +#endif + +#undef __CLC_DECLARE_SINCOS diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos_helpers.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos_helpers.cl new file mode 100644 index 0000000000..0ea1195fff --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos_helpers.cl @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define bitalign(hi, lo, shift) ((hi) << (32 - (shift))) | ((lo) >> (shift)); + +#define FULL_MUL(A, B, HI, LO) \ + LO = A * B; \ + HI = __clc_mul_hi(A, B) + +#define FULL_MAD(A, B, C, HI, LO) \ + LO = ((A) * (B) + (C)); \ + HI = __clc_mul_hi(A, B); \ + HI += LO < C ? 1U : 0U; + +#define __FLOAT_ONLY +#define __CLC_BODY + +#include + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +#include +#include +#include + +#define bytealign(src0, src1, src2) \ + (__CLC_CONVERT_UINTN( \ + ((__CLC_CONVERT_LONGN((src0)) << 32) | __CLC_CONVERT_LONGN((src1))) >> \ + (((src2) & 3) * 8))) + +#define __DOUBLE_ONLY +#define __CLC_BODY + +#include + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos_helpers.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos_helpers.inc new file mode 100644 index 0000000000..29c742136b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos_helpers.inc @@ -0,0 +1,323 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_DEF _CLC_OVERLOAD __CLC_FLOATN __clc_sinf_piby4(__CLC_FLOATN x, + __CLC_FLOATN y) { + // Taylor series for sin(x) is x - x^3/3! + x^5/5! - x^7/7! ... + // = x * (1 - x^2/3! + x^4/5! - x^6/7! ... + // = x * f(w) + // where w = x*x and f(w) = (1 - w/3! + w^2/5! - w^3/7! ... + // We use a minimax approximation of (f(w) - 1) / w + // because this produces an expansion in even powers of x. + + const __CLC_FLOATN c1 = -0.1666666666e0f; + const __CLC_FLOATN c2 = 0.8333331876e-2f; + const __CLC_FLOATN c3 = -0.198400874e-3f; + const __CLC_FLOATN c4 = 0.272500015e-5f; + const __CLC_FLOATN c5 = -2.5050759689e-08f; // 0xb2d72f34 + const __CLC_FLOATN c6 = 1.5896910177e-10f; // 0x2f2ec9d3 + + __CLC_FLOATN z = x * x; + __CLC_FLOATN v = z * x; + __CLC_FLOATN r = __clc_mad( + z, __clc_mad(z, __clc_mad(z, __clc_mad(z, c6, c5), c4), c3), c2); + __CLC_FLOATN ret = + x - __clc_mad(v, -c1, __clc_mad(z, __clc_mad(y, 0.5f, -v * r), -y)); + + return ret; +} + +_CLC_DEF _CLC_OVERLOAD __CLC_FLOATN __clc_cosf_piby4(__CLC_FLOATN x, + __CLC_FLOATN y) { + // Taylor series for cos(x) is 1 - x^2/2! + x^4/4! - x^6/6! ... + // = f(w) + // where w = x*x and f(w) = (1 - w/2! + w^2/4! - w^3/6! ... + // We use a minimax approximation of (f(w) - 1 + w/2) / (w*w) + // because this produces an expansion in even powers of x. + + const __CLC_FLOATN c1 = 0.416666666e-1f; + const __CLC_FLOATN c2 = -0.138888876e-2f; + const __CLC_FLOATN c3 = 0.248006008e-4f; + const __CLC_FLOATN c4 = -0.2730101334e-6f; + const __CLC_FLOATN c5 = 2.0875723372e-09f; // 0x310f74f6 + const __CLC_FLOATN c6 = -1.1359647598e-11f; // 0xad47d74e + + __CLC_FLOATN z = x * x; + __CLC_FLOATN r = + z * + __clc_mad( + z, + __clc_mad(z, __clc_mad(z, __clc_mad(z, __clc_mad(z, c6, c5), c4), c3), + c2), + c1); + + // if |x| < 0.3 + __CLC_FLOATN qx = 0.0f; + + __CLC_INTN ix = __CLC_AS_INTN(x) & EXSIGNBIT_SP32; + + // 0.78125 > |x| >= 0.3 + __CLC_FLOATN xby4 = __CLC_AS_FLOATN(ix - 0x01000000); + qx = ((ix >= 0x3e99999a) & (ix <= 0x3f480000)) ? xby4 : qx; + + // x > 0.78125 + qx = ix > 0x3f480000 ? 0.28125f : qx; + + __CLC_FLOATN hz = __clc_mad(z, 0.5f, -qx); + __CLC_FLOATN a = 1.0f - qx; + __CLC_FLOATN ret = a - (hz - __clc_mad(z, r, -x * y)); + return ret; +} + +_CLC_DECL _CLC_OVERLOAD __CLC_FLOATN __clc_tanf_piby4(__CLC_FLOATN x, + __CLC_INTN regn) { + // Core Remez [1,2] approximation to tan(x) on the interval [0,pi/4]. + __CLC_FLOATN r = x * x; + + __CLC_FLOATN a = + __clc_mad(r, -0.0172032480471481694693109f, 0.385296071263995406715129f); + + __CLC_FLOATN b = __clc_mad( + r, + __clc_mad(r, 0.01844239256901656082986661f, -0.51396505478854532132342f), + 1.15588821434688393452299f); + + __CLC_FLOATN t = __clc_mad(x * r, __clc_native_divide(a, b), x); + __CLC_FLOATN tr = -MATH_RECIP(t); + + return (regn & 1) != 0 ? tr : t; +} + +_CLC_DEF _CLC_OVERLOAD void __clc_fullMulS(private __CLC_FLOATN *hi, + private __CLC_FLOATN *lo, + __CLC_FLOATN a, __CLC_FLOATN b, + __CLC_FLOATN bh, __CLC_FLOATN bt) { + if (__CLC_HAVE_HW_FMA32()) { + __CLC_FLOATN ph = a * b; + *hi = ph; + *lo = __clc_fma(a, b, -ph); + } else { + __CLC_FLOATN ah = __CLC_AS_FLOATN(__CLC_AS_UINTN(a) & 0xfffff000U); + __CLC_FLOATN at = a - ah; + __CLC_FLOATN ph = a * b; + __CLC_FLOATN pt = __clc_mad( + at, bt, __clc_mad(at, bh, __clc_mad(ah, bt, __clc_mad(ah, bh, -ph)))); + *hi = ph; + *lo = pt; + } +} + +_CLC_DEF _CLC_OVERLOAD __CLC_FLOATN __clc_removePi2S(private __CLC_FLOATN *hi, + private __CLC_FLOATN *lo, + __CLC_FLOATN x) { + // 72 bits of pi/2 + const __CLC_FLOATN fpiby2_1 = (__CLC_FLOATN)0xC90FDA / 0x1.0p+23f; + const __CLC_FLOATN fpiby2_1_h = (__CLC_FLOATN)0xC90 / 0x1.0p+11f; + const __CLC_FLOATN fpiby2_1_t = (__CLC_FLOATN)0xFDA / 0x1.0p+23f; + + const __CLC_FLOATN fpiby2_2 = (__CLC_FLOATN)0xA22168 / 0x1.0p+47f; + const __CLC_FLOATN fpiby2_2_h = (__CLC_FLOATN)0xA22 / 0x1.0p+35f; + const __CLC_FLOATN fpiby2_2_t = (__CLC_FLOATN)0x168 / 0x1.0p+47f; + + const __CLC_FLOATN fpiby2_3 = (__CLC_FLOATN)0xC234C4 / 0x1.0p+71f; + const __CLC_FLOATN fpiby2_3_h = (__CLC_FLOATN)0xC23 / 0x1.0p+59f; + const __CLC_FLOATN fpiby2_3_t = (__CLC_FLOATN)0x4C4 / 0x1.0p+71f; + + const __CLC_FLOATN twobypi = 0x1.45f306p-1f; + + __CLC_FLOATN fnpi2 = __clc_trunc(__clc_mad(x, twobypi, 0.5f)); + + // subtract n * pi/2 from x + __CLC_FLOATN rhead, rtail; + __clc_fullMulS(&rhead, &rtail, fnpi2, fpiby2_1, fpiby2_1_h, fpiby2_1_t); + __CLC_FLOATN v = x - rhead; + __CLC_FLOATN rem = v + (((x - v) - rhead) - rtail); + + __CLC_FLOATN rhead2, rtail2; + __clc_fullMulS(&rhead2, &rtail2, fnpi2, fpiby2_2, fpiby2_2_h, fpiby2_2_t); + v = rem - rhead2; + rem = v + (((rem - v) - rhead2) - rtail2); + + __CLC_FLOATN rhead3, rtail3; + __clc_fullMulS(&rhead3, &rtail3, fnpi2, fpiby2_3, fpiby2_3_h, fpiby2_3_t); + v = rem - rhead3; + + *hi = v + ((rem - v) - rhead3); + *lo = -rtail3; + return fnpi2; +} + +_CLC_DEF _CLC_OVERLOAD __CLC_INTN __clc_argReductionSmallS( + private __CLC_FLOATN *r, private __CLC_FLOATN *rr, __CLC_FLOATN x) { + __CLC_FLOATN fnpi2 = __clc_removePi2S(r, rr, x); + return __CLC_CONVERT_INTN(fnpi2) & 0x3; +} + +_CLC_DEF _CLC_OVERLOAD __CLC_INTN __clc_argReductionLargeS( + private __CLC_FLOATN *r, private __CLC_FLOATN *rr, __CLC_FLOATN x) { + __CLC_INTN xe = __CLC_AS_INTN((__CLC_AS_UINTN(x) >> 23) - 127); + __CLC_UINTN xm = 0x00800000U | (__CLC_AS_UINTN(x) & 0x7fffffU); + + // 224 bits of 2/PI: . A2F9836E 4E441529 FC2757D1 F534DDC0 DB629599 3C439041 + // FE5163AB + const __CLC_UINTN b6 = 0xA2F9836EU; + const __CLC_UINTN b5 = 0x4E441529U; + const __CLC_UINTN b4 = 0xFC2757D1U; + const __CLC_UINTN b3 = 0xF534DDC0U; + const __CLC_UINTN b2 = 0xDB629599U; + const __CLC_UINTN b1 = 0x3C439041U; + const __CLC_UINTN b0 = 0xFE5163ABU; + + __CLC_UINTN p0, p1, p2, p3, p4, p5, p6, p7, c0, c1; + + FULL_MUL(xm, b0, c0, p0); + FULL_MAD(xm, b1, c0, c1, p1); + FULL_MAD(xm, b2, c1, c0, p2); + FULL_MAD(xm, b3, c0, c1, p3); + FULL_MAD(xm, b4, c1, c0, p4); + FULL_MAD(xm, b5, c0, c1, p5); + FULL_MAD(xm, b6, c1, p7, p6); + + __CLC_UINTN fbits = (__CLC_UINTN)224 + (__CLC_UINTN)23 - __CLC_AS_UINTN(xe); + + // shift amount to get 2 lsb of integer part at top 2 bits + // min: 25 (xe=18) max: 134 (xe=127) + __CLC_UINTN shift = 256U - 2 - fbits; + + // Shift by up to 134/32 = 4 words + __CLC_INTN c = shift > 31; + p7 = c ? p6 : p7; + p6 = c ? p5 : p6; + p5 = c ? p4 : p5; + p4 = c ? p3 : p4; + p3 = c ? p2 : p3; + p2 = c ? p1 : p2; + p1 = c ? p0 : p1; + shift -= (c ? 32U : 0U); + + c = shift > 31; + p7 = c ? p6 : p7; + p6 = c ? p5 : p6; + p5 = c ? p4 : p5; + p4 = c ? p3 : p4; + p3 = c ? p2 : p3; + p2 = c ? p1 : p2; + shift -= (c ? 32U : 0U); + + c = shift > 31; + p7 = c ? p6 : p7; + p6 = c ? p5 : p6; + p5 = c ? p4 : p5; + p4 = c ? p3 : p4; + p3 = c ? p2 : p3; + shift -= (c ? 32U : 0U); + + c = shift > 31; + p7 = c ? p6 : p7; + p6 = c ? p5 : p6; + p5 = c ? p4 : p5; + p4 = c ? p3 : p4; + shift -= (c ? 32U : 0U); + + // bitalign cannot handle a shift of 32 + c = shift > 0; + shift = 32 - shift; + __CLC_UINTN t7 = bitalign(p7, p6, shift); + __CLC_UINTN t6 = bitalign(p6, p5, shift); + __CLC_UINTN t5 = bitalign(p5, p4, shift); + p7 = c ? t7 : p7; + p6 = c ? t6 : p6; + p5 = c ? t5 : p5; + + // Get 2 lsb of int part and msb of fraction + __CLC_INTN i = __CLC_AS_INTN(p7 >> 29U); + + // Scoot up 2 more bits so only fraction remains + p7 = bitalign(p7, p6, 30); + p6 = bitalign(p6, p5, 30); + p5 = bitalign(p5, p4, 30); + + // Subtract 1 if msb of fraction is 1, i.e. fraction >= 0.5 + __CLC_UINTN flip = (i & 1) != 0 ? 0xFFFFFFFFU : 0U; + __CLC_UINTN sign = (i & 1) != 0 ? 0x80000000U : 0U; + p7 = p7 ^ flip; + p6 = p6 ^ flip; + p5 = p5 ^ flip; + + // Find exponent and shift away leading zeroes and hidden bit + xe = __CLC_AS_INTN(__clc_clz(p7)) + 1; + shift = 32 - __CLC_AS_UINTN(xe); + p7 = bitalign(p7, p6, shift); + p6 = bitalign(p6, p5, shift); + + // Most significant part of fraction + __CLC_FLOATN q1 = + __CLC_AS_FLOATN(sign | ((127U - __CLC_AS_UINTN(xe)) << 23U) | p7 >> 9); + + // Shift out bits we captured on q1 + p7 = bitalign(p7, p6, 32 - 23); + + // Get 24 more bits of fraction in another float, there are not long strings + // of zeroes here + __CLC_INTN xxe = __CLC_AS_INTN(__clc_clz(p7)) + 1; + p7 = bitalign(p7, p6, 32 - xxe); + __CLC_FLOATN q0 = __CLC_AS_FLOATN( + sign | ((127U - __CLC_AS_UINTN(xe + 23 + xxe)) << 23U) | p7 >> 9); + + // At this point, the fraction q1 + q0 is correct to at least 48 bits + // Now we need to multiply the fraction by pi/2 + // This loses us about 4 bits + // pi/2 = C90 FDA A22 168 C23 4C4 + + const __CLC_FLOATN pio2h = (__CLC_FLOATN)0xc90fda / 0x1.0p+23f; + const __CLC_FLOATN pio2hh = (__CLC_FLOATN)0xc90 / 0x1.0p+11f; + const __CLC_FLOATN pio2ht = (__CLC_FLOATN)0xfda / 0x1.0p+23f; + const __CLC_FLOATN pio2t = (__CLC_FLOATN)0xa22168 / 0x1.0p+47f; + + __CLC_FLOATN rh, rt; + + if (__CLC_HAVE_HW_FMA32()) { + rh = q1 * pio2h; + rt = __clc_fma(q0, pio2h, __clc_fma(q1, pio2t, __clc_fma(q1, pio2h, -rh))); + } else { + __CLC_FLOATN q1h = __CLC_AS_FLOATN(__CLC_AS_UINTN(q1) & 0xfffff000); + __CLC_FLOATN q1t = q1 - q1h; + rh = q1 * pio2h; + rt = __clc_mad( + q1t, pio2ht, + __clc_mad(q1t, pio2hh, + __clc_mad(q1h, pio2ht, __clc_mad(q1h, pio2hh, -rh)))); + rt = __clc_mad(q0, pio2h, __clc_mad(q1, pio2t, rt)); + } + + __CLC_FLOATN t = rh + rt; + rt = rt - (t - rh); + + *r = t; + *rr = rt; + return ((i >> 1) + (i & 1)) & 0x3; +} + +_CLC_DEF _CLC_OVERLOAD __CLC_INTN __clc_argReductionS(private __CLC_FLOATN *r, + private __CLC_FLOATN *rr, + __CLC_FLOATN x) { + __CLC_INTN is_small = x < (__CLC_FLOATN)0x1.0p+23f; +#ifdef __CLC_SCALAR + if (is_small) + return __clc_argReductionSmallS(r, rr, x); + else + return __clc_argReductionLargeS(r, rr, x); +#else + __CLC_FLOATN r1, rr1, r2, rr2; + __CLC_INTN ret1 = __clc_argReductionSmallS(&r1, &rr1, x); + __CLC_INTN ret2 = __clc_argReductionLargeS(&r2, &rr2, x); + *r = is_small ? r1 : r2; + *rr = is_small ? rr1 : rr2; + return is_small ? ret1 : ret2; +#endif +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos_helpers_fp64.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos_helpers_fp64.inc new file mode 100644 index 0000000000..9b5776d9b0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sincos_helpers_fp64.inc @@ -0,0 +1,235 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// Reduction for medium sized arguments +_CLC_DEF _CLC_OVERLOAD void +__clc_remainder_piby2_medium(__CLC_DOUBLEN x, private __CLC_DOUBLEN *r, + private __CLC_DOUBLEN *rr, + private __CLC_INTN *regn) { + // How many pi/2 is x a multiple of? + const __CLC_DOUBLEN two_by_pi = 0x1.45f306dc9c883p-1; + __CLC_DOUBLEN dnpi2 = __clc_trunc(__clc_fma(x, two_by_pi, 0.5)); + + const __CLC_DOUBLEN piby2_h = -7074237752028440.0 / 0x1.0p+52; + const __CLC_DOUBLEN piby2_m = -2483878800010755.0 / 0x1.0p+105; + const __CLC_DOUBLEN piby2_t = -3956492004828932.0 / 0x1.0p+158; + + // Compute product of npi2 with 159 bits of 2/pi + __CLC_DOUBLEN p_hh = piby2_h * dnpi2; + __CLC_DOUBLEN p_ht = __clc_fma(piby2_h, dnpi2, -p_hh); + __CLC_DOUBLEN p_mh = piby2_m * dnpi2; + __CLC_DOUBLEN p_mt = __clc_fma(piby2_m, dnpi2, -p_mh); + __CLC_DOUBLEN p_th = piby2_t * dnpi2; + __CLC_DOUBLEN p_tt = __clc_fma(piby2_t, dnpi2, -p_th); + + // Reduce to 159 bits + __CLC_DOUBLEN ph = p_hh; + __CLC_DOUBLEN pm = p_ht + p_mh; + __CLC_DOUBLEN t = p_mh - (pm - p_ht); + __CLC_DOUBLEN pt = p_th + t + p_mt + p_tt; + t = ph + pm; + pm = pm - (t - ph); + ph = t; + t = pm + pt; + pt = pt - (t - pm); + pm = t; + + // Subtract from x + t = x + ph; + __CLC_DOUBLEN qh = t + pm; + __CLC_DOUBLEN qt = pm - (qh - t) + pt; + + *r = qh; + *rr = qt; + *regn = __CLC_CONVERT_INTN(__CLC_CONVERT_LONGN(dnpi2)) & 0x3; +} + +// Given positive argument x, reduce it to the range [-pi/4,pi/4] using +// extra precision, and return the result in r, rr. +// Return value "regn" tells how many lots of pi/2 were subtracted +// from x to put it in the range [-pi/4,pi/4], mod 4. +_CLC_DEF _CLC_OVERLOAD void +__clc_remainder_piby2_large(__CLC_DOUBLEN x, private __CLC_DOUBLEN *r, + private __CLC_DOUBLEN *rr, + private __CLC_INTN *regn) { + + __CLC_LONGN ux = __CLC_AS_LONGN(x); + __CLC_INTN e = __CLC_CONVERT_INTN(ux >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64; + __CLC_INTN i = __clc_max(23, (e >> 3) + 17); + __CLC_INTN j = 150 - i; + __CLC_INTN j16 = j & ~0xf; + __CLC_DOUBLEN fract_temp; + + // The following extracts 192 consecutive bits of 2/pi aligned on an arbitrary + // byte boundary + __CLC_ULONGN q0 = USE_TABLE(pibits_tbl, j16); + __CLC_ULONGN q1 = USE_TABLE(pibits_tbl, (j16 + 8)); + __CLC_ULONGN q2 = USE_TABLE(pibits_tbl, (j16 + 16)); + __CLC_ULONGN q3 = USE_TABLE(pibits_tbl, (j16 + 24)); + __CLC_ULONGN q4 = USE_TABLE(pibits_tbl, (j16 + 32)); + + __CLC_UINTN q0s0 = __CLC_CONVERT_UINTN(q0); + __CLC_UINTN q0s1 = __CLC_CONVERT_UINTN(q0 >> 32); + + __CLC_UINTN q1s0 = __CLC_CONVERT_UINTN(q1); + __CLC_UINTN q1s1 = __CLC_CONVERT_UINTN(q1 >> 32); + + __CLC_UINTN q2s0 = __CLC_CONVERT_UINTN(q2); + __CLC_UINTN q2s1 = __CLC_CONVERT_UINTN(q2 >> 32); + + __CLC_UINTN q3s0 = __CLC_CONVERT_UINTN(q3); + __CLC_UINTN q3s1 = __CLC_CONVERT_UINTN(q3 >> 32); + + __CLC_UINTN q4s0 = __CLC_CONVERT_UINTN(q4); + __CLC_UINTN q4s1 = __CLC_CONVERT_UINTN(q4 >> 32); + + __CLC_INTN k = (j >> 2) & 0x3; + __CLC_INTN c0 = k == 0; + __CLC_INTN c1 = k == 1; + __CLC_INTN c2 = k == 2; + __CLC_INTN c3 = k == 3; + + __CLC_UINTN u0, u1, u2, u3, u4, u5, u6; + + u0 = c1 ? q0s1 : q0s0; + u0 = c2 ? q1s0 : u0; + u0 = c3 ? q1s1 : u0; + + u1 = c1 ? q1s0 : q0s1; + u1 = c2 ? q1s1 : u1; + u1 = c3 ? q2s0 : u1; + + u2 = c1 ? q1s1 : q1s0; + u2 = c2 ? q2s0 : u2; + u2 = c3 ? q2s1 : u2; + + u3 = c1 ? q2s0 : q1s1; + u3 = c2 ? q2s1 : u3; + u3 = c3 ? q3s0 : u3; + + u4 = c1 ? q2s1 : q2s0; + u4 = c2 ? q3s0 : u4; + u4 = c3 ? q3s1 : u4; + + u5 = c1 ? q3s0 : q2s1; + u5 = c2 ? q3s1 : u5; + u5 = c3 ? q4s0 : u5; + + u6 = c1 ? q3s1 : q3s0; + u6 = c2 ? q4s0 : u6; + u6 = c3 ? q4s1 : u6; + + __CLC_UINTN v0 = bytealign(u1, u0, j); + __CLC_UINTN v1 = bytealign(u2, u1, j); + __CLC_UINTN v2 = bytealign(u3, u2, j); + __CLC_UINTN v3 = bytealign(u4, u3, j); + __CLC_UINTN v4 = bytealign(u5, u4, j); + __CLC_UINTN v5 = bytealign(u6, u5, j); + + // Place those 192 bits in 4 48-bit doubles along with correct exponent + // If i > 1018 we would get subnormals so we scale p up and x down to get the + // same product + i = 2 + 8 * i; + x *= __CLC_CONVERT_BIT_INTN(i > 1018) ? 0x1.0p-136 : 1.0; + i -= i > 1018 ? 136 : 0; + +#define doublen_lohi(x, y) \ + __CLC_AS_DOUBLEN(__CLC_CONVERT_ULONGN((x)) & 0xFFFFFFFF | \ + __CLC_CONVERT_ULONGN((y)) << 32) + + __CLC_UINTN ua = __CLC_CONVERT_UINTN(EXPBIAS_DP64 + EXPSHIFTBITS_DP64 - i) + << 20; + __CLC_DOUBLEN a = doublen_lohi((__CLC_ULONGN)0, ua); + __CLC_DOUBLEN p0 = doublen_lohi(v0, ua | (v1 & 0xffffU)) - a; + ua += 0x03000000U; + a = doublen_lohi((__CLC_ULONGN)0, ua); + __CLC_DOUBLEN p1 = + doublen_lohi(((v2 << 16) | (v1 >> 16)), (ua | (v2 >> 16))) - a; + ua += 0x03000000U; + a = doublen_lohi((__CLC_ULONGN)0, ua); + __CLC_DOUBLEN p2 = doublen_lohi(v3, (ua | (v4 & 0xffffU))) - a; + ua += 0x03000000U; + a = doublen_lohi((__CLC_ULONGN)0, ua); + __CLC_DOUBLEN p3 = + doublen_lohi(((v5 << 16) | (v4 >> 16)), (ua | (v5 >> 16))) - a; + +#undef doublen_lohi + + // Exact multiply + __CLC_DOUBLEN f0h = p0 * x; + __CLC_DOUBLEN f0l = __clc_fma(p0, x, -f0h); + __CLC_DOUBLEN f1h = p1 * x; + __CLC_DOUBLEN f1l = __clc_fma(p1, x, -f1h); + __CLC_DOUBLEN f2h = p2 * x; + __CLC_DOUBLEN f2l = __clc_fma(p2, x, -f2h); + __CLC_DOUBLEN f3h = p3 * x; + __CLC_DOUBLEN f3l = __clc_fma(p3, x, -f3h); + + // Accumulate product into 4 doubles + __CLC_DOUBLEN s, t; + + __CLC_DOUBLEN f3 = f3h + f2h; + t = f2h - (f3 - f3h); + s = f3l + t; + t = t - (s - f3l); + + __CLC_DOUBLEN f2 = s + f1h; + t = f1h - (f2 - s) + t; + s = f2l + t; + t = t - (s - f2l); + + __CLC_DOUBLEN f1 = s + f0h; + t = f0h - (f1 - s) + t; + s = f1l + t; + + __CLC_DOUBLEN f0 = s + f0l; + + // Strip off unwanted large integer bits + f3 = 0x1.0p+10 * __clc_fract(f3 * 0x1.0p-10, &fract_temp); + f3 += f3 + f2 < 0.0 ? 0x1.0p+10 : 0.0; + + // Compute least significant integer bits + t = f3 + f2; + __CLC_DOUBLEN di = t - __clc_fract(t, &fract_temp); + i = __CLC_CONVERT_INTN(__CLC_CONVERT_FLOATN(di)); + + // Shift out remaining integer part + f3 -= di; + s = f3 + f2; + t = f2 - (s - f3); + f3 = s; + f2 = t; + s = f2 + f1; + t = f1 - (s - f2); + f2 = s; + f1 = t; + f1 += f0; + + // Subtract 1 if fraction is >= 0.5, and update regn + __CLC_INTN g = __CLC_CONVERT_INTN(f3 >= 0.5 ? 1L : 0L); + i += g; + f3 -= __CLC_CONVERT_DOUBLEN(__CLC_CONVERT_FLOATN(g)); + + // Shift up bits + s = f3 + f2; + t = f2 - (s - f3); + f3 = s; + f2 = t + f1; + + // Multiply precise fraction by pi/2 to get radians + const __CLC_DOUBLEN p2h = 7074237752028440.0 / 0x1.0p+52; + const __CLC_DOUBLEN p2t = 4967757600021510.0 / 0x1.0p+106; + + __CLC_DOUBLEN rhi = f3 * p2h; + __CLC_DOUBLEN rlo = + __clc_fma(f2, p2h, __clc_fma(f3, p2t, __clc_fma(f3, p2h, -rhi))); + + *r = rhi + rlo; + *rr = rlo - (*r - rhi); + *regn = i & 0x3; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinh.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinh.cl new file mode 100644 index 0000000000..bd0b488b16 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinh.cl @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinh.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinh.inc new file mode 100644 index 0000000000..799cc32105 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinh.inc @@ -0,0 +1,201 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_sinh(__CLC_GENTYPE x) { + // After dealing with special cases the computation is split into regions as + // follows. abs(x) >= max_sinh_arg: sinh(x) = sign(x)*Inf abs(x) >= + // small_threshold: sinh(x) = sign(x)*exp(abs(x))/2 computed using the + // splitexp and scaleDouble functions as for exp_amd(). abs(x) < + // small_threshold: compute p = exp(y) - 1 and then z = 0.5*(p+(p/(p+1.0))) + // sinh(x) is then sign(x)*z. + + const __CLC_GENTYPE max_sinh_arg = 0x1.65a9fap+6f; + const __CLC_GENTYPE small_threshold = 0x1.0a2b24p+3f; + + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_GENTYPE y = __clc_fabs(x); + __CLC_UINTN aux = __CLC_AS_UINTN(y); + __CLC_UINTN xs = ux ^ aux; + + // We find the integer part y0 of y and the increment dy = y - y0. We then + // compute z = sinh(y) = sinh(y0)cosh(dy) + cosh(y0)sinh(dy) where sinh(y0) + // and cosh(y0) are tabulated above. + __CLC_INTN ind = __CLC_CONVERT_INTN(y); + ind = __CLC_CONVERT_UINTN(ind) > 36U ? 0 : ind; + + __CLC_GENTYPE dy = y - __CLC_CONVERT_GENTYPE(ind); + __CLC_GENTYPE dy2 = dy * dy; + + __CLC_GENTYPE sdy = __clc_mad( + dy2, + __clc_mad( + dy2, + __clc_mad( + dy2, + __clc_mad( + dy2, + __clc_mad(dy2, + __clc_mad(dy2, 0.7746188980094184251527126e-12f, + 0.160576793121939886190847e-9f), + 0.250521176994133472333666e-7f), + 0.275573191913636406057211e-5f), + 0.198412698413242405162014e-3f), + 0.833333333333329931873097e-2f), + 0.166666666666666667013899e0f); + sdy = __clc_mad(sdy, dy * dy2, dy); + + __CLC_GENTYPE cdy = __clc_mad( + dy2, + __clc_mad( + dy2, + __clc_mad( + dy2, + __clc_mad( + dy2, + __clc_mad(dy2, + __clc_mad(dy2, 0.1163921388172173692062032e-10f, + 0.208744349831471353536305e-8f), + 0.275573350756016588011357e-6f), + 0.248015872460622433115785e-4f), + 0.138888888889814854814536e-2f), + 0.416666666666660876512776e-1f), + 0.500000000000000005911074e0f); + cdy = __clc_mad(cdy, dy2, 1.0f); + + __CLC_GENTYPE sinhcoshh = USE_TABLE(sinhcosh_tbl_head, ind); + __CLC_GENTYPE sinhcosht = USE_TABLE(sinhcosh_tbl_tail, ind); + __CLC_GENTYPE z = __clc_mad(sinhcosht, sdy, sinhcoshh * cdy); + z = __CLC_AS_GENTYPE(xs | __CLC_AS_UINTN(z)); + + // When y is large enough so that the negative exponential is negligible, + // so sinh(y) is approximated by sign(x)*exp(y)/2. + __CLC_GENTYPE t = __clc_exp(y - 0x1.62e500p-1f); + __CLC_GENTYPE zsmall = __clc_mad(0x1.a0210ep-18f, t, t); + zsmall = __CLC_AS_GENTYPE(xs | __CLC_AS_UINTN(zsmall)); + z = y >= small_threshold ? zsmall : z; + + // Corner cases + __CLC_GENTYPE zinf = __CLC_AS_GENTYPE(PINFBITPATT_SP32 | xs); + z = y >= max_sinh_arg ? zinf : z; + z = aux > PINFBITPATT_SP32 || aux < 0x38800000U ? x : z; + + return z; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_sinh(__CLC_GENTYPE x) { + // After dealing with special cases the computation is split into + // regions as follows: + // + // abs(x) >= max_sinh_arg: + // sinh(x) = sign(x)*Inf + // + // abs(x) >= small_threshold: + // sinh(x) = sign(x)*exp(abs(x))/2 computed using the + // splitexp and scaleDouble functions as for exp_amd(). + // + // abs(x) < small_threshold: + // compute p = exp(y) - 1 and then z = 0.5*(p+(p/(p+1.0))) + // sinh(x) is then sign(x)*z. + + // 0x408633ce8fb9f87e + const __CLC_GENTYPE max_sinh_arg = 7.10475860073943977113e+02; + + // This is where exp(-x) is insignificant compared to exp(x) = ln(2^27) + const __CLC_GENTYPE small_threshold = 0x1.2b708872320e2p+4; + + __CLC_GENTYPE y = __clc_fabs(x); + + // In this range we find the integer part y0 of y + // and the increment dy = y - y0. We then compute + // z = sinh(y) = sinh(y0)cosh(dy) + cosh(y0)sinh(dy) + // where sinh(y0) and cosh(y0) are obtained from tables + + __CLC_INTN ind = __clc_min(__CLC_CONVERT_INTN(y), 36); + __CLC_GENTYPE dy = y - __CLC_CONVERT_GENTYPE(ind); + __CLC_GENTYPE dy2 = dy * dy; + + __CLC_GENTYPE sdy = + dy * dy2 * + __clc_fma( + dy2, + __clc_fma( + dy2, + __clc_fma( + dy2, + __clc_fma( + dy2, + __clc_fma(dy2, + __clc_fma(dy2, 0.7746188980094184251527126e-12, + 0.160576793121939886190847e-9), + 0.250521176994133472333666e-7), + 0.275573191913636406057211e-5), + 0.198412698413242405162014e-3), + 0.833333333333329931873097e-2), + 0.166666666666666667013899e0); + + __CLC_GENTYPE cdy = + dy2 * + __clc_fma( + dy2, + __clc_fma( + dy2, + __clc_fma( + dy2, + __clc_fma( + dy2, + __clc_fma(dy2, + __clc_fma(dy2, 0.1163921388172173692062032e-10, + 0.208744349831471353536305e-8), + 0.275573350756016588011357e-6), + 0.248015872460622433115785e-4), + 0.138888888889814854814536e-2), + 0.416666666666660876512776e-1), + 0.500000000000000005911074e0); + + // At this point sinh(dy) is approximated by dy + sdy. + // Shift some significant bits from dy to sdy. + __CLC_GENTYPE sdy1 = + __CLC_AS_GENTYPE(__CLC_AS_ULONGN(dy) & 0xfffffffff8000000UL); + __CLC_GENTYPE sdy2 = sdy + (dy - sdy1); + + __CLC_GENTYPE cl = USE_TABLE(cosh_tbl_head, ind); + __CLC_GENTYPE ct = USE_TABLE(cosh_tbl_tail, ind); + __CLC_GENTYPE sl = USE_TABLE(sinh_tbl_head, ind); + __CLC_GENTYPE st = USE_TABLE(sinh_tbl_tail, ind); + + __CLC_GENTYPE z = + __clc_fma(cl, sdy1, + __clc_fma(sl, cdy, + __clc_fma(cl, sdy2, + __clc_fma(ct, sdy1, + __clc_fma(st, cdy, ct * sdy2)) + + st))) + + sl; + + // Other cases + z = (y < 0x1.0p-28) || __clc_isnan(x) || __clc_isinf(x) ? y : z; + + __CLC_GENTYPE t = __clc_exp(y - 0x1.62e42fefa3800p-1); + t = __clc_fma(t, -0x1.ef35793c76641p-45, t); + z = y >= small_threshold ? t : z; + z = y >= max_sinh_arg ? __CLC_AS_GENTYPE((__CLC_ULONGN)PINFBITPATT_DP64) : z; + + return __clc_copysign(z, x); +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_sinh(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_sinh(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinpi.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinpi.cl new file mode 100644 index 0000000000..6cff247707 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinpi.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinpi.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinpi.inc new file mode 100644 index 0000000000..264609aeac --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sinpi.inc @@ -0,0 +1,114 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_sinpi(__CLC_GENTYPE x) { + __CLC_INTN ix = __CLC_AS_INTN(x); + __CLC_INTN xsgn = ix & (__CLC_INTN)0x80000000; + ix ^= xsgn; + __CLC_GENTYPE absx = __clc_fabs(x); + __CLC_INTN iax = __CLC_CONVERT_INTN(absx); + __CLC_GENTYPE r = absx - __CLC_CONVERT_GENTYPE(iax); + __CLC_INTN xodd = + xsgn ^ ((iax & 0x1) != 0 ? (__CLC_INTN)0x80000000 : (__CLC_INTN)0); + + // Initialize with return for +-Inf and NaN + __CLC_INTN ir = QNANBITPATT_SP32; + + // 2^23 <= |x| < Inf, the result is always integer + ir = ix < PINFBITPATT_SP32 ? xsgn : ir; + + // 0x1.0p-7 <= |x| < 2^23, result depends on which 0.25 interval + + // r < 1.0 + __CLC_GENTYPE a = 1.0f - r; + __CLC_INTN e = 0; + + // r <= 0.75 + __CLC_INTN c = r <= 0.75f; + a = c ? r - 0.5f : a; + e = c ? 1 : e; + + // r < 0.5 + c = r < 0.5f; + a = c ? 0.5f - r : a; + + // 0 < r <= 0.25 + c = r <= 0.25f; + a = c ? r : a; + e = c ? 0 : e; + + __CLC_GENTYPE sinval, cosval; + __clc_sincos_piby4(a * M_PI_F, &sinval, &cosval); + __CLC_INTN jr = xodd ^ __CLC_AS_INTN(e != 0 ? cosval : sinval); + + ir = ix < 0x4b000000 ? jr : ir; + + return __CLC_AS_GENTYPE(ir); +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_sinpi(__CLC_GENTYPE x) { + __CLC_LONGN ix = __CLC_AS_LONGN(x); + __CLC_LONGN xsgn = ix & (__CLC_LONGN)0x8000000000000000L; + ix ^= xsgn; + __CLC_GENTYPE absx = __clc_fabs(x); + __CLC_LONGN iax = __CLC_CONVERT_LONGN(absx); + __CLC_GENTYPE r = absx - __CLC_CONVERT_GENTYPE(iax); + __CLC_LONGN xodd = + xsgn ^ + ((iax & 0x1L) != 0 ? (__CLC_LONGN)0x8000000000000000L : (__CLC_LONGN)0L); + + // Initialize with return for +-Inf and NaN + __CLC_LONGN ir = QNANBITPATT_DP64; + + // 2^23 <= |x| < Inf, the result is always integer + ir = ix < PINFBITPATT_DP64 ? xsgn : ir; + + // 0x1.0p-7 <= |x| < 2^23, result depends on which 0.25 interval + + // r < 1.0 + __CLC_GENTYPE a = 1.0 - r; + __CLC_LONGN e = 0; + + // r <= 0.75 + __CLC_LONGN c = r <= 0.75; + __CLC_GENTYPE t = r - 0.5; + a = c ? t : a; + e = c ? 1 : e; + + // r < 0.5 + c = r < 0.5; + t = 0.5 - r; + a = c ? t : a; + + // r <= 0.25 + c = r <= 0.25; + a = c ? r : a; + e = c ? 0 : e; + + __CLC_GENTYPE api = a * M_PI; + + __CLC_GENTYPE sinval, cosval; + __clc_sincos_piby4(api, 0.0, &sinval, &cosval); + __CLC_LONGN jr = xodd ^ __CLC_AS_LONGN(e != 0 ? cosval : sinval); + + ir = absx < 0x1.0p+52 ? jr : ir; + + return __CLC_AS_GENTYPE(ir); +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_sinpi(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_sinpi(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sqrt.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sqrt.cl new file mode 100644 index 0000000000..3fa82fdd71 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sqrt.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sqrt.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sqrt.inc new file mode 100644 index 0000000000..61e341993f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sqrt.inc @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +__attribute__((weak)) _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE +__clc_sqrt(__CLC_GENTYPE val) { + return __builtin_elementwise_sqrt(val); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sw_fma.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sw_fma.cl new file mode 100644 index 0000000000..ee4734078d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_sw_fma.cl @@ -0,0 +1,166 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct fp { + ulong mantissa; + int exponent; + uint sign; +}; + +_CLC_DEF _CLC_OVERLOAD float __clc_sw_fma(float a, float b, float c) { + /* special cases */ + if (__clc_isnan(a) || __clc_isnan(b) || __clc_isnan(c) || __clc_isinf(a) || + __clc_isinf(b)) { + return __clc_mad(a, b, c); + } + + /* If only c is inf, and both a,b are regular numbers, the result is c*/ + if (__clc_isinf(c)) { + return c; + } + + a = __clc_flush_denormal_if_not_supported(a); + b = __clc_flush_denormal_if_not_supported(b); + c = __clc_flush_denormal_if_not_supported(c); + + if (c == 0) { + return a * b; + } + + struct fp st_a, st_b, st_c; + + st_a.exponent = a == .0f ? 0 : ((__clc_as_uint(a) & 0x7f800000) >> 23) - 127; + st_b.exponent = b == .0f ? 0 : ((__clc_as_uint(b) & 0x7f800000) >> 23) - 127; + st_c.exponent = c == .0f ? 0 : ((__clc_as_uint(c) & 0x7f800000) >> 23) - 127; + + st_a.mantissa = a == .0f ? 0 : (__clc_as_uint(a) & 0x7fffff) | 0x800000; + st_b.mantissa = b == .0f ? 0 : (__clc_as_uint(b) & 0x7fffff) | 0x800000; + st_c.mantissa = c == .0f ? 0 : (__clc_as_uint(c) & 0x7fffff) | 0x800000; + + st_a.sign = __clc_as_uint(a) & 0x80000000; + st_b.sign = __clc_as_uint(b) & 0x80000000; + st_c.sign = __clc_as_uint(c) & 0x80000000; + + // Multiplication. + // Move the product to the highest bits to maximize precision + // mantissa is 24 bits => product is 48 bits, 2bits non-fraction. + // Add one bit for future addition overflow, + // add another bit to detect subtraction underflow + struct fp st_mul; + st_mul.sign = st_a.sign ^ st_b.sign; + st_mul.mantissa = (st_a.mantissa * st_b.mantissa) << 14ul; + st_mul.exponent = st_mul.mantissa ? st_a.exponent + st_b.exponent : 0; + + // FIXME: Detecting a == 0 || b == 0 above crashed GCN isel + if (st_mul.exponent == 0 && st_mul.mantissa == 0) + return c; + +// Mantissa is 23 fractional bits, shift it the same way as product mantissa +#define C_ADJUST 37ul + + // both exponents are bias adjusted + int exp_diff = st_mul.exponent - st_c.exponent; + + st_c.mantissa <<= C_ADJUST; + ulong cutoff_bits = 0; + ulong cutoff_mask = (1ul << __clc_abs(exp_diff)) - 1ul; + if (exp_diff > 0) { + cutoff_bits = + exp_diff >= 64 ? st_c.mantissa : (st_c.mantissa & cutoff_mask); + st_c.mantissa = exp_diff >= 64 ? 0 : (st_c.mantissa >> exp_diff); + } else { + cutoff_bits = + -exp_diff >= 64 ? st_mul.mantissa : (st_mul.mantissa & cutoff_mask); + st_mul.mantissa = -exp_diff >= 64 ? 0 : (st_mul.mantissa >> -exp_diff); + } + + struct fp st_fma; + st_fma.sign = st_mul.sign; + st_fma.exponent = __clc_max(st_mul.exponent, st_c.exponent); + if (st_c.sign == st_mul.sign) { + st_fma.mantissa = st_mul.mantissa + st_c.mantissa; + } else { + // cutoff bits borrow one + st_fma.mantissa = + st_mul.mantissa - st_c.mantissa - + (cutoff_bits && (st_mul.exponent > st_c.exponent) ? 1 : 0); + } + + // underflow: st_c.sign != st_mul.sign, and magnitude switches the sign + if (st_fma.mantissa > LONG_MAX) { + st_fma.mantissa = 0 - st_fma.mantissa; + st_fma.sign = st_mul.sign ^ 0x80000000; + } + + // detect overflow/underflow + int overflow_bits = 3 - __clc_clz(st_fma.mantissa); + + // adjust exponent + st_fma.exponent += overflow_bits; + + // handle underflow + if (overflow_bits < 0) { + st_fma.mantissa <<= -overflow_bits; + overflow_bits = 0; + } + + // rounding + ulong trunc_mask = (1ul << (C_ADJUST + overflow_bits)) - 1; + ulong trunc_bits = (st_fma.mantissa & trunc_mask) | (cutoff_bits != 0); + ulong last_bit = st_fma.mantissa & (1ul << (C_ADJUST + overflow_bits)); + ulong grs_bits = (0x4ul << (C_ADJUST - 3 + overflow_bits)); + + // round to nearest even + if ((trunc_bits > grs_bits) || (trunc_bits == grs_bits && last_bit != 0)) { + st_fma.mantissa += (1ul << (C_ADJUST + overflow_bits)); + } + + // Shift mantissa back to bit 23 + st_fma.mantissa = (st_fma.mantissa >> (C_ADJUST + overflow_bits)); + + // Detect rounding overflow + if (st_fma.mantissa > 0xffffff) { + ++st_fma.exponent; + st_fma.mantissa >>= 1; + } + + if (st_fma.mantissa == 0) { + return .0f; + } + + // Flating point range limit + if (st_fma.exponent > 127) { + return __clc_as_float(__clc_as_uint(INFINITY) | st_fma.sign); + } + + // Flush denormals + if (st_fma.exponent <= -127) { + return __clc_as_float(st_fma.sign); + } + + return __clc_as_float(st_fma.sign | ((st_fma.exponent + 127) << 23) | + ((uint)st_fma.mantissa & 0x7fffff)); +} + +#define __FLOAT_ONLY +#define FUNCTION __clc_sw_fma +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tables.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tables.cl new file mode 100644 index 0000000000..7db00532c8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tables.cl @@ -0,0 +1,1711 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +DECLARE_TABLE(float, LOG_INV_TBL_EP_HEAD, 129) = { + 0x1.000000p+1f, 0x1.fc0000p+0f, 0x1.f80000p+0f, 0x1.f40000p+0f, + 0x1.f00000p+0f, 0x1.ec0000p+0f, 0x1.e80000p+0f, 0x1.e40000p+0f, + 0x1.e00000p+0f, 0x1.de0000p+0f, 0x1.da0000p+0f, 0x1.d60000p+0f, + 0x1.d40000p+0f, 0x1.d00000p+0f, 0x1.cc0000p+0f, 0x1.ca0000p+0f, + 0x1.c60000p+0f, 0x1.c20000p+0f, 0x1.c00000p+0f, 0x1.bc0000p+0f, + 0x1.ba0000p+0f, 0x1.b60000p+0f, 0x1.b40000p+0f, 0x1.b20000p+0f, + 0x1.ae0000p+0f, 0x1.ac0000p+0f, 0x1.a80000p+0f, 0x1.a60000p+0f, + 0x1.a40000p+0f, 0x1.a00000p+0f, 0x1.9e0000p+0f, 0x1.9c0000p+0f, + 0x1.980000p+0f, 0x1.960000p+0f, 0x1.940000p+0f, 0x1.920000p+0f, + 0x1.8e0000p+0f, 0x1.8c0000p+0f, 0x1.8a0000p+0f, 0x1.880000p+0f, + 0x1.860000p+0f, 0x1.820000p+0f, 0x1.800000p+0f, 0x1.7e0000p+0f, + 0x1.7c0000p+0f, 0x1.7a0000p+0f, 0x1.780000p+0f, 0x1.760000p+0f, + 0x1.740000p+0f, 0x1.720000p+0f, 0x1.700000p+0f, 0x1.6e0000p+0f, + 0x1.6c0000p+0f, 0x1.6a0000p+0f, 0x1.680000p+0f, 0x1.660000p+0f, + 0x1.640000p+0f, 0x1.620000p+0f, 0x1.600000p+0f, 0x1.5e0000p+0f, + 0x1.5c0000p+0f, 0x1.5a0000p+0f, 0x1.580000p+0f, 0x1.560000p+0f, + 0x1.540000p+0f, 0x1.520000p+0f, 0x1.500000p+0f, 0x1.500000p+0f, + 0x1.4e0000p+0f, 0x1.4c0000p+0f, 0x1.4a0000p+0f, 0x1.480000p+0f, + 0x1.460000p+0f, 0x1.460000p+0f, 0x1.440000p+0f, 0x1.420000p+0f, + 0x1.400000p+0f, 0x1.3e0000p+0f, 0x1.3e0000p+0f, 0x1.3c0000p+0f, + 0x1.3a0000p+0f, 0x1.380000p+0f, 0x1.380000p+0f, 0x1.360000p+0f, + 0x1.340000p+0f, 0x1.320000p+0f, 0x1.320000p+0f, 0x1.300000p+0f, + 0x1.2e0000p+0f, 0x1.2e0000p+0f, 0x1.2c0000p+0f, 0x1.2a0000p+0f, + 0x1.280000p+0f, 0x1.280000p+0f, 0x1.260000p+0f, 0x1.240000p+0f, + 0x1.240000p+0f, 0x1.220000p+0f, 0x1.200000p+0f, 0x1.200000p+0f, + 0x1.1e0000p+0f, 0x1.1e0000p+0f, 0x1.1c0000p+0f, 0x1.1a0000p+0f, + 0x1.1a0000p+0f, 0x1.180000p+0f, 0x1.180000p+0f, 0x1.160000p+0f, + 0x1.140000p+0f, 0x1.140000p+0f, 0x1.120000p+0f, 0x1.120000p+0f, + 0x1.100000p+0f, 0x1.0e0000p+0f, 0x1.0e0000p+0f, 0x1.0c0000p+0f, + 0x1.0c0000p+0f, 0x1.0a0000p+0f, 0x1.0a0000p+0f, 0x1.080000p+0f, + 0x1.080000p+0f, 0x1.060000p+0f, 0x1.060000p+0f, 0x1.040000p+0f, + 0x1.040000p+0f, 0x1.020000p+0f, 0x1.020000p+0f, 0x1.000000p+0f, + 0x1.000000p+0f, +}; + +CLC_TABLE_FUNCTION(float, LOG_INV_TBL_EP_HEAD, log_inv_tbl_ep_head); + +DECLARE_TABLE(float, LOG_INV_TBL_EP_TAIL, 129) = { + 0x0.000000p+0f, 0x1.fc07f0p-14f, 0x1.f81f82p-12f, 0x1.196792p-10f, + 0x1.f07c20p-10f, 0x1.80f660p-9f, 0x1.131ac0p-8f, 0x1.73ac90p-8f, + 0x1.e1e1e2p-8f, 0x1.75b8fep-10f, 0x1.cc0ed8p-9f, 0x1.7b654cp-8f, + 0x1.d41d42p-12f, 0x1.96b1eep-9f, 0x1.856890p-8f, 0x1.2cc158p-10f, + 0x1.1c71c8p-8f, 0x1.f8f01cp-8f, 0x1.c0e070p-9f, 0x1.d2b89ap-8f, + 0x1.9f2298p-9f, 0x1.d6c3dep-8f, 0x1.d0369ep-9f, 0x1.b20364p-15f, + 0x1.286bcap-8f, 0x1.5c06b2p-10f, 0x1.8ef606p-8f, 0x1.a034dap-9f, + 0x1.a41a42p-12f, 0x1.6d3f98p-8f, 0x1.91d2a2p-9f, 0x1.68a772p-11f, + 0x1.99999ap-8f, 0x1.0e4f80p-8f, 0x1.161f9ap-9f, 0x1.f693a2p-13f, + 0x1.9c18fap-8f, 0x1.3018d4p-8f, 0x1.9721eep-9f, 0x1.b97c2ap-10f, + 0x1.861862p-12f, 0x1.c977acp-8f, 0x1.818182p-8f, 0x1.405fd0p-8f, + 0x1.05f418p-8f, 0x1.a4411cp-9f, 0x1.499030p-9f, 0x1.f7390ep-10f, + 0x1.745d18p-10f, 0x1.0a1fd2p-10f, 0x1.702e06p-11f, 0x1.f76b44p-12f, + 0x1.6c16c2p-12f, 0x1.3cd154p-12f, 0x1.681682p-12f, 0x1.ec6a52p-12f, + 0x1.642c86p-11f, 0x1.fd3b80p-11f, 0x1.605816p-10f, 0x1.d6ee34p-10f, + 0x1.310572p-9f, 0x1.80ad60p-9f, 0x1.da4610p-9f, 0x1.1ed3c6p-8f, + 0x1.555556p-8f, 0x1.909490p-8f, 0x1.d07eaep-8f, 0x1.501502p-12f, + 0x1.7829ccp-10f, 0x1.5710e4p-9f, 0x1.fad40ap-9f, 0x1.539e3cp-8f, + 0x1.ae147ap-8f, 0x1.978fecp-13f, 0x1.be1958p-10f, 0x1.acc4bap-9f, + 0x1.414142p-8f, 0x1.b013fcp-8f, 0x1.165e72p-11f, 0x1.32b490p-9f, + 0x1.13b13cp-8f, 0x1.91c2c2p-8f, 0x1.381382p-12f, 0x1.31be7cp-9f, + 0x1.21cfb2p-8f, 0x1.ae45b6p-8f, 0x1.f1a516p-11f, 0x1.a32026p-9f, + 0x1.684bdap-8f, 0x1.2e025cp-15f, 0x1.3f69b0p-9f, 0x1.404ad0p-8f, + 0x1.e4129ep-8f, 0x1.160252p-9f, 0x1.350b88p-8f, 0x1.e22708p-8f, + 0x1.24924ap-9f, 0x1.45678ap-8f, 0x1.fb7812p-8f, 0x1.68e18cp-9f, + 0x1.7047dcp-8f, 0x1.779da0p-11f, 0x1.e0d5b4p-9f, 0x1.b4a404p-8f, + 0x1.ee5846p-10f, 0x1.453808p-8f, 0x1.181182p-12f, 0x1.c0d128p-9f, + 0x1.b1e5f8p-8f, 0x1.0be1c2p-9f, 0x1.5c8114p-8f, 0x1.ac73aep-11f, + 0x1.111112p-8f, 0x1.ef0110p-8f, 0x1.9ead7cp-9f, 0x1.b20a88p-8f, + 0x1.2e29f8p-9f, 0x1.7e6ec2p-8f, 0x1.a0429ap-10f, 0x1.53f390p-8f, + 0x1.084210p-10f, 0x1.3260a4p-8f, 0x1.26e978p-11f, 0x1.197f7ep-8f, + 0x1.041042p-12f, 0x1.091b52p-8f, 0x1.020408p-14f, 0x1.010102p-8f, + 0x0.000000p+0f, +}; +CLC_TABLE_FUNCTION(float, LOG_INV_TBL_EP_TAIL, log_inv_tbl_ep_tail); + +DECLARE_TABLE(float, LOGE_TBL_LO, 129) = { + 0x0.000000p+0f, 0x1.fe0000p-8f, 0x1.fc0000p-7f, 0x1.7b8000p-6f, + 0x1.f82000p-6f, 0x1.39e000p-5f, 0x1.774000p-5f, 0x1.b42000p-5f, + 0x1.f0a000p-5f, 0x1.164000p-4f, 0x1.340000p-4f, 0x1.51a000p-4f, + 0x1.6f0000p-4f, 0x1.8c2000p-4f, 0x1.a92000p-4f, 0x1.c5e000p-4f, + 0x1.e26000p-4f, 0x1.fec000p-4f, 0x1.0d6000p-3f, 0x1.1b6000p-3f, + 0x1.294000p-3f, 0x1.370000p-3f, 0x1.44c000p-3f, 0x1.526000p-3f, + 0x1.5fe000p-3f, 0x1.6d6000p-3f, 0x1.7aa000p-3f, 0x1.87e000p-3f, + 0x1.952000p-3f, 0x1.a22000p-3f, 0x1.af2000p-3f, 0x1.bc2000p-3f, + 0x1.c8e000p-3f, 0x1.d5c000p-3f, 0x1.e26000p-3f, 0x1.ef0000p-3f, + 0x1.fb8000p-3f, 0x1.040000p-2f, 0x1.0a2000p-2f, 0x1.104000p-2f, + 0x1.166000p-2f, 0x1.1c8000p-2f, 0x1.228000p-2f, 0x1.288000p-2f, + 0x1.2e8000p-2f, 0x1.346000p-2f, 0x1.3a6000p-2f, 0x1.404000p-2f, + 0x1.460000p-2f, 0x1.4be000p-2f, 0x1.51a000p-2f, 0x1.576000p-2f, + 0x1.5d0000p-2f, 0x1.62c000p-2f, 0x1.686000p-2f, 0x1.6e0000p-2f, + 0x1.738000p-2f, 0x1.792000p-2f, 0x1.7ea000p-2f, 0x1.842000p-2f, + 0x1.89a000p-2f, 0x1.8f0000p-2f, 0x1.946000p-2f, 0x1.99c000p-2f, + 0x1.9f2000p-2f, 0x1.a48000p-2f, 0x1.a9c000p-2f, 0x1.af0000p-2f, + 0x1.b44000p-2f, 0x1.b98000p-2f, 0x1.bea000p-2f, 0x1.c3c000p-2f, + 0x1.c8e000p-2f, 0x1.ce0000p-2f, 0x1.d32000p-2f, 0x1.d82000p-2f, + 0x1.dd4000p-2f, 0x1.e24000p-2f, 0x1.e74000p-2f, 0x1.ec2000p-2f, + 0x1.f12000p-2f, 0x1.f60000p-2f, 0x1.fae000p-2f, 0x1.ffc000p-2f, + 0x1.024000p-1f, 0x1.04a000p-1f, 0x1.072000p-1f, 0x1.098000p-1f, + 0x1.0be000p-1f, 0x1.0e4000p-1f, 0x1.108000p-1f, 0x1.12e000p-1f, + 0x1.154000p-1f, 0x1.178000p-1f, 0x1.19e000p-1f, 0x1.1c2000p-1f, + 0x1.1e8000p-1f, 0x1.20c000p-1f, 0x1.230000p-1f, 0x1.254000p-1f, + 0x1.278000p-1f, 0x1.29c000p-1f, 0x1.2c0000p-1f, 0x1.2e4000p-1f, + 0x1.306000p-1f, 0x1.32a000p-1f, 0x1.34e000p-1f, 0x1.370000p-1f, + 0x1.392000p-1f, 0x1.3b6000p-1f, 0x1.3d8000p-1f, 0x1.3fa000p-1f, + 0x1.41c000p-1f, 0x1.43e000p-1f, 0x1.460000p-1f, 0x1.482000p-1f, + 0x1.4a4000p-1f, 0x1.4c6000p-1f, 0x1.4e6000p-1f, 0x1.508000p-1f, + 0x1.52a000p-1f, 0x1.54a000p-1f, 0x1.56a000p-1f, 0x1.58c000p-1f, + 0x1.5ac000p-1f, 0x1.5cc000p-1f, 0x1.5ee000p-1f, 0x1.60e000p-1f, + 0x1.62e000p-1f, +}; + +DECLARE_TABLE(float, LOGE_TBL_HI, 129) = { + 0x0.000000p+0f, 0x1.535882p-23f, 0x1.5161f8p-20f, 0x1.1b07d4p-18f, + 0x1.361cf0p-19f, 0x1.0f73fcp-18f, 0x1.63d8cap-19f, 0x1.bae232p-18f, + 0x1.86008ap-20f, 0x1.36eea2p-16f, 0x1.d7961ap-16f, 0x1.073f06p-16f, + 0x1.a515cap-17f, 0x1.45d630p-16f, 0x1.b4e92ap-18f, 0x1.523d6ep-18f, + 0x1.076e2ap-16f, 0x1.2263b6p-17f, 0x1.7e7cd0p-15f, 0x1.2ad52ep-15f, + 0x1.52f81ep-15f, 0x1.fc201ep-15f, 0x1.2b6ccap-15f, 0x1.cbc742p-16f, + 0x1.3070a6p-15f, 0x1.fce33ap-20f, 0x1.890210p-15f, 0x1.a06520p-15f, + 0x1.6a73d0p-17f, 0x1.bc1fe2p-15f, 0x1.c94e80p-15f, 0x1.0ce85ap-16f, + 0x1.f7c79ap-15f, 0x1.0b5a7cp-18f, 0x1.076e2ap-15f, 0x1.5b97b8p-16f, + 0x1.186d5ep-15f, 0x1.2ca5a6p-17f, 0x1.24e272p-14f, 0x1.8bf9aep-14f, + 0x1.5cabaap-14f, 0x1.3182d2p-15f, 0x1.41fbcep-14f, 0x1.5a13dep-14f, + 0x1.c575c2p-15f, 0x1.dd9a98p-14f, 0x1.3155a4p-16f, 0x1.843434p-17f, + 0x1.8bc21cp-14f, 0x1.7e55dcp-16f, 0x1.5b0e5ap-15f, 0x1.dc5d14p-16f, + 0x1.bdbf58p-14f, 0x1.05e572p-15f, 0x1.903d36p-15f, 0x1.1d5456p-15f, + 0x1.d7f6bap-14f, 0x1.4abfbap-15f, 0x1.f07704p-15f, 0x1.a3b43cp-15f, + 0x1.9c360ap-17f, 0x1.1e8736p-14f, 0x1.941c20p-14f, 0x1.958116p-14f, + 0x1.23ecbep-14f, 0x1.024396p-16f, 0x1.d93534p-15f, 0x1.293246p-14f, + 0x1.eef798p-15f, 0x1.625a4cp-16f, 0x1.4d9da6p-14f, 0x1.d7a7ccp-14f, + 0x1.f7c79ap-14f, 0x1.af0b84p-14f, 0x1.fcfc00p-15f, 0x1.e7258ap-14f, + 0x1.a81306p-16f, 0x1.1034f8p-15f, 0x1.09875ap-16f, 0x1.99d246p-14f, + 0x1.1ebf5ep-15f, 0x1.23fa70p-14f, 0x1.588f78p-14f, 0x1.2e0856p-14f, + 0x1.52a5a4p-13f, 0x1.df9da8p-13f, 0x1.f2e0e6p-16f, 0x1.bd3d5cp-15f, + 0x1.cb9094p-15f, 0x1.261746p-15f, 0x1.f39e2cp-13f, 0x1.719592p-13f, + 0x1.87a5e8p-14f, 0x1.eabbd8p-13f, 0x1.cd68cep-14f, 0x1.b81f70p-13f, + 0x1.7d79c0p-15f, 0x1.b9a324p-14f, 0x1.30d7bep-13f, 0x1.5bce98p-13f, + 0x1.5e1288p-13f, 0x1.37fec2p-13f, 0x1.d3da88p-14f, 0x1.d0db90p-15f, + 0x1.d7334ep-13f, 0x1.133912p-13f, 0x1.44ece6p-16f, 0x1.17b546p-13f, + 0x1.e0d356p-13f, 0x1.0893fep-14f, 0x1.026a70p-13f, 0x1.5b84d0p-13f, + 0x1.8fe846p-13f, 0x1.9fe2f8p-13f, 0x1.8bc21cp-13f, 0x1.53d1eap-13f, + 0x1.f0bb60p-14f, 0x1.e6bf32p-15f, 0x1.d811b6p-13f, 0x1.13cc00p-13f, + 0x1.6932dep-16f, 0x1.246798p-13f, 0x1.f9d5b2p-13f, 0x1.5b6b9ap-14f, + 0x1.404c34p-13f, 0x1.b1dc6cp-13f, 0x1.54920ap-20f, 0x1.97a23cp-16f, + 0x1.0bfbe8p-15f, +}; + +CLC_TABLE_FUNCTION(float, LOGE_TBL_LO, loge_tbl_lo); +CLC_TABLE_FUNCTION(float, LOGE_TBL_HI, loge_tbl_hi); + +DECLARE_TABLE(float, LOG_INV_TBL, 129) = { + 0x1.000000p+1f, 0x1.fc07f0p+0f, 0x1.f81f82p+0f, 0x1.f4465ap+0f, + 0x1.f07c20p+0f, 0x1.ecc07cp+0f, 0x1.e9131ap+0f, 0x1.e573acp+0f, + 0x1.e1e1e2p+0f, 0x1.de5d6ep+0f, 0x1.dae608p+0f, 0x1.d77b66p+0f, + 0x1.d41d42p+0f, 0x1.d0cb58p+0f, 0x1.cd8568p+0f, 0x1.ca4b30p+0f, + 0x1.c71c72p+0f, 0x1.c3f8f0p+0f, 0x1.c0e070p+0f, 0x1.bdd2b8p+0f, + 0x1.bacf92p+0f, 0x1.b7d6c4p+0f, 0x1.b4e81cp+0f, 0x1.b20364p+0f, + 0x1.af286cp+0f, 0x1.ac5702p+0f, 0x1.a98ef6p+0f, 0x1.a6d01ap+0f, + 0x1.a41a42p+0f, 0x1.a16d40p+0f, 0x1.9ec8eap+0f, 0x1.9c2d14p+0f, + 0x1.99999ap+0f, 0x1.970e50p+0f, 0x1.948b10p+0f, 0x1.920fb4p+0f, + 0x1.8f9c18p+0f, 0x1.8d3018p+0f, 0x1.8acb90p+0f, 0x1.886e60p+0f, + 0x1.861862p+0f, 0x1.83c978p+0f, 0x1.818182p+0f, 0x1.7f4060p+0f, + 0x1.7d05f4p+0f, 0x1.7ad220p+0f, 0x1.78a4c8p+0f, 0x1.767dcep+0f, + 0x1.745d18p+0f, 0x1.724288p+0f, 0x1.702e06p+0f, 0x1.6e1f76p+0f, + 0x1.6c16c2p+0f, 0x1.6a13cep+0f, 0x1.681682p+0f, 0x1.661ec6p+0f, + 0x1.642c86p+0f, 0x1.623fa8p+0f, 0x1.605816p+0f, 0x1.5e75bcp+0f, + 0x1.5c9882p+0f, 0x1.5ac056p+0f, 0x1.58ed24p+0f, 0x1.571ed4p+0f, + 0x1.555556p+0f, 0x1.539094p+0f, 0x1.51d07ep+0f, 0x1.501502p+0f, + 0x1.4e5e0ap+0f, 0x1.4cab88p+0f, 0x1.4afd6ap+0f, 0x1.49539ep+0f, + 0x1.47ae14p+0f, 0x1.460cbcp+0f, 0x1.446f86p+0f, 0x1.42d662p+0f, + 0x1.414142p+0f, 0x1.3fb014p+0f, 0x1.3e22ccp+0f, 0x1.3c995ap+0f, + 0x1.3b13b2p+0f, 0x1.3991c2p+0f, 0x1.381382p+0f, 0x1.3698e0p+0f, + 0x1.3521d0p+0f, 0x1.33ae46p+0f, 0x1.323e34p+0f, 0x1.30d190p+0f, + 0x1.2f684cp+0f, 0x1.2e025cp+0f, 0x1.2c9fb4p+0f, 0x1.2b404ap+0f, + 0x1.29e412p+0f, 0x1.288b02p+0f, 0x1.27350cp+0f, 0x1.25e228p+0f, + 0x1.24924ap+0f, 0x1.234568p+0f, 0x1.21fb78p+0f, 0x1.20b470p+0f, + 0x1.1f7048p+0f, 0x1.1e2ef4p+0f, 0x1.1cf06ap+0f, 0x1.1bb4a4p+0f, + 0x1.1a7b96p+0f, 0x1.194538p+0f, 0x1.181182p+0f, 0x1.16e068p+0f, + 0x1.15b1e6p+0f, 0x1.1485f0p+0f, 0x1.135c82p+0f, 0x1.12358ep+0f, + 0x1.111112p+0f, 0x1.0fef02p+0f, 0x1.0ecf56p+0f, 0x1.0db20ap+0f, + 0x1.0c9714p+0f, 0x1.0b7e6ep+0f, 0x1.0a6810p+0f, 0x1.0953f4p+0f, + 0x1.084210p+0f, 0x1.073260p+0f, 0x1.0624dep+0f, 0x1.051980p+0f, + 0x1.041042p+0f, 0x1.03091cp+0f, 0x1.020408p+0f, 0x1.010102p+0f, + 0x1.000000p+0f, +}; + +CLC_TABLE_FUNCTION(float, LOG_INV_TBL, log_inv_tbl); + +DECLARE_TABLE(float2, LOG2_TBL, 129) = { + (float2)(0x0.000000p+0f, 0x0.000000p+0f), + (float2)(0x1.6f8000p-7f, 0x1.942dbap-17f), + (float2)(0x1.6e0000p-6f, 0x1.e5a170p-16f), + (float2)(0x1.118000p-5f, 0x1.347544p-15f), + (float2)(0x1.6b8000p-5f, 0x1.69bac6p-16f), + (float2)(0x1.c48000p-5f, 0x1.7eae42p-15f), + (float2)(0x1.0e8000p-4f, 0x1.9c4fd0p-15f), + (float2)(0x1.3a8000p-4f, 0x1.17ee92p-15f), + (float2)(0x1.660000p-4f, 0x1.fb7d64p-15f), + (float2)(0x1.918000p-4f, 0x1.42dc8cp-17f), + (float2)(0x1.bc8000p-4f, 0x1.0902b6p-18f), + (float2)(0x1.e70000p-4f, 0x1.7608bep-15f), + (float2)(0x1.088000p-3f, 0x1.162336p-13f), + (float2)(0x1.1d8000p-3f, 0x1.3465d4p-13f), + (float2)(0x1.328000p-3f, 0x1.74f13cp-14f), + (float2)(0x1.470000p-3f, 0x1.aa7e60p-13f), + (float2)(0x1.5c0000p-3f, 0x1.a39fbcp-19f), + (float2)(0x1.700000p-3f, 0x1.d0b53ap-13f), + (float2)(0x1.848000p-3f, 0x1.0af40ap-13f), + (float2)(0x1.988000p-3f, 0x1.b741dep-13f), + (float2)(0x1.ac8000p-3f, 0x1.d78b6cp-13f), + (float2)(0x1.c08000p-3f, 0x1.6db376p-13f), + (float2)(0x1.d48000p-3f, 0x1.ee4c32p-15f), + (float2)(0x1.e80000p-3f, 0x1.02f9d2p-13f), + (float2)(0x1.fb8000p-3f, 0x1.05ae40p-13f), + (float2)(0x1.078000p-2f, 0x1.0adbb0p-14f), + (float2)(0x1.110000p-2f, 0x1.83ed68p-13f), + (float2)(0x1.1a8000p-2f, 0x1.016ca4p-12f), + (float2)(0x1.240000p-2f, 0x1.01eac2p-12f), + (float2)(0x1.2d8000p-2f, 0x1.887e26p-13f), + (float2)(0x1.370000p-2f, 0x1.24cea4p-14f), + (float2)(0x1.400000p-2f, 0x1.918ec6p-12f), + (float2)(0x1.498000p-2f, 0x1.3c25e6p-13f), + (float2)(0x1.528000p-2f, 0x1.6f7f12p-12f), + (float2)(0x1.5c0000p-2f, 0x1.a39fbcp-18f), + (float2)(0x1.650000p-2f, 0x1.8fe466p-14f), + (float2)(0x1.6e0000p-2f, 0x1.10e6cep-13f), + (float2)(0x1.770000p-2f, 0x1.d2ba7ep-14f), + (float2)(0x1.800000p-2f, 0x1.4ac62cp-15f), + (float2)(0x1.888000p-2f, 0x1.a71cb8p-12f), + (float2)(0x1.918000p-2f, 0x1.dd448ep-13f), + (float2)(0x1.9a8000p-2f, 0x1.1c8f10p-21f), + (float2)(0x1.a30000p-2f, 0x1.bb053ep-13f), + (float2)(0x1.ab8000p-2f, 0x1.861e5ep-12f), + (float2)(0x1.b40000p-2f, 0x1.fafdcep-12f), + (float2)(0x1.bd0000p-2f, 0x1.e5d3cep-15f), + (float2)(0x1.c58000p-2f, 0x1.2fad28p-14f), + (float2)(0x1.ce0000p-2f, 0x1.492474p-15f), + (float2)(0x1.d60000p-2f, 0x1.d4f80cp-12f), + (float2)(0x1.de8000p-2f, 0x1.4ff510p-12f), + (float2)(0x1.e70000p-2f, 0x1.3550f2p-13f), + (float2)(0x1.ef0000p-2f, 0x1.b59ccap-12f), + (float2)(0x1.f78000p-2f, 0x1.42b464p-13f), + (float2)(0x1.ff8000p-2f, 0x1.5e66a0p-12f), + (float2)(0x1.038000p-1f, 0x1.f6a2e4p-11f), + (float2)(0x1.080000p-1f, 0x1.39e4fep-14f), + (float2)(0x1.0c0000p-1f, 0x1.0500d6p-13f), + (float2)(0x1.100000p-1f, 0x1.13b152p-13f), + (float2)(0x1.140000p-1f, 0x1.93f542p-14f), + (float2)(0x1.180000p-1f, 0x1.467b94p-16f), + (float2)(0x1.1b8000p-1f, 0x1.cc47a4p-11f), + (float2)(0x1.1f8000p-1f, 0x1.78f4c2p-11f), + (float2)(0x1.238000p-1f, 0x1.107508p-11f), + (float2)(0x1.278000p-1f, 0x1.2602c2p-12f), + (float2)(0x1.2b8000p-1f, 0x1.a39fbcp-20f), + (float2)(0x1.2f0000p-1f, 0x1.5a1d7ap-11f), + (float2)(0x1.330000p-1f, 0x1.3e355ap-12f), + (float2)(0x1.368000p-1f, 0x1.cffedap-11f), + (float2)(0x1.3a8000p-1f, 0x1.d9fd50p-12f), + (float2)(0x1.3e0000p-1f, 0x1.f64de6p-11f), + (float2)(0x1.420000p-1f, 0x1.d83f4cp-12f), + (float2)(0x1.458000p-1f, 0x1.cea628p-11f), + (float2)(0x1.498000p-1f, 0x1.3c25e6p-12f), + (float2)(0x1.4d0000p-1f, 0x1.5a96ccp-11f), + (float2)(0x1.510000p-1f, 0x1.18708ap-17f), + (float2)(0x1.548000p-1f, 0x1.374652p-12f), + (float2)(0x1.580000p-1f, 0x1.2089a6p-11f), + (float2)(0x1.5b8000p-1f, 0x1.93432cp-11f), + (float2)(0x1.5f0000p-1f, 0x1.f3fd06p-11f), + (float2)(0x1.630000p-1f, 0x1.0b8f54p-13f), + (float2)(0x1.668000p-1f, 0x1.004722p-12f), + (float2)(0x1.6a0000p-1f, 0x1.57cf2cp-12f), + (float2)(0x1.6d8000p-1f, 0x1.8cb53ap-12f), + (float2)(0x1.710000p-1f, 0x1.9f4d8ap-12f), + (float2)(0x1.748000p-1f, 0x1.8feb26p-12f), + (float2)(0x1.780000p-1f, 0x1.5edfeep-12f), + (float2)(0x1.7b8000p-1f, 0x1.0c7c9ap-12f), + (float2)(0x1.7f0000p-1f, 0x1.322182p-13f), + (float2)(0x1.828000p-1f, 0x1.3ab7cep-18f), + (float2)(0x1.858000p-1f, 0x1.a82c2cp-11f), + (float2)(0x1.890000p-1f, 0x1.3dd2c0p-11f), + (float2)(0x1.8c8000p-1f, 0x1.871da4p-12f), + (float2)(0x1.900000p-1f, 0x1.cc2c00p-14f), + (float2)(0x1.930000p-1f, 0x1.9fdb68p-11f), + (float2)(0x1.968000p-1f, 0x1.ed6956p-12f), + (float2)(0x1.9a0000p-1f, 0x1.f1a760p-14f), + (float2)(0x1.9d0000p-1f, 0x1.767f54p-11f), + (float2)(0x1.a08000p-1f, 0x1.3f6d26p-12f), + (float2)(0x1.a38000p-1f, 0x1.b9fce2p-11f), + (float2)(0x1.a70000p-1f, 0x1.8ae816p-12f), + (float2)(0x1.aa0000p-1f, 0x1.c23d60p-11f), + (float2)(0x1.ad8000p-1f, 0x1.60f388p-12f), + (float2)(0x1.b08000p-1f, 0x1.9049aep-11f), + (float2)(0x1.b40000p-1f, 0x1.8734a8p-13f), + (float2)(0x1.b70000p-1f, 0x1.2523d4p-11f), + (float2)(0x1.ba0000p-1f, 0x1.da6ce6p-11f), + (float2)(0x1.bd8000p-1f, 0x1.038e62p-12f), + (float2)(0x1.c08000p-1f, 0x1.1b511ep-11f), + (float2)(0x1.c38000p-1f, 0x1.a728b8p-11f), + (float2)(0x1.c70000p-1f, 0x1.2b5d22p-14f), + (float2)(0x1.ca0000p-1f, 0x1.2c6e54p-12f), + (float2)(0x1.cd0000p-1f, 0x1.f35064p-12f), + (float2)(0x1.d00000p-1f, 0x1.4fdb48p-11f), + (float2)(0x1.d30000p-1f, 0x1.98ec9ep-11f), + (float2)(0x1.d60000p-1f, 0x1.d4f80cp-11f), + (float2)(0x1.d98000p-1f, 0x1.0643d6p-17f), + (float2)(0x1.dc8000p-1f, 0x1.33567ep-14f), + (float2)(0x1.df8000p-1f, 0x1.e0410cp-14f), + (float2)(0x1.e28000p-1f, 0x1.142e0ep-13f), + (float2)(0x1.e58000p-1f, 0x1.063c88p-13f), + (float2)(0x1.e88000p-1f, 0x1.8d66c4p-14f), + (float2)(0x1.eb8000p-1f, 0x1.57e32ap-15f), + (float2)(0x1.ee0000p-1f, 0x1.ed1c6cp-11f), + (float2)(0x1.f10000p-1f, 0x1.b8a076p-11f), + (float2)(0x1.f40000p-1f, 0x1.7822f2p-11f), + (float2)(0x1.f70000p-1f, 0x1.2bbc3ap-11f), + (float2)(0x1.fa0000p-1f, 0x1.a708bap-12f), + (float2)(0x1.fd0000p-1f, 0x1.be4c7ep-13f), + (float2)(0x1.000000p+0f, 0x0.000000p+0f) +}; + +TABLE_FUNCTION(float2, LOG2_TBL, log2_tbl); + +DECLARE_TABLE(float2, LOG10_TBL, 129) = { + (float2)(0x0.000000p+0f, 0x0.000000p+0f), + (float2)(0x1.ba8000p-9f, 0x1.f51c88p-19f), + (float2)(0x1.b90000p-8f, 0x1.1da93ep-18f), + (float2)(0x1.498000p-7f, 0x1.8428a2p-18f), + (float2)(0x1.b58000p-7f, 0x1.a423acp-17f), + (float2)(0x1.108000p-6f, 0x1.41d422p-17f), + (float2)(0x1.458000p-6f, 0x1.d3d6b2p-16f), + (float2)(0x1.7a8000p-6f, 0x1.70f7cep-16f), + (float2)(0x1.af0000p-6f, 0x1.7e4ac0p-16f), + (float2)(0x1.e38000p-6f, 0x1.ab2f40p-24f), + (float2)(0x1.0b8000p-5f, 0x1.00d40ap-16f), + (float2)(0x1.250000p-5f, 0x1.40b03ep-15f), + (float2)(0x1.3e8000p-5f, 0x1.446668p-15f), + (float2)(0x1.580000p-5f, 0x1.1c7758p-16f), + (float2)(0x1.710000p-5f, 0x1.20d09ep-15f), + (float2)(0x1.8a0000p-5f, 0x1.fd6f5cp-16f), + (float2)(0x1.a30000p-5f, 0x1.53ac12p-18f), + (float2)(0x1.bb8000p-5f, 0x1.4d02c6p-16f), + (float2)(0x1.d40000p-5f, 0x1.d5164ep-17f), + (float2)(0x1.ec0000p-5f, 0x1.991facp-15f), + (float2)(0x1.020000p-4f, 0x1.0a307cp-14f), + (float2)(0x1.0e0000p-4f, 0x1.e94ec0p-15f), + (float2)(0x1.1a0000p-4f, 0x1.1a22a8p-15f), + (float2)(0x1.258000p-4f, 0x1.d4857ap-14f), + (float2)(0x1.318000p-4f, 0x1.982ae2p-15f), + (float2)(0x1.3d0000p-4f, 0x1.74cd70p-14f), + (float2)(0x1.488000p-4f, 0x1.cfb476p-14f), + (float2)(0x1.540000p-4f, 0x1.ddcc64p-14f), + (float2)(0x1.5f8000p-4f, 0x1.a01222p-14f), + (float2)(0x1.6b0000p-4f, 0x1.177dbcp-14f), + (float2)(0x1.768000p-4f, 0x1.140a24p-16f), + (float2)(0x1.818000p-4f, 0x1.298f40p-14f), + (float2)(0x1.8c8000p-4f, 0x1.c60e20p-14f), + (float2)(0x1.980000p-4f, 0x1.b65052p-18f), + (float2)(0x1.a30000p-4f, 0x1.53ac12p-17f), + (float2)(0x1.ad8000p-4f, 0x1.f41d04p-14f), + (float2)(0x1.b88000p-4f, 0x1.7934eap-14f), + (float2)(0x1.c38000p-4f, 0x1.75252ep-15f), + (float2)(0x1.ce0000p-4f, 0x1.b90790p-14f), + (float2)(0x1.d90000p-4f, 0x1.d5866ap-16f), + (float2)(0x1.e38000p-4f, 0x1.e0d586p-15f), + (float2)(0x1.ee0000p-4f, 0x1.2ae984p-14f), + (float2)(0x1.f88000p-4f, 0x1.25a0d0p-14f), + (float2)(0x1.018000p-3f, 0x1.c2a064p-15f), + (float2)(0x1.068000p-3f, 0x1.2f59e8p-13f), + (float2)(0x1.0b8000p-3f, 0x1.cf424cp-13f), + (float2)(0x1.110000p-3f, 0x1.42f080p-15f), + (float2)(0x1.160000p-3f, 0x1.684156p-14f), + (float2)(0x1.1b0000p-3f, 0x1.f38f64p-14f), + (float2)(0x1.200000p-3f, 0x1.22077ap-13f), + (float2)(0x1.250000p-3f, 0x1.2d34d6p-13f), + (float2)(0x1.2a0000p-3f, 0x1.1ba328p-13f), + (float2)(0x1.2f0000p-3f, 0x1.db48e2p-14f), + (float2)(0x1.340000p-3f, 0x1.4712a0p-14f), + (float2)(0x1.390000p-3f, 0x1.ed0894p-16f), + (float2)(0x1.3d8000p-3f, 0x1.bc39b6p-13f), + (float2)(0x1.428000p-3f, 0x1.1f9ff8p-13f), + (float2)(0x1.478000p-3f, 0x1.a07d3ap-15f), + (float2)(0x1.4c0000p-3f, 0x1.9601fap-13f), + (float2)(0x1.510000p-3f, 0x1.532214p-14f), + (float2)(0x1.558000p-3f, 0x1.a31462p-13f), + (float2)(0x1.5a8000p-3f, 0x1.05a584p-14f), + (float2)(0x1.5f0000p-3f, 0x1.4911c8p-13f), + (float2)(0x1.638000p-3f, 0x1.f615fep-13f), + (float2)(0x1.688000p-3f, 0x1.1445b0p-14f), + (float2)(0x1.6d0000p-3f, 0x1.057abcp-13f), + (float2)(0x1.718000p-3f, 0x1.685f0ap-13f), + (float2)(0x1.760000p-3f, 0x1.b31022p-13f), + (float2)(0x1.7a8000p-3f, 0x1.e5cd62p-13f), + (float2)(0x1.7f8000p-3f, 0x1.aa6ca8p-22f), + (float2)(0x1.840000p-3f, 0x1.1944bcp-19f), + (float2)(0x1.880000p-3f, 0x1.f0b980p-13f), + (float2)(0x1.8c8000p-3f, 0x1.c60e20p-13f), + (float2)(0x1.910000p-3f, 0x1.849daep-13f), + (float2)(0x1.958000p-3f, 0x1.2ca202p-13f), + (float2)(0x1.9a0000p-3f, 0x1.7ca842p-14f), + (float2)(0x1.9e8000p-3f, 0x1.cf6180p-16f), + (float2)(0x1.a28000p-3f, 0x1.9fa186p-13f), + (float2)(0x1.a70000p-3f, 0x1.df5554p-14f), + (float2)(0x1.ab8000p-3f, 0x1.51eaccp-16f), + (float2)(0x1.af8000p-3f, 0x1.4f8e88p-13f), + (float2)(0x1.b40000p-3f, 0x1.7f49aap-15f), + (float2)(0x1.b80000p-3f, 0x1.5b3c72p-13f), + (float2)(0x1.bc8000p-3f, 0x1.07fd5cp-15f), + (float2)(0x1.c08000p-3f, 0x1.144d18p-13f), + (float2)(0x1.c48000p-3f, 0x1.d25700p-13f), + (float2)(0x1.c90000p-3f, 0x1.f1369ep-15f), + (float2)(0x1.cd0000p-3f, 0x1.1260fap-13f), + (float2)(0x1.d10000p-3f, 0x1.94c038p-13f), + (float2)(0x1.d58000p-3f, 0x1.ccfdb8p-20f), + (float2)(0x1.d98000p-3f, 0x1.7c70dap-15f), + (float2)(0x1.dd8000p-3f, 0x1.4ee87ap-14f), + (float2)(0x1.e18000p-3f, 0x1.b99d86p-14f), + (float2)(0x1.e58000p-3f, 0x1.feafc0p-14f), + (float2)(0x1.e98000p-3f, 0x1.0f3b16p-13f), + (float2)(0x1.ed8000p-3f, 0x1.0ca34cp-13f), + (float2)(0x1.f18000p-3f, 0x1.ef75b2p-14f), + (float2)(0x1.f58000p-3f, 0x1.a15704p-14f), + (float2)(0x1.f98000p-3f, 0x1.2f3cfap-14f), + (float2)(0x1.fd8000p-3f, 0x1.32f1dcp-15f), + (float2)(0x1.008000p-2f, 0x1.f02d90p-13f), + (float2)(0x1.028000p-2f, 0x1.821964p-13f), + (float2)(0x1.048000p-2f, 0x1.02a708p-13f), + (float2)(0x1.068000p-2f, 0x1.c7f450p-15f), + (float2)(0x1.080000p-2f, 0x1.e820cap-12f), + (float2)(0x1.0a0000p-2f, 0x1.8ecd14p-12f), + (float2)(0x1.0c0000p-2f, 0x1.2d15f4p-12f), + (float2)(0x1.0e0000p-2f, 0x1.861b72p-13f), + (float2)(0x1.100000p-2f, 0x1.4319e6p-14f), + (float2)(0x1.118000p-2f, 0x1.d6520ep-12f), + (float2)(0x1.138000p-2f, 0x1.53c218p-12f), + (float2)(0x1.158000p-2f, 0x1.925000p-13f), + (float2)(0x1.178000p-2f, 0x1.b4a7a2p-15f), + (float2)(0x1.190000p-2f, 0x1.9c19eep-12f), + (float2)(0x1.1b0000p-2f, 0x1.f38f64p-13f), + (float2)(0x1.1d0000p-2f, 0x1.3ebb32p-14f), + (float2)(0x1.1e8000p-2f, 0x1.9ddf96p-12f), + (float2)(0x1.208000p-2f, 0x1.c8d472p-13f), + (float2)(0x1.228000p-2f, 0x1.1af536p-15f), + (float2)(0x1.240000p-2f, 0x1.5acca0p-12f), + (float2)(0x1.260000p-2f, 0x1.158770p-13f), + (float2)(0x1.278000p-2f, 0x1.b35350p-12f), + (float2)(0x1.298000p-2f, 0x1.a91532p-13f), + (float2)(0x1.2b0000p-2f, 0x1.ee7896p-12f), + (float2)(0x1.2d0000p-2f, 0x1.012c1cp-12f), + (float2)(0x1.2f0000p-2f, 0x1.967ab4p-17f), + (float2)(0x1.308000p-2f, 0x1.111e3cp-12f), + (float2)(0x1.328000p-2f, 0x1.cf340ep-17f), + (float2)(0x1.340000p-2f, 0x1.04d426p-12f), +}; + +TABLE_FUNCTION(float2, LOG10_TBL, log10_tbl); + + +DECLARE_TABLE(float, EXP_TBL, 65) = { + 0x1.000000p+0f, 0x1.02c9a4p+0f, 0x1.059b0ep+0f, 0x1.087452p+0f, + 0x1.0b5586p+0f, 0x1.0e3ec4p+0f, 0x1.11301ep+0f, 0x1.1429aap+0f, + 0x1.172b84p+0f, 0x1.1a35bep+0f, 0x1.1d4874p+0f, 0x1.2063b8p+0f, + 0x1.2387a6p+0f, 0x1.26b456p+0f, 0x1.29e9e0p+0f, 0x1.2d285ap+0f, + 0x1.306fe0p+0f, 0x1.33c08cp+0f, 0x1.371a74p+0f, 0x1.3a7db4p+0f, + 0x1.3dea64p+0f, 0x1.4160a2p+0f, 0x1.44e086p+0f, 0x1.486a2cp+0f, + 0x1.4bfdaep+0f, 0x1.4f9b28p+0f, 0x1.5342b6p+0f, 0x1.56f474p+0f, + 0x1.5ab07ep+0f, 0x1.5e76f2p+0f, 0x1.6247ecp+0f, 0x1.662388p+0f, + 0x1.6a09e6p+0f, 0x1.6dfb24p+0f, 0x1.71f75ep+0f, 0x1.75feb6p+0f, + 0x1.7a1148p+0f, 0x1.7e2f34p+0f, 0x1.82589ap+0f, 0x1.868d9ap+0f, + 0x1.8ace54p+0f, 0x1.8f1aeap+0f, 0x1.93737cp+0f, 0x1.97d82ap+0f, + 0x1.9c4918p+0f, 0x1.a0c668p+0f, 0x1.a5503cp+0f, 0x1.a9e6b6p+0f, + 0x1.ae89fap+0f, 0x1.b33a2cp+0f, 0x1.b7f770p+0f, 0x1.bcc1eap+0f, + 0x1.c199bep+0f, 0x1.c67f12p+0f, 0x1.cb720ep+0f, 0x1.d072d4p+0f, + 0x1.d5818ep+0f, 0x1.da9e60p+0f, 0x1.dfc974p+0f, 0x1.e502eep+0f, + 0x1.ea4afap+0f, 0x1.efa1bep+0f, 0x1.f50766p+0f, 0x1.fa7c18p+0f, + 0x1.000000p+1f, +}; + +CLC_TABLE_FUNCTION(float, EXP_TBL, exp_tbl); + +DECLARE_TABLE(float, EXP_TBL_EP_HEAD, 65) = { + 0x1.000000p+0f, 0x1.02c000p+0f, 0x1.058000p+0f, 0x1.084000p+0f, + 0x1.0b4000p+0f, 0x1.0e0000p+0f, 0x1.110000p+0f, 0x1.140000p+0f, + 0x1.170000p+0f, 0x1.1a0000p+0f, 0x1.1d4000p+0f, 0x1.204000p+0f, + 0x1.238000p+0f, 0x1.268000p+0f, 0x1.29c000p+0f, 0x1.2d0000p+0f, + 0x1.304000p+0f, 0x1.33c000p+0f, 0x1.370000p+0f, 0x1.3a4000p+0f, + 0x1.3dc000p+0f, 0x1.414000p+0f, 0x1.44c000p+0f, 0x1.484000p+0f, + 0x1.4bc000p+0f, 0x1.4f8000p+0f, 0x1.534000p+0f, 0x1.56c000p+0f, + 0x1.5a8000p+0f, 0x1.5e4000p+0f, 0x1.624000p+0f, 0x1.660000p+0f, + 0x1.6a0000p+0f, 0x1.6dc000p+0f, 0x1.71c000p+0f, 0x1.75c000p+0f, + 0x1.7a0000p+0f, 0x1.7e0000p+0f, 0x1.824000p+0f, 0x1.868000p+0f, + 0x1.8ac000p+0f, 0x1.8f0000p+0f, 0x1.934000p+0f, 0x1.97c000p+0f, + 0x1.9c4000p+0f, 0x1.a0c000p+0f, 0x1.a54000p+0f, 0x1.a9c000p+0f, + 0x1.ae8000p+0f, 0x1.b30000p+0f, 0x1.b7c000p+0f, 0x1.bcc000p+0f, + 0x1.c18000p+0f, 0x1.c64000p+0f, 0x1.cb4000p+0f, 0x1.d04000p+0f, + 0x1.d58000p+0f, 0x1.da8000p+0f, 0x1.dfc000p+0f, 0x1.e50000p+0f, + 0x1.ea4000p+0f, 0x1.ef8000p+0f, 0x1.f50000p+0f, 0x1.fa4000p+0f, + 0x1.000000p+1f, +}; + +CLC_TABLE_FUNCTION(float, EXP_TBL_EP_HEAD, exp_tbl_ep_head); + +DECLARE_TABLE(float, EXP_TBL_EP_TAIL, 65) = { + 0x0.000000p+0f, 0x1.347ceep-13f, 0x1.b0d314p-12f, 0x1.a28c3ap-11f, + 0x1.586cf8p-12f, 0x1.f61968p-11f, 0x1.80e808p-11f, 0x1.4d5754p-11f, + 0x1.5c1e3ep-11f, 0x1.adf5b6p-11f, 0x1.0e62d0p-13f, 0x1.1dc430p-11f, + 0x1.e9b9d4p-14f, 0x1.a2b2f0p-11f, 0x1.4efa8ep-11f, 0x1.42d372p-11f, + 0x1.7f0518p-11f, 0x1.164c82p-17f, 0x1.a7373ap-12f, 0x1.ed9a72p-11f, + 0x1.532608p-11f, 0x1.0510fap-11f, 0x1.043030p-11f, 0x1.515ae0p-11f, + 0x1.ed6a9ap-11f, 0x1.b2769cp-12f, 0x1.5ab4eap-15f, 0x1.a39b5ap-11f, + 0x1.83eea4p-11f, 0x1.b78ad6p-11f, 0x1.fac0e8p-14f, 0x1.1c412ap-11f, + 0x1.3cccfep-13f, 0x1.d91e32p-11f, 0x1.baf476p-11f, 0x1.f5ab20p-11f, + 0x1.1473eap-12f, 0x1.799b66p-11f, 0x1.89994cp-12f, 0x1.b33688p-13f, + 0x1.ca8454p-13f, 0x1.ae9914p-12f, 0x1.9bd866p-11f, 0x1.829fdep-12f, + 0x1.230546p-13f, 0x1.99ed76p-14f, 0x1.03b23ep-12f, 0x1.35aabcp-11f, + 0x1.3f32b4p-13f, 0x1.d15c26p-11f, 0x1.bb797cp-11f, 0x1.e904bcp-16f, + 0x1.9bdd84p-12f, 0x1.f8972ap-11f, 0x1.906e76p-11f, 0x1.96a502p-11f, + 0x1.8dcfbap-16f, 0x1.e603dap-12f, 0x1.2e66f6p-13f, 0x1.773c58p-15f, + 0x1.5f4548p-13f, 0x1.0df730p-11f, 0x1.d96db8p-14f, 0x1.e0c0cep-11f, + 0x0.000000p+0f, +}; + +CLC_TABLE_FUNCTION(float, EXP_TBL_EP_TAIL, exp_tbl_ep_tail); + +DECLARE_TABLE(float, CBRT_TBL_HEAD, 129) = { + 0x1.000000p+0f, 0x1.008000p+0f, 0x1.014000p+0f, 0x1.01c000p+0f, + 0x1.028000p+0f, 0x1.034000p+0f, 0x1.03c000p+0f, 0x1.048000p+0f, + 0x1.050000p+0f, 0x1.05c000p+0f, 0x1.068000p+0f, 0x1.070000p+0f, + 0x1.07c000p+0f, 0x1.084000p+0f, 0x1.090000p+0f, 0x1.098000p+0f, + 0x1.0a4000p+0f, 0x1.0ac000p+0f, 0x1.0b4000p+0f, 0x1.0c0000p+0f, + 0x1.0c8000p+0f, 0x1.0d4000p+0f, 0x1.0dc000p+0f, 0x1.0e4000p+0f, + 0x1.0f0000p+0f, 0x1.0f8000p+0f, 0x1.104000p+0f, 0x1.10c000p+0f, + 0x1.114000p+0f, 0x1.120000p+0f, 0x1.128000p+0f, 0x1.130000p+0f, + 0x1.13c000p+0f, 0x1.144000p+0f, 0x1.14c000p+0f, 0x1.154000p+0f, + 0x1.160000p+0f, 0x1.168000p+0f, 0x1.170000p+0f, 0x1.178000p+0f, + 0x1.184000p+0f, 0x1.18c000p+0f, 0x1.194000p+0f, 0x1.19c000p+0f, + 0x1.1a4000p+0f, 0x1.1b0000p+0f, 0x1.1b8000p+0f, 0x1.1c0000p+0f, + 0x1.1c8000p+0f, 0x1.1d0000p+0f, 0x1.1d8000p+0f, 0x1.1e4000p+0f, + 0x1.1ec000p+0f, 0x1.1f4000p+0f, 0x1.1fc000p+0f, 0x1.204000p+0f, + 0x1.20c000p+0f, 0x1.214000p+0f, 0x1.21c000p+0f, 0x1.224000p+0f, + 0x1.22c000p+0f, 0x1.238000p+0f, 0x1.240000p+0f, 0x1.248000p+0f, + 0x1.250000p+0f, 0x1.258000p+0f, 0x1.260000p+0f, 0x1.268000p+0f, + 0x1.270000p+0f, 0x1.278000p+0f, 0x1.280000p+0f, 0x1.288000p+0f, + 0x1.290000p+0f, 0x1.298000p+0f, 0x1.2a0000p+0f, 0x1.2a8000p+0f, + 0x1.2b0000p+0f, 0x1.2b8000p+0f, 0x1.2c0000p+0f, 0x1.2c4000p+0f, + 0x1.2cc000p+0f, 0x1.2d4000p+0f, 0x1.2dc000p+0f, 0x1.2e4000p+0f, + 0x1.2ec000p+0f, 0x1.2f4000p+0f, 0x1.2fc000p+0f, 0x1.304000p+0f, + 0x1.30c000p+0f, 0x1.314000p+0f, 0x1.318000p+0f, 0x1.320000p+0f, + 0x1.328000p+0f, 0x1.330000p+0f, 0x1.338000p+0f, 0x1.340000p+0f, + 0x1.344000p+0f, 0x1.34c000p+0f, 0x1.354000p+0f, 0x1.35c000p+0f, + 0x1.364000p+0f, 0x1.36c000p+0f, 0x1.370000p+0f, 0x1.378000p+0f, + 0x1.380000p+0f, 0x1.388000p+0f, 0x1.390000p+0f, 0x1.394000p+0f, + 0x1.39c000p+0f, 0x1.3a4000p+0f, 0x1.3ac000p+0f, 0x1.3b0000p+0f, + 0x1.3b8000p+0f, 0x1.3c0000p+0f, 0x1.3c8000p+0f, 0x1.3cc000p+0f, + 0x1.3d4000p+0f, 0x1.3dc000p+0f, 0x1.3e4000p+0f, 0x1.3e8000p+0f, + 0x1.3f0000p+0f, 0x1.3f8000p+0f, 0x1.400000p+0f, 0x1.404000p+0f, + 0x1.40c000p+0f, 0x1.414000p+0f, 0x1.418000p+0f, 0x1.420000p+0f, + 0x1.428000p+0f, +}; + +CLC_TABLE_FUNCTION(float, CBRT_TBL_HEAD, cbrt_tbl_head); + +DECLARE_TABLE(float, CBRT_TBL_TAIL, 129) = { + 0x0.000000p+0f, 0x1.51cb0ap-11f, 0x1.39221ep-12f, 0x1.e06908p-11f, + 0x1.1d6978p-11f, 0x1.4ea1bep-13f, 0x1.833b8ep-11f, 0x1.587002p-12f, + 0x1.ceb290p-11f, 0x1.d57f34p-12f, 0x1.cc53acp-21f, 0x1.0fe098p-11f, + 0x1.91b586p-15f, 0x1.1c362ep-11f, 0x1.94398ep-15f, 0x1.1055bcp-11f, + 0x1.7e63cap-19f, 0x1.d99e1ap-12f, 0x1.d258dep-11f, 0x1.645962p-12f, + 0x1.8c5b0ep-11f, 0x1.83d0c8p-13f, 0x1.300812p-11f, 0x1.f9a65ap-11f, + 0x1.7bbcd8p-12f, 0x1.7cbf68p-11f, 0x1.b2c166p-14f, 0x1.d56ea4p-12f, + 0x1.99eb32p-11f, 0x1.1007a2p-13f, 0x1.d212aap-12f, 0x1.890f18p-11f, + 0x1.2104e2p-14f, 0x1.74961ep-12f, 0x1.4b9b66p-11f, 0x1.d81e66p-11f, + 0x1.7f825cp-13f, 0x1.c5dca2p-12f, 0x1.6153bap-11f, 0x1.db1cc2p-11f, + 0x1.4154b0p-13f, 0x1.821114p-12f, 0x1.2d4240p-11f, 0x1.950d82p-11f, + 0x1.f8755cp-11f, 0x1.5e12a4p-13f, 0x1.648c38p-12f, 0x1.08c43ep-11f, + 0x1.5b0970p-11f, 0x1.a91fe8p-11f, 0x1.f311b6p-11f, 0x1.c74618p-14f, + 0x1.eabb54p-13f, 0x1.70db14p-12f, 0x1.e45cbcp-12f, 0x1.27faa6p-11f, + 0x1.59db98p-11f, 0x1.87da46p-11f, 0x1.b1ffa0p-11f, 0x1.d85478p-11f, + 0x1.fae17ep-11f, 0x1.9af40cp-15f, 0x1.a6319ep-14f, 0x1.30baa6p-13f, + 0x1.7fc362p-13f, 0x1.c05362p-13f, 0x1.f28a98p-13f, 0x1.0b4442p-12f, + 0x1.16361ap-12f, 0x1.1a2a2ap-12f, 0x1.172f8ep-12f, 0x1.0d5530p-12f, + 0x1.f9538ep-13f, 0x1.ca77b0p-13f, 0x1.8e336ap-13f, 0x1.44a304p-13f, + 0x1.dbc4c8p-14f, 0x1.141a2ap-14f, 0x1.93e44cp-17f, 0x1.e6e432p-11f, + 0x1.c447c6p-11f, 0x1.9e80d8p-11f, 0x1.7595dcp-11f, 0x1.498d30p-11f, + 0x1.1a6d1ep-11f, 0x1.d077bap-12f, 0x1.65ff1ep-12f, 0x1.eaf912p-13f, + 0x1.fbefb8p-14f, 0x1.44905ap-19f, 0x1.c017e6p-11f, 0x1.7bfdbep-11f, + 0x1.34fbc6p-11f, 0x1.d62f48p-12f, 0x1.3cadc6p-12f, 0x1.3afc06p-13f, + 0x1.fc556ep-11f, 0x1.a71f84p-11f, 0x1.4f2290p-11f, 0x1.e8c79cp-12f, + 0x1.2dd0d8p-12f, 0x1.b5ac2ep-14f, 0x1.d3d02ap-11f, 0x1.6e3d58p-11f, + 0x1.060200p-11f, 0x1.364608p-12f, 0x1.6d29b6p-14f, 0x1.bd8d5ep-11f, + 0x1.4ae030p-11f, 0x1.ab44b2p-12f, 0x1.7761cep-13f, 0x1.e38710p-11f, + 0x1.66b2b0p-11f, 0x1.cebf96p-12f, 0x1.964b20p-13f, 0x1.e15004p-11f, + 0x1.5a9bcep-11f, 0x1.a2f4d8p-12f, 0x1.17c056p-13f, 0x1.b800f8p-11f, + 0x1.27b132p-11f, 0x1.2a09b8p-12f, 0x0.000000p+0f, 0x1.68a69cp-11f, + 0x1.9df950p-12f, 0x1.983050p-14f, 0x1.94c6a4p-11f, 0x1.e88494p-12f, + 0x1.45f31ap-13f, +}; + +CLC_TABLE_FUNCTION(float, CBRT_TBL_TAIL, cbrt_tbl_tail); + +// Tabulated values of sinh(i) and cosh(i) for i = 0,...,36. +DECLARE_TABLE(float, SINHCOSH_TBL_HEAD, 37) = { + 0x0.000000p+0f, 0x1.2cd9fcp+0f, 0x1.d03cf6p+1f, 0x1.40926ep+3f, + 0x1.b4a380p+4f, 0x1.28d016p+6f, 0x1.936d22p+7f, 0x1.122876p+9f, + 0x1.749ea6p+10f, 0x1.fa7158p+11f, 0x1.5829dcp+13f, 0x1.d3c448p+14f, + 0x1.3de166p+16f, 0x1.b00b5ap+17f, 0x1.259ac4p+19f, 0x1.8f0ccap+20f, + 0x1.0f2ebep+22f, 0x1.709348p+23f, 0x1.f4f220p+24f, 0x1.546d90p+26f, + 0x1.ceb088p+27f, 0x1.3a6e20p+29f, 0x1.ab5adcp+30f, 0x1.226af4p+32f, + 0x1.8ab7fcp+33f, 0x1.0c3d3ap+35f, 0x1.6c9326p+36f, 0x1.ef8230p+37f, + 0x1.50bba4p+39f, 0x1.c9aae4p+40f, 0x1.370470p+42f, 0x1.a6b766p+43f, + 0x1.1f43fcp+45f, 0x1.866f34p+46f, 0x1.0953e2p+48f, 0x1.689e22p+49f, + 0x1.ea215ap+50f, +}; + +CLC_TABLE_FUNCTION(float, SINHCOSH_TBL_HEAD, sinhcosh_tbl_head); + +DECLARE_TABLE(float, SINHCOSH_TBL_TAIL, 37) = { + 0x1.000000p+0f, 0x1.8b0756p+0f, 0x1.e18fa0p+1f, 0x1.422a4ap+3f, + 0x1.b4ee86p+4f, 0x1.28d6fcp+6f, 0x1.936e68p+7f, 0x1.122894p+9f, + 0x1.749eaap+10f, 0x1.fa7158p+11f, 0x1.5829dep+13f, 0x1.d3c448p+14f, + 0x1.3de166p+16f, 0x1.b00b5ap+17f, 0x1.259ac4p+19f, 0x1.8f0ccap+20f, + 0x1.0f2ebep+22f, 0x1.709348p+23f, 0x1.f4f220p+24f, 0x1.546d90p+26f, + 0x1.ceb088p+27f, 0x1.3a6e20p+29f, 0x1.ab5adcp+30f, 0x1.226af4p+32f, + 0x1.8ab7fcp+33f, 0x1.0c3d3ap+35f, 0x1.6c9326p+36f, 0x1.ef8230p+37f, + 0x1.50bba4p+39f, 0x1.c9aae4p+40f, 0x1.370470p+42f, 0x1.a6b766p+43f, + 0x1.1f43fcp+45f, 0x1.866f34p+46f, 0x1.0953e2p+48f, 0x1.689e22p+49f, + 0x1.ea215ap+50f, +}; + +CLC_TABLE_FUNCTION(float, SINHCOSH_TBL_TAIL, sinhcosh_tbl_tail); + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +DECLARE_TABLE(double, LN_TBL_LO, 65) = { + 0x0.0000000000000p+0, 0x1.fc0a800000000p-7, 0x1.f829800000000p-6, + 0x1.7745800000000p-5, 0x1.f0a3000000000p-5, 0x1.341d700000000p-4, + 0x1.6f0d200000000p-4, 0x1.a926d00000000p-4, 0x1.e270700000000p-4, + 0x1.0d77e00000000p-3, 0x1.2955280000000p-3, 0x1.44d2b00000000p-3, + 0x1.5ff3000000000p-3, 0x1.7ab8900000000p-3, 0x1.9525a80000000p-3, + 0x1.af3c900000000p-3, 0x1.c8ff780000000p-3, 0x1.e270700000000p-3, + 0x1.fb91800000000p-3, 0x1.0a324c0000000p-2, 0x1.1675c80000000p-2, + 0x1.22941c0000000p-2, 0x1.2e8e280000000p-2, 0x1.3a64c40000000p-2, + 0x1.4618bc0000000p-2, 0x1.51aad80000000p-2, 0x1.5d1bd80000000p-2, + 0x1.686c800000000p-2, 0x1.739d7c0000000p-2, 0x1.7eaf800000000p-2, + 0x1.89a3380000000p-2, 0x1.9479400000000p-2, 0x1.9f323c0000000p-2, + 0x1.a9cec80000000p-2, 0x1.b44f740000000p-2, 0x1.beb4d80000000p-2, + 0x1.c8ff7c0000000p-2, 0x1.d32fe40000000p-2, 0x1.dd46a00000000p-2, + 0x1.e744240000000p-2, 0x1.f128f40000000p-2, 0x1.faf5880000000p-2, + 0x1.02552a0000000p-1, 0x1.0723e40000000p-1, 0x1.0be72e0000000p-1, + 0x1.109f380000000p-1, 0x1.154c3c0000000p-1, 0x1.19ee6a0000000p-1, + 0x1.1e85f40000000p-1, 0x1.23130c0000000p-1, 0x1.2795e00000000p-1, + 0x1.2c0e9e0000000p-1, 0x1.307d720000000p-1, 0x1.34e2880000000p-1, + 0x1.393e0c0000000p-1, 0x1.3d90260000000p-1, 0x1.41d8fe0000000p-1, + 0x1.4618bc0000000p-1, 0x1.4a4f840000000p-1, 0x1.4e7d800000000p-1, + 0x1.52a2d20000000p-1, 0x1.56bf9c0000000p-1, 0x1.5ad4040000000p-1, + 0x1.5ee02a0000000p-1, 0x1.62e42e0000000p-1, +}; + +CLC_TABLE_FUNCTION(double, LN_TBL_LO, ln_tbl_lo); + +DECLARE_TABLE(double, LN_TBL_HI, 65) = { + 0x0.0000000000000p+0, 0x1.61f807c79f3dbp-28, 0x1.873c1980267c8p-25, + 0x1.ec65b9f88c69ep-26, 0x1.8022c54cc2f99p-26, 0x1.2c37a3a125330p-25, + 0x1.15cad69737c93p-25, 0x1.d256ab1b285e9p-27, 0x1.b8abcb97a7aa2p-26, + 0x1.f34239659a5dcp-25, 0x1.e07fd48d30177p-25, 0x1.b32df4799f4f6p-25, + 0x1.c29e4f4f21cf8p-25, 0x1.086c848df1b59p-30, 0x1.cf456b4764130p-27, + 0x1.3a02ffcb63398p-25, 0x1.1e6a6886b0976p-25, 0x1.b8abcb97a7aa2p-25, + 0x1.b578f8aa35552p-25, 0x1.139c871afb9fcp-25, 0x1.5d5d30701ce64p-25, + 0x1.de7bcb2d12142p-25, 0x1.d708e984e1664p-25, 0x1.56945e9c72f36p-26, + 0x1.0e2f613e85bdap-29, 0x1.cb7e0b42724f6p-28, 0x1.fac04e52846c7p-25, + 0x1.e9b14aec442bep-26, 0x1.b5de8034e7126p-25, 0x1.dc157e1b259d3p-25, + 0x1.b05096ad69c62p-28, 0x1.c2116faba4cddp-26, 0x1.65fcc25f95b47p-25, + 0x1.a9a08498d4850p-26, 0x1.de647b1465f77p-25, 0x1.da71b7bf7861dp-26, + 0x1.e6a6886b09760p-28, 0x1.f0075eab0ef64p-25, 0x1.3071282fb989bp-28, + 0x1.0eb43c3f1bed2p-25, 0x1.faf06ecb35c84p-26, 0x1.ef1e63db35f68p-27, + 0x1.69743fb1a71a5p-27, 0x1.c1cdf404e5796p-25, 0x1.094aa0ada625ep-27, + 0x1.e2d4c96fde3ecp-25, 0x1.2f4d5e9a98f34p-25, 0x1.467c96ecc5cbep-25, + 0x1.e7040d03dec5ap-25, 0x1.7bebf4282de36p-25, 0x1.289b11aeb783fp-25, + 0x1.a891d1772f538p-26, 0x1.34f10be1fb591p-25, 0x1.d9ce1d316eb93p-25, + 0x1.3562a19a9c442p-25, 0x1.4e2adf548084cp-26, 0x1.08ce55cc8c97ap-26, + 0x1.0e2f613e85bdap-28, 0x1.db03ebb0227bfp-25, 0x1.1b75bb09cb098p-25, + 0x1.96f16abb9df22p-27, 0x1.5b3f399411c62p-25, 0x1.86b3e59f65355p-26, + 0x1.2482ceae1ac12p-26, 0x1.efa39ef35793cp-25, +}; + +CLC_TABLE_FUNCTION(double, LN_TBL_HI, ln_tbl_hi); + +// Arrays atan_jby256_head and atan_jby256_tail contain leading and trailing +// parts respectively of precomputed values of atan(j/256), for j = 16, 17, ..., +// 256. atan_jby256_head contains the first 21 bits of precision, and +// atan_jby256_tail contains a further 53 bits precision. + +DECLARE_TABLE(double, ATAN_JBY256_TBL_HEAD, 241) = { + 0x1.ff55b00000000p-5, 0x1.0f99e00000000p-4, 0x1.1f86d00000000p-4, + 0x1.2f71900000000p-4, 0x1.3f59f00000000p-4, 0x1.4f3fd00000000p-4, + 0x1.5f23200000000p-4, 0x1.6f03b00000000p-4, 0x1.7ee1800000000p-4, + 0x1.8ebc500000000p-4, 0x1.9e94100000000p-4, 0x1.ae68a00000000p-4, + 0x1.be39e00000000p-4, 0x1.ce07c00000000p-4, 0x1.ddd2100000000p-4, + 0x1.ed98c00000000p-4, 0x1.fd5ba00000000p-4, 0x1.068d500000000p-3, + 0x1.0e6ad00000000p-3, 0x1.1646500000000p-3, 0x1.1e1fa00000000p-3, + 0x1.25f6e00000000p-3, 0x1.2dcbd00000000p-3, 0x1.359e800000000p-3, + 0x1.3d6ee00000000p-3, 0x1.453ce00000000p-3, 0x1.4d08700000000p-3, + 0x1.54d1800000000p-3, 0x1.5c98100000000p-3, 0x1.645bf00000000p-3, + 0x1.6c1d400000000p-3, 0x1.73dbd00000000p-3, 0x1.7b97b00000000p-3, + 0x1.8350b00000000p-3, 0x1.8b06e00000000p-3, 0x1.92ba300000000p-3, + 0x1.9a6a800000000p-3, 0x1.a217e00000000p-3, 0x1.a9c2300000000p-3, + 0x1.b169600000000p-3, 0x1.b90d700000000p-3, 0x1.c0ae500000000p-3, + 0x1.c84bf00000000p-3, 0x1.cfe6500000000p-3, 0x1.d77d500000000p-3, + 0x1.df11000000000p-3, 0x1.e6a1400000000p-3, 0x1.ee2e100000000p-3, + 0x1.f5b7500000000p-3, 0x1.fd3d100000000p-3, 0x1.025fa00000000p-2, + 0x1.061ee00000000p-2, 0x1.09dc500000000p-2, 0x1.0d97e00000000p-2, + 0x1.1151a00000000p-2, 0x1.1509700000000p-2, 0x1.18bf500000000p-2, + 0x1.1c73500000000p-2, 0x1.2025500000000p-2, 0x1.23d5600000000p-2, + 0x1.2783700000000p-2, 0x1.2b2f700000000p-2, 0x1.2ed9800000000p-2, + 0x1.3281800000000p-2, 0x1.3627700000000p-2, 0x1.39cb400000000p-2, + 0x1.3d6d100000000p-2, 0x1.410cb00000000p-2, 0x1.44aa400000000p-2, + 0x1.4845a00000000p-2, 0x1.4bdee00000000p-2, 0x1.4f75f00000000p-2, + 0x1.530ad00000000p-2, 0x1.569d800000000p-2, 0x1.5a2e000000000p-2, + 0x1.5dbc300000000p-2, 0x1.6148400000000p-2, 0x1.64d1f00000000p-2, + 0x1.6859700000000p-2, 0x1.6bdea00000000p-2, 0x1.6f61900000000p-2, + 0x1.72e2200000000p-2, 0x1.7660700000000p-2, 0x1.79dc600000000p-2, + 0x1.7d56000000000p-2, 0x1.80cd400000000p-2, 0x1.8442200000000p-2, + 0x1.87b4b00000000p-2, 0x1.8b24d00000000p-2, 0x1.8e92900000000p-2, + 0x1.91fde00000000p-2, 0x1.9566d00000000p-2, 0x1.98cd500000000p-2, + 0x1.9c31600000000p-2, 0x1.9f93000000000p-2, 0x1.a2f2300000000p-2, + 0x1.a64ee00000000p-2, 0x1.a9a9200000000p-2, 0x1.ad00f00000000p-2, + 0x1.b056400000000p-2, 0x1.b3a9100000000p-2, 0x1.b6f9600000000p-2, + 0x1.ba47300000000p-2, 0x1.bd92800000000p-2, 0x1.c0db400000000p-2, + 0x1.c421900000000p-2, 0x1.c765500000000p-2, 0x1.caa6800000000p-2, + 0x1.cde5300000000p-2, 0x1.d121500000000p-2, 0x1.d45ae00000000p-2, + 0x1.d791f00000000p-2, 0x1.dac6700000000p-2, 0x1.ddf8500000000p-2, + 0x1.e127b00000000p-2, 0x1.e454800000000p-2, 0x1.e77eb00000000p-2, + 0x1.eaa6500000000p-2, 0x1.edcb600000000p-2, 0x1.f0ede00000000p-2, + 0x1.f40dd00000000p-2, 0x1.f72b200000000p-2, 0x1.fa45d00000000p-2, + 0x1.fd5e000000000p-2, 0x1.0039c00000000p-1, 0x1.01c3400000000p-1, + 0x1.034b700000000p-1, 0x1.04d2500000000p-1, 0x1.0657e00000000p-1, + 0x1.07dc300000000p-1, 0x1.095f300000000p-1, 0x1.0ae0e00000000p-1, + 0x1.0c61400000000p-1, 0x1.0de0500000000p-1, 0x1.0f5e200000000p-1, + 0x1.10daa00000000p-1, 0x1.1255d00000000p-1, 0x1.13cfb00000000p-1, + 0x1.1548500000000p-1, 0x1.16bfa00000000p-1, 0x1.1835a00000000p-1, + 0x1.19aa500000000p-1, 0x1.1b1dc00000000p-1, 0x1.1c8fe00000000p-1, + 0x1.1e00b00000000p-1, 0x1.1f70400000000p-1, 0x1.20de800000000p-1, + 0x1.224b700000000p-1, 0x1.23b7100000000p-1, 0x1.2521700000000p-1, + 0x1.268a900000000p-1, 0x1.27f2600000000p-1, 0x1.2958e00000000p-1, + 0x1.2abe200000000p-1, 0x1.2c22100000000p-1, 0x1.2d84c00000000p-1, + 0x1.2ee6200000000p-1, 0x1.3046400000000p-1, 0x1.31a5200000000p-1, + 0x1.3302b00000000p-1, 0x1.345f000000000p-1, 0x1.35ba000000000p-1, + 0x1.3713d00000000p-1, 0x1.386c500000000p-1, 0x1.39c3900000000p-1, + 0x1.3b19800000000p-1, 0x1.3c6e400000000p-1, 0x1.3dc1c00000000p-1, + 0x1.3f13f00000000p-1, 0x1.4064f00000000p-1, 0x1.41b4a00000000p-1, + 0x1.4303200000000p-1, 0x1.4450600000000p-1, 0x1.459c600000000p-1, + 0x1.46e7200000000p-1, 0x1.4830a00000000p-1, 0x1.4978f00000000p-1, + 0x1.4ac0000000000p-1, 0x1.4c05e00000000p-1, 0x1.4d4a800000000p-1, + 0x1.4e8de00000000p-1, 0x1.4fd0100000000p-1, 0x1.5111000000000p-1, + 0x1.5250c00000000p-1, 0x1.538f500000000p-1, 0x1.54cca00000000p-1, + 0x1.5608d00000000p-1, 0x1.5743c00000000p-1, 0x1.587d800000000p-1, + 0x1.59b6000000000p-1, 0x1.5aed600000000p-1, 0x1.5c23900000000p-1, + 0x1.5d58900000000p-1, 0x1.5e8c600000000p-1, 0x1.5fbf000000000p-1, + 0x1.60f0800000000p-1, 0x1.6220d00000000p-1, 0x1.634ff00000000p-1, + 0x1.647de00000000p-1, 0x1.65aab00000000p-1, 0x1.66d6600000000p-1, + 0x1.6800e00000000p-1, 0x1.692a400000000p-1, 0x1.6a52700000000p-1, + 0x1.6b79800000000p-1, 0x1.6c9f700000000p-1, 0x1.6dc4400000000p-1, + 0x1.6ee7f00000000p-1, 0x1.700a700000000p-1, 0x1.712be00000000p-1, + 0x1.724c300000000p-1, 0x1.736b600000000p-1, 0x1.7489700000000p-1, + 0x1.75a6700000000p-1, 0x1.76c2400000000p-1, 0x1.77dd100000000p-1, + 0x1.78f6b00000000p-1, 0x1.7a0f400000000p-1, 0x1.7b26c00000000p-1, + 0x1.7c3d300000000p-1, 0x1.7d52800000000p-1, 0x1.7e66c00000000p-1, + 0x1.7f79e00000000p-1, 0x1.808c000000000p-1, 0x1.819d000000000p-1, + 0x1.82ad000000000p-1, 0x1.83bbe00000000p-1, 0x1.84c9c00000000p-1, + 0x1.85d6900000000p-1, 0x1.86e2500000000p-1, 0x1.87ed000000000p-1, + 0x1.88f6b00000000p-1, 0x1.89ff500000000p-1, 0x1.8b06f00000000p-1, + 0x1.8c0d900000000p-1, 0x1.8d13200000000p-1, 0x1.8e17a00000000p-1, + 0x1.8f1b300000000p-1, 0x1.901db00000000p-1, 0x1.911f300000000p-1, + 0x1.921fb00000000p-1, +}; + +CLC_TABLE_FUNCTION(double, ATAN_JBY256_TBL_HEAD, atan_jby256_tbl_head); + +DECLARE_TABLE(double, ATAN_JBY256_TBL_TAIL, 241) = { + 0x1.6e59fbd38db2cp-26, 0x1.4e3aa54dedf96p-25, 0x1.7e105ab1bda88p-25, + 0x1.8c5254d013fd0p-27, 0x1.cf8ab3ad62670p-29, 0x1.9dca4bec80468p-26, + 0x1.3f4b5ec98a8dap-26, 0x1.b9d49619d81fep-25, 0x1.3017887460934p-27, + 0x1.11e3eca0b9944p-26, 0x1.4f3f73c5a332ep-26, 0x1.c71c8ae0e00a6p-26, + 0x1.7cde0f86fbdc7p-25, 0x1.70f328c889c72p-26, 0x1.c07ae9b994efep-26, + 0x1.0c8021d7b1698p-27, 0x1.35585edb8cb22p-25, 0x1.0842567b30e96p-24, + 0x1.99e811031472ep-24, 0x1.041821416bceep-25, 0x1.f6086e4dc96f4p-24, + 0x1.71a535c5f1b58p-27, 0x1.65f743fe63ca1p-24, 0x1.dbd733472d014p-24, + 0x1.d18cc4d8b0d1dp-24, 0x1.8c12553c8fb29p-24, 0x1.53b49e2e8f991p-24, + 0x1.7422ae148c141p-24, 0x1.e3ec269df56a8p-27, 0x1.ff6754e7e0ac9p-24, + 0x1.131267b1b5aadp-24, 0x1.d14fa403a94bcp-24, 0x1.2f396c089a3d8p-25, + 0x1.c731d78fa95bbp-24, 0x1.c50f385177399p-24, 0x1.f41409c6f2c20p-25, + 0x1.d2d90c4c39ec0p-24, 0x1.80420696f2106p-25, 0x1.b40327943a2e8p-27, + 0x1.5d35e02f3d2a2p-25, 0x1.4a498288117b0p-25, 0x1.35da119afb324p-25, + 0x1.14e85cdb9a908p-24, 0x1.38754e5547b9ap-25, 0x1.be40ae6ce3246p-24, + 0x1.0c993b3bea7e7p-24, 0x1.1d2dd89ac3359p-24, 0x1.1476603332c46p-25, + 0x1.f25901bac55b7p-24, 0x1.f881b7c826e28p-24, 0x1.441996d698d20p-24, + 0x1.407ac521ea089p-23, 0x1.2fb0c6c4b1723p-23, 0x1.ca135966a3e18p-23, + 0x1.b1218e4d646e4p-25, 0x1.d4e72a350d288p-25, 0x1.4617e2f04c329p-23, + 0x1.096ec41e82650p-25, 0x1.9f91f25773e6ep-24, 0x1.59c0820f1d674p-25, + 0x1.02bf7a2df1064p-25, 0x1.fb36bfc40508fp-23, 0x1.ea08f3f8dc892p-24, + 0x1.3ed6254656a0ep-24, 0x1.b83f5e5e69c58p-25, 0x1.d6ec2af768592p-23, + 0x1.493889a226f94p-25, 0x1.5ad8fa65279bap-23, 0x1.b615784d45434p-25, + 0x1.09a184368f145p-23, 0x1.61a2439b0d91cp-24, 0x1.ce1a65e39a978p-24, + 0x1.32a39a93b6a66p-23, 0x1.1c3699af804e7p-23, 0x1.75e0f4e44ede8p-26, + 0x1.f77ced1a7a83bp-23, 0x1.84e7f0cb1b500p-29, 0x1.ec6b838b02dfep-23, + 0x1.3ebf4dfbeda87p-23, 0x1.9397aed9cb475p-23, 0x1.07937bc239c54p-24, + 0x1.aa754553131b6p-23, 0x1.4a05d407c45dcp-24, 0x1.132231a206dd0p-23, + 0x1.2d8ecfdd69c88p-24, 0x1.a852c74218606p-24, 0x1.71bf2baeebb50p-23, + 0x1.83d7db7491820p-27, 0x1.ca50d92b6da14p-25, 0x1.6f5cde8530298p-26, + 0x1.f343198910740p-24, 0x1.0e8d241ccd80ap-24, 0x1.1535ac619e6c8p-24, + 0x1.7316041c36cd2p-24, 0x1.985a000637d8ep-24, 0x1.f2f29858c0a68p-25, + 0x1.879847f96d909p-23, 0x1.ab3d319e12e42p-23, 0x1.5088162dfc4c2p-24, + 0x1.05749a1cd9d8cp-25, 0x1.da65c6c6b8618p-26, 0x1.739bf7df1ad64p-25, + 0x1.bc31252aa3340p-25, 0x1.e528191ad3aa8p-26, 0x1.929d93df19f18p-23, + 0x1.ff11eb693a080p-26, 0x1.55ae3f145a3a0p-27, 0x1.cbcd8c6c0ca82p-24, + 0x1.0cb04d425d304p-24, 0x1.9adfcab5be678p-24, 0x1.93d90c5662508p-23, + 0x1.68489bd35ff40p-24, 0x1.586ed3da2b7e0p-28, 0x1.7604d2e850eeep-23, + 0x1.ac1d12bfb53d8p-24, 0x1.9b3d468274740p-28, 0x1.fc5d68d10e53cp-24, + 0x1.8f9e51884becbp-23, 0x1.a87f0869c06d1p-23, 0x1.31e7279f685fap-23, + 0x1.6a8282f9719b0p-27, 0x1.0d2724a8a44e0p-25, 0x1.a60524b11ad4ep-23, + 0x1.75fdf832750f0p-26, 0x1.cf06902e4cd36p-23, 0x1.e82422d4f6d10p-25, + 0x1.24a091063e6c0p-26, 0x1.8a1a172dc6f38p-24, 0x1.29b6619f8a92dp-22, + 0x1.9274d9c1b70c8p-24, 0x1.0c34b1fbb7930p-26, 0x1.639866c20eb50p-25, + 0x1.6d6d0f6832e9ep-23, 0x1.af54def99f25ep-22, 0x1.16cfc52a00262p-22, + 0x1.dcc1e83569c32p-23, 0x1.37f7a551ed425p-22, 0x1.f6360adc98887p-22, + 0x1.2c6ec8d35a2c1p-22, 0x1.bd44df84cb036p-23, 0x1.117cf826e310ep-22, + 0x1.ca533f332cfc9p-22, 0x1.0f208509dbc2ep-22, 0x1.cd07d93c945dep-23, + 0x1.57bdfd67e6d72p-22, 0x1.aab89c516c658p-24, 0x1.3e823b1a1b8a0p-25, + 0x1.307464a9d6d3cp-23, 0x1.c5993cd438843p-22, 0x1.ba2fca02ab554p-22, + 0x1.01a5b6983a268p-23, 0x1.273d1b350efc8p-25, 0x1.64c238c37b0c6p-23, + 0x1.aded07370a300p-25, 0x1.78091197eb47ep-23, 0x1.4b0f245e0dabcp-24, + 0x1.080d9794e2eafp-22, 0x1.d4ec242b60c76p-23, 0x1.221d2f940caa0p-27, + 0x1.cdbc42b2bba5cp-24, 0x1.cce37bb440840p-25, 0x1.6c1d999cf1dd0p-22, + 0x1.bed8a07eb0870p-26, 0x1.69ed88f490e3cp-24, 0x1.cd41719b73ef0p-25, + 0x1.cbc4ac95b41b7p-22, 0x1.238f1b890f5d7p-22, 0x1.50c4282259cc4p-24, + 0x1.713d2de87b3e2p-22, 0x1.1d5a7d2255276p-23, 0x1.c0dfd48227ac1p-22, + 0x1.1c964dab76753p-22, 0x1.6de56d5704496p-23, 0x1.4aeb71fd19968p-23, + 0x1.fbf91c57b1918p-23, 0x1.d6bef7fbe5d9ap-22, 0x1.464d3dc249066p-22, + 0x1.638e2ec4d9073p-22, 0x1.16f4a7247ea7cp-24, 0x1.1a0a740f1d440p-28, + 0x1.6edbb0114a33cp-23, 0x1.dbee8bf1d513cp-24, 0x1.5b8bdb0248f73p-22, + 0x1.7de3d3f5eac64p-22, 0x1.ee24187ae448ap-23, 0x1.e06c591ec5192p-22, + 0x1.4e3861a332738p-24, 0x1.a9599dcc2bfe4p-24, 0x1.f732fbad43468p-25, + 0x1.eb9f573b727d9p-22, 0x1.8b212a2eb9897p-22, 0x1.384884c167215p-22, + 0x1.0e2d363020051p-22, 0x1.2820879fbd022p-22, 0x1.a1ab9893e4b30p-22, + 0x1.2d1b817a24478p-23, 0x1.15d7b8ded4878p-25, 0x1.8968f9db3a5e4p-24, + 0x1.71c4171fe135fp-22, 0x1.6d80f605d0d8cp-22, 0x1.c91f043691590p-24, + 0x1.39f8a15fce2b2p-23, 0x1.55beda9d94b80p-27, 0x1.b12c15d60949ap-23, + 0x1.24167b312bfe3p-22, 0x1.0ab8633070277p-22, 0x1.54554ebbc80eep-23, + 0x1.0204aef5a4bb8p-25, 0x1.8af08c679cf2cp-22, 0x1.0852a330ae6c8p-22, + 0x1.6d3eb9ec32916p-23, 0x1.685cb7fcbbafep-23, 0x1.1f751c1e0bd95p-22, + 0x1.705b1b0f72560p-26, 0x1.b98d8d808ca92p-22, 0x1.2ea22c75cc980p-25, + 0x1.7aba62bca0350p-22, 0x1.d73833442278cp-22, 0x1.5a5ca1fb18bf9p-22, + 0x1.1a6092b6ecf28p-25, 0x1.44fd049aac104p-24, 0x1.c114fd8df5180p-29, + 0x1.5972f130feae5p-22, 0x1.ca034a55fe198p-24, 0x1.6e2b149990227p-22, + 0x1.b00000294592cp-24, 0x1.8b9bdc442620ep-22, 0x1.d94fdfabf3e4ep-23, + 0x1.5db30b145ad9ap-23, 0x1.e3e1eb95022b0p-23, 0x1.d5b8b45442bd6p-22, + 0x1.7a046231ecd2ep-22, 0x1.feafe3ef55232p-22, 0x1.839e7bfd78267p-22, + 0x1.45cf49d6fa900p-25, 0x1.be3132b27f380p-27, 0x1.533980bb84f9fp-22, + 0x1.889e2ce3ba390p-26, 0x1.f7778c3ad0cc8p-24, 0x1.46660cec4eba2p-23, + 0x1.5110b4611a626p-23, +}; + +CLC_TABLE_FUNCTION(double, ATAN_JBY256_TBL_TAIL, atan_jby256_tbl_tail); + +DECLARE_TABLE(double, LOG_F_INV_TBL_HEAD, 258) = { + 0x1.0000000000000p+1, 0x1.fe00000000000p+0, 0x1.fc00000000000p+0, + 0x1.fa00000000000p+0, 0x1.f800000000000p+0, 0x1.f600000000000p+0, + 0x1.f400000000000p+0, 0x1.f200000000000p+0, 0x1.f000000000000p+0, + 0x1.ee00000000000p+0, 0x1.ec00000000000p+0, 0x1.ea00000000000p+0, + 0x1.e900000000000p+0, 0x1.e700000000000p+0, 0x1.e500000000000p+0, + 0x1.e300000000000p+0, 0x1.e100000000000p+0, 0x1.e000000000000p+0, + 0x1.de00000000000p+0, 0x1.dc00000000000p+0, 0x1.da00000000000p+0, + 0x1.d900000000000p+0, 0x1.d700000000000p+0, 0x1.d500000000000p+0, + 0x1.d400000000000p+0, 0x1.d200000000000p+0, 0x1.d000000000000p+0, + 0x1.cf00000000000p+0, 0x1.cd00000000000p+0, 0x1.cb00000000000p+0, + 0x1.ca00000000000p+0, 0x1.c800000000000p+0, 0x1.c700000000000p+0, + 0x1.c500000000000p+0, 0x1.c300000000000p+0, 0x1.c200000000000p+0, + 0x1.c000000000000p+0, 0x1.bf00000000000p+0, 0x1.bd00000000000p+0, + 0x1.bc00000000000p+0, 0x1.ba00000000000p+0, 0x1.b900000000000p+0, + 0x1.b700000000000p+0, 0x1.b600000000000p+0, 0x1.b400000000000p+0, + 0x1.b300000000000p+0, 0x1.b200000000000p+0, 0x1.b000000000000p+0, + 0x1.af00000000000p+0, 0x1.ad00000000000p+0, 0x1.ac00000000000p+0, + 0x1.aa00000000000p+0, 0x1.a900000000000p+0, 0x1.a800000000000p+0, + 0x1.a600000000000p+0, 0x1.a500000000000p+0, 0x1.a400000000000p+0, + 0x1.a200000000000p+0, 0x1.a100000000000p+0, 0x1.a000000000000p+0, + 0x1.9e00000000000p+0, 0x1.9d00000000000p+0, 0x1.9c00000000000p+0, + 0x1.9a00000000000p+0, 0x1.9900000000000p+0, 0x1.9800000000000p+0, + 0x1.9700000000000p+0, 0x1.9500000000000p+0, 0x1.9400000000000p+0, + 0x1.9300000000000p+0, 0x1.9200000000000p+0, 0x1.9000000000000p+0, + 0x1.8f00000000000p+0, 0x1.8e00000000000p+0, 0x1.8d00000000000p+0, + 0x1.8b00000000000p+0, 0x1.8a00000000000p+0, 0x1.8900000000000p+0, + 0x1.8800000000000p+0, 0x1.8700000000000p+0, 0x1.8600000000000p+0, + 0x1.8400000000000p+0, 0x1.8300000000000p+0, 0x1.8200000000000p+0, + 0x1.8100000000000p+0, 0x1.8000000000000p+0, 0x1.7f00000000000p+0, + 0x1.7e00000000000p+0, 0x1.7d00000000000p+0, 0x1.7b00000000000p+0, + 0x1.7a00000000000p+0, 0x1.7900000000000p+0, 0x1.7800000000000p+0, + 0x1.7700000000000p+0, 0x1.7600000000000p+0, 0x1.7500000000000p+0, + 0x1.7400000000000p+0, 0x1.7300000000000p+0, 0x1.7200000000000p+0, + 0x1.7100000000000p+0, 0x1.7000000000000p+0, 0x1.6f00000000000p+0, + 0x1.6e00000000000p+0, 0x1.6d00000000000p+0, 0x1.6c00000000000p+0, + 0x1.6b00000000000p+0, 0x1.6a00000000000p+0, 0x1.6900000000000p+0, + 0x1.6800000000000p+0, 0x1.6700000000000p+0, 0x1.6600000000000p+0, + 0x1.6500000000000p+0, 0x1.6400000000000p+0, 0x1.6300000000000p+0, + 0x1.6200000000000p+0, 0x1.6100000000000p+0, 0x1.6000000000000p+0, + 0x1.5f00000000000p+0, 0x1.5e00000000000p+0, 0x1.5d00000000000p+0, + 0x1.5c00000000000p+0, 0x1.5b00000000000p+0, 0x1.5a00000000000p+0, + 0x1.5900000000000p+0, 0x1.5800000000000p+0, 0x1.5800000000000p+0, + 0x1.5700000000000p+0, 0x1.5600000000000p+0, 0x1.5500000000000p+0, + 0x1.5400000000000p+0, 0x1.5300000000000p+0, 0x1.5200000000000p+0, + 0x1.5100000000000p+0, 0x1.5000000000000p+0, 0x1.5000000000000p+0, + 0x1.4f00000000000p+0, 0x1.4e00000000000p+0, 0x1.4d00000000000p+0, + 0x1.4c00000000000p+0, 0x1.4b00000000000p+0, 0x1.4a00000000000p+0, + 0x1.4a00000000000p+0, 0x1.4900000000000p+0, 0x1.4800000000000p+0, + 0x1.4700000000000p+0, 0x1.4600000000000p+0, 0x1.4600000000000p+0, + 0x1.4500000000000p+0, 0x1.4400000000000p+0, 0x1.4300000000000p+0, + 0x1.4200000000000p+0, 0x1.4200000000000p+0, 0x1.4100000000000p+0, + 0x1.4000000000000p+0, 0x1.3f00000000000p+0, 0x1.3e00000000000p+0, + 0x1.3e00000000000p+0, 0x1.3d00000000000p+0, 0x1.3c00000000000p+0, + 0x1.3b00000000000p+0, 0x1.3b00000000000p+0, 0x1.3a00000000000p+0, + 0x1.3900000000000p+0, 0x1.3800000000000p+0, 0x1.3800000000000p+0, + 0x1.3700000000000p+0, 0x1.3600000000000p+0, 0x1.3500000000000p+0, + 0x1.3500000000000p+0, 0x1.3400000000000p+0, 0x1.3300000000000p+0, + 0x1.3200000000000p+0, 0x1.3200000000000p+0, 0x1.3100000000000p+0, + 0x1.3000000000000p+0, 0x1.3000000000000p+0, 0x1.2f00000000000p+0, + 0x1.2e00000000000p+0, 0x1.2e00000000000p+0, 0x1.2d00000000000p+0, + 0x1.2c00000000000p+0, 0x1.2b00000000000p+0, 0x1.2b00000000000p+0, + 0x1.2a00000000000p+0, 0x1.2900000000000p+0, 0x1.2900000000000p+0, + 0x1.2800000000000p+0, 0x1.2700000000000p+0, 0x1.2700000000000p+0, + 0x1.2600000000000p+0, 0x1.2500000000000p+0, 0x1.2500000000000p+0, + 0x1.2400000000000p+0, 0x1.2300000000000p+0, 0x1.2300000000000p+0, + 0x1.2200000000000p+0, 0x1.2100000000000p+0, 0x1.2100000000000p+0, + 0x1.2000000000000p+0, 0x1.2000000000000p+0, 0x1.1f00000000000p+0, + 0x1.1e00000000000p+0, 0x1.1e00000000000p+0, 0x1.1d00000000000p+0, + 0x1.1c00000000000p+0, 0x1.1c00000000000p+0, 0x1.1b00000000000p+0, + 0x1.1b00000000000p+0, 0x1.1a00000000000p+0, 0x1.1900000000000p+0, + 0x1.1900000000000p+0, 0x1.1800000000000p+0, 0x1.1800000000000p+0, + 0x1.1700000000000p+0, 0x1.1600000000000p+0, 0x1.1600000000000p+0, + 0x1.1500000000000p+0, 0x1.1500000000000p+0, 0x1.1400000000000p+0, + 0x1.1300000000000p+0, 0x1.1300000000000p+0, 0x1.1200000000000p+0, + 0x1.1200000000000p+0, 0x1.1100000000000p+0, 0x1.1100000000000p+0, + 0x1.1000000000000p+0, 0x1.0f00000000000p+0, 0x1.0f00000000000p+0, + 0x1.0e00000000000p+0, 0x1.0e00000000000p+0, 0x1.0d00000000000p+0, + 0x1.0d00000000000p+0, 0x1.0c00000000000p+0, 0x1.0c00000000000p+0, + 0x1.0b00000000000p+0, 0x1.0a00000000000p+0, 0x1.0a00000000000p+0, + 0x1.0900000000000p+0, 0x1.0900000000000p+0, 0x1.0800000000000p+0, + 0x1.0800000000000p+0, 0x1.0700000000000p+0, 0x1.0700000000000p+0, + 0x1.0600000000000p+0, 0x1.0600000000000p+0, 0x1.0500000000000p+0, + 0x1.0500000000000p+0, 0x1.0400000000000p+0, 0x1.0400000000000p+0, + 0x1.0300000000000p+0, 0x1.0300000000000p+0, 0x1.0200000000000p+0, + 0x1.0200000000000p+0, 0x1.0100000000000p+0, 0x1.0100000000000p+0, + 0x1.0000000000000p+0, 0x1.0000000000000p+0, +}; + +CLC_TABLE_FUNCTION(double, LOG_F_INV_TBL_HEAD, log_f_inv_tbl_head); + +DECLARE_TABLE(double, LOG_F_INV_TBL_TAIL, 258) = { + 0x0.0000000000000p+0, 0x1.fe01fe01fe020p-16, 0x1.fc07f01fc07f0p-14, + 0x1.1caa01fa11caap-12, 0x1.f81f81f81f820p-12, 0x1.8856506ddaba6p-11, + 0x1.196792909c560p-10, 0x1.7d9108c2ad433p-10, 0x1.f07c1f07c1f08p-10, + 0x1.38ff08b1c03ddp-9, 0x1.80f6603d980f6p-9, 0x1.d00f57403d5d0p-9, + 0x1.31abf0b7672a0p-12, 0x1.06a965d43919bp-10, 0x1.ceb240795ceb2p-10, + 0x1.522f3b834e67fp-9, 0x1.c3c3c3c3c3c3cp-9, 0x1.e01e01e01e01ep-12, + 0x1.75b8fe21a291cp-10, 0x1.403b9403b9404p-9, 0x1.cc0ed7303b5ccp-9, + 0x1.79118f3fc4da2p-11, 0x1.ed952e0b0ce46p-10, 0x1.95900eae56404p-9, + 0x1.d41d41d41d41dp-12, 0x1.cb28ff16c69aep-10, 0x1.96b1edd80e866p-9, + 0x1.372e225fe30d9p-11, 0x1.0ad12073615a2p-9, 0x1.cdb2c0397cdb3p-9, + 0x1.2cc157b864407p-10, 0x1.64cb5f7148404p-9, 0x1.c71c71c71c71cp-12, + 0x1.129a21a930b84p-9, 0x1.f1e0387f1e038p-9, 0x1.ad4e4ba80709bp-10, + 0x1.c0e070381c0e0p-9, 0x1.60fba1a362bb0p-10, 0x1.a5713280dee96p-9, + 0x1.3f59620f9ece9p-10, 0x1.9f22983759f23p-9, 0x1.478ac63fc8d5cp-10, + 0x1.ad87bb4671656p-9, 0x1.78b8efbb8148cp-10, 0x1.d0369d0369d03p-9, + 0x1.d212b601b3748p-10, 0x1.b2036406c80d9p-15, 0x1.29663b24547d1p-9, + 0x1.435e50d79435ep-11, 0x1.7d0ff2920bc03p-9, 0x1.5c06b15c06b16p-10, + 0x1.e3a5f0fd7f954p-9, 0x1.1dec0d4c77b03p-9, 0x1.73289870ac52ep-11, + 0x1.a034da034da03p-9, 0x1.d041da2292856p-10, 0x1.a41a41a41a41ap-12, + 0x1.8550f8a39409dp-9, 0x1.b4fe5e92c0686p-10, 0x1.a01a01a01a01ap-12, + 0x1.91d2a2067b23ap-9, 0x1.e7c5dada0b4e5p-10, 0x1.68a7725080ce1p-11, + 0x1.c49d4aa21b490p-9, 0x1.3333333333333p-9, 0x1.4bc363b03fccfp-10, + 0x1.c9f01970e4f81p-13, 0x1.97617c6ef5b25p-9, 0x1.161f9add3c0cap-9, + 0x1.319fe6cb39806p-10, 0x1.f693a1c451ab3p-13, 0x1.a9e240321a9e2p-9, + 0x1.3831f3831f383p-9, 0x1.949ebc4dcfc1cp-10, 0x1.80c6980c6980cp-11, + 0x1.f9d00c5fe7403p-9, 0x1.9721ed7e75347p-9, 0x1.381ec0313381fp-9, + 0x1.b97c2aec12653p-10, 0x1.09ef3024ae3bap-10, 0x1.8618618618618p-12, + 0x1.e0184f00c2780p-9, 0x1.92ef5657dba52p-9, 0x1.4940305494030p-9, + 0x1.0303030303030p-9, 0x1.8060180601806p-10, 0x1.017f405fd017fp-10, + 0x1.12a8ad278e8ddp-11, 0x1.7d05f417d05f4p-14, 0x1.d67245c02f7d6p-9, + 0x1.a4411c1d986a9p-9, 0x1.754d76c7316dfp-9, 0x1.49902f149902fp-9, + 0x1.21023358c1a68p-9, 0x1.f7390d2a6c406p-10, 0x1.b2b0805d5b2b1p-10, + 0x1.745d1745d1746p-10, 0x1.3c31507fa32c4p-10, 0x1.0a1fd1b7af017p-10, + 0x1.bc36ce3e0453ap-11, 0x1.702e05c0b8170p-11, 0x1.300b79300b793p-11, + 0x1.f76b4337c6cb1p-12, 0x1.a62681c860fb0p-12, 0x1.6c16c16c16c17p-12, + 0x1.490aa31a3cfc7p-12, 0x1.3cd153729043ep-12, 0x1.473a88d0bfd2ep-12, + 0x1.6816816816817p-12, 0x1.9f36016719f36p-12, 0x1.ec6a5122f9016p-12, + 0x1.27c29da5519cfp-11, 0x1.642c8590b2164p-11, 0x1.ab5c45606f00bp-11, + 0x1.fd3b80b11fd3cp-11, 0x1.2cda0c6ba4eaap-10, 0x1.6058160581606p-10, + 0x1.990d0a4b7ef87p-10, 0x1.d6ee340579d6fp-10, 0x1.0cf87d9c54a69p-9, + 0x1.310572620ae4cp-9, 0x1.5798c8ff522a2p-9, 0x1.80ad602b580adp-9, + 0x1.ac3e24799546fp-9, 0x1.da46102b1da46p-9, 0x1.5805601580560p-14, + 0x1.ed3c506b39a23p-12, 0x1.cbdd3e2970f60p-11, 0x1.5555555555555p-10, + 0x1.c979aee0bf805p-10, 0x1.21291e81fd58ep-9, 0x1.5fead500a9580p-9, + 0x1.a0fd5c5f02a3ap-9, 0x1.e45c223898adcp-9, 0x1.5015015015015p-12, + 0x1.c7b16ea64d422p-11, 0x1.7829cbc14e5e1p-10, 0x1.0877db8589720p-9, + 0x1.5710e4b5edceap-9, 0x1.a7dbb4d1fc1c8p-9, 0x1.fad40a57eb503p-9, + 0x1.3fd6bb00a5140p-11, 0x1.4e78ecb419ba9p-10, 0x1.00a44029100a4p-9, + 0x1.5c28f5c28f5c3p-9, 0x1.b9c68b2c0cc4ap-9, 0x1.978feb9f34381p-13, + 0x1.ecf163bb6500ap-11, 0x1.be1958b67ebb9p-10, 0x1.44e6157dc9a3bp-9, + 0x1.acc4baa3f0ddfp-9, 0x1.6a4cbcb2a247bp-13, 0x1.0505050505050p-10, + 0x1.e0b4439959819p-10, 0x1.6027f6027f602p-9, 0x1.d1e854b5e0db4p-9, + 0x1.165e7254813e2p-11, 0x1.76646a9d716efp-10, 0x1.32b48f757ce88p-9, + 0x1.ac1b24652a906p-9, 0x1.3b13b13b13b14p-12, 0x1.490e1eb208984p-10, + 0x1.2385830fec66ep-9, 0x1.a45a6cc111b7ep-9, 0x1.3813813813814p-12, + 0x1.56f472517b708p-10, 0x1.31be7bc0e8f2ap-9, 0x1.b9cbf3e55f044p-9, + 0x1.0e7d95bc609a9p-11, 0x1.9e6b3804d19e7p-10, 0x1.5c8b6af7963c2p-9, + 0x1.eb9dad43bf402p-9, 0x1.f1a515885fb37p-11, 0x1.0eeb1d3d76c02p-9, + 0x1.a320261a32026p-9, 0x1.c82ac40260390p-12, 0x1.a12f684bda12fp-10, + 0x1.69d43fda2962cp-9, 0x1.2e025c04b8097p-15, 0x1.42804b542804bp-10, + 0x1.3f69b02593f6ap-9, 0x1.df31cb46e21fap-9, 0x1.012b404ad012bp-10, + 0x1.23925e7820a7fp-9, 0x1.c8253c8253c82p-9, 0x1.b92ddc02526e5p-11, + 0x1.1602511602511p-9, 0x1.bf471439c9adfp-9, 0x1.a85c40939a85cp-11, + 0x1.166f9ac024d16p-9, 0x1.c44e10125e227p-9, 0x1.cebf48bbd90e5p-11, + 0x1.2492492492492p-9, 0x1.d6f2e2ec0b673p-9, 0x1.159e26af37c05p-10, + 0x1.4024540245402p-9, 0x1.f6f0243f6f024p-9, 0x1.5e60121579805p-10, + 0x1.68e18cf81b10fp-9, 0x1.2012012012012p-12, 0x1.c11f7047dc11fp-10, + 0x1.9e878ff70985ep-9, 0x1.779d9fdc3a219p-11, 0x1.1eace5c957907p-9, + 0x1.e0d5b450239e1p-9, 0x1.48bf073816367p-10, 0x1.694808dda5202p-9, + 0x1.7c67f2bae2b21p-12, 0x1.ee58469ee5847p-10, 0x1.c0233c0233c02p-9, + 0x1.14e02328a7012p-10, 0x1.561072057b573p-9, 0x1.1811811811812p-12, + 0x1.e28646f5a1060p-10, 0x1.c0d1284e6f1d7p-9, 0x1.23543f0c80459p-10, + 0x1.63cbeea4e1a09p-9, 0x1.b9a3fdd5c8cb8p-12, 0x1.0be1c159a76d2p-9, + 0x1.e1d1a688e4838p-9, 0x1.72044d72044d7p-10, 0x1.91713db81577bp-9, + 0x1.ac73ae9819b50p-11, 0x1.460334e904cf6p-9, 0x1.1111111111111p-12, + 0x1.feef80441fef0p-10, 0x1.de021fde021fep-9, 0x1.7b7eacc9686a0p-10, + 0x1.9ead7cd391fbcp-9, 0x1.0195609804390p-10, 0x1.641511e8d2b32p-9, + 0x1.222b1acf1ce96p-11, 0x1.2e29f79b47582p-9, 0x1.4f0d1682e11cdp-13, + 0x1.f9bb096771e4dp-10, 0x1.e5ee45dd96ae2p-9, 0x1.a0429a0429a04p-10, + 0x1.bb74d5f06c021p-9, 0x1.4fce404254fcep-10, 0x1.95766eacbc402p-9, + 0x1.0842108421084p-10, 0x1.73e5371d5c338p-9, 0x1.930523fbe3368p-11, + 0x1.56b38f225f6c4p-9, 0x1.26e978d4fdf3bp-11, 0x1.3dd40e4eb0cc6p-9, + 0x1.97f7d73404146p-12, 0x1.293982cc98af1p-9, 0x1.0410410410410p-12, + 0x1.18d6f048ff7e4p-9, 0x1.236a3ebc349dep-13, 0x1.0c9f8ee53d18cp-9, + 0x1.0204081020408p-14, 0x1.0486ca2f46ea6p-9, 0x1.0101010101010p-16, + 0x1.0080402010080p-9, 0x0.0000000000000p+0, +}; + +CLC_TABLE_FUNCTION(double, LOG_F_INV_TBL_TAIL, log_f_inv_tbl_tail); + +DECLARE_TABLE(double, POWLOG_TBL_HEAD, 258) = { + 0x0.0000000000000p+0, 0x1.ff00aa0000000p-9, 0x1.fe02a60000000p-8, + 0x1.7dc4750000000p-7, 0x1.fc0a8b0000000p-7, 0x1.3cea440000000p-6, + 0x1.7b91b00000000p-6, 0x1.b9fc020000000p-6, 0x1.f829b00000000p-6, + 0x1.1b0d980000000p-5, 0x1.39e87b0000000p-5, 0x1.58a5ba0000000p-5, + 0x1.77458f0000000p-5, 0x1.95c8300000000p-5, 0x1.b42dd70000000p-5, + 0x1.d276b80000000p-5, 0x1.f0a30c0000000p-5, 0x1.0759830000000p-4, + 0x1.16536e0000000p-4, 0x1.253f620000000p-4, 0x1.341d790000000p-4, + 0x1.42edcb0000000p-4, 0x1.51b0730000000p-4, 0x1.60658a0000000p-4, + 0x1.6f0d280000000p-4, 0x1.7da7660000000p-4, 0x1.8c345d0000000p-4, + 0x1.9ab4240000000p-4, 0x1.a926d30000000p-4, 0x1.b78c820000000p-4, + 0x1.c5e5480000000p-4, 0x1.d4313d0000000p-4, 0x1.e270760000000p-4, + 0x1.f0a30c0000000p-4, 0x1.fec9130000000p-4, 0x1.0671510000000p-3, + 0x1.0d77e70000000p-3, 0x1.1478580000000p-3, 0x1.1b72ad0000000p-3, + 0x1.2266f10000000p-3, 0x1.29552f0000000p-3, 0x1.303d710000000p-3, + 0x1.371fc20000000p-3, 0x1.3dfc2b0000000p-3, 0x1.44d2b60000000p-3, + 0x1.4ba36f0000000p-3, 0x1.526e5e0000000p-3, 0x1.59338d0000000p-3, + 0x1.5ff3070000000p-3, 0x1.66acd40000000p-3, 0x1.6d60fe0000000p-3, + 0x1.740f8f0000000p-3, 0x1.7ab8900000000p-3, 0x1.815c0a0000000p-3, + 0x1.87fa060000000p-3, 0x1.8e928d0000000p-3, 0x1.9525a90000000p-3, + 0x1.9bb3620000000p-3, 0x1.a23bc10000000p-3, 0x1.a8becf0000000p-3, + 0x1.af3c940000000p-3, 0x1.b5b5190000000p-3, 0x1.bc28670000000p-3, + 0x1.c296850000000p-3, 0x1.c8ff7c0000000p-3, 0x1.cf63540000000p-3, + 0x1.d5c2160000000p-3, 0x1.dc1bca0000000p-3, 0x1.e270760000000p-3, + 0x1.e8c0250000000p-3, 0x1.ef0adc0000000p-3, 0x1.f550a50000000p-3, + 0x1.fb91860000000p-3, 0x1.00e6c40000000p-2, 0x1.0402590000000p-2, + 0x1.071b850000000p-2, 0x1.0a324e0000000p-2, 0x1.0d46b50000000p-2, + 0x1.1058bf0000000p-2, 0x1.1368700000000p-2, 0x1.1675ca0000000p-2, + 0x1.1980d20000000p-2, 0x1.1c898c0000000p-2, 0x1.1f8ff90000000p-2, + 0x1.22941f0000000p-2, 0x1.2596010000000p-2, 0x1.2895a10000000p-2, + 0x1.2b93030000000p-2, 0x1.2e8e2b0000000p-2, 0x1.31871c0000000p-2, + 0x1.347dd90000000p-2, 0x1.3772660000000p-2, 0x1.3a64c50000000p-2, + 0x1.3d54fa0000000p-2, 0x1.4043080000000p-2, 0x1.432ef20000000p-2, + 0x1.4618bc0000000p-2, 0x1.4900680000000p-2, 0x1.4be5f90000000p-2, + 0x1.4ec9730000000p-2, 0x1.51aad80000000p-2, 0x1.548a2c0000000p-2, + 0x1.5767710000000p-2, 0x1.5a42ab0000000p-2, 0x1.5d1bdb0000000p-2, + 0x1.5ff3070000000p-2, 0x1.62c82f0000000p-2, 0x1.659b570000000p-2, + 0x1.686c810000000p-2, 0x1.6b3bb20000000p-2, 0x1.6e08ea0000000p-2, + 0x1.70d42e0000000p-2, 0x1.739d7f0000000p-2, 0x1.7664e10000000p-2, + 0x1.792a550000000p-2, 0x1.7bede00000000p-2, 0x1.7eaf830000000p-2, + 0x1.816f410000000p-2, 0x1.842d1d0000000p-2, 0x1.86e9190000000p-2, + 0x1.89a3380000000p-2, 0x1.8c5b7c0000000p-2, 0x1.8f11e80000000p-2, + 0x1.91c67e0000000p-2, 0x1.9479410000000p-2, 0x1.972a340000000p-2, + 0x1.99d9580000000p-2, 0x1.9c86b00000000p-2, 0x1.9f323e0000000p-2, + 0x1.a1dc060000000p-2, 0x1.a484090000000p-2, 0x1.a72a490000000p-2, + 0x1.a9cec90000000p-2, 0x1.ac718c0000000p-2, 0x1.af12930000000p-2, + 0x1.b1b1e00000000p-2, 0x1.b44f770000000p-2, 0x1.b6eb590000000p-2, + 0x1.b985890000000p-2, 0x1.bc1e080000000p-2, 0x1.beb4d90000000p-2, + 0x1.c149ff0000000p-2, 0x1.c3dd7a0000000p-2, 0x1.c66f4e0000000p-2, + 0x1.c8ff7c0000000p-2, 0x1.cb8e070000000p-2, 0x1.ce1af00000000p-2, + 0x1.d0a63a0000000p-2, 0x1.d32fe70000000p-2, 0x1.d5b7f90000000p-2, + 0x1.d83e720000000p-2, 0x1.dac3530000000p-2, 0x1.dd46a00000000p-2, + 0x1.dfc8590000000p-2, 0x1.e248810000000p-2, 0x1.e4c71a0000000p-2, + 0x1.e744260000000p-2, 0x1.e9bfa60000000p-2, 0x1.ec399d0000000p-2, + 0x1.eeb20c0000000p-2, 0x1.f128f50000000p-2, 0x1.f39e5b0000000p-2, + 0x1.f6123f0000000p-2, 0x1.f884a30000000p-2, 0x1.faf5880000000p-2, + 0x1.fd64f20000000p-2, 0x1.ffd2e00000000p-2, 0x1.011fab0000000p-1, + 0x1.02552a0000000p-1, 0x1.0389ee0000000p-1, 0x1.04bdf90000000p-1, + 0x1.05f14b0000000p-1, 0x1.0723e50000000p-1, 0x1.0855c80000000p-1, + 0x1.0986f40000000p-1, 0x1.0ab76b0000000p-1, 0x1.0be72e0000000p-1, + 0x1.0d163c0000000p-1, 0x1.0e44980000000p-1, 0x1.0f72410000000p-1, + 0x1.109f390000000p-1, 0x1.11cb810000000p-1, 0x1.12f7190000000p-1, + 0x1.1422020000000p-1, 0x1.154c3d0000000p-1, 0x1.1675ca0000000p-1, + 0x1.179eab0000000p-1, 0x1.18c6e00000000p-1, 0x1.19ee6b0000000p-1, + 0x1.1b154b0000000p-1, 0x1.1c3b810000000p-1, 0x1.1d610f0000000p-1, + 0x1.1e85f50000000p-1, 0x1.1faa340000000p-1, 0x1.20cdcd0000000p-1, + 0x1.21f0bf0000000p-1, 0x1.23130d0000000p-1, 0x1.2434b60000000p-1, + 0x1.2555bc0000000p-1, 0x1.2676200000000p-1, 0x1.2795e10000000p-1, + 0x1.28b5000000000p-1, 0x1.29d37f0000000p-1, 0x1.2af15f0000000p-1, + 0x1.2c0e9e0000000p-1, 0x1.2d2b400000000p-1, 0x1.2e47430000000p-1, + 0x1.2f62a90000000p-1, 0x1.307d730000000p-1, 0x1.3197a00000000p-1, + 0x1.32b1330000000p-1, 0x1.33ca2b0000000p-1, 0x1.34e2890000000p-1, + 0x1.35fa4e0000000p-1, 0x1.37117b0000000p-1, 0x1.38280f0000000p-1, + 0x1.393e0d0000000p-1, 0x1.3a53730000000p-1, 0x1.3b68440000000p-1, + 0x1.3c7c7f0000000p-1, 0x1.3d90260000000p-1, 0x1.3ea3390000000p-1, + 0x1.3fb5b80000000p-1, 0x1.40c7a40000000p-1, 0x1.41d8fe0000000p-1, + 0x1.42e9c60000000p-1, 0x1.43f9fe0000000p-1, 0x1.4509a50000000p-1, + 0x1.4618bc0000000p-1, 0x1.4727430000000p-1, 0x1.48353d0000000p-1, + 0x1.4942a80000000p-1, 0x1.4a4f850000000p-1, 0x1.4b5bd60000000p-1, + 0x1.4c679a0000000p-1, 0x1.4d72d30000000p-1, 0x1.4e7d810000000p-1, + 0x1.4f87a30000000p-1, 0x1.50913c0000000p-1, 0x1.519a4c0000000p-1, + 0x1.52a2d20000000p-1, 0x1.53aad00000000p-1, 0x1.54b2460000000p-1, + 0x1.55b9350000000p-1, 0x1.56bf9d0000000p-1, 0x1.57c57f0000000p-1, + 0x1.58cadb0000000p-1, 0x1.59cfb20000000p-1, 0x1.5ad4040000000p-1, + 0x1.5bd7d30000000p-1, 0x1.5cdb1d0000000p-1, 0x1.5ddde50000000p-1, + 0x1.5ee02a0000000p-1, 0x1.5fe1ed0000000p-1, 0x1.60e32f0000000p-1, + 0x1.61e3ef0000000p-1, 0x1.62e42e0000000p-1, 0x0.0000000000000p+0, +}; + +CLC_TABLE_FUNCTION(double, POWLOG_TBL_HEAD, powlog_tbl_head); + +DECLARE_TABLE(double, POWLOG_TBL_TAIL, 258) = { + 0x0.0000000000000p+0, 0x1.5885e0250435ap-36, 0x1.620cf11f86ed2p-33, + 0x1.f0214edba4a25p-32, 0x1.f807c79f3db4ep-36, 0x1.a352ba779a52bp-33, + 0x1.f56c46aa49fd5p-32, 0x1.ebe465fef5196p-32, 0x1.cf0660099f1f8p-31, + 0x1.247b2ff85945dp-30, 0x1.3fd7abf5202b6p-30, 0x1.f91c9a918d51ep-30, + 0x1.8cb73f118d3cap-31, 0x1.d91c7d6fad074p-30, 0x1.1971bec28d14cp-33, + 0x1.5b616a423c78ap-30, 0x1.162a6617cc971p-37, 0x1.66391c4c06d29p-30, + 0x1.d46f5c1d0c4b8p-29, 0x1.e14282df1f6d3p-29, 0x1.86f47424a660dp-30, + 0x1.d4c8de077753ep-29, 0x1.e0c307ed24f1cp-29, 0x1.26ea18763bdd3p-29, + 0x1.5cad69737c933p-29, 0x1.af62599088901p-29, 0x1.8c66c83d6b2d0p-30, + 0x1.880ceb36fb30fp-30, 0x1.495aac6ca17a4p-29, 0x1.761db4210878cp-29, + 0x1.eb78e862bac2fp-29, 0x1.9b2cd75790dd9p-30, 0x1.c55e5cbd3d50fp-29, + 0x1.162a6617cc971p-36, 0x1.dbeabaaa2e519p-32, 0x1.652cb7150c647p-30, + 0x1.9a11cb2cd2ee2p-28, 0x1.19d0ab1a28813p-29, 0x1.4bd9e80a41811p-29, + 0x1.214b596faa3dfp-28, 0x1.03fea46980bb8p-28, 0x1.1c8ffa5fd28c7p-28, + 0x1.e8f743bcd96c5p-35, 0x1.d98c5395315c6p-32, 0x1.996fa3ccfa7b2p-28, + 0x1.cd2af2ad13037p-30, 0x1.d0da1bd17200ep-30, 0x1.330410ba68b75p-28, + 0x1.4f27a790e7c41p-32, 0x1.3956a86f6ff1bp-30, 0x1.c6748723551d9p-29, + 0x1.500de9326cdfcp-29, 0x1.086c848df1b59p-30, 0x1.4357ead6836ffp-31, + 0x1.4832442408024p-29, 0x1.d10da8154b13dp-28, 0x1.9e8ad68ec8260p-28, + 0x1.cfbf706abaf18p-28, 0x1.fc56ac6326e23p-28, 0x1.9105e3185cf21p-28, + 0x1.d017fe5b19cc0p-28, 0x1.d1f6b48dd13fep-28, 0x1.0b63358a7e73ap-29, + 0x1.63063028c211cp-29, 0x1.e6a6886b09760p-29, 0x1.c138bb891cd03p-28, + 0x1.69f7722b7221ap-28, 0x1.57d8fac1a628cp-32, 0x1.c55e5cbd3d50fp-28, + 0x1.552d2ff48fe2ep-30, 0x1.7b8b26ca431bcp-28, 0x1.92decdc1c5f6dp-29, + 0x1.abc7c551aaa8cp-28, 0x1.6b540731a354bp-28, 0x1.2d341036b89efp-28, + 0x1.f9ab21a3a2e0fp-27, 0x1.39c871afb9fbdp-29, 0x1.e6add2c81f640p-28, + 0x1.35c95aa313f41p-27, 0x1.49d4582f6cc53p-29, 0x1.7574c1c07398fp-27, + 0x1.ba846dece9e8dp-27, 0x1.6999fafbc68e7p-30, 0x1.c9145e51b0103p-27, + 0x1.79ef2cb44850ap-27, 0x1.beec73de11275p-31, 0x1.ef4351af5a498p-29, + 0x1.5713a493b4a50p-27, 0x1.5c23a61385992p-27, 0x1.2a88309f57299p-27, + 0x1.530faa9ac8acep-27, 0x1.5fec2d792a758p-29, 0x1.5a517a71cbcd7p-28, + 0x1.707dc3e1cd9a3p-28, 0x1.a1a9f8ef43049p-28, 0x1.409d0276b3674p-27, + 0x1.0e2f613e85bd9p-29, 0x1.0027433001e5fp-32, 0x1.5dde2836d3265p-28, + 0x1.300134d7aaf04p-29, 0x1.cb7e0b42724f5p-28, 0x1.d6e93167e6308p-29, + 0x1.d1569b1526adbp-28, 0x1.e99fc338a1a41p-31, 0x1.eb01394a11b1cp-27, + 0x1.4f27a790e7c41p-31, 0x1.5ce3ca97b7af9p-29, 0x1.81f0f940ed857p-29, + 0x1.d36295d88857cp-27, 0x1.1aca1ec4af526p-29, 0x1.45743c7182726p-27, + 0x1.3c491aead337ep-29, 0x1.aef401a738931p-28, 0x1.1cede76092a29p-29, + 0x1.fba8f44f82bb4p-27, 0x1.46f5f7f3c3e1ap-27, 0x1.7055f86c9674bp-27, + 0x1.b41a92b6b6e1ap-27, 0x1.43d162e927628p-27, 0x1.466174013f9b1p-27, + 0x1.b05096ad69c62p-28, 0x1.0b169150faa58p-27, 0x1.cd98b1df85da7p-28, + 0x1.68b507b0f8fa8p-27, 0x1.8422df57499bap-27, 0x1.1351586970274p-30, + 0x1.17e08acba92eep-30, 0x1.6e04314dd0229p-29, 0x1.97f3097e56d1ap-27, + 0x1.356e655901286p-28, 0x1.cb761457f94d6p-31, 0x1.9af67a85a9dacp-28, + 0x1.53410931a909fp-27, 0x1.2c587206058f5p-29, 0x1.23bc358899c22p-29, + 0x1.d7bf8b6d223cbp-27, 0x1.7991ec5197ddbp-27, 0x1.a79e6bb3a9219p-27, + 0x1.a4c43ed663ec5p-28, 0x1.61b5a1484f438p-27, 0x1.b4e36f7ef0c3ap-27, + 0x1.15f026acd0d1bp-30, 0x1.f36b535cecf05p-28, 0x1.ffb7fbf3eb5c6p-29, + 0x1.e6a6886b09760p-28, 0x1.135eb27f5bbc3p-28, 0x1.70be7d6f6fa57p-27, + 0x1.ce43cc84ab338p-27, 0x1.c01d7aac3bd91p-27, 0x1.5c58d07961060p-27, + 0x1.628bcf941456ep-28, 0x1.c58b2a8461cd2p-27, 0x1.3071282fb989ap-28, + 0x1.20dab6a80f09cp-27, 0x1.4f8d84c397b1ep-27, 0x1.0d0ee08599e48p-27, + 0x1.d68787e37da36p-30, 0x1.66187d591bafcp-28, 0x1.2346600bae772p-29, + 0x1.90377d0d61b8ep-28, 0x1.f5e0dd966b907p-27, 0x1.9023cb79a00e2p-27, + 0x1.4e05158c28ad8p-27, 0x1.bfa7b08b18ae4p-28, 0x1.ef1e63db35f67p-27, + 0x1.ec2ae39493d4fp-31, 0x1.0afe930ab2fa0p-27, 0x1.25ff8a1810dd4p-29, + 0x1.69743fb1a71a5p-27, 0x1.f9cc676785571p-26, 0x1.b524da4cbf982p-26, + 0x1.a4c8b381535b8p-26, 0x1.839be809caf2cp-26, 0x1.0968a1cb82c13p-26, + 0x1.eae6a41723fb5p-26, 0x1.d9c29a380a4dbp-26, 0x1.094aa0ada625ep-27, + 0x1.973ad6fc108cap-26, 0x1.747322fdbab97p-27, 0x1.93692fa9d4221p-26, + 0x1.c5a992dfbc7d9p-26, 0x1.e1f33e102387ap-27, 0x1.64fbef14c048cp-27, + 0x1.490f513ca5e3bp-27, 0x1.7a6af4d4c799dp-28, 0x1.7574c1c07398fp-26, + 0x1.7b133417f8c1cp-26, 0x1.feb9e0c176514p-26, 0x1.19f25bb3172f7p-27, + 0x1.5f68a7bbfb852p-27, 0x1.ee278497929f1p-26, 0x1.ccee006109d58p-26, + 0x1.ce081a07bd8b3p-26, 0x1.70e12981817b8p-26, 0x1.92ab6d93503d0p-29, + 0x1.8cb7dd7c3b61ep-26, 0x1.efafd0a0b78dap-27, 0x1.e907267c4288ep-26, + 0x1.d31ef96780875p-26, 0x1.3430dfcd2ad50p-29, 0x1.44d88d75bc1f9p-28, + 0x1.bec0f055e04fcp-26, 0x1.d85611590b9adp-26, 0x1.320568e583229p-32, + 0x1.a891d1772f538p-26, 0x1.2edc9dabba74dp-29, 0x1.b9009a1015086p-27, + 0x1.2a12a8c5b1a19p-26, 0x1.a7885f0fdac85p-28, 0x1.f4ffcd43ac691p-26, + 0x1.2243ae2640aadp-26, 0x1.46513299035d3p-26, 0x1.b39c3a62dd725p-26, + 0x1.ba6dd40049f51p-26, 0x1.51d1ed7177409p-27, 0x1.cb0f2fd7f5216p-26, + 0x1.ab150cd4e2213p-28, 0x1.cfd7bf3193844p-26, 0x1.3fff8455f1dbdp-26, + 0x1.fee640b905fc9p-26, 0x1.4e2adf548084cp-26, 0x1.b597adc1ecdd2p-28, + 0x1.345bd096d3a75p-27, 0x1.101b9d2453c8bp-26, 0x1.08ce55cc8c979p-26, + 0x1.bbf017e595f71p-26, 0x1.7ce733bd393dcp-28, 0x1.33bb0a503f8a1p-29, + 0x1.0e2f613e85bd9p-28, 0x1.e67555a635b3cp-26, 0x1.ea88df73d5e8bp-29, + 0x1.d17e03bda18a8p-28, 0x1.b607d76044f7ep-26, 0x1.2adc4e71bc2fcp-26, + 0x1.f99dc7362d1d9p-26, 0x1.473fa008e6a6ap-26, 0x1.b75bb09cb0985p-29, + 0x1.ea04dd10b9abap-26, 0x1.802d0d6979674p-26, 0x1.74688ccd99094p-30, + 0x1.96f16abb9df22p-27, 0x1.6e66df2aa374fp-27, 0x1.e66525ea4550ap-27, + 0x1.2d02f34f20cbdp-27, 0x1.6cfce65047188p-27, 0x1.9b78c842d58b8p-28, + 0x1.735e624c24bc9p-27, 0x1.7eba1f7dd1adfp-27, 0x1.86b3e59f65355p-26, + 0x1.ce38e637f1b4dp-30, 0x1.8d82ec919edc7p-26, 0x1.c52648ddcfa37p-27, + 0x1.2482ceae1ac12p-26, 0x1.5a312311aba4fp-26, 0x1.11e236329f225p-27, + 0x1.b48c8cd2f246cp-26, 0x1.efa39ef35793cp-25, 0x0.0000000000000p+0, +}; + +CLC_TABLE_FUNCTION(double, POWLOG_TBL_TAIL, powlog_tbl_tail); + +DECLARE_TABLE(double, TWO_TO_JBY64_EP_HEAD, 64) = { + 0x1.0000000000000p+0, 0x1.02c9a30000000p+0, 0x1.059b0d0000000p+0, + 0x1.0874510000000p+0, 0x1.0b55860000000p+0, 0x1.0e3ec30000000p+0, + 0x1.11301d0000000p+0, 0x1.1429aa0000000p+0, 0x1.172b830000000p+0, + 0x1.1a35be0000000p+0, 0x1.1d48730000000p+0, 0x1.2063b80000000p+0, + 0x1.2387a60000000p+0, 0x1.26b4560000000p+0, 0x1.29e9df0000000p+0, + 0x1.2d285a0000000p+0, 0x1.306fe00000000p+0, 0x1.33c08b0000000p+0, + 0x1.371a730000000p+0, 0x1.3a7db30000000p+0, 0x1.3dea640000000p+0, + 0x1.4160a20000000p+0, 0x1.44e0860000000p+0, 0x1.486a2b0000000p+0, + 0x1.4bfdad0000000p+0, 0x1.4f9b270000000p+0, 0x1.5342b50000000p+0, + 0x1.56f4730000000p+0, 0x1.5ab07d0000000p+0, 0x1.5e76f10000000p+0, + 0x1.6247eb0000000p+0, 0x1.6623880000000p+0, 0x1.6a09e60000000p+0, + 0x1.6dfb230000000p+0, 0x1.71f75e0000000p+0, 0x1.75feb50000000p+0, + 0x1.7a11470000000p+0, 0x1.7e2f330000000p+0, 0x1.8258990000000p+0, + 0x1.868d990000000p+0, 0x1.8ace540000000p+0, 0x1.8f1ae90000000p+0, + 0x1.93737b0000000p+0, 0x1.97d8290000000p+0, 0x1.9c49180000000p+0, + 0x1.a0c6670000000p+0, 0x1.a5503b0000000p+0, 0x1.a9e6b50000000p+0, + 0x1.ae89f90000000p+0, 0x1.b33a2b0000000p+0, 0x1.b7f76f0000000p+0, + 0x1.bcc1e90000000p+0, 0x1.c199bd0000000p+0, 0x1.c67f120000000p+0, + 0x1.cb720d0000000p+0, 0x1.d072d40000000p+0, 0x1.d5818d0000000p+0, + 0x1.da9e600000000p+0, 0x1.dfc9730000000p+0, 0x1.e502ee0000000p+0, + 0x1.ea4afa0000000p+0, 0x1.efa1be0000000p+0, 0x1.f507650000000p+0, + 0x1.fa7c180000000p+0, +}; + +CLC_TABLE_FUNCTION(double, TWO_TO_JBY64_EP_HEAD, two_to_jby64_ep_tbl_head); + +DECLARE_TABLE(double, TWO_TO_JBY64_EP_TAIL, 64) = { + 0x0.0000000000000p+0, 0x1.cef00c1dcdef9p-25, 0x1.8ac2ba1d73e2ap-27, + 0x1.0eb37901186bep-25, 0x1.9f3121ec53172p-25, 0x1.69e8d10103a17p-27, + 0x1.25b50a4ebbf1ap-32, 0x1.d525bbf668203p-25, 0x1.8faa2f5b9bef9p-25, + 0x1.6df96ea796d31p-25, 0x1.68b9aa7805b80p-28, 0x1.0c519ac771dd6p-25, + 0x1.ceac470cd83f5p-25, 0x1.789f37495e99cp-26, 0x1.47f7b84b09745p-26, + 0x1.b900c2d002475p-26, 0x1.4636e2a5bd1abp-25, 0x1.320b7fa64e430p-27, + 0x1.ceaa72a9c5154p-26, 0x1.3967fdba86f24p-26, 0x1.82468446b6824p-25, + 0x1.f72e29f84325bp-28, 0x1.8624b40c4dbd0p-30, 0x1.704f3404f068ep-26, + 0x1.4d8a89c750e5ep-26, 0x1.a74b29ab4cf62p-26, 0x1.a753e077c2a0fp-26, + 0x1.ad49f699bb2c0p-26, 0x1.a90a852b19260p-25, 0x1.6b48521ba6f93p-26, + 0x1.d2ac258f87d03p-31, 0x1.2a91124893ecfp-27, 0x1.9fcef32422cbep-26, + 0x1.8ca345de441c5p-25, 0x1.1d8bee7ba46e1p-25, 0x1.9099f22fdba6ap-26, + 0x1.f580c36bea881p-27, 0x1.b3d398841740ap-26, 0x1.2999c25159f11p-25, + 0x1.68925d901c83bp-25, 0x1.15506dadd3e2ap-27, 0x1.22aee6c57304ep-25, + 0x1.9b8bc9e8a0387p-29, 0x1.fbc9c9f173d24p-25, 0x1.51f8480e3e235p-27, + 0x1.6bbcac96535b5p-25, 0x1.1f12ae45a1224p-27, 0x1.5e7f6fd0fac90p-26, + 0x1.2b5a75abd0e69p-25, 0x1.09e2bf5ed7fa1p-25, 0x1.7daf237553d84p-27, + 0x1.2f074891ee83dp-30, 0x1.b0aa538444196p-25, 0x1.cafa29694426fp-25, + 0x1.9df20d22a0797p-25, 0x1.40f12f71a1e45p-25, 0x1.9f7490e4bb40bp-25, + 0x1.ed9942b84600dp-27, 0x1.bdcdaf5cb4656p-27, 0x1.e2cffd89cf44cp-26, + 0x1.52486cc2c7b9dp-27, 0x1.cc2b44eee3fa4p-25, 0x1.6dc8a80ce9f09p-25, + 0x1.9e90d82e90a7ep-28, +}; + +CLC_TABLE_FUNCTION(double, TWO_TO_JBY64_EP_TAIL, two_to_jby64_ep_tbl_tail); + +DECLARE_TABLE(double, CBRT_INV_TBL, 257) = { + 0x1.0000000000000p+1, 0x1.fe01fe01fe020p+0, 0x1.fc07f01fc07f0p+0, + 0x1.fa11caa01fa12p+0, 0x1.f81f81f81f820p+0, 0x1.f6310aca0dbb5p+0, + 0x1.f44659e4a4271p+0, 0x1.f25f644230ab5p+0, 0x1.f07c1f07c1f08p+0, + 0x1.ee9c7f8458e02p+0, 0x1.ecc07b301ecc0p+0, 0x1.eae807aba01ebp+0, + 0x1.e9131abf0b767p+0, 0x1.e741aa59750e4p+0, 0x1.e573ac901e574p+0, + 0x1.e3a9179dc1a73p+0, 0x1.e1e1e1e1e1e1ep+0, 0x1.e01e01e01e01ep+0, + 0x1.de5d6e3f8868ap+0, 0x1.dca01dca01dcap+0, 0x1.dae6076b981dbp+0, + 0x1.d92f2231e7f8ap+0, 0x1.d77b654b82c34p+0, 0x1.d5cac807572b2p+0, + 0x1.d41d41d41d41dp+0, 0x1.d272ca3fc5b1ap+0, 0x1.d0cb58f6ec074p+0, + 0x1.cf26e5c44bfc6p+0, 0x1.cd85689039b0bp+0, 0x1.cbe6d9601cbe7p+0, + 0x1.ca4b3055ee191p+0, 0x1.c8b265afb8a42p+0, 0x1.c71c71c71c71cp+0, + 0x1.c5894d10d4986p+0, 0x1.c3f8f01c3f8f0p+0, 0x1.c26b5392ea01cp+0, + 0x1.c0e070381c0e0p+0, 0x1.bf583ee868d8bp+0, 0x1.bdd2b899406f7p+0, + 0x1.bc4fd65883e7bp+0, 0x1.bacf914c1bad0p+0, 0x1.b951e2b18ff23p+0, + 0x1.b7d6c3dda338bp+0, 0x1.b65e2e3beee05p+0, 0x1.b4e81b4e81b4fp+0, + 0x1.b37484ad806cep+0, 0x1.b2036406c80d9p+0, 0x1.b094b31d922a4p+0, + 0x1.af286bca1af28p+0, 0x1.adbe87f94905ep+0, 0x1.ac5701ac5701bp+0, + 0x1.aaf1d2f87ebfdp+0, 0x1.a98ef606a63bep+0, 0x1.a82e65130e159p+0, + 0x1.a6d01a6d01a6dp+0, 0x1.a574107688a4ap+0, 0x1.a41a41a41a41ap+0, + 0x1.a2c2a87c51ca0p+0, 0x1.a16d3f97a4b02p+0, 0x1.a01a01a01a01ap+0, + 0x1.9ec8e951033d9p+0, 0x1.9d79f176b682dp+0, 0x1.9c2d14ee4a102p+0, + 0x1.9ae24ea5510dap+0, 0x1.999999999999ap+0, 0x1.9852f0d8ec0ffp+0, + 0x1.970e4f80cb872p+0, 0x1.95cbb0be377aep+0, 0x1.948b0fcd6e9e0p+0, + 0x1.934c67f9b2ce6p+0, 0x1.920fb49d0e229p+0, 0x1.90d4f120190d5p+0, + 0x1.8f9c18f9c18fap+0, 0x1.8e6527af1373fp+0, 0x1.8d3018d3018d3p+0, + 0x1.8bfce8062ff3ap+0, 0x1.8acb90f6bf3aap+0, 0x1.899c0f601899cp+0, + 0x1.886e5f0abb04ap+0, 0x1.87427bcc092b9p+0, 0x1.8618618618618p+0, + 0x1.84f00c2780614p+0, 0x1.83c977ab2beddp+0, 0x1.82a4a0182a4a0p+0, + 0x1.8181818181818p+0, 0x1.8060180601806p+0, 0x1.7f405fd017f40p+0, + 0x1.7e225515a4f1dp+0, 0x1.7d05f417d05f4p+0, 0x1.7beb3922e017cp+0, + 0x1.7ad2208e0ecc3p+0, 0x1.79baa6bb6398bp+0, 0x1.78a4c8178a4c8p+0, + 0x1.77908119ac60dp+0, 0x1.767dce434a9b1p+0, 0x1.756cac201756dp+0, + 0x1.745d1745d1746p+0, 0x1.734f0c541fe8dp+0, 0x1.724287f46debcp+0, + 0x1.713786d9c7c09p+0, 0x1.702e05c0b8170p+0, 0x1.6f26016f26017p+0, + 0x1.6e1f76b4337c7p+0, 0x1.6d1a62681c861p+0, 0x1.6c16c16c16c17p+0, + 0x1.6b1490aa31a3dp+0, 0x1.6a13cd1537290p+0, 0x1.691473a88d0c0p+0, + 0x1.6816816816817p+0, 0x1.6719f3601671ap+0, 0x1.661ec6a5122f9p+0, + 0x1.6524f853b4aa3p+0, 0x1.642c8590b2164p+0, 0x1.63356b88ac0dep+0, + 0x1.623fa77016240p+0, 0x1.614b36831ae94p+0, 0x1.6058160581606p+0, + 0x1.5f66434292dfcp+0, 0x1.5e75bb8d015e7p+0, 0x1.5d867c3ece2a5p+0, + 0x1.5c9882b931057p+0, 0x1.5babcc647fa91p+0, 0x1.5ac056b015ac0p+0, + 0x1.59d61f123ccaap+0, 0x1.58ed2308158edp+0, 0x1.5805601580560p+0, + 0x1.571ed3c506b3ap+0, 0x1.56397ba7c52e2p+0, 0x1.5555555555555p+0, + 0x1.54725e6bb82fep+0, 0x1.5390948f40febp+0, 0x1.52aff56a8054bp+0, + 0x1.51d07eae2f815p+0, 0x1.50f22e111c4c5p+0, 0x1.5015015015015p+0, + 0x1.4f38f62dd4c9bp+0, 0x1.4e5e0a72f0539p+0, 0x1.4d843bedc2c4cp+0, + 0x1.4cab88725af6ep+0, 0x1.4bd3edda68fe1p+0, 0x1.4afd6a052bf5bp+0, + 0x1.4a27fad76014ap+0, 0x1.49539e3b2d067p+0, 0x1.4880522014880p+0, + 0x1.47ae147ae147bp+0, 0x1.46dce34596066p+0, 0x1.460cbc7f5cf9ap+0, + 0x1.453d9e2c776cap+0, 0x1.446f86562d9fbp+0, 0x1.43a2730abee4dp+0, + 0x1.42d6625d51f87p+0, 0x1.420b5265e5951p+0, 0x1.4141414141414p+0, + 0x1.40782d10e6566p+0, 0x1.3fb013fb013fbp+0, 0x1.3ee8f42a5af07p+0, + 0x1.3e22cbce4a902p+0, 0x1.3d5d991aa75c6p+0, 0x1.3c995a47babe7p+0, + 0x1.3bd60d9232955p+0, 0x1.3b13b13b13b14p+0, 0x1.3a524387ac822p+0, + 0x1.3991c2c187f63p+0, 0x1.38d22d366088ep+0, 0x1.3813813813814p+0, + 0x1.3755bd1c945eep+0, 0x1.3698df3de0748p+0, 0x1.35dce5f9f2af8p+0, + 0x1.3521cfb2b78c1p+0, 0x1.34679ace01346p+0, 0x1.33ae45b57bcb2p+0, + 0x1.32f5ced6a1dfap+0, 0x1.323e34a2b10bfp+0, 0x1.3187758e9ebb6p+0, + 0x1.30d190130d190p+0, 0x1.301c82ac40260p+0, 0x1.2f684bda12f68p+0, + 0x1.2eb4ea1fed14bp+0, 0x1.2e025c04b8097p+0, 0x1.2d50a012d50a0p+0, + 0x1.2c9fb4d812ca0p+0, 0x1.2bef98e5a3711p+0, 0x1.2b404ad012b40p+0, + 0x1.2a91c92f3c105p+0, 0x1.29e4129e4129ep+0, 0x1.293725bb804a5p+0, + 0x1.288b01288b013p+0, 0x1.27dfa38a1ce4dp+0, 0x1.27350b8812735p+0, + 0x1.268b37cd60127p+0, 0x1.25e22708092f1p+0, 0x1.2539d7e9177b2p+0, + 0x1.2492492492492p+0, 0x1.23eb79717605bp+0, 0x1.23456789abcdfp+0, + 0x1.22a0122a0122ap+0, 0x1.21fb78121fb78p+0, 0x1.21579804855e6p+0, + 0x1.20b470c67c0d9p+0, 0x1.2012012012012p+0, 0x1.1f7047dc11f70p+0, + 0x1.1ecf43c7fb84cp+0, 0x1.1e2ef3b3fb874p+0, 0x1.1d8f5672e4abdp+0, + 0x1.1cf06ada2811dp+0, 0x1.1c522fc1ce059p+0, 0x1.1bb4a4046ed29p+0, + 0x1.1b17c67f2bae3p+0, 0x1.1a7b9611a7b96p+0, 0x1.19e0119e0119ep+0, + 0x1.19453808ca29cp+0, 0x1.18ab083902bdbp+0, 0x1.1811811811812p+0, + 0x1.1778a191bd684p+0, 0x1.16e0689427379p+0, 0x1.1648d50fc3201p+0, + 0x1.15b1e5f75270dp+0, 0x1.151b9a3fdd5c9p+0, 0x1.1485f0e0acd3bp+0, + 0x1.13f0e8d344724p+0, 0x1.135c81135c811p+0, 0x1.12c8b89edc0acp+0, + 0x1.12358e75d3033p+0, 0x1.11a3019a74826p+0, 0x1.1111111111111p+0, + 0x1.107fbbe011080p+0, 0x1.0fef010fef011p+0, 0x1.0f5edfab325a2p+0, + 0x1.0ecf56be69c90p+0, 0x1.0e40655826011p+0, 0x1.0db20a88f4696p+0, + 0x1.0d24456359e3ap+0, 0x1.0c9714fbcda3bp+0, 0x1.0c0a7868b4171p+0, + 0x1.0b7e6ec259dc8p+0, 0x1.0af2f722eecb5p+0, 0x1.0a6810a6810a7p+0, + 0x1.09ddba6af8360p+0, 0x1.0953f39010954p+0, 0x1.08cabb37565e2p+0, + 0x1.0842108421084p+0, 0x1.07b9f29b8eae2p+0, 0x1.073260a47f7c6p+0, + 0x1.06ab59c7912fbp+0, 0x1.0624dd2f1a9fcp+0, 0x1.059eea0727586p+0, + 0x1.05197f7d73404p+0, 0x1.04949cc1664c5p+0, 0x1.0410410410410p+0, + 0x1.038c6b78247fcp+0, 0x1.03091b51f5e1ap+0, 0x1.02864fc7729e9p+0, + 0x1.0204081020408p+0, 0x1.0182436517a37p+0, 0x1.0101010101010p+0, + 0x1.0080402010080p+0, 0x1.0000000000000p+0, +}; + +CLC_TABLE_FUNCTION(double, CBRT_INV_TBL, cbrt_inv_tbl); + +DECLARE_TABLE(double, CBRT_DBL_TBL_HEAD, 257) = { + 0x1.0000000000000p+0, 0x1.0055380000000p+0, 0x1.00aa390000000p+0, + 0x1.00ff010000000p+0, 0x1.0153920000000p+0, 0x1.01a7eb0000000p+0, + 0x1.01fc0d0000000p+0, 0x1.024ff80000000p+0, 0x1.02a3ad0000000p+0, + 0x1.02f72b0000000p+0, 0x1.034a750000000p+0, 0x1.039d880000000p+0, + 0x1.03f0670000000p+0, 0x1.0443110000000p+0, 0x1.0495870000000p+0, + 0x1.04e7c80000000p+0, 0x1.0539d60000000p+0, 0x1.058bb00000000p+0, + 0x1.05dd570000000p+0, 0x1.062ecc0000000p+0, 0x1.06800e0000000p+0, + 0x1.06d11e0000000p+0, 0x1.0721fc0000000p+0, 0x1.0772a80000000p+0, + 0x1.07c3230000000p+0, 0x1.08136d0000000p+0, 0x1.0863860000000p+0, + 0x1.08b36f0000000p+0, 0x1.0903280000000p+0, 0x1.0952b10000000p+0, + 0x1.09a20a0000000p+0, 0x1.09f1340000000p+0, 0x1.0a402f0000000p+0, + 0x1.0a8efc0000000p+0, 0x1.0add990000000p+0, 0x1.0b2c090000000p+0, + 0x1.0b7a4b0000000p+0, 0x1.0bc85f0000000p+0, 0x1.0c16450000000p+0, + 0x1.0c63fe0000000p+0, 0x1.0cb18b0000000p+0, 0x1.0cfeeb0000000p+0, + 0x1.0d4c1e0000000p+0, 0x1.0d99250000000p+0, 0x1.0de6010000000p+0, + 0x1.0e32b00000000p+0, 0x1.0e7f340000000p+0, 0x1.0ecb8d0000000p+0, + 0x1.0f17bb0000000p+0, 0x1.0f63bf0000000p+0, 0x1.0faf970000000p+0, + 0x1.0ffb460000000p+0, 0x1.1046cb0000000p+0, 0x1.1092250000000p+0, + 0x1.10dd560000000p+0, 0x1.11285e0000000p+0, 0x1.11733d0000000p+0, + 0x1.11bdf30000000p+0, 0x1.1208800000000p+0, 0x1.1252e40000000p+0, + 0x1.129d210000000p+0, 0x1.12e7350000000p+0, 0x1.1331210000000p+0, + 0x1.137ae60000000p+0, 0x1.13c4840000000p+0, 0x1.140dfa0000000p+0, + 0x1.1457490000000p+0, 0x1.14a0710000000p+0, 0x1.14e9730000000p+0, + 0x1.15324e0000000p+0, 0x1.157b030000000p+0, 0x1.15c3920000000p+0, + 0x1.160bfc0000000p+0, 0x1.16543f0000000p+0, 0x1.169c5d0000000p+0, + 0x1.16e4560000000p+0, 0x1.172c2a0000000p+0, 0x1.1773d90000000p+0, + 0x1.17bb630000000p+0, 0x1.1802c90000000p+0, 0x1.184a0a0000000p+0, + 0x1.1891270000000p+0, 0x1.18d8210000000p+0, 0x1.191ef60000000p+0, + 0x1.1965a80000000p+0, 0x1.19ac360000000p+0, 0x1.19f2a10000000p+0, + 0x1.1a38e90000000p+0, 0x1.1a7f0e0000000p+0, 0x1.1ac5100000000p+0, + 0x1.1b0af00000000p+0, 0x1.1b50ad0000000p+0, 0x1.1b96480000000p+0, + 0x1.1bdbc10000000p+0, 0x1.1c21180000000p+0, 0x1.1c664d0000000p+0, + 0x1.1cab610000000p+0, 0x1.1cf0530000000p+0, 0x1.1d35230000000p+0, + 0x1.1d79d30000000p+0, 0x1.1dbe620000000p+0, 0x1.1e02cf0000000p+0, + 0x1.1e471d0000000p+0, 0x1.1e8b490000000p+0, 0x1.1ecf550000000p+0, + 0x1.1f13410000000p+0, 0x1.1f570d0000000p+0, 0x1.1f9ab90000000p+0, + 0x1.1fde450000000p+0, 0x1.2021b20000000p+0, 0x1.2064ff0000000p+0, + 0x1.20a82c0000000p+0, 0x1.20eb3b0000000p+0, 0x1.212e2a0000000p+0, + 0x1.2170fb0000000p+0, 0x1.21b3ac0000000p+0, 0x1.21f63f0000000p+0, + 0x1.2238b40000000p+0, 0x1.227b0a0000000p+0, 0x1.22bd420000000p+0, + 0x1.22ff5c0000000p+0, 0x1.2341570000000p+0, 0x1.2383350000000p+0, + 0x1.23c4f60000000p+0, 0x1.2406980000000p+0, 0x1.24481d0000000p+0, + 0x1.2489850000000p+0, 0x1.24cad00000000p+0, 0x1.250bfe0000000p+0, + 0x1.254d0e0000000p+0, 0x1.258e020000000p+0, 0x1.25ced90000000p+0, + 0x1.260f940000000p+0, 0x1.2650320000000p+0, 0x1.2690b40000000p+0, + 0x1.26d1190000000p+0, 0x1.2711630000000p+0, 0x1.2751900000000p+0, + 0x1.2791a20000000p+0, 0x1.27d1980000000p+0, 0x1.2811720000000p+0, + 0x1.2851310000000p+0, 0x1.2890d50000000p+0, 0x1.28d05d0000000p+0, + 0x1.290fca0000000p+0, 0x1.294f1c0000000p+0, 0x1.298e530000000p+0, + 0x1.29cd700000000p+0, 0x1.2a0c710000000p+0, 0x1.2a4b580000000p+0, + 0x1.2a8a250000000p+0, 0x1.2ac8d70000000p+0, 0x1.2b076f0000000p+0, + 0x1.2b45ec0000000p+0, 0x1.2b84500000000p+0, 0x1.2bc29a0000000p+0, + 0x1.2c00c90000000p+0, 0x1.2c3ee00000000p+0, 0x1.2c7cdc0000000p+0, + 0x1.2cbabf0000000p+0, 0x1.2cf8880000000p+0, 0x1.2d36390000000p+0, + 0x1.2d73d00000000p+0, 0x1.2db14d0000000p+0, 0x1.2deeb20000000p+0, + 0x1.2e2bfe0000000p+0, 0x1.2e69310000000p+0, 0x1.2ea64b0000000p+0, + 0x1.2ee34d0000000p+0, 0x1.2f20360000000p+0, 0x1.2f5d070000000p+0, + 0x1.2f99bf0000000p+0, 0x1.2fd65f0000000p+0, 0x1.3012e70000000p+0, + 0x1.304f570000000p+0, 0x1.308baf0000000p+0, 0x1.30c7ef0000000p+0, + 0x1.3104180000000p+0, 0x1.3140280000000p+0, 0x1.317c210000000p+0, + 0x1.31b8020000000p+0, 0x1.31f3cd0000000p+0, 0x1.322f7f0000000p+0, + 0x1.326b1b0000000p+0, 0x1.32a69f0000000p+0, 0x1.32e20c0000000p+0, + 0x1.331d620000000p+0, 0x1.3358a20000000p+0, 0x1.3393ca0000000p+0, + 0x1.33cedc0000000p+0, 0x1.3409d70000000p+0, 0x1.3444bc0000000p+0, + 0x1.347f8a0000000p+0, 0x1.34ba420000000p+0, 0x1.34f4e30000000p+0, + 0x1.352f6f0000000p+0, 0x1.3569e40000000p+0, 0x1.35a4430000000p+0, + 0x1.35de8c0000000p+0, 0x1.3618bf0000000p+0, 0x1.3652dd0000000p+0, + 0x1.368ce40000000p+0, 0x1.36c6d60000000p+0, 0x1.3700b30000000p+0, + 0x1.373a7a0000000p+0, 0x1.37742b0000000p+0, 0x1.37adc70000000p+0, + 0x1.37e74e0000000p+0, 0x1.3820c00000000p+0, 0x1.385a1c0000000p+0, + 0x1.3893640000000p+0, 0x1.38cc960000000p+0, 0x1.3905b40000000p+0, + 0x1.393ebd0000000p+0, 0x1.3977b10000000p+0, 0x1.39b0910000000p+0, + 0x1.39e95c0000000p+0, 0x1.3a22120000000p+0, 0x1.3a5ab40000000p+0, + 0x1.3a93410000000p+0, 0x1.3acbbb0000000p+0, 0x1.3b04200000000p+0, + 0x1.3b3c700000000p+0, 0x1.3b74ad0000000p+0, 0x1.3bacd60000000p+0, + 0x1.3be4eb0000000p+0, 0x1.3c1ceb0000000p+0, 0x1.3c54d90000000p+0, + 0x1.3c8cb20000000p+0, 0x1.3cc4770000000p+0, 0x1.3cfc2a0000000p+0, + 0x1.3d33c80000000p+0, 0x1.3d6b530000000p+0, 0x1.3da2cb0000000p+0, + 0x1.3dda2f0000000p+0, 0x1.3e11800000000p+0, 0x1.3e48be0000000p+0, + 0x1.3e7fe80000000p+0, 0x1.3eb7000000000p+0, 0x1.3eee040000000p+0, + 0x1.3f24f60000000p+0, 0x1.3f5bd40000000p+0, 0x1.3f92a00000000p+0, + 0x1.3fc9590000000p+0, 0x1.3fffff0000000p+0, 0x1.4036930000000p+0, + 0x1.406d140000000p+0, 0x1.40a3830000000p+0, 0x1.40d9df0000000p+0, + 0x1.4110290000000p+0, 0x1.4146600000000p+0, 0x1.417c850000000p+0, + 0x1.41b2980000000p+0, 0x1.41e8990000000p+0, 0x1.421e880000000p+0, + 0x1.4254640000000p+0, 0x1.428a2f0000000p+0, +}; + +CLC_TABLE_FUNCTION(double, CBRT_DBL_TBL_HEAD, cbrt_dbl_tbl_head); + +DECLARE_TABLE(double, CBRT_DBL_TBL_TAIL, 257) = { + 0x0.0000000000000p+0, 0x1.e6a24c81e4294p-25, 0x1.8548511e3a785p-26, + 0x1.4eb9336ec07f6p-25, 0x1.0ea64b8b750e1p-27, 0x1.61637cff8a53cp-27, + 0x1.0733bf7bd1943p-27, 0x1.666911345ccedp-26, 0x1.77b7a3f592f14p-27, + 0x1.f18d3dd1a5402p-25, 0x1.be2f5a58ee9a4p-29, 0x1.8901f8f085fa7p-25, + 0x1.c68b8cd5b5d69p-26, 0x1.a6b0e8624be42p-26, 0x1.c4b22b06f68e7p-36, + 0x1.0f3f0afcabe9bp-25, 0x1.48495bca4e1b7p-26, 0x1.6107f1abdfdc3p-25, + 0x1.e67261878288ap-25, 0x1.a6bc155286f1ep-26, 0x1.8a759c64a85f2p-26, + 0x1.5fce70a4a8d09p-27, 0x1.2f9cbf373fe1dp-28, 0x1.90564ce4ac359p-26, + 0x1.ac29ce761b02fp-26, 0x1.cb752f497381cp-26, 0x1.8bb9e1cfb35e0p-25, + 0x1.5b4917099de90p-25, 0x1.cc77ac9c65ef2p-26, 0x1.7a0f3e7be3dbap-26, + 0x1.6ec851ee0c16fp-25, 0x1.89449bf2946dap-25, 0x1.98f25301ba223p-25, + 0x1.47d5ec651f549p-28, 0x1.c33ec9a86007ap-25, 0x1.e0b6653e92649p-26, + 0x1.bd64ac09d755fp-28, 0x1.f537506f78167p-29, 0x1.2c382d1b3735ep-25, + 0x1.e20ed659f99e1p-25, 0x1.86b633a9c182ap-26, 0x1.45cfd5a65e777p-27, + 0x1.0c8770f58bca4p-25, 0x1.739e44b0933c5p-25, 0x1.27dc3d9ce7bd8p-31, + 0x1.3c53c7c5a7b64p-25, 0x1.9669683830cecp-25, 0x1.8d772c39bdcc4p-25, + 0x1.9b0008bcf6d7bp-25, 0x1.bbb305825ce4fp-28, 0x1.da3f4af13a406p-25, + 0x1.f36b96f74ce86p-26, 0x1.65c002303f790p-30, 0x1.82f84095ba7d5p-25, + 0x1.d46433541b2c6p-25, 0x1.71c3d56e93a89p-25, 0x1.98dcef4e40012p-26, + 0x1.530ebef17fe03p-27, 0x1.e8b8fa3715066p-27, 0x1.ab26eb3b211dcp-25, + 0x1.54dd4dc906307p-27, 0x1.c9f962387984ep-26, 0x1.c62a959afec09p-25, + 0x1.638d9ac6a866ap-25, 0x1.38704eca8a22dp-28, 0x1.e6c9e1db14f8fp-27, + 0x1.8744b7f9c9eaap-26, 0x1.6c2893486373bp-25, 0x1.b36bce31699b7p-26, + 0x1.71e3813d200c7p-25, 0x1.99755ab40aa88p-25, 0x1.b45ca0e4bcfc0p-25, + 0x1.2dd090d869c5dp-28, 0x1.4fe0516b917dap-25, 0x1.94563226317a2p-25, + 0x1.53d8fafc2c851p-25, 0x1.dcbd41fbd41a3p-26, 0x1.862ff5285f59cp-26, + 0x1.3072ea97a1e1cp-25, 0x1.2839075184805p-26, 0x1.4b0323e9eff42p-25, + 0x1.b158893c45484p-25, 0x1.149ef0fc35826p-28, 0x1.f2e77ea96acaap-26, + 0x1.200074c471a95p-26, 0x1.3f8cc517f6f04p-25, 0x1.60ba2e311bb55p-25, + 0x1.4b788730bbec3p-25, 0x1.57090795ee20cp-25, 0x1.d9ffe983670b1p-25, + 0x1.2a463ff61bfdap-25, 0x1.9d1bc6a5e65cfp-25, 0x1.8718abaa9e922p-25, + 0x1.3c2f52ffa342ep-25, 0x1.0fae13ff42c80p-25, 0x1.5440f0ef00d57p-25, + 0x1.6fcd22d4e3c1ep-27, 0x1.e0c60b409e863p-27, 0x1.f9cab5a5f0333p-25, + 0x1.30f24744c333dp-25, 0x1.b50622a76b2fep-27, 0x1.fdb94ba595375p-25, + 0x1.861b9b945a171p-28, 0x1.54348015188c4p-25, 0x1.b54d149865523p-25, + 0x1.a0bb783d9de33p-25, 0x1.629d12b1a2157p-25, 0x1.467fe35d179dfp-25, + 0x1.9763f3e26c8f7p-25, 0x1.3f798bb9f7679p-26, 0x1.52e577e855898p-26, + 0x1.fde47e5502c3ap-25, 0x1.cbd0b548d96a0p-26, 0x1.a9cd9f7be8de8p-25, + 0x1.22bbe704886dep-26, 0x1.e3dea8317f020p-25, 0x1.e812085ac8855p-25, + 0x1.c87144f24cb07p-26, 0x1.1e128ee311fa2p-25, 0x1.b5c163d61a2d3p-26, + 0x1.7d97e7fb90633p-27, 0x1.efe899d50f6a7p-25, 0x1.d0333eb75de5ap-25, + 0x1.0e590be73a573p-27, 0x1.8ce8dcac3cdd2p-25, 0x1.ee8a48954064bp-25, + 0x1.aa62f18461e09p-25, 0x1.01e5940986a15p-25, 0x1.b082f4f9b8d4cp-28, + 0x1.876e0e5527f5ap-25, 0x1.3617080831e6bp-25, 0x1.81b26e34aa4a2p-25, + 0x1.52ee66dfab0c1p-26, 0x1.d85a5329e8819p-26, 0x1.105c1b646b5d1p-26, + 0x1.bb6690c1a379cp-25, 0x1.86aeba73ce3a9p-26, 0x1.dd16198294dd4p-25, + 0x1.454e675775e83p-25, 0x1.3842e026197eap-25, 0x1.f1ce0e70c44d2p-25, + 0x1.ad636441a5627p-25, 0x1.4c205d7212abbp-26, 0x1.167c86c116419p-25, + 0x1.38ec3ef16e294p-25, 0x1.473fceace9321p-25, 0x1.7af53a836dba7p-25, + 0x1.a51f3c383b652p-30, 0x1.3696da190822dp-25, 0x1.2f9adec77074bp-25, + 0x1.8190fd5bee55fp-28, 0x1.bfee8fac68e55p-27, 0x1.31c9d6bc5f68ap-28, + 0x1.89d0523737edfp-25, 0x1.a295943bf47bbp-26, 0x1.96be32e5b3207p-28, + 0x1.e44c7d909fa0ep-25, 0x1.b2505da94d9eap-29, 0x1.0c851f46c9c98p-25, + 0x1.da71f7d9aa3b7p-26, 0x1.f1b605d019ef1p-25, 0x1.386e8a2189563p-27, + 0x1.b19fa5d306ba7p-28, 0x1.dd749b67aef76p-25, 0x1.76ff6f1dc04b0p-25, + 0x1.35a33d0b232a6p-25, 0x1.4bdc80024a4e1p-25, 0x1.ebd61770fd723p-25, + 0x1.4769fc537264dp-25, 0x1.9021f429f3b98p-25, 0x1.ee7083efbd606p-26, + 0x1.ad985552a6b1ap-25, 0x1.e3df778772160p-25, 0x1.ca5d76ddc9b34p-25, + 0x1.91154ffdbaf74p-25, 0x1.67bdd57fb306ap-25, 0x1.7dc255ac40886p-25, + 0x1.219f38e8afafep-32, 0x1.2416bf9669a04p-25, 0x1.11c96b2b3987fp-25, + 0x1.f99ed447e1177p-25, 0x1.3245826328a11p-30, 0x1.6f56dd1e645f8p-25, + 0x1.6164946945535p-27, 0x1.e37d59d190028p-26, 0x1.68671f12bf828p-25, + 0x1.e8ecbca6aabbdp-25, 0x1.3f49e109a5912p-26, 0x1.b8a0e11ec3043p-25, + 0x1.5fae00aed691ap-25, 0x1.c0569bece3e4ap-25, 0x1.05e26744efbfep-25, + 0x1.5b570a94be5c5p-25, 0x1.d6f156ea0e063p-26, 0x1.e0ca7612fc484p-25, + 0x1.963c927b25258p-27, 0x1.47930aa725a5cp-26, 0x1.8a79fe3af43b3p-26, + 0x1.e6dc29c41bdafp-26, 0x1.57a2e76f863a5p-25, 0x1.ae3b61716354dp-29, + 0x1.65fb5df6906b1p-25, 0x1.6177d7f588f7bp-25, 0x1.ad55abd091b67p-28, + 0x1.55337b2422d76p-30, 0x1.084ebe86972d5p-25, 0x1.56395808e1ea3p-25, + 0x1.1bce21b40fba7p-25, 0x1.006f94605b515p-26, 0x1.aa676aceb1f7dp-25, + 0x1.8229f76554ce6p-26, 0x1.eabfc6cf57330p-25, 0x1.4daed9c0ce8bcp-25, + 0x1.0ff1768237141p-25, 0x1.575f83051b085p-25, 0x1.2667deb523e29p-27, + 0x1.816996954f4fdp-30, 0x1.87cfccf4d9cd4p-26, 0x1.2c5d018198353p-26, + 0x1.a7a898dcc34aap-25, 0x1.cead6dadc36d1p-29, 0x1.a55759c498bdfp-29, + 0x1.c414a9ef6de04p-25, 0x1.3e2108a6e58fap-25, 0x1.587fd7643d77cp-26, + 0x1.901eb1d3ff3dfp-28, 0x1.f2ccd7c812fc6p-25, 0x1.1c8ee70a01049p-29, + 0x1.63e8d02831eecp-26, 0x1.f61a42a92c7ffp-25, 0x1.a917399c84d24p-34, + 0x1.e9197c8eec2f0p-26, 0x1.e6f842f5a1378p-26, 0x1.fac242a90a0fcp-29, + 0x1.35ed726610227p-26, 0x1.0e0d64804b15bp-26, 0x1.560675daba814p-31, + 0x1.37388c8768032p-25, 0x1.ee3c89f9e01f5p-28, 0x1.39f6f0d09747cp-25, + 0x1.322c327abb8f0p-27, 0x1.961b347c8ac80p-25, 0x1.3711fbbd0f118p-25, + 0x1.4fad8d7718ffbp-25, 0x1.fffffffffffffp-25, 0x1.67efa79ec35b4p-25, + 0x1.a737687a254a8p-25, 0x1.bace0f87d924dp-26, 0x1.29e37c237e392p-25, + 0x1.57ce7ac3f3012p-26, 0x1.82829359f8fbdp-25, 0x1.cc9be42d14676p-25, + 0x1.a8f001c137d0bp-25, 0x1.36127687dda05p-25, 0x1.24dba322646f0p-26, + 0x1.dc43f1ed210b4p-25, 0x1.31ae515c447bbp-25, +}; + +CLC_TABLE_FUNCTION(double, CBRT_DBL_TBL_TAIL, cbrt_dbl_tbl_tail); + +DECLARE_TABLE(double, CBRT_REM_TBL_HEAD, 5) = { + 0x1.428a2f0000000p-1, 0x1.965fea0000000p-1, 0x1.0000000000000p+0, + 0x1.428a2f0000000p+0, 0x1.965fea0000000p+0, +}; + +CLC_TABLE_FUNCTION(double, CBRT_REM_TBL_HEAD, cbrt_rem_tbl_head); + +DECLARE_TABLE(double, CBRT_REM_TBL_TAIL, 5) = { + 0x1.31ae515c447bbp-26, 0x1.4f5b8f20ac166p-27, 0x0.0000000000000p+0, + 0x1.31ae515c447bbp-25, 0x1.4f5b8f20ac166p-26, +}; + +CLC_TABLE_FUNCTION(double, CBRT_REM_TBL_TAIL, cbrt_rem_tbl_tail); + +DECLARE_TABLE(double, SINH_TBL_HEAD, 37) = { + 0x0.0000000000000p+0, 0x1.2cd9fc0000000p+0, 0x1.d03cf60000000p+1, + 0x1.40926e0000000p+3, 0x1.b4a3800000000p+4, 0x1.28d0160000000p+6, + 0x1.936d228000000p+7, 0x1.1228768000000p+9, 0x1.749ea50000000p+10, + 0x1.fa71570000000p+11, 0x1.5829dc8000000p+13, 0x1.d3c4488000000p+14, + 0x1.3de1650000000p+16, 0x1.b00b590000000p+17, 0x1.259ac48000000p+19, + 0x1.8f0cca8000000p+20, 0x1.0f2ebd0000000p+22, 0x1.7093488000000p+23, + 0x1.f4f2208000000p+24, 0x1.546d8f8000000p+26, 0x1.ceb0888000000p+27, + 0x1.3a6e1f8000000p+29, 0x1.ab5adb8000000p+30, 0x1.226af30000000p+32, + 0x1.8ab7fb0000000p+33, 0x1.0c3d390000000p+35, 0x1.6c93268000000p+36, + 0x1.ef822f0000000p+37, 0x1.50bba30000000p+39, 0x1.c9aae40000000p+40, + 0x1.3704708000000p+42, 0x1.a6b7658000000p+43, 0x1.1f43fc8000000p+45, + 0x1.866f348000000p+46, 0x1.0953e28000000p+48, 0x1.689e220000000p+49, + 0x1.ea215a0000000p+50, +}; + +DECLARE_TABLE(double, SINH_TBL_TAIL, 37) = { + 0x0.0000000000000p+0, 0x1.13ae6096a0092p-26, 0x1.db70cfb79a640p-26, + 0x1.c2526b66dc067p-23, 0x1.b81b18647f380p-23, 0x1.bc1cdd1e1eb08p-20, + 0x1.d9f201534fb09p-19, 0x1.d1c064a4e9954p-18, 0x1.4eca65d06ea74p-18, + 0x1.0c259bcc0ecc5p-15, 0x1.b5a6647cf9016p-13, 0x1.9691adefb0870p-15, + 0x1.3410fc29cde38p-10, 0x1.6a31a50b6fb3cp-11, 0x1.7defc71805c40p-10, + 0x1.eb49fd80e0babp-6, 0x1.4fffc7bcd5920p-7, 0x1.03a93b6c63435p-3, + 0x1.1940bb255fd1cp-4, 0x1.ed26e14260b50p-2, 0x1.b47401fc9f2a2p+0, + 0x1.67bb3f55634f1p+3, 0x1.c435ff8194ddcp+2, 0x1.d8fee052ba63ap+5, + 0x1.51d7edccde3f6p+7, 0x1.04b1644557d1ap+8, 0x1.6a6b5ca0a9dc4p+8, + 0x1.fd9cc72249abap+11, 0x1.e58de693edab5p+13, 0x1.8c70158ac6363p+14, + 0x1.7614764f43e20p+15, 0x1.6337db36fc718p+17, 0x1.12d98b1f611e2p+19, + 0x1.392bc108b37ccp+19, 0x1.ce87bdc3473dcp+22, 0x1.bc8d5ae99ad14p+21, + 0x1.d20d76744835cp+22, +}; + +DECLARE_TABLE(double, COSH_TBL_HEAD, 37) = { + 0x1.0000000000000p+0, 0x1.8b07550000000p+0, 0x1.e18fa08000000p+1, + 0x1.422a490000000p+3, 0x1.b4ee858000000p+4, 0x1.28d6fc8000000p+6, + 0x1.936e678000000p+7, 0x1.1228948000000p+9, 0x1.749eaa8000000p+10, + 0x1.fa71580000000p+11, 0x1.5829dd0000000p+13, 0x1.d3c4488000000p+14, + 0x1.3de1650000000p+16, 0x1.b00b590000000p+17, 0x1.259ac48000000p+19, + 0x1.8f0cca8000000p+20, 0x1.0f2ebd0000000p+22, 0x1.7093488000000p+23, + 0x1.f4f2208000000p+24, 0x1.546d8f8000000p+26, 0x1.ceb0888000000p+27, + 0x1.3a6e1f8000000p+29, 0x1.ab5adb8000000p+30, 0x1.226af30000000p+32, + 0x1.8ab7fb0000000p+33, 0x1.0c3d390000000p+35, 0x1.6c93268000000p+36, + 0x1.ef822f0000000p+37, 0x1.50bba30000000p+39, 0x1.c9aae40000000p+40, + 0x1.3704708000000p+42, 0x1.a6b7658000000p+43, 0x1.1f43fc8000000p+45, + 0x1.866f348000000p+46, 0x1.0953e28000000p+48, 0x1.689e220000000p+49, + 0x1.ea215a0000000p+50, +}; + +DECLARE_TABLE(double, COSH_TBL_TAIL, 37) = { + 0x0.0000000000000p+0, 0x1.d9f5504c2bd28p-28, 0x1.7cb66f0a4c9fdp-25, + 0x1.f58617928e588p-23, 0x1.bc7d000c38d48p-25, 0x1.f7f9d4e329998p-21, + 0x1.6e6e464885269p-19, 0x1.ba3a8b946c154p-19, 0x1.3f4e76110d5a4p-18, + 0x1.17622515a3e2bp-15, 0x1.4dc4b528af3d0p-17, 0x1.1156278615e10p-14, + 0x1.35ad50ed821f5p-10, 0x1.6b61055f2935cp-11, 0x1.7e2794a601240p-10, + 0x1.eb4b45f6aadd3p-6, 0x1.5000b967b3698p-7, 0x1.03a940fadc092p-3, + 0x1.1940bf3bf874cp-4, 0x1.ed26e1a2a2110p-2, 0x1.b4740205796d6p+0, + 0x1.67bb3f55cb85dp+3, 0x1.c435ff81e18acp+2, 0x1.d8fee052bdea4p+5, + 0x1.51d7edccde926p+7, 0x1.04b1644557e0ep+8, 0x1.6a6b5ca0a9e1cp+8, + 0x1.fd9cc72249abep+11, 0x1.e58de693edab5p+13, 0x1.8c70158ac6364p+14, + 0x1.7614764f43e20p+15, 0x1.6337db36fc718p+17, 0x1.12d98b1f611e2p+19, + 0x1.392bc108b37ccp+19, 0x1.ce87bdc3473dcp+22, 0x1.bc8d5ae99ad14p+21, + 0x1.d20d76744835cp+22, +}; + +CLC_TABLE_FUNCTION(double, SINH_TBL_HEAD, sinh_tbl_head); +CLC_TABLE_FUNCTION(double, SINH_TBL_TAIL, sinh_tbl_tail); +CLC_TABLE_FUNCTION(double, COSH_TBL_HEAD, cosh_tbl_head); +CLC_TABLE_FUNCTION(double, COSH_TBL_TAIL, cosh_tbl_tail); + +DECLARE_TABLE(uchar, PIBITS_TBL, ) = { + 224, 241, 27, 193, 12, 88, 33, 116, 53, 126, 196, 126, 237, 175, 169, + 75, 74, 41, 222, 231, 28, 244, 236, 197, 151, 175, 31, 235, 158, 212, + 181, 168, 127, 121, 154, 253, 24, 61, 221, 38, 44, 159, 60, 251, 217, + 180, 125, 180, 41, 104, 45, 70, 188, 188, 63, 96, 22, 120, 255, 95, + 226, 127, 236, 160, 228, 247, 46, 126, 17, 114, 210, 231, 76, 13, 230, + 88, 71, 230, 4, 249, 125, 209, 154, 192, 113, 166, 19, 18, 237, 186, + 212, 215, 8, 162, 251, 156, 166, 196, 114, 172, 119, 248, 115, 72, 70, + 39, 168, 187, 36, 25, 128, 75, 55, 9, 233, 184, 145, 220, 134, 21, + 239, 122, 175, 142, 69, 249, 7, 65, 14, 241, 100, 86, 138, 109, 3, + 119, 211, 212, 71, 95, 157, 240, 167, 84, 16, 57, 185, 13, 230, 139, + 2, 0, 0, 0, 0, 0, 0, 0}; + +_CLC_DEF _CLC_OVERLOAD ulong TABLE_MANGLE(pibits_tbl)(int idx) { + return *(__constant ulong *)(PIBITS_TBL + idx); +} +_CLC_DEF _CLC_OVERLOAD ulong2 TABLE_MANGLE(pibits_tbl)(int2 idx) { + return (ulong2){*(__constant ulong *)(PIBITS_TBL + idx.s0), + *(__constant ulong *)(PIBITS_TBL + idx.s1)}; +} +_CLC_DEF _CLC_OVERLOAD ulong3 TABLE_MANGLE(pibits_tbl)(int3 idx) { + return (ulong3){*(__constant ulong *)(PIBITS_TBL + idx.s0), + *(__constant ulong *)(PIBITS_TBL + idx.s1), + *(__constant ulong *)(PIBITS_TBL + idx.s2)}; +} +_CLC_DEF _CLC_OVERLOAD ulong4 TABLE_MANGLE(pibits_tbl)(int4 idx) { + return (ulong4){*(__constant ulong *)(PIBITS_TBL + idx.s0), + *(__constant ulong *)(PIBITS_TBL + idx.s1), + *(__constant ulong *)(PIBITS_TBL + idx.s2), + *(__constant ulong *)(PIBITS_TBL + idx.s3)}; +} +_CLC_DEF _CLC_OVERLOAD ulong8 TABLE_MANGLE(pibits_tbl)(int8 idx) { + return (ulong8){*(__constant ulong *)(PIBITS_TBL + idx.s0), + *(__constant ulong *)(PIBITS_TBL + idx.s1), + *(__constant ulong *)(PIBITS_TBL + idx.s2), + *(__constant ulong *)(PIBITS_TBL + idx.s3), + *(__constant ulong *)(PIBITS_TBL + idx.s4), + *(__constant ulong *)(PIBITS_TBL + idx.s5), + *(__constant ulong *)(PIBITS_TBL + idx.s6), + *(__constant ulong *)(PIBITS_TBL + idx.s7)}; +} +_CLC_DEF _CLC_OVERLOAD ulong16 TABLE_MANGLE(pibits_tbl)(int16 idx) { + return (ulong16){*(__constant ulong *)(PIBITS_TBL + idx.s0), + *(__constant ulong *)(PIBITS_TBL + idx.s1), + *(__constant ulong *)(PIBITS_TBL + idx.s2), + *(__constant ulong *)(PIBITS_TBL + idx.s3), + *(__constant ulong *)(PIBITS_TBL + idx.s4), + *(__constant ulong *)(PIBITS_TBL + idx.s5), + *(__constant ulong *)(PIBITS_TBL + idx.s6), + *(__constant ulong *)(PIBITS_TBL + idx.s7), + *(__constant ulong *)(PIBITS_TBL + idx.s8), + *(__constant ulong *)(PIBITS_TBL + idx.s9), + *(__constant ulong *)(PIBITS_TBL + idx.sA), + *(__constant ulong *)(PIBITS_TBL + idx.sB), + *(__constant ulong *)(PIBITS_TBL + idx.sC), + *(__constant ulong *)(PIBITS_TBL + idx.sD), + *(__constant ulong *)(PIBITS_TBL + idx.sE), + *(__constant ulong *)(PIBITS_TBL + idx.sF)}; +} + +#endif // cl_khr_fp64 diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tan.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tan.cl new file mode 100644 index 0000000000..adf42c43d0 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tan.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tan.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tan.inc new file mode 100644 index 0000000000..8a318a53a3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tan.inc @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_tan(__CLC_GENTYPE x) { + __CLC_GENTYPE absx = __clc_fabs(x); + __CLC_UINTN x_signbit = __CLC_AS_UINTN(x) & SIGNBIT_SP32; + + __CLC_GENTYPE r0, r1; + __CLC_INTN regn = __clc_argReductionS(&r0, &r1, absx); + + __CLC_GENTYPE t = __clc_tanf_piby4(r0 + r1, regn); + t = __CLC_AS_GENTYPE(__CLC_AS_UINTN(t) ^ x_signbit); + + t = __clc_select(t, __CLC_GENTYPE_NAN, __clc_isnan(x) || __clc_isinf(x)); + // Take care of subnormals + t = (x == 0.0f) ? x : t; + return t; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_tan(__CLC_GENTYPE x) { + __CLC_GENTYPE y = __clc_fabs(x); + + __CLC_BIT_INTN is_medium = y < 0x1.0p+30; + + __CLC_INTN regn_m, regn_l; + __CLC_GENTYPE r_m, r_l, rr_m, rr_l; + + __clc_remainder_piby2_medium(y, &r_m, &rr_m, ®n_m); + __clc_remainder_piby2_large(y, &r_l, &rr_l, ®n_l); + + __CLC_GENTYPE r = is_medium ? r_m : r_l; + __CLC_GENTYPE rr = is_medium ? rr_m : rr_l; + __CLC_INTN regn = __CLC_CONVERT_INTN(is_medium) ? regn_m : regn_l; + + __CLC_GENTYPE lead, tail; + __clc_tan_piby4(r, rr, &lead, &tail); + + __CLC_LONGN t = + __CLC_AS_LONGN(__CLC_CONVERT_BIT_INTN((regn & 1) != 0) ? tail : lead); + t ^= __CLC_CONVERT_BIT_INTN(x < 0.0) << 63; + + return __clc_isnan(x) || __clc_isinf(x) ? __CLC_GENTYPE_NAN + : __CLC_AS_GENTYPE(t); +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_tan(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_tan(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanh.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanh.cl new file mode 100644 index 0000000000..aedcb0c38d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanh.cl @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanh.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanh.inc new file mode 100644 index 0000000000..a25fd58fcb --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanh.inc @@ -0,0 +1,137 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_tanh(__CLC_GENTYPE x) { + // The definition of tanh(x) is sinh(x)/cosh(x), which is also equivalent + // to the following three formulae: + // 1. (exp(x) - exp(-x))/(exp(x) + exp(-x)) + // 2. (1 - (2/(exp(2*x) + 1 ))) + // 3. (exp(2*x) - 1)/(exp(2*x) + 1) + // but computationally, some formulae are better on some ranges. + + const __CLC_GENTYPE large_threshold = 0x1.0a2b24p+3f; + + __CLC_UINTN ux = __CLC_AS_UINTN(x); + __CLC_UINTN aux = ux & EXSIGNBIT_SP32; + __CLC_UINTN xs = ux ^ aux; + + __CLC_GENTYPE y = __CLC_AS_GENTYPE(aux); + __CLC_GENTYPE y2 = y * y; + + __CLC_GENTYPE a1 = __clc_mad( + y2, __clc_mad(y2, 0.4891631088530669873e-4F, -0.14628356048797849e-2F), + -0.28192806108402678e0F); + __CLC_GENTYPE b1 = + __clc_mad(y2, 0.3427017942262751343e0F, 0.845784192581041099e0F); + + __CLC_GENTYPE a2 = __clc_mad( + y2, __clc_mad(y2, 0.3827534993599483396e-4F, -0.12325644183611929e-2F), + -0.24069858695196524e0F); + __CLC_GENTYPE b2 = + __clc_mad(y2, 0.292529068698052819e0F, 0.72209738473684982e0F); + + __CLC_INTN c = y < 0.9f; + __CLC_GENTYPE a = c ? a1 : a2; + __CLC_GENTYPE b = c ? b1 : b2; + __CLC_GENTYPE zlo = __clc_mad(MATH_DIVIDE(a, b), y * y2, y); + + __CLC_GENTYPE p = __clc_exp(2.0f * y) + 1.0f; + __CLC_GENTYPE zhi = 1.0F - MATH_DIVIDE(2.0F, p); + + __CLC_GENTYPE z = y <= 1.0f ? zlo : zhi; + z = __CLC_AS_GENTYPE(xs | __CLC_AS_UINTN(z)); + + // Edge cases + __CLC_GENTYPE sone = __CLC_AS_GENTYPE(0x3f800000U | xs); + z = y > large_threshold ? sone : z; + z = aux < 0x39000000 || aux > 0x7f800000 ? x : z; + + return z; +} + +#elif __CLC_FPSIZE == 64 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_tanh(__CLC_GENTYPE x) { + // The definition of tanh(x) is sinh(x)/cosh(x), which is also equivalent + // to the following three formulae: + // 1. (exp(x) - exp(-x))/(exp(x) + exp(-x)) + // 2. (1 - (2/(exp(2*x) + 1 ))) + // 3. (exp(2*x) - 1)/(exp(2*x) + 1) + // but computationally, some formulae are better on some ranges. + + // The point at which e^-x is insignificant compared to e^x = ln(2^27) + const __CLC_GENTYPE large_threshold = 0x1.2b708872320e2p+4; + + __CLC_ULONGN ux = __CLC_AS_ULONGN(x); + __CLC_ULONGN ax = ux & ~SIGNBIT_DP64; + __CLC_ULONGN sx = ux ^ ax; + __CLC_GENTYPE y = __CLC_AS_GENTYPE(ax); + __CLC_GENTYPE y2 = y * y; + + // y < 0.9 + __CLC_GENTYPE znl = + __clc_fma(y2, + __clc_fma(y2, + __clc_fma(y2, -0.142077926378834722618091e-7, + -0.200047621071909498730453e-3), + -0.176016349003044679402273e-1), + -0.274030424656179760118928e0); + + __CLC_GENTYPE zdl = + __clc_fma(y2, + __clc_fma(y2, + __clc_fma(y2, 0.2091140262529164482568557e-3, + 0.201562166026937652780575e-1), + 0.381641414288328849317962e0), + 0.822091273968539282568011e0); + + // 0.9 <= y <= 1 + __CLC_GENTYPE znm = + __clc_fma(y2, + __clc_fma(y2, + __clc_fma(y2, -0.115475878996143396378318e-7, + -0.165597043903549960486816e-3), + -0.146173047288731678404066e-1), + -0.227793870659088295252442e0); + + __CLC_GENTYPE zdm = + __clc_fma(y2, + __clc_fma(y2, + __clc_fma(y2, 0.173076050126225961768710e-3, + 0.167358775461896562588695e-1), + 0.317204558977294374244770e0), + 0.683381611977295894959554e0); + + __CLC_LONGN c = y < 0.9; + __CLC_GENTYPE zn = c ? znl : znm; + __CLC_GENTYPE zd = c ? zdl : zdm; + __CLC_GENTYPE z = y + y * y2 * MATH_DIVIDE(zn, zd); + + // y > 1 + __CLC_GENTYPE p = __clc_exp(2.0 * y) + 1.0; + __CLC_GENTYPE zg = 1.0 - 2.0 / p; + + z = y > 1.0 ? zg : z; + + // Other cases + z = y < 0x1.0p-28 || ax > PINFBITPATT_DP64 ? x : z; + + z = y > large_threshold ? 1.0 : z; + + return __CLC_AS_GENTYPE(sx | __CLC_AS_ULONGN(z)); +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_tanh(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_tanh(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanpi.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanpi.cl new file mode 100644 index 0000000000..f1265892d1 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanpi.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanpi.inc b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanpi.inc new file mode 100644 index 0000000000..3a2f5dcf7b --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tanpi.inc @@ -0,0 +1,132 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_tanpi(__CLC_GENTYPE x) { + __CLC_INTN ix = __CLC_AS_INTN(x); + __CLC_INTN xsgn = ix & (__CLC_INTN)SIGNBIT_SP32; + __CLC_INTN xnsgn = xsgn ^ (__CLC_INTN)SIGNBIT_SP32; + ix ^= xsgn; + __CLC_GENTYPE absx = __clc_fabs(x); + __CLC_INTN iax = __CLC_CONVERT_INTN(absx); + __CLC_GENTYPE r = absx - __CLC_CONVERT_GENTYPE(iax); + __CLC_INTN xodd = xsgn ^ __CLC_AS_INTN((iax & 0x1) != 0 ? SIGNBIT_SP32 : 0); + + // Initialize with return for +-Inf and NaN + __CLC_INTN ir = QNANBITPATT_SP32; + + // 2^24 <= |x| < Inf, the result is always even integer + ir = ix < PINFBITPATT_SP32 ? xsgn : ir; + + // 2^23 <= |x| < 2^24, the result is always integer + ir = ix < 0x4b800000 ? xodd : ir; + + // 0x1.0p-7 <= |x| < 2^23, result depends on which 0.25 interval + + // r < 1.0 + __CLC_GENTYPE a = 1.0f - r; + __CLC_INTN e = 0; + __CLC_INTN s = xnsgn; + + // r <= 0.75 + __CLC_INTN c = r <= 0.75f; + a = c ? r - 0.5f : a; + e = c ? 1 : e; + s = c ? xsgn : s; + + // r < 0.5 + c = r < 0.5f; + a = c ? 0.5f - r : a; + s = c ? xnsgn : s; + + // 0 < r <= 0.25 + c = r <= 0.25f; + a = c ? r : a; + e = c ? 0 : e; + s = c ? xsgn : s; + + __CLC_GENTYPE t = __clc_tanf_piby4(a * M_PI_F, 0); + __CLC_GENTYPE tr = -__clc_native_recip(t); + __CLC_INTN jr = s ^ __CLC_AS_INTN(e != 0 ? tr : t); + + jr = r == 0.5f ? xodd | 0x7f800000 : jr; + + ir = ix < 0x4b000000 ? jr : ir; + + return __CLC_AS_GENTYPE(ir); +} + +#elif __CLC_FPSIZE == 64 + +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_tanpi(__CLC_GENTYPE x) { + __CLC_LONGN ix = __CLC_AS_LONGN(x); + __CLC_LONGN xsgn = ix & (__CLC_LONGN)0x8000000000000000L; + __CLC_LONGN xnsgn = xsgn ^ (__CLC_LONGN)0x8000000000000000L; + ix ^= xsgn; + __CLC_GENTYPE absx = __clc_fabs(x); + __CLC_LONGN iax = __CLC_CONVERT_LONGN(absx); + __CLC_GENTYPE r = absx - __CLC_CONVERT_GENTYPE(iax); + __CLC_LONGN xodd = + xsgn ^ __CLC_AS_LONGN((iax & 0x1) != 0 ? 0x8000000000000000L : 0L); + + // Initialize with return for +-Inf and NaN + __CLC_LONGN ir = QNANBITPATT_DP64; + + // 2^53 <= |x| < Inf, the result is always even integer + ir = ix < PINFBITPATT_DP64 ? xsgn : ir; + + // 2^52 <= |x| < 2^53, the result is always integer + ir = ix < 0x4340000000000000L ? xodd : ir; + + // 0x1.0p-14 <= |x| < 2^53, result depends on which 0.25 interval + + // r < 1.0 + __CLC_GENTYPE a = 1.0 - r; + __CLC_LONGN e = 0; + __CLC_LONGN s = xnsgn; + + // r <= 0.75 + __CLC_LONGN c = r <= 0.75; + __CLC_GENTYPE t = r - 0.5; + a = c ? t : a; + e = c ? 1 : e; + s = c ? xsgn : s; + + // r < 0.5 + c = r < 0.5; + t = 0.5 - r; + a = c ? t : a; + s = c ? xnsgn : s; + + // r <= 0.25 + c = r <= 0.25; + a = c ? r : a; + e = c ? 0 : e; + s = c ? xsgn : s; + + __CLC_GENTYPE api = a * M_PI; + __CLC_GENTYPE lo, hi; + __clc_tan_piby4(api, 0.0, &lo, &hi); + __CLC_LONGN jr = s ^ __CLC_AS_LONGN(e != 0 ? hi : lo); + + __CLC_LONGN si = xodd | 0x7ff0000000000000L; + jr = r == 0.5 ? si : jr; + + ir = ix < 0x4330000000000000L ? jr : ir; + + return __CLC_AS_GENTYPE(ir); +} + +#elif __CLC_FPSIZE == 16 + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_tanpi(__CLC_GENTYPE x) { + return __CLC_CONVERT_GENTYPE(__clc_tanpi(__CLC_CONVERT_FLOATN(x))); +} + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tgamma.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tgamma.cl new file mode 100644 index 0000000000..e0fed98026 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_tgamma.cl @@ -0,0 +1,82 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF float __clc_tgamma(float x) { + const float pi = 3.1415926535897932384626433832795f; + float absx = __clc_fabs(x); + float lg = __clc_lgamma(absx); + float g = __clc_exp(lg); + + if (x < 0.0f) { + float z = __clc_sinpi(x); + g = g * absx * z; + g = pi / g; + g = g == 0 ? INFINITY : g; + g = z == 0 ? FLT_NAN : g; + } + + return g; +} + +#define __FLOAT_ONLY +#define FUNCTION __clc_tgamma +#define __CLC_BODY +#include +#undef FUNCTION + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF double __clc_tgamma(double x) { + const double pi = 3.1415926535897932384626433832795; + double absx = __clc_fabs(x); + double lg = __clc_lgamma(absx); + double g = __clc_exp(lg); + + if (x < 0.0) { + double z = __clc_sinpi(x); + g = g * absx * z; + g = pi / g; + g = g == 0 ? INFINITY : g; + g = z == 0 ? DBL_NAN : g; + } + + return g; +} + +#define __DOUBLE_ONLY +#define FUNCTION __clc_tgamma +#define __CLC_BODY +#include +#undef FUNCTION + +#endif + +#ifdef cl_khr_fp16 + +#include + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// Forward the half version of this builtin onto the float one +#define __HALF_ONLY +#define FUNCTION __clc_tgamma +#define __CLC_BODY +#include + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_trunc.cl b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_trunc.cl new file mode 100644 index 0000000000..6261d04cd2 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/math/clc_trunc.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define FUNCTION __clc_trunc +#define __IMPL_FUNCTION(x) __builtin_elementwise_trunc +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/misc/clc_shuffle.cl b/local/recipes/dev/libclc/source/clc/lib/generic/misc/clc_shuffle.cl new file mode 100644 index 0000000000..f02e7aec9a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/misc/clc_shuffle.cl @@ -0,0 +1,173 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define _CLC_ELEMENT_CASES2(VAR) \ + case 0: \ + return VAR.s0; \ + case 1: \ + return VAR.s1; + +#define _CLC_ELEMENT_CASES4(VAR) \ + _CLC_ELEMENT_CASES2(VAR) \ + case 2: \ + return VAR.s2; \ + case 3: \ + return VAR.s3; + +#define _CLC_ELEMENT_CASES8(VAR) \ + _CLC_ELEMENT_CASES4(VAR) \ + case 4: \ + return VAR.s4; \ + case 5: \ + return VAR.s5; \ + case 6: \ + return VAR.s6; \ + case 7: \ + return VAR.s7; + +#define _CLC_ELEMENT_CASES16(VAR) \ + _CLC_ELEMENT_CASES8(VAR) \ + case 8: \ + return VAR.s8; \ + case 9: \ + return VAR.s9; \ + case 10: \ + return VAR.sA; \ + case 11: \ + return VAR.sB; \ + case 12: \ + return VAR.sC; \ + case 13: \ + return VAR.sD; \ + case 14: \ + return VAR.sE; \ + case 15: \ + return VAR.sF; + +#define _CLC_GET_ELEMENT_DEFINE(ARGTYPE, ARGSIZE, IDXTYPE) \ + _CLC_INLINE ARGTYPE __clc_get_el_##ARGTYPE##ARGSIZE##_##IDXTYPE( \ + ARGTYPE##ARGSIZE x, IDXTYPE idx) { \ + switch (idx) { _CLC_ELEMENT_CASES##ARGSIZE(x) default : return 0; } \ + } + +#define _CLC_SHUFFLE_SET_ONE_ELEMENT(ARGTYPE, ARGSIZE, INDEX, MASKTYPE) \ + ret_val.s##INDEX = \ + __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.s##INDEX); + +#define _CLC_SHUFFLE_SET_2_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + ret_val.s0 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.s0); \ + ret_val.s1 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.s1); + +#define _CLC_SHUFFLE_SET_4_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_SET_2_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + ret_val.s2 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.s2); \ + ret_val.s3 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.s3); + +#define _CLC_SHUFFLE_SET_8_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_SET_4_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + ret_val.s4 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.s4); \ + ret_val.s5 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.s5); \ + ret_val.s6 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.s6); \ + ret_val.s7 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.s7); + +#define _CLC_SHUFFLE_SET_16_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_SET_8_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + ret_val.s8 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.s8); \ + ret_val.s9 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.s9); \ + ret_val.sA = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.sA); \ + ret_val.sB = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.sB); \ + ret_val.sC = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.sC); \ + ret_val.sD = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.sD); \ + ret_val.sE = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.sE); \ + ret_val.sF = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, mask.sF); + +#define _CLC_SHUFFLE_DEFINE2(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_DEF _CLC_OVERLOAD ARGTYPE##2 __clc_shuffle(ARGTYPE##ARGSIZE x, \ + MASKTYPE##2 mask) { \ + ARGTYPE##2 ret_val; \ + mask &= (MASKTYPE##2)(ARGSIZE - 1); \ + _CLC_SHUFFLE_SET_2_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + return ret_val; \ + } + +#define _CLC_SHUFFLE_DEFINE4(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_DEF _CLC_OVERLOAD ARGTYPE##4 __clc_shuffle(ARGTYPE##ARGSIZE x, \ + MASKTYPE##4 mask) { \ + ARGTYPE##4 ret_val; \ + mask &= (MASKTYPE##4)(ARGSIZE - 1); \ + _CLC_SHUFFLE_SET_4_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + return ret_val; \ + } + +#define _CLC_SHUFFLE_DEFINE8(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_DEF _CLC_OVERLOAD ARGTYPE##8 __clc_shuffle(ARGTYPE##ARGSIZE x, \ + MASKTYPE##8 mask) { \ + ARGTYPE##8 ret_val; \ + mask &= (MASKTYPE##8)(ARGSIZE - 1); \ + _CLC_SHUFFLE_SET_8_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + return ret_val; \ + } + +#define _CLC_SHUFFLE_DEFINE16(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_DEF _CLC_OVERLOAD ARGTYPE##16 __clc_shuffle(ARGTYPE##ARGSIZE x, \ + MASKTYPE##16 mask) { \ + ARGTYPE##16 ret_val; \ + mask &= (MASKTYPE##16)(ARGSIZE - 1); \ + _CLC_SHUFFLE_SET_16_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + return ret_val; \ + } + +#define _CLC_VECTOR_SHUFFLE_MASKSIZE(INTYPE, ARGSIZE, MASKTYPE) \ + _CLC_GET_ELEMENT_DEFINE(INTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_DEFINE2(INTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_DEFINE4(INTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_DEFINE8(INTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_DEFINE16(INTYPE, ARGSIZE, MASKTYPE) + +#define _CLC_VECTOR_SHUFFLE_INSIZE(TYPE, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE_MASKSIZE(TYPE, 2, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE_MASKSIZE(TYPE, 4, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE_MASKSIZE(TYPE, 8, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE_MASKSIZE(TYPE, 16, MASKTYPE) + +_CLC_VECTOR_SHUFFLE_INSIZE(char, uchar) +_CLC_VECTOR_SHUFFLE_INSIZE(short, ushort) +_CLC_VECTOR_SHUFFLE_INSIZE(int, uint) +_CLC_VECTOR_SHUFFLE_INSIZE(long, ulong) +_CLC_VECTOR_SHUFFLE_INSIZE(uchar, uchar) +_CLC_VECTOR_SHUFFLE_INSIZE(ushort, ushort) +_CLC_VECTOR_SHUFFLE_INSIZE(uint, uint) +_CLC_VECTOR_SHUFFLE_INSIZE(ulong, ulong) +_CLC_VECTOR_SHUFFLE_INSIZE(float, uint) +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +_CLC_VECTOR_SHUFFLE_INSIZE(double, ulong) +#endif +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +_CLC_VECTOR_SHUFFLE_INSIZE(half, ushort) +#endif + +#undef _CLC_ELEMENT_CASES2 +#undef _CLC_ELEMENT_CASES4 +#undef _CLC_ELEMENT_CASES8 +#undef _CLC_ELEMENT_CASES16 +#undef _CLC_GET_ELEMENT_DEFINE +#undef _CLC_SHUFFLE_SET_ONE_ELEMENT +#undef _CLC_SHUFFLE_SET_2_ELEMENTS +#undef _CLC_SHUFFLE_SET_4_ELEMENTS +#undef _CLC_SHUFFLE_SET_8_ELEMENTS +#undef _CLC_SHUFFLE_SET_16_ELEMENTS +#undef _CLC_SHUFFLE_DEFINE2 +#undef _CLC_SHUFFLE_DEFINE4 +#undef _CLC_SHUFFLE_DEFINE8 +#undef _CLC_SHUFFLE_DEFINE16 +#undef _CLC_VECTOR_SHUFFLE_MASKSIZE +#undef _CLC_VECTOR_SHUFFLE_INSIZE diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/misc/clc_shuffle2.cl b/local/recipes/dev/libclc/source/clc/lib/generic/misc/clc_shuffle2.cl new file mode 100644 index 0000000000..db97f7c5cf --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/misc/clc_shuffle2.cl @@ -0,0 +1,173 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define _CLC_ELEMENT_CASES2(VAR) \ + case 0: \ + return VAR.s0; \ + case 1: \ + return VAR.s1; + +#define _CLC_ELEMENT_CASES4(VAR) \ + _CLC_ELEMENT_CASES2(VAR) \ + case 2: \ + return VAR.s2; \ + case 3: \ + return VAR.s3; + +#define _CLC_ELEMENT_CASES8(VAR) \ + _CLC_ELEMENT_CASES4(VAR) \ + case 4: \ + return VAR.s4; \ + case 5: \ + return VAR.s5; \ + case 6: \ + return VAR.s6; \ + case 7: \ + return VAR.s7; + +#define _CLC_ELEMENT_CASES16(VAR) \ + _CLC_ELEMENT_CASES8(VAR) \ + case 8: \ + return VAR.s8; \ + case 9: \ + return VAR.s9; \ + case 10: \ + return VAR.sA; \ + case 11: \ + return VAR.sB; \ + case 12: \ + return VAR.sC; \ + case 13: \ + return VAR.sD; \ + case 14: \ + return VAR.sE; \ + case 15: \ + return VAR.sF; + +#define _CLC_GET_ELEMENT_DEFINE(ARGTYPE, ARGSIZE, IDXTYPE) \ + _CLC_INLINE ARGTYPE __clc_get_el_##ARGTYPE##ARGSIZE##_##IDXTYPE( \ + ARGTYPE##ARGSIZE x, ARGTYPE##ARGSIZE y, IDXTYPE idx) { \ + if (idx < ARGSIZE) \ + switch (idx) { _CLC_ELEMENT_CASES##ARGSIZE(x) default : return 0; } \ + else \ + switch (idx - ARGSIZE) { \ + _CLC_ELEMENT_CASES##ARGSIZE(y) default : return 0; \ + } \ + } + +#define _CLC_SHUFFLE_SET_2_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + ret_val.s0 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.s0); \ + ret_val.s1 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.s1); + +#define _CLC_SHUFFLE_SET_4_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_SET_2_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + ret_val.s2 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.s2); \ + ret_val.s3 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.s3); + +#define _CLC_SHUFFLE_SET_8_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_SET_4_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + ret_val.s4 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.s4); \ + ret_val.s5 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.s5); \ + ret_val.s6 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.s6); \ + ret_val.s7 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.s7); + +#define _CLC_SHUFFLE_SET_16_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_SET_8_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + ret_val.s8 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.s8); \ + ret_val.s9 = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.s9); \ + ret_val.sA = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.sA); \ + ret_val.sB = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.sB); \ + ret_val.sC = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.sC); \ + ret_val.sD = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.sD); \ + ret_val.sE = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.sE); \ + ret_val.sF = __clc_get_el_##ARGTYPE##ARGSIZE##_##MASKTYPE(x, y, mask.sF); + +#define _CLC_SHUFFLE_DEFINE2(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_DEF _CLC_OVERLOAD ARGTYPE##2 __clc_shuffle2( \ + ARGTYPE##ARGSIZE x, ARGTYPE##ARGSIZE y, MASKTYPE##2 mask) { \ + ARGTYPE##2 ret_val; \ + mask &= (MASKTYPE##2)(ARGSIZE * 2 - 1); \ + _CLC_SHUFFLE_SET_2_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + return ret_val; \ + } + +#define _CLC_SHUFFLE_DEFINE4(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_DEF _CLC_OVERLOAD ARGTYPE##4 __clc_shuffle2( \ + ARGTYPE##ARGSIZE x, ARGTYPE##ARGSIZE y, MASKTYPE##4 mask) { \ + ARGTYPE##4 ret_val; \ + mask &= (MASKTYPE##4)(ARGSIZE * 2 - 1); \ + _CLC_SHUFFLE_SET_4_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + return ret_val; \ + } + +#define _CLC_SHUFFLE_DEFINE8(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_DEF _CLC_OVERLOAD ARGTYPE##8 __clc_shuffle2( \ + ARGTYPE##ARGSIZE x, ARGTYPE##ARGSIZE y, MASKTYPE##8 mask) { \ + ARGTYPE##8 ret_val; \ + mask &= (MASKTYPE##8)(ARGSIZE * 2 - 1); \ + _CLC_SHUFFLE_SET_8_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + return ret_val; \ + } + +#define _CLC_SHUFFLE_DEFINE16(ARGTYPE, ARGSIZE, MASKTYPE) \ + _CLC_DEF _CLC_OVERLOAD ARGTYPE##16 __clc_shuffle2( \ + ARGTYPE##ARGSIZE x, ARGTYPE##ARGSIZE y, MASKTYPE##16 mask) { \ + ARGTYPE##16 ret_val; \ + mask &= (MASKTYPE##16)(ARGSIZE * 2 - 1); \ + _CLC_SHUFFLE_SET_16_ELEMENTS(ARGTYPE, ARGSIZE, MASKTYPE) \ + return ret_val; \ + } + +#define _CLC_VECTOR_SHUFFLE_MASKSIZE(INTYPE, ARGSIZE, MASKTYPE) \ + _CLC_GET_ELEMENT_DEFINE(INTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_DEFINE2(INTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_DEFINE4(INTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_DEFINE8(INTYPE, ARGSIZE, MASKTYPE) \ + _CLC_SHUFFLE_DEFINE16(INTYPE, ARGSIZE, MASKTYPE) + +#define _CLC_VECTOR_SHUFFLE_INSIZE(TYPE, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE_MASKSIZE(TYPE, 2, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE_MASKSIZE(TYPE, 4, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE_MASKSIZE(TYPE, 8, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE_MASKSIZE(TYPE, 16, MASKTYPE) + +_CLC_VECTOR_SHUFFLE_INSIZE(char, uchar) +_CLC_VECTOR_SHUFFLE_INSIZE(short, ushort) +_CLC_VECTOR_SHUFFLE_INSIZE(int, uint) +_CLC_VECTOR_SHUFFLE_INSIZE(long, ulong) +_CLC_VECTOR_SHUFFLE_INSIZE(uchar, uchar) +_CLC_VECTOR_SHUFFLE_INSIZE(ushort, ushort) +_CLC_VECTOR_SHUFFLE_INSIZE(uint, uint) +_CLC_VECTOR_SHUFFLE_INSIZE(ulong, ulong) +_CLC_VECTOR_SHUFFLE_INSIZE(float, uint) +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +_CLC_VECTOR_SHUFFLE_INSIZE(double, ulong) +#endif +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +_CLC_VECTOR_SHUFFLE_INSIZE(half, ushort) +#endif + +#undef _CLC_ELEMENT_CASES2 +#undef _CLC_ELEMENT_CASES4 +#undef _CLC_ELEMENT_CASES8 +#undef _CLC_ELEMENT_CASES16 +#undef _CLC_GET_ELEMENT_DEFINE +#undef _CLC_SHUFFLE_SET_2_ELEMENTS +#undef _CLC_SHUFFLE_SET_4_ELEMENTS +#undef _CLC_SHUFFLE_SET_8_ELEMENTS +#undef _CLC_SHUFFLE_SET_16_ELEMENTS +#undef _CLC_SHUFFLE_DEFINE2 +#undef _CLC_SHUFFLE_DEFINE4 +#undef _CLC_SHUFFLE_DEFINE8 +#undef _CLC_SHUFFLE_DEFINE16 +#undef _CLC_VECTOR_SHUFFLE_MASKSIZE +#undef _CLC_VECTOR_SHUFFLE_INSIZE diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_all.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_all.cl new file mode 100644 index 0000000000..29f6d68366 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_all.cl @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define _CLC_ALL(v) (((v) >> ((sizeof(v) * 8) - 1)) & 0x1) + +#define _CLC_ALL_VEC(TYPE) \ + _CLC_OVERLOAD _CLC_DEF int __clc_all(TYPE v) { \ + return _CLC_ALL(__builtin_reduce_and(v)); \ + } + +#define _CLC_DEFINE_ALL(TYPE) \ + _CLC_OVERLOAD _CLC_DEF int __clc_all(TYPE v) { return _CLC_ALL(v); } \ + _CLC_ALL_VEC(TYPE##2) \ + _CLC_ALL_VEC(TYPE##3) \ + _CLC_ALL_VEC(TYPE##4) \ + _CLC_ALL_VEC(TYPE##8) \ + _CLC_ALL_VEC(TYPE##16) + +_CLC_DEFINE_ALL(char) +_CLC_DEFINE_ALL(short) +_CLC_DEFINE_ALL(int) +_CLC_DEFINE_ALL(long) diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_any.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_any.cl new file mode 100644 index 0000000000..dc04ac5ae5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_any.cl @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define _CLC_ANY(v) (((v) >> ((sizeof(v) * 8) - 1)) & 0x1) + +#define _CLC_ANY_VEC(TYPE) \ + _CLC_OVERLOAD _CLC_DEF int __clc_any(TYPE v) { \ + return _CLC_ANY(__builtin_reduce_or(v)); \ + } + +#define _CLC_DEFINE_ANY(TYPE) \ + _CLC_OVERLOAD _CLC_DEF int __clc_any(TYPE v) { return _CLC_ANY(v); } \ + _CLC_ANY_VEC(TYPE##2) \ + _CLC_ANY_VEC(TYPE##3) \ + _CLC_ANY_VEC(TYPE##4) \ + _CLC_ANY_VEC(TYPE##8) \ + _CLC_ANY_VEC(TYPE##16) + +_CLC_DEFINE_ANY(char) +_CLC_DEFINE_ANY(short) +_CLC_DEFINE_ANY(int) +_CLC_DEFINE_ANY(long) diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_bitselect.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_bitselect.cl new file mode 100644 index 0000000000..2976b8947e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_bitselect.cl @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include + +#define FLOAT_BITSELECT(f_type, i_type, width) \ + _CLC_OVERLOAD _CLC_DEF f_type##width __clc_bitselect( \ + f_type##width x, f_type##width y, f_type##width z) { \ + return __clc_as_##f_type##width(__clc_bitselect( \ + __clc_as_##i_type##width(x), __clc_as_##i_type##width(y), \ + __clc_as_##i_type##width(z))); \ + } + +FLOAT_BITSELECT(float, uint, ) +FLOAT_BITSELECT(float, uint, 2) +FLOAT_BITSELECT(float, uint, 3) +FLOAT_BITSELECT(float, uint, 4) +FLOAT_BITSELECT(float, uint, 8) +FLOAT_BITSELECT(float, uint, 16) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +FLOAT_BITSELECT(double, ulong, ) +FLOAT_BITSELECT(double, ulong, 2) +FLOAT_BITSELECT(double, ulong, 3) +FLOAT_BITSELECT(double, ulong, 4) +FLOAT_BITSELECT(double, ulong, 8) +FLOAT_BITSELECT(double, ulong, 16) + +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +FLOAT_BITSELECT(half, ushort, ) +FLOAT_BITSELECT(half, ushort, 2) +FLOAT_BITSELECT(half, ushort, 3) +FLOAT_BITSELECT(half, ushort, 4) +FLOAT_BITSELECT(half, ushort, 8) +FLOAT_BITSELECT(half, ushort, 16) + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_bitselect.inc b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_bitselect.inc new file mode 100644 index 0000000000..a377edfc9f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_bitselect.inc @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_bitselect(__CLC_GENTYPE x, + __CLC_GENTYPE y, + __CLC_GENTYPE z) { + return ((x) ^ ((z) & ((y) ^ (x)))); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isequal.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isequal.cl new file mode 100644 index 0000000000..8ee9d153d3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isequal.cl @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define _CLC_RELATIONAL_OP(X, Y) (X) == (Y) + +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, int, __clc_isequal, float, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_isequal(double, double) returns an int, but the +// vector versions return long. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, long, __clc_isequal, double, double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_isequal(half, half) returns an int, but the +// vector versions return short. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, short, __clc_isequal, half, half) + +#endif + +#undef _CLC_RELATIONAL_OP diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isfinite.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isfinite.cl new file mode 100644 index 0000000000..9963e2e7dc --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isfinite.cl @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEFINE_ISFPCLASS(int, int, __clc_isfinite, fcFinite, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_isfinite(double) returns an int, but the vector +// versions return long. +_CLC_DEFINE_ISFPCLASS(int, long, __clc_isfinite, fcFinite, double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_isfinite(half) returns an int, but the vector +// versions return short. +_CLC_DEFINE_ISFPCLASS(int, short, __clc_isfinite, fcFinite, half) + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isgreater.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isgreater.cl new file mode 100644 index 0000000000..2f7a3a56fa --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isgreater.cl @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define _CLC_RELATIONAL_OP(X, Y) (X) > (Y) + +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, int, __clc_isgreater, float, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_isgreater(double, double) returns an int, but the +// vector versions return long. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, long, __clc_isgreater, double, double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_isgreater(half, half) returns an int, but the +// vector versions return short. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, short, __clc_isgreater, half, half) + +#endif + +#undef _CLC_RELATIONAL_OP diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isgreaterequal.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isgreaterequal.cl new file mode 100644 index 0000000000..17cb755908 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isgreaterequal.cl @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define _CLC_RELATIONAL_OP(X, Y) (X) >= (Y) + +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, int, __clc_isgreaterequal, float, + float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_isgreaterequal(double, double) returns an int, +// but the vector versions return long. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, long, __clc_isgreaterequal, double, + double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_isgreaterequal(half, hafl) returns an int, but +// the vector versions return short. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, short, __clc_isgreaterequal, half, + half) + +#endif + +#undef _CLC_RELATIONAL_OP diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isinf.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isinf.cl new file mode 100644 index 0000000000..de0d0f658e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isinf.cl @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEFINE_ISFPCLASS(int, int, __clc_isinf, fcInf, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_isinf(double) returns an int, but the vector +// versions return long. +_CLC_DEFINE_ISFPCLASS(int, long, __clc_isinf, fcInf, double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_isinf(half) returns an int, but the vector +// versions return short. +_CLC_DEFINE_ISFPCLASS(int, short, __clc_isinf, fcInf, half) + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isless.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isless.cl new file mode 100644 index 0000000000..71ee5b0a07 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isless.cl @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define _CLC_RELATIONAL_OP(X, Y) (X) < (Y) + +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, int, __clc_isless, float, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_isless(double, double) returns an int, but +// the vector versions return long. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, long, __clc_isless, double, double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_isless(half, half) returns an int, but the +// vector versions return short. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, short, __clc_isless, half, half) + +#endif + +#undef _CLC_RELATIONAL_OP diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_islessequal.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_islessequal.cl new file mode 100644 index 0000000000..eec8c1a89f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_islessequal.cl @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define _CLC_RELATIONAL_OP(X, Y) (X) <= (Y) + +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, int, __clc_islessequal, float, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_islessequal(double, double) returns an int, but +// the vector versions return long. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, long, __clc_islessequal, double, + double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_islessequal(half, half) returns an int, but the +// vector versions return short. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, short, __clc_islessequal, half, half) + +#endif + +#undef _CLC_RELATIONAL_OP diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_islessgreater.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_islessgreater.cl new file mode 100644 index 0000000000..da7cf17d2a --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_islessgreater.cl @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define _CLC_RELATIONAL_OP(X, Y) ((X) < (Y)) || ((X) > (Y)) + +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, int, __clc_islessgreater, float, + float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_islessgreater(double, double) returns an int, but +// the vector versions return long. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, long, __clc_islessgreater, double, + double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_islessgreater(half, half) returns an int, but the +// vector versions return short. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, short, __clc_islessgreater, half, + half) + +#endif + +#undef _CLC_RELATIONAL_OP diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isnan.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isnan.cl new file mode 100644 index 0000000000..c01d6122c9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isnan.cl @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEFINE_ISFPCLASS(int, int, __clc_isnan, fcNan, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_isnan(double) returns an int, but the vector +// versions return a long. +_CLC_DEFINE_ISFPCLASS(int, long, __clc_isnan, fcNan, double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_isnan(half) returns an int, but the vector +// versions return a short. +_CLC_DEFINE_ISFPCLASS(int, short, __clc_isnan, fcNan, half) + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isnormal.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isnormal.cl new file mode 100644 index 0000000000..9fabd19e74 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isnormal.cl @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEFINE_ISFPCLASS(int, int, __clc_isnormal, fcNormal, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_isnormal(double) returns an int, but the vector +// versions return long. +_CLC_DEFINE_ISFPCLASS(int, long, __clc_isnormal, fcNormal, double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_isnormal(half) returns an int, but the vector +// versions return short. +_CLC_DEFINE_ISFPCLASS(int, short, __clc_isnormal, fcNormal, half) + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isnotequal.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isnotequal.cl new file mode 100644 index 0000000000..3b5af6f009 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isnotequal.cl @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define _CLC_RELATIONAL_OP(X, Y) (X) != (Y) + +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, int, __clc_isnotequal, float, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_isnotequal(double, double) returns an int, but +// the vector versions return long. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, long, __clc_isnotequal, double, double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_isnotequal(half, half) returns an int, but the +// vector versions return short. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, short, __clc_isnotequal, half, half) + +#endif + +#undef _CLC_RELATIONAL_OP diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isordered.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isordered.cl new file mode 100644 index 0000000000..112bec568d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isordered.cl @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define _CLC_RELATIONAL_OP(X, Y) \ + __clc_isequal((X), (X)) && __clc_isequal((Y), (Y)) + +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, int, __clc_isordered, float, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_isordered(double, double) returns an int, but the +// vector versions return long. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, long, __clc_isordered, double, double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_isordered(half, half) returns an int, but the +// vector versions return short. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, short, __clc_isordered, half, half) + +#endif + +#undef _CLC_RELATIONAL_OP diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isunordered.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isunordered.cl new file mode 100644 index 0000000000..1a7c0c1387 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_isunordered.cl @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define _CLC_RELATIONAL_OP(X, Y) \ + !__clc_isequal((X), (X)) || !__clc_isequal((Y), (Y)) + +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, int, __clc_isunordered, float, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_isunordered(double, double) returns an int, but +// the vector versions return long. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, long, __clc_isunordered, double, double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_isunordered(half, half) returns an int, but the +// vector versions return short. +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, short, __clc_isunordered, half, half) + +#endif + +#undef _CLC_RELATIONAL_OP diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_select.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_select.cl new file mode 100644 index 0000000000..ddf24ed0b8 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_select.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_SELECT_FN __clc_select +#define __CLC_SELECT_DEF(x, y, z) return z ? y : x + +#define __CLC_BODY +#include +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_signbit.cl b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_signbit.cl new file mode 100644 index 0000000000..d8736a72b3 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/relational/clc_signbit.cl @@ -0,0 +1,90 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define _CLC_DEFINE_RELATIONAL_UNARY_VEC2(RET_TYPE, FUNCTION, ARG_TYPE) \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ + return (RET_TYPE)((RET_TYPE){FUNCTION(x.lo), FUNCTION(x.hi)} != \ + (RET_TYPE)0); \ + } + +#define _CLC_DEFINE_RELATIONAL_UNARY_VEC3(RET_TYPE, FUNCTION, ARG_TYPE) \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ + return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0), FUNCTION(x.s1), \ + FUNCTION(x.s2)} != (RET_TYPE)0); \ + } + +#define _CLC_DEFINE_RELATIONAL_UNARY_VEC4(RET_TYPE, FUNCTION, ARG_TYPE) \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ + return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0), FUNCTION(x.s1), \ + FUNCTION(x.s2), \ + FUNCTION(x.s3)} != (RET_TYPE)0); \ + } + +#define _CLC_DEFINE_RELATIONAL_UNARY_VEC8(RET_TYPE, FUNCTION, ARG_TYPE) \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ + return ( \ + RET_TYPE)((RET_TYPE){FUNCTION(x.s0), FUNCTION(x.s1), FUNCTION(x.s2), \ + FUNCTION(x.s3), FUNCTION(x.s4), FUNCTION(x.s5), \ + FUNCTION(x.s6), FUNCTION(x.s7)} != (RET_TYPE)0); \ + } + +#define _CLC_DEFINE_RELATIONAL_UNARY_VEC16(RET_TYPE, FUNCTION, ARG_TYPE) \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ + return ( \ + RET_TYPE)((RET_TYPE){FUNCTION(x.s0), FUNCTION(x.s1), FUNCTION(x.s2), \ + FUNCTION(x.s3), FUNCTION(x.s4), FUNCTION(x.s5), \ + FUNCTION(x.s6), FUNCTION(x.s7), FUNCTION(x.s8), \ + FUNCTION(x.s9), FUNCTION(x.sa), FUNCTION(x.sb), \ + FUNCTION(x.sc), FUNCTION(x.sd), FUNCTION(x.se), \ + FUNCTION(x.sf)} != (RET_TYPE)0); \ + } + +#define _CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(RET_TYPE, FUNCTION, ARG_TYPE) \ + _CLC_DEFINE_RELATIONAL_UNARY_VEC2(RET_TYPE##2, FUNCTION, ARG_TYPE##2) \ + _CLC_DEFINE_RELATIONAL_UNARY_VEC3(RET_TYPE##3, FUNCTION, ARG_TYPE##3) \ + _CLC_DEFINE_RELATIONAL_UNARY_VEC4(RET_TYPE##4, FUNCTION, ARG_TYPE##4) \ + _CLC_DEFINE_RELATIONAL_UNARY_VEC8(RET_TYPE##8, FUNCTION, ARG_TYPE##8) \ + _CLC_DEFINE_RELATIONAL_UNARY_VEC16(RET_TYPE##16, FUNCTION, ARG_TYPE##16) + +_CLC_DEF _CLC_OVERLOAD int __clc_signbit(float x) { + return __builtin_signbitf(x); +} + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(int, __clc_signbit, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of __clc_signbit(double) returns an int, but the vector +// versions return long. + +_CLC_DEF _CLC_OVERLOAD int __clc_signbit(double x) { + return __builtin_signbit(x); +} + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(long, __clc_signbit, double) + +#endif +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// The scalar version of __clc_signbit(half) returns an int, but the vector +// versions return short. + +_CLC_DEF _CLC_OVERLOAD int __clc_signbit(half x) { + return __builtin_signbit(x); +} + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(short, __clc_signbit, half) + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_clamp.cl b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_clamp.cl new file mode 100644 index 0000000000..4d83a08e44 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_clamp.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_clamp.inc b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_clamp.inc new file mode 100644 index 0000000000..571f6470e5 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_clamp.inc @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_clamp(__CLC_GENTYPE x, + __CLC_GENTYPE y, + __CLC_GENTYPE z) { + return (x > z ? z : (x < y ? y : x)); +} + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_clamp(__CLC_GENTYPE x, + __CLC_SCALAR_GENTYPE y, + __CLC_SCALAR_GENTYPE z) { + return (x > (__CLC_GENTYPE)z ? (__CLC_GENTYPE)z + : (x < (__CLC_GENTYPE)y ? (__CLC_GENTYPE)y : x)); +} +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_max.cl b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_max.cl new file mode 100644 index 0000000000..092ce33b38 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_max.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_max.inc b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_max.inc new file mode 100644 index 0000000000..882f29ce30 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_max.inc @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_max(__CLC_GENTYPE a, + __CLC_GENTYPE b) { + return (a > b ? a : b); +} + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_max(__CLC_GENTYPE a, + __CLC_SCALAR_GENTYPE b) { + return (a > (__CLC_GENTYPE)b ? a : (__CLC_GENTYPE)b); +} +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_min.cl b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_min.cl new file mode 100644 index 0000000000..d34a606839 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_min.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_min.inc b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_min.inc new file mode 100644 index 0000000000..d8a51291db --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_min.inc @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_min(__CLC_GENTYPE a, + __CLC_GENTYPE b) { + return (b < a ? b : a); +} + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_min(__CLC_GENTYPE a, + __CLC_SCALAR_GENTYPE b) { + return (b < (__CLC_GENTYPE)a ? (__CLC_GENTYPE)b : a); +} +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vload.cl b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vload.cl new file mode 100644 index 0000000000..e4003e4a96 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vload.cl @@ -0,0 +1,130 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define VLOAD_VECTORIZE(PRIM_TYPE, ADDR_SPACE) \ + _CLC_OVERLOAD _CLC_DEF PRIM_TYPE##2 __clc_vload2( \ + size_t offset, const ADDR_SPACE PRIM_TYPE *x) { \ + return *( \ + (const ADDR_SPACE less_aligned_##PRIM_TYPE##2 *)(&x[2 * offset])); \ + } \ + \ + _CLC_OVERLOAD _CLC_DEF PRIM_TYPE##3 __clc_vload3( \ + size_t offset, const ADDR_SPACE PRIM_TYPE *x) { \ + PRIM_TYPE##2 vec = \ + *((const ADDR_SPACE less_aligned_##PRIM_TYPE##2 *)(&x[3 * offset])); \ + return (PRIM_TYPE##3)(vec.s0, vec.s1, x[offset * 3 + 2]); \ + } \ + \ + _CLC_OVERLOAD _CLC_DEF PRIM_TYPE##4 __clc_vload4( \ + size_t offset, const ADDR_SPACE PRIM_TYPE *x) { \ + return *( \ + (const ADDR_SPACE less_aligned_##PRIM_TYPE##4 *)(&x[4 * offset])); \ + } \ + \ + _CLC_OVERLOAD _CLC_DEF PRIM_TYPE##8 __clc_vload8( \ + size_t offset, const ADDR_SPACE PRIM_TYPE *x) { \ + return *( \ + (const ADDR_SPACE less_aligned_##PRIM_TYPE##8 *)(&x[8 * offset])); \ + } \ + \ + _CLC_OVERLOAD _CLC_DEF PRIM_TYPE##16 __clc_vload16( \ + size_t offset, const ADDR_SPACE PRIM_TYPE *x) { \ + return *( \ + (const ADDR_SPACE less_aligned_##PRIM_TYPE##16 *)(&x[16 * offset])); \ + } + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +#define VLOAD_VECTORIZE_GENERIC VLOAD_VECTORIZE +#else +// The generic address space isn't available, so make the macro do nothing +#define VLOAD_VECTORIZE_GENERIC(X, Y) +#endif + +#define VLOAD_ADDR_SPACES(__CLC_SCALAR_GENTYPE) \ + VLOAD_VECTORIZE(__CLC_SCALAR_GENTYPE, __private) \ + VLOAD_VECTORIZE(__CLC_SCALAR_GENTYPE, __local) \ + VLOAD_VECTORIZE(__CLC_SCALAR_GENTYPE, __constant) \ + VLOAD_VECTORIZE(__CLC_SCALAR_GENTYPE, __global) \ + VLOAD_VECTORIZE_GENERIC(__CLC_SCALAR_GENTYPE, __generic) + +#define VLOAD_TYPES() \ + VLOAD_ADDR_SPACES(char) \ + VLOAD_ADDR_SPACES(uchar) \ + VLOAD_ADDR_SPACES(short) \ + VLOAD_ADDR_SPACES(ushort) \ + VLOAD_ADDR_SPACES(int) \ + VLOAD_ADDR_SPACES(uint) \ + VLOAD_ADDR_SPACES(long) \ + VLOAD_ADDR_SPACES(ulong) \ + VLOAD_ADDR_SPACES(float) + +VLOAD_TYPES() + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +VLOAD_ADDR_SPACES(double) +#endif +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +VLOAD_ADDR_SPACES(half) +#endif + +/* vload_half are legal even without cl_khr_fp16 */ +/* no vload_half for double */ +#define VEC_LOAD1(val, AS) val = __builtin_load_halff(&mem[offset++]); +#define VEC_LOAD2(val, AS) \ + VEC_LOAD1(val.lo, AS) \ + VEC_LOAD1(val.hi, AS) +#define VEC_LOAD3(val, AS) \ + VEC_LOAD1(val.s0, AS) \ + VEC_LOAD1(val.s1, AS) \ + VEC_LOAD1(val.s2, AS) +#define VEC_LOAD4(val, AS) \ + VEC_LOAD2(val.lo, AS) \ + VEC_LOAD2(val.hi, AS) +#define VEC_LOAD8(val, AS) \ + VEC_LOAD4(val.lo, AS) \ + VEC_LOAD4(val.hi, AS) +#define VEC_LOAD16(val, AS) \ + VEC_LOAD8(val.lo, AS) \ + VEC_LOAD8(val.hi, AS) + +#define __FUNC(SUFFIX, VEC_SIZE, OFFSET_SIZE, TYPE, AS) \ + _CLC_OVERLOAD _CLC_DEF TYPE __clc_vload_half##SUFFIX(size_t offset, \ + const AS half *mem) { \ + offset *= VEC_SIZE; \ + TYPE __tmp; \ + VEC_LOAD##VEC_SIZE(__tmp, AS) return __tmp; \ + } \ + _CLC_OVERLOAD _CLC_DEF TYPE __clc_vloada_half##SUFFIX(size_t offset, \ + const AS half *mem) { \ + offset *= OFFSET_SIZE; \ + TYPE __tmp; \ + VEC_LOAD##VEC_SIZE(__tmp, AS) return __tmp; \ + } + +#define FUNC(SUFFIX, VEC_SIZE, OFFSET_SIZE, TYPE, AS) \ + __FUNC(SUFFIX, VEC_SIZE, OFFSET_SIZE, TYPE, AS) + +#define __CLC_BODY "clc_vload_half.inc" +#include +#undef FUNC +#undef __FUNC +#undef VEC_LOAD16 +#undef VEC_LOAD8 +#undef VEC_LOAD4 +#undef VEC_LOAD3 +#undef VEC_LOAD2 +#undef VEC_LOAD1 +#undef VLOAD_TYPES +#undef VLOAD_ADDR_SPACES +#undef VLOAD_VECTORIZE +#undef VLOAD_VECTORIZE_GENERIC diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vload_half.inc b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vload_half.inc new file mode 100644 index 0000000000..aaf067d75d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vload_half.inc @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __CLC_FPSIZE == 32 + +#ifndef __CLC_SCALAR + +#if __CLC_VECSIZE == 3 +#define __CLC_OFFSET 4 +#else +#define __CLC_OFFSET __CLC_VECSIZE +#endif + +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __private); +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __local); +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __global); +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __constant); +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __generic); +#endif + +#undef __CLC_OFFSET +#else +FUNC(, 1, 1, __CLC_GENTYPE, __private); +FUNC(, 1, 1, __CLC_GENTYPE, __local); +FUNC(, 1, 1, __CLC_GENTYPE, __global); +FUNC(, 1, 1, __CLC_GENTYPE, __constant); +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +FUNC(, 1, 1, __CLC_GENTYPE, __generic); +#endif +#endif +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vstore.cl b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vstore.cl new file mode 100644 index 0000000000..adde58aec9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vstore.cl @@ -0,0 +1,268 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include + +#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable + +#define VSTORE_VECTORIZE(PRIM_TYPE, ADDR_SPACE) \ + typedef PRIM_TYPE##2 less_aligned_##ADDR_SPACE##PRIM_TYPE##2 \ + __attribute__((aligned(sizeof(PRIM_TYPE)))); \ + _CLC_OVERLOAD _CLC_DEF void __clc_vstore2(PRIM_TYPE##2 vec, size_t offset, \ + ADDR_SPACE PRIM_TYPE *mem) { \ + *((ADDR_SPACE less_aligned_##ADDR_SPACE##PRIM_TYPE##2 \ + *)(&mem[2 * offset])) = vec; \ + } \ + \ + _CLC_OVERLOAD _CLC_DEF void __clc_vstore3(PRIM_TYPE##3 vec, size_t offset, \ + ADDR_SPACE PRIM_TYPE *mem) { \ + *((ADDR_SPACE less_aligned_##ADDR_SPACE##PRIM_TYPE##2 \ + *)(&mem[3 * offset])) = (PRIM_TYPE##2)(vec.s0, vec.s1); \ + mem[3 * offset + 2] = vec.s2; \ + } \ + \ + typedef PRIM_TYPE##4 less_aligned_##ADDR_SPACE##PRIM_TYPE##4 \ + __attribute__((aligned(sizeof(PRIM_TYPE)))); \ + _CLC_OVERLOAD _CLC_DEF void __clc_vstore4(PRIM_TYPE##4 vec, size_t offset, \ + ADDR_SPACE PRIM_TYPE *mem) { \ + *((ADDR_SPACE less_aligned_##ADDR_SPACE##PRIM_TYPE##4 \ + *)(&mem[4 * offset])) = vec; \ + } \ + \ + typedef PRIM_TYPE##8 less_aligned_##ADDR_SPACE##PRIM_TYPE##8 \ + __attribute__((aligned(sizeof(PRIM_TYPE)))); \ + _CLC_OVERLOAD _CLC_DEF void __clc_vstore8(PRIM_TYPE##8 vec, size_t offset, \ + ADDR_SPACE PRIM_TYPE *mem) { \ + *((ADDR_SPACE less_aligned_##ADDR_SPACE##PRIM_TYPE##8 \ + *)(&mem[8 * offset])) = vec; \ + } \ + \ + typedef PRIM_TYPE##16 less_aligned_##ADDR_SPACE##PRIM_TYPE##16 \ + __attribute__((aligned(sizeof(PRIM_TYPE)))); \ + _CLC_OVERLOAD _CLC_DEF void __clc_vstore16(PRIM_TYPE##16 vec, size_t offset, \ + ADDR_SPACE PRIM_TYPE *mem) { \ + *((ADDR_SPACE less_aligned_##ADDR_SPACE##PRIM_TYPE##16 \ + *)(&mem[16 * offset])) = vec; \ + } + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +#define VSTORE_VECTORIZE_GENERIC VSTORE_VECTORIZE +#else +// The generic address space isn't available, so make the macro do nothing +#define VSTORE_VECTORIZE_GENERIC(X, Y) +#endif + +#define VSTORE_ADDR_SPACES(__CLC_SCALAR___CLC_GENTYPE) \ + VSTORE_VECTORIZE(__CLC_SCALAR___CLC_GENTYPE, __private) \ + VSTORE_VECTORIZE(__CLC_SCALAR___CLC_GENTYPE, __local) \ + VSTORE_VECTORIZE(__CLC_SCALAR___CLC_GENTYPE, __global) \ + VSTORE_VECTORIZE_GENERIC(__CLC_SCALAR___CLC_GENTYPE, __generic) + +VSTORE_ADDR_SPACES(char) +VSTORE_ADDR_SPACES(uchar) +VSTORE_ADDR_SPACES(short) +VSTORE_ADDR_SPACES(ushort) +VSTORE_ADDR_SPACES(int) +VSTORE_ADDR_SPACES(uint) +VSTORE_ADDR_SPACES(long) +VSTORE_ADDR_SPACES(ulong) +VSTORE_ADDR_SPACES(float) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +VSTORE_ADDR_SPACES(double) +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +VSTORE_ADDR_SPACES(half) +#endif + +#define VEC_STORE1(val, ROUNDF, BUILTIN) BUILTIN(ROUNDF(val), &mem[offset++]); + +#define VEC_STORE2(val, ROUNDF, BUILTIN) \ + VEC_STORE1(val.lo, ROUNDF, BUILTIN) \ + VEC_STORE1(val.hi, ROUNDF, BUILTIN) +#define VEC_STORE3(val, ROUNDF, BUILTIN) \ + VEC_STORE1(val.s0, ROUNDF, BUILTIN) \ + VEC_STORE1(val.s1, ROUNDF, BUILTIN) \ + VEC_STORE1(val.s2, ROUNDF, BUILTIN) +#define VEC_STORE4(val, ROUNDF, BUILTIN) \ + VEC_STORE2(val.lo, ROUNDF, BUILTIN) \ + VEC_STORE2(val.hi, ROUNDF, BUILTIN) +#define VEC_STORE8(val, ROUNDF, BUILTIN) \ + VEC_STORE4(val.lo, ROUNDF, BUILTIN) \ + VEC_STORE4(val.hi, ROUNDF, BUILTIN) +#define VEC_STORE16(val, ROUNDF, BUILTIN) \ + VEC_STORE8(val.lo, ROUNDF, BUILTIN) \ + VEC_STORE8(val.hi, ROUNDF, BUILTIN) + +#define __FUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, AS, ROUNDF, BUILTIN) \ + _CLC_OVERLOAD _CLC_DEF void __clc_vstore_half##SUFFIX( \ + TYPE vec, size_t offset, AS half *mem) { \ + offset *= VEC_SIZE; \ + VEC_STORE##VEC_SIZE(vec, ROUNDF, BUILTIN) \ + } \ + _CLC_OVERLOAD _CLC_DEF void __clc_vstorea_half##SUFFIX( \ + TYPE vec, size_t offset, AS half *mem) { \ + offset *= OFFSET; \ + VEC_STORE##VEC_SIZE(vec, ROUNDF, BUILTIN) \ + } + +_CLC_DEF _CLC_OVERLOAD float __clc_noop(float x) { return x; } +_CLC_DEF _CLC_OVERLOAD float __clc_rtz(float x) { + /* Remove lower 13 bits to make sure the number is rounded down */ + int mask = 0xffffe000; + const int exp = (__clc_as_uint(x) >> 23 & 0xff) - 127; + /* Denormals cannot be flushed, and they use different bit for rounding */ + if (exp < -14) + mask <<= __clc_min(-(exp + 14), 10); + /* RTZ does not produce Inf for large numbers */ + if (__clc_fabs(x) > 65504.0f && !__clc_isinf(x)) + return __clc_copysign(65504.0f, x); + /* Handle nan corner case */ + if (__clc_isnan(x)) + return x; + return __clc_as_float(__clc_as_uint(x) & mask); +} +_CLC_DEF _CLC_OVERLOAD float __clc_rti(float x) { + const float inf = __clc_copysign(INFINITY, x); + /* Set lower 13 bits */ + int mask = (1 << 13) - 1; + const int exp = (__clc_as_uint(x) >> 23 & 0xff) - 127; + /* Denormals cannot be flushed, and they use different bit for rounding */ + if (exp < -14) + mask = (1 << (13 + __clc_min(-(exp + 14), 10))) - 1; + /* Handle nan corner case */ + if (__clc_isnan(x)) + return x; + const float next = + __clc_nextafter(__clc_as_float(__clc_as_uint(x) | mask), inf); + return ((__clc_as_uint(x) & mask) == 0) ? x : next; +} +_CLC_DEF _CLC_OVERLOAD float __clc_rtn(float x) { + return ((__clc_as_uint(x) & 0x80000000) == 0) ? __clc_rtz(x) : __clc_rti(x); +} +_CLC_DEF _CLC_OVERLOAD float __clc_rtp(float x) { + return ((__clc_as_uint(x) & 0x80000000) == 0) ? __clc_rti(x) : __clc_rtz(x); +} +_CLC_DEF _CLC_OVERLOAD float __clc_rte(float x) { + /* Mantisa + implicit bit */ + const uint mantissa = (__clc_as_uint(x) & 0x7fffff) | (1u << 23); + const int exp = (__clc_as_uint(x) >> 23 & 0xff) - 127; + int shift = 13; + if (exp < -14) { + /* The default assumes lower 13 bits are rounded, + * but it might be more for denormals. + * Shifting beyond last == 0b, and qr == 00b is not necessary */ + shift += __clc_min(-(exp + 14), 15); + } + int mask = (1 << shift) - 1; + const uint grs = mantissa & mask; + const uint last = mantissa & (1 << shift); + /* IEEE round up rule is: grs > 101b or grs == 100b and last == 1. + * exp > 15 should round to inf. */ + bool roundup = (grs > (1 << (shift - 1))) || + (grs == (1 << (shift - 1)) && last != 0) || (exp > 15); + return roundup ? __clc_rti(x) : __clc_rtz(x); +} + +#ifdef cl_khr_fp64 +_CLC_DEF _CLC_OVERLOAD double __clc_noop(double x) { return x; } +_CLC_DEF _CLC_OVERLOAD double __clc_rtz(double x) { + /* Remove lower 42 bits to make sure the number is rounded down */ + ulong mask = 0xfffffc0000000000UL; + const int exp = (__clc_as_ulong(x) >> 52 & 0x7ff) - 1023; + /* Denormals cannot be flushed, and they use different bit for rounding */ + if (exp < -14) + mask <<= __clc_min(-(exp + 14), 10); + /* RTZ does not produce Inf for large numbers */ + if (__clc_fabs(x) > 65504.0 && !__clc_isinf(x)) + return __clc_copysign(65504.0, x); + /* Handle nan corner case */ + if (__clc_isnan(x)) + return x; + return __clc_as_double(__clc_as_ulong(x) & mask); +} +_CLC_DEF _CLC_OVERLOAD double __clc_rti(double x) { + const double inf = __clc_copysign((double)INFINITY, x); + /* Set lower 42 bits */ + long mask = (1UL << 42UL) - 1UL; + const int exp = (__clc_as_ulong(x) >> 52 & 0x7ff) - 1023; + /* Denormals cannot be flushed, and they use different bit for rounding */ + if (exp < -14) + mask = (1UL << (42UL + __clc_min(-(exp + 14), 10))) - 1; + /* Handle nan corner case */ + if (__clc_isnan(x)) + return x; + const double next = + __clc_nextafter(__clc_as_double(__clc_as_ulong(x) | mask), inf); + return ((__clc_as_ulong(x) & mask) == 0) ? x : next; +} +_CLC_DEF _CLC_OVERLOAD double __clc_rtn(double x) { + return ((__clc_as_ulong(x) & 0x8000000000000000UL) == 0) ? __clc_rtz(x) + : __clc_rti(x); +} +_CLC_DEF _CLC_OVERLOAD double __clc_rtp(double x) { + return ((__clc_as_ulong(x) & 0x8000000000000000UL) == 0) ? __clc_rti(x) + : __clc_rtz(x); +} +_CLC_DEF _CLC_OVERLOAD double __clc_rte(double x) { + /* Mantisa + implicit bit */ + const ulong mantissa = (__clc_as_ulong(x) & 0xfffffffffffff) | (1UL << 52); + const int exp = (__clc_as_ulong(x) >> 52 & 0x7ff) - 1023; + int shift = 42; + if (exp < -14) { + /* The default assumes lower 13 bits are rounded, + * but it might be more for denormals. + * Shifting beyond last == 0b, and qr == 00b is not necessary */ + shift += __clc_min(-(exp + 14), 15); + } + ulong mask = (1UL << shift) - 1UL; + const ulong grs = mantissa & mask; + const ulong last = mantissa & (1UL << shift); + /* IEEE round up rule is: grs > 101b or grs == 100b and last == 1. + * exp > 15 should round to inf. */ + bool roundup = (grs > (1UL << (shift - 1UL))) || + (grs == (1UL << (shift - 1UL)) && last != 0) || (exp > 15); + return roundup ? __clc_rti(x) : __clc_rtz(x); +} +#endif + +#define __XFUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, AS, BUILTIN) \ + __FUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, AS, __clc_noop, BUILTIN) \ + __FUNC(SUFFIX##_rtz, VEC_SIZE, OFFSET, TYPE, AS, __clc_rtz, BUILTIN) \ + __FUNC(SUFFIX##_rtn, VEC_SIZE, OFFSET, TYPE, AS, __clc_rtn, BUILTIN) \ + __FUNC(SUFFIX##_rtp, VEC_SIZE, OFFSET, TYPE, AS, __clc_rtp, BUILTIN) \ + __FUNC(SUFFIX##_rte, VEC_SIZE, OFFSET, TYPE, AS, __clc_rte, BUILTIN) + +#define FUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, AS, BUILTIN) \ + __XFUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, AS, BUILTIN) + +#define __CLC_BODY "clc_vstore_half.inc" +#include +#undef FUNC +#undef __XFUNC +#undef __FUNC +#undef VEC_LOAD16 +#undef VEC_LOAD8 +#undef VEC_LOAD4 +#undef VEC_LOAD3 +#undef VEC_LOAD2 +#undef VEC_LOAD1 +#undef DECLARE_HELPER +#undef VSTORE_ADDR_SPACES +#undef VSTORE_VECTORIZE +#undef VSTORE_VECTORIZE_GENERIC diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vstore_half.inc b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vstore_half.inc new file mode 100644 index 0000000000..02d645357f --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/shared/clc_vstore_half.inc @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// This does not exist for fp16 +#if __CLC_FPSIZE > 16 + +#if __CLC_FPSIZE == 32 +#define STORE_HALF_BUILTIN __builtin_store_halff +#elif __CLC_FPSIZE == 64 +#define STORE_HALF_BUILTIN __builtin_store_half +#else +#error "Invalid FP size" +#endif + +#ifndef __CLC_SCALAR + +#if __CLC_VECSIZE == 3 +#define __CLC_OFFSET 4 +#else +#define __CLC_OFFSET __CLC_VECSIZE +#endif + +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __private, + STORE_HALF_BUILTIN); +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __local, + STORE_HALF_BUILTIN); +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __global, + STORE_HALF_BUILTIN); +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __generic, + STORE_HALF_BUILTIN); +#endif + +#undef __CLC_OFFSET +#else +FUNC(, 1, 1, __CLC_GENTYPE, __private, STORE_HALF_BUILTIN); +FUNC(, 1, 1, __CLC_GENTYPE, __local, STORE_HALF_BUILTIN); +FUNC(, 1, 1, __CLC_GENTYPE, __global, STORE_HALF_BUILTIN); +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +FUNC(, 1, 1, __CLC_GENTYPE, __generic, STORE_HALF_BUILTIN); +#endif +#endif + +#undef STORE_HALF_BUILTIN + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_local_linear_id.cl b/local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_local_linear_id.cl new file mode 100644 index 0000000000..fd7905568d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_local_linear_id.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF size_t __clc_get_local_linear_id() { + return __clc_get_local_id(2) * __clc_get_local_size(1) * + __clc_get_local_size(0) + + __clc_get_local_id(1) * __clc_get_local_size(0) + + __clc_get_local_id(0); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_num_sub_groups.cl b/local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_num_sub_groups.cl new file mode 100644 index 0000000000..c61e838ebc --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_num_sub_groups.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF uint __clc_get_num_sub_groups() { + size_t linear_size = __clc_get_local_size(0) * __clc_get_local_size(1) * + __clc_get_local_size(2); + uint sg_size = __clc_get_max_sub_group_size(); + return (uint)((linear_size + sg_size - 1) / sg_size); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_sub_group_id.cl b/local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_sub_group_id.cl new file mode 100644 index 0000000000..fa98e05550 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_sub_group_id.cl @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF uint __clc_get_sub_group_id() { + // sreg.warpid is volatile and doesn't represent virtual warp index + // see https://docs.nvidia.com/cuda/parallel-thread-execution/index.html + size_t id_x = __clc_get_local_id(0); + size_t id_y = __clc_get_local_id(1); + size_t id_z = __clc_get_local_id(2); + size_t size_x = __clc_get_local_size(0); + size_t size_y = __clc_get_local_size(1); + size_t size_z = __clc_get_local_size(2); + uint sg_size = __clc_get_max_sub_group_size(); + return (id_z * size_y * size_x + id_y * size_x + id_x) / sg_size; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_sub_group_size.cl b/local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_sub_group_size.cl new file mode 100644 index 0000000000..8ab4afe1ae --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/generic/workitem/clc_get_sub_group_size.cl @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF uint __clc_get_sub_group_size() { + if (__clc_get_sub_group_id() != __clc_get_num_sub_groups() - 1) { + return __clc_get_max_sub_group_size(); + } + size_t size_x = __clc_get_local_size(0); + size_t size_y = __clc_get_local_size(1); + size_t size_z = __clc_get_local_size(2); + size_t linear_size = size_z * size_y * size_x; + size_t uniform_groups = __clc_get_num_sub_groups() - 1; + size_t uniform_size = __clc_get_max_sub_group_size() * uniform_groups; + return linear_size - uniform_size; +} diff --git a/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/SOURCES b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/SOURCES new file mode 100644 index 0000000000..05368c5e4d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/SOURCES @@ -0,0 +1,7 @@ +workitem/clc_get_global_id.cl +workitem/clc_get_group_id.cl +workitem/clc_get_local_id.cl +workitem/clc_get_local_size.cl +workitem/clc_get_max_sub_group_size.cl +workitem/clc_get_num_groups.cl +workitem/clc_get_sub_group_local_id.cl diff --git a/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_global_id.cl b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_global_id.cl new file mode 100644 index 0000000000..0782ef0b15 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_global_id.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF size_t __clc_get_global_id(uint dim) { + return __clc_get_group_id(dim) * __clc_get_local_size(dim) + + __clc_get_local_id(dim); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_group_id.cl b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_group_id.cl new file mode 100644 index 0000000000..200b1bfd70 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_group_id.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_OVERLOAD _CLC_DEF size_t __clc_get_group_id(uint dim) { + switch (dim) { + case 0: + return __nvvm_read_ptx_sreg_ctaid_x(); + case 1: + return __nvvm_read_ptx_sreg_ctaid_y(); + case 2: + return __nvvm_read_ptx_sreg_ctaid_z(); + default: + return 0; + } +} diff --git a/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_local_id.cl b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_local_id.cl new file mode 100644 index 0000000000..8c5b313b81 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_local_id.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_OVERLOAD _CLC_DEF size_t __clc_get_local_id(uint dim) { + switch (dim) { + case 0: + return __nvvm_read_ptx_sreg_tid_x(); + case 1: + return __nvvm_read_ptx_sreg_tid_y(); + case 2: + return __nvvm_read_ptx_sreg_tid_z(); + default: + return 0; + } +} diff --git a/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_local_size.cl b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_local_size.cl new file mode 100644 index 0000000000..4525c85f1e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_local_size.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_OVERLOAD _CLC_DEF size_t __clc_get_local_size(uint dim) { + switch (dim) { + case 0: + return __nvvm_read_ptx_sreg_ntid_x(); + case 1: + return __nvvm_read_ptx_sreg_ntid_y(); + case 2: + return __nvvm_read_ptx_sreg_ntid_z(); + default: + return 0; + } +} diff --git a/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_max_sub_group_size.cl b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_max_sub_group_size.cl new file mode 100644 index 0000000000..6f0634d6f9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_max_sub_group_size.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_OVERLOAD _CLC_DEF uint __clc_get_max_sub_group_size() { + return __nvvm_read_ptx_sreg_warpsize(); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_num_groups.cl b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_num_groups.cl new file mode 100644 index 0000000000..495864751e --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_num_groups.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_OVERLOAD _CLC_DEF size_t __clc_get_num_groups(uint dim) { + switch (dim) { + case 0: + return __nvvm_read_ptx_sreg_nctaid_x(); + case 1: + return __nvvm_read_ptx_sreg_nctaid_y(); + case 2: + return __nvvm_read_ptx_sreg_nctaid_z(); + default: + return 0; + } +} diff --git a/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_sub_group_local_id.cl b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_sub_group_local_id.cl new file mode 100644 index 0000000000..1448f8a8b9 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/ptx-nvidiacl/workitem/clc_get_sub_group_local_id.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_OVERLOAD _CLC_DEF uint __clc_get_sub_group_local_id() { + return __nvvm_read_ptx_sreg_laneid(); +} diff --git a/local/recipes/dev/libclc/source/clc/lib/r600/SOURCES b/local/recipes/dev/libclc/source/clc/lib/r600/SOURCES new file mode 100644 index 0000000000..75d32f4f53 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/r600/SOURCES @@ -0,0 +1,4 @@ +math/clc_fmax.cl +math/clc_fmin.cl +math/clc_native_rsqrt.cl +math/clc_rsqrt_override.cl diff --git a/local/recipes/dev/libclc/source/clc/lib/r600/math/clc_fmax.cl b/local/recipes/dev/libclc/source/clc/lib/r600/math/clc_fmax.cl new file mode 100644 index 0000000000..689e51a982 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/r600/math/clc_fmax.cl @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +_CLC_DEF _CLC_OVERLOAD float __clc_fmax(float x, float y) { + // Flush denormals if not enabled. Otherwise fmax instruction flushes the + // values for comparison, but outputs original denormal + x = __clc_flush_denormal_if_not_supported(x); + y = __clc_flush_denormal_if_not_supported(y); + return __builtin_fmaxf(x, y); +} + +#define __FLOAT_ONLY +#define FUNCTION __clc_fmax +#define __CLC_BODY +#include +#undef FUNCTION + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEF _CLC_OVERLOAD double __clc_fmax(double x, double y) { + return __builtin_fmax(x, y); +} + +#define __DOUBLE_ONLY +#define FUNCTION __clc_fmax +#define __CLC_BODY +#include +#undef FUNCTION + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/r600/math/clc_fmin.cl b/local/recipes/dev/libclc/source/clc/lib/r600/math/clc_fmin.cl new file mode 100644 index 0000000000..22cb7046a4 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/r600/math/clc_fmin.cl @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +_CLC_DEF _CLC_OVERLOAD float __clc_fmin(float x, float y) { + // fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise + // fmin instruction flushes the values for comparison, but outputs original + // denormal + x = __clc_flush_denormal_if_not_supported(x); + y = __clc_flush_denormal_if_not_supported(y); + return __builtin_fminf(x, y); +} + +#define __FLOAT_ONLY +#define FUNCTION __clc_fmin +#define __CLC_BODY +#include +#undef FUNCTION + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEF _CLC_OVERLOAD double __clc_fmin(double x, double y) { + return __builtin_fmin(x, y); +} + +#define __DOUBLE_ONLY +#define FUNCTION __clc_fmin +#define __CLC_BODY +#include +#undef FUNCTION + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/r600/math/clc_native_rsqrt.cl b/local/recipes/dev/libclc/source/clc/lib/r600/math/clc_native_rsqrt.cl new file mode 100644 index 0000000000..b596657080 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/r600/math/clc_native_rsqrt.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF float __clc_native_rsqrt(float x) { + return __builtin_r600_recipsqrt_ieeef(x); +} + +#define __FLOAT_ONLY +#define FUNCTION __clc_native_rsqrt +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/clc/lib/r600/math/clc_rsqrt_override.cl b/local/recipes/dev/libclc/source/clc/lib/r600/math/clc_rsqrt_override.cl new file mode 100644 index 0000000000..75355df56d --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/r600/math/clc_rsqrt_override.cl @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF float __clc_rsqrt(float x) { + return __builtin_r600_recipsqrt_ieeef(x); +} + +#define __FLOAT_ONLY +#define FUNCTION __clc_rsqrt +#define __CLC_BODY +#include +#undef FUNCTION + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF double __clc_rsqrt(double x) { + return __builtin_r600_recipsqrt_ieee(x); +} + +#define __DOUBLE_ONLY +#define FUNCTION __clc_rsqrt +#define __CLC_BODY +#include +#undef FUNCTION + +#endif diff --git a/local/recipes/dev/libclc/source/clc/lib/spirv/SOURCES b/local/recipes/dev/libclc/source/clc/lib/spirv/SOURCES new file mode 100644 index 0000000000..cd6e0b2ea7 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/spirv/SOURCES @@ -0,0 +1 @@ +math/clc_runtime_has_hw_fma32.cl diff --git a/local/recipes/dev/libclc/source/clc/lib/spirv/math/clc_runtime_has_hw_fma32.cl b/local/recipes/dev/libclc/source/clc/lib/spirv/math/clc_runtime_has_hw_fma32.cl new file mode 100644 index 0000000000..2f6ad2c517 --- /dev/null +++ b/local/recipes/dev/libclc/source/clc/lib/spirv/math/clc_runtime_has_hw_fma32.cl @@ -0,0 +1,9 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +bool __clc_runtime_has_hw_fma32() { return false; } diff --git a/local/recipes/dev/libclc/source/cmake/modules/AddLibclc.cmake b/local/recipes/dev/libclc/source/cmake/modules/AddLibclc.cmake new file mode 100644 index 0000000000..597bb64265 --- /dev/null +++ b/local/recipes/dev/libclc/source/cmake/modules/AddLibclc.cmake @@ -0,0 +1,485 @@ +# Compiles an OpenCL C - or assembles an LL file - to bytecode +# +# Arguments: +# * TARGET +# Custom target to create +# * TRIPLE +# Target triple for which to compile the bytecode file. +# * INPUT +# File to compile/assemble to bytecode +# * OUTPUT +# Bytecode file to generate +# * EXTRA_OPTS ... +# List of compiler options to use. Note that some are added by default. +# * DEPENDENCIES ... +# List of extra dependencies to inject +# +# Depends on the clang, llvm-as, and llvm-link targets for compiling, +# assembling, and linking, respectively. +function(compile_to_bc) + cmake_parse_arguments(ARG + "" + "TARGET;TRIPLE;INPUT;OUTPUT" + "EXTRA_OPTS;DEPENDENCIES" + ${ARGN} + ) + + # If this is an LLVM IR file (identified solely by its file suffix), + # pre-process it with clang to a temp file, then assemble that to bytecode. + set( TMP_SUFFIX ) + get_filename_component( FILE_EXT ${ARG_INPUT} EXT ) + if( NOT ${FILE_EXT} STREQUAL ".ll" ) + # Pass '-c' when not running the preprocessor + set( PP_OPTS -c ) + else() + set( PP_OPTS -E;-P ) + set( TMP_SUFFIX .tmp ) + endif() + + set( TARGET_ARG ) + if( ARG_TRIPLE ) + set( TARGET_ARG "-target" ${ARG_TRIPLE} ) + endif() + + # Ensure the directory we are told to output to exists + get_filename_component( ARG_OUTPUT_DIR ${ARG_OUTPUT} DIRECTORY ) + file( MAKE_DIRECTORY ${ARG_OUTPUT_DIR} ) + + add_custom_command( + OUTPUT ${ARG_OUTPUT}${TMP_SUFFIX} + COMMAND ${clang_exe} + ${TARGET_ARG} + ${PP_OPTS} + ${ARG_EXTRA_OPTS} + -MD -MF ${ARG_OUTPUT}.d -MT ${ARG_OUTPUT}${TMP_SUFFIX} + # LLVM 13 enables standard includes by default - we don't want + # those when pre-processing IR. We disable it unconditionally. + $<$:-cl-no-stdinc> + -emit-llvm + -o ${ARG_OUTPUT}${TMP_SUFFIX} + -x cl + ${ARG_INPUT} + DEPENDS + ${clang_target} + ${ARG_INPUT} + ${ARG_DEPENDENCIES} + DEPFILE ${ARG_OUTPUT}.d + ) + # FIXME: The target is added to ensure the parallel build of source files. + # However, this may result in a large number of targets. + # Starting with CMake 3.27, DEPENDS_EXPLICIT_ONLY can be used with + # add_custom_command to enable parallel build. + # Refer to https://gitlab.kitware.com/cmake/cmake/-/issues/17097 for details. + add_custom_target( ${ARG_TARGET} DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} ) + + if( ${FILE_EXT} STREQUAL ".ll" ) + add_custom_command( + OUTPUT ${ARG_OUTPUT} + COMMAND ${llvm-as_exe} -o ${ARG_OUTPUT} ${ARG_OUTPUT}${TMP_SUFFIX} + DEPENDS ${llvm-as_target} ${ARG_OUTPUT}${TMP_SUFFIX} + ) + endif() +endfunction() + +# Links together one or more bytecode files +# +# Arguments: +# * INTERNALIZE +# Set if -internalize flag should be passed when linking +# * TARGET +# Custom target to create +# * INPUT ... +# List of bytecode files to link together +# * DEPENDENCIES ... +# List of extra dependencies to inject +function(link_bc) + cmake_parse_arguments(ARG + "INTERNALIZE" + "TARGET" + "INPUTS;DEPENDENCIES" + ${ARGN} + ) + + set( LINK_INPUT_ARG ${ARG_INPUTS} ) + if( WIN32 OR CYGWIN ) + # Create a response file in case the number of inputs exceeds command-line + # character limits on certain platforms. + file( TO_CMAKE_PATH ${LIBCLC_ARCH_OBJFILE_DIR}/${ARG_TARGET}.rsp RSP_FILE ) + # Turn it into a space-separate list of input files + list( JOIN ARG_INPUTS " " RSP_INPUT ) + file( GENERATE OUTPUT ${RSP_FILE} CONTENT ${RSP_INPUT} ) + # Ensure that if this file is removed, we re-run CMake + set_property( DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS + ${RSP_FILE} + ) + set( LINK_INPUT_ARG "@${RSP_FILE}" ) + endif() + + if( ARG_INTERNALIZE ) + set( link_flags --internalize --only-needed ) + endif() + + add_custom_command( + OUTPUT ${ARG_TARGET}.bc + COMMAND ${llvm-link_exe} ${link_flags} -o ${ARG_TARGET}.bc ${LINK_INPUT_ARG} + DEPENDS ${llvm-link_target} ${ARG_DEPENDENCIES} ${ARG_INPUTS} ${RSP_FILE} + ) + + add_custom_target( ${ARG_TARGET} ALL DEPENDS ${ARG_TARGET}.bc ) + set_target_properties( ${ARG_TARGET} PROPERTIES + TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET}.bc + FOLDER "libclc/Device IR/Linking" + ) +endfunction() + +# Decomposes and returns variables based on a libclc triple and architecture +# combination. Returns data via one or more optional output variables. +# +# Arguments: +# * TRIPLE +# libclc target triple to query +# * DEVICE +# libclc device to query +# +# Optional Arguments: +# * CPU +# Variable name to be set to the target CPU +# * ARCH_SUFFIX +# Variable name to be set to the triple/architecture suffix +# * CLANG_TRIPLE +# Variable name to be set to the normalized clang triple +function(get_libclc_device_info) + cmake_parse_arguments(ARG + "" + "TRIPLE;DEVICE;CPU;ARCH_SUFFIX;CLANG_TRIPLE" + "" + ${ARGN} + ) + + if( NOT ARG_TRIPLE OR NOT ARG_DEVICE ) + message( FATAL_ERROR "Must provide both TRIPLE and DEVICE" ) + endif() + + string( REPLACE "-" ";" TRIPLE ${ARG_TRIPLE} ) + list( GET TRIPLE 0 ARCH ) + + # Some targets don't have a specific device architecture to target + if( ARG_DEVICE STREQUAL none OR ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 ) + set( cpu ) + set( arch_suffix "${ARG_TRIPLE}" ) + else() + set( cpu "${ARG_DEVICE}" ) + set( arch_suffix "${ARG_DEVICE}-${ARG_TRIPLE}" ) + endif() + + if( ARG_CPU ) + set( ${ARG_CPU} ${cpu} PARENT_SCOPE ) + endif() + + if( ARG_ARCH_SUFFIX ) + set( ${ARG_ARCH_SUFFIX} ${arch_suffix} PARENT_SCOPE ) + endif() + + # Some libclc targets are not real clang triples: return their canonical + # triples. + if( ARCH STREQUAL spirv OR ARCH STREQUAL clspv ) + set( ARG_TRIPLE "spir--" ) + elseif( ARCH STREQUAL spirv64 OR ARCH STREQUAL clspv64 ) + set( ARG_TRIPLE "spir64--" ) + endif() + + if( ARG_CLANG_TRIPLE ) + set( ${ARG_CLANG_TRIPLE} ${ARG_TRIPLE} PARENT_SCOPE ) + endif() +endfunction() + +# Compiles a list of library source files (provided by LIB_FILES/GEN_FILES) and +# compiles them to LLVM bytecode (or SPIR-V), links them together and optimizes +# them. +# +# For bytecode libraries, a list of ALIASES may optionally be provided to +# produce additional symlinks. +# +# Arguments: +# * ARCH +# libclc architecture being built +# * ARCH_SUFFIX +# libclc architecture/triple suffix +# * TRIPLE +# Triple used to compile +# +# Optional Arguments: +# * CLC_INTERNAL +# Pass if compiling the internal CLC builtin libraries, which are not +# optimized and do not have aliases created. +# * LIB_FILES ... +# List of files that should be built for this library +# * GEN_FILES ... +# List of generated files (in build dir) that should be built for this library +# * COMPILE_FLAGS ... +# Compilation options (for clang) +# * OPT_FLAGS ... +# Optimization options (for opt) +# * ALIASES ... +# List of aliases +# * INTERNAL_LINK_DEPENDENCIES ... +# A list of extra bytecode file's targets. The bitcode files will be linked +# into the builtin library. Symbols from these link dependencies will be +# internalized during linking. +function(add_libclc_builtin_set) + cmake_parse_arguments(ARG + "CLC_INTERNAL" + "ARCH;TRIPLE;ARCH_SUFFIX" + "LIB_FILES;GEN_FILES;COMPILE_FLAGS;OPT_FLAGS;ALIASES;INTERNAL_LINK_DEPENDENCIES" + ${ARGN} + ) + + if( NOT ARG_ARCH OR NOT ARG_ARCH_SUFFIX OR NOT ARG_TRIPLE ) + message( FATAL_ERROR "Must provide ARCH, ARCH_SUFFIX, and TRIPLE" ) + endif() + + set( bytecode_files ) + set( bytecode_ir_files ) + set( compile_tgts ) + foreach( file IN LISTS ARG_GEN_FILES ARG_LIB_FILES ) + # We need to take each file and produce an absolute input file, as well + # as a unique architecture-specific output file. We deal with a mix of + # different input files, which makes this trickier. + set( input_file_dep ) + if( ${file} IN_LIST ARG_GEN_FILES ) + # Generated files are given just as file names, which we must make + # absolute to the binary directory. + set( input_file ${CMAKE_CURRENT_BINARY_DIR}/${file} ) + set( output_file "${LIBCLC_ARCH_OBJFILE_DIR}/${file}.bc" ) + # If a target exists that generates this file, add that as a dependency + # of the custom command. + if( TARGET generate-${file} ) + set( input_file_dep generate-${file} ) + endif() + else() + # Other files are originally relative to each SOURCE file, which are + # then make relative to the libclc root directory. We must normalize + # the path (e.g., ironing out any ".."), then make it relative to the + # root directory again, and use that relative path component for the + # binary path. + get_filename_component( abs_path ${file} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) + file( RELATIVE_PATH root_rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${abs_path} ) + set( input_file ${CMAKE_CURRENT_SOURCE_DIR}/${file} ) + set( output_file "${LIBCLC_ARCH_OBJFILE_DIR}/${root_rel_path}.bc" ) + endif() + + get_filename_component( file_dir ${file} DIRECTORY ) + + string( REPLACE "/" "-" replaced ${file} ) + set( tgt compile_tgt-${ARG_ARCH_SUFFIX}${replaced}) + + set( file_specific_compile_options ) + get_source_file_property( compile_opts ${file} COMPILE_OPTIONS) + if( compile_opts ) + set( file_specific_compile_options "${compile_opts}" ) + endif() + + compile_to_bc( + TARGET ${tgt} + TRIPLE ${ARG_TRIPLE} + INPUT ${input_file} + OUTPUT ${output_file} + EXTRA_OPTS -fno-builtin -nostdlib "${ARG_COMPILE_FLAGS}" + "${file_specific_compile_options}" + -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir} + DEPENDENCIES ${input_file_dep} + ) + list( APPEND compile_tgts ${tgt} ) + + # Collect all files originating in LLVM IR separately + get_filename_component( file_ext ${file} EXT ) + if( ${file_ext} STREQUAL ".ll" ) + list( APPEND bytecode_ir_files ${output_file} ) + else() + list( APPEND bytecode_files ${output_file} ) + endif() + endforeach() + + # Prepend all LLVM IR files to the list so they are linked into the final + # bytecode modules first. This helps to suppress unnecessary warnings + # regarding different data layouts while linking. Any LLVM IR files without a + # data layout will (silently) be given the first data layout the linking + # process comes across. + list( PREPEND bytecode_files ${bytecode_ir_files} ) + + set( builtins_comp_lib_tgt builtins.comp.${ARG_ARCH_SUFFIX} ) + add_custom_target( ${builtins_comp_lib_tgt} + DEPENDS ${bytecode_files} ${compile_tgts} + ) + set_target_properties( ${builtins_comp_lib_tgt} PROPERTIES FOLDER "libclc/Device IR/Comp" ) + + if( NOT bytecode_files ) + message(FATAL_ERROR "Cannot create an empty builtins library") + endif() + + set( builtins_link_lib_tgt builtins.link.${ARG_ARCH_SUFFIX} ) + + if( NOT ARG_INTERNAL_LINK_DEPENDENCIES ) + link_bc( + TARGET ${builtins_link_lib_tgt} + INPUTS ${bytecode_files} + DEPENDENCIES ${builtins_comp_lib_tgt} + ) + else() + # If we have libraries to link while internalizing their symbols, we need + # two separate link steps; the --internalize flag applies to all link + # inputs but the first. + set( builtins_link_lib_tmp_tgt builtins.link.pre-deps.${ARG_ARCH_SUFFIX} ) + link_bc( + TARGET ${builtins_link_lib_tmp_tgt} + INPUTS ${bytecode_files} + DEPENDENCIES ${builtins_comp_lib_tgt} + ) + set( internal_link_depend_files ) + foreach( tgt ${ARG_INTERNAL_LINK_DEPENDENCIES} ) + list( APPEND internal_link_depend_files $ ) + endforeach() + link_bc( + INTERNALIZE + TARGET ${builtins_link_lib_tgt} + INPUTS $ + ${internal_link_depend_files} + DEPENDENCIES ${builtins_link_lib_tmp_tgt} ${ARG_INTERNAL_LINK_DEPENDENCIES} + ) + endif() + + # For the CLC internal builtins, exit here - we only optimize the targets' + # entry points once we've linked the CLC buitins into them + if( ARG_CLC_INTERNAL ) + return() + endif() + + set( builtins_link_lib $ ) + + if( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 ) + set( spv_suffix ${ARG_ARCH_SUFFIX}.spv ) + add_custom_command( OUTPUT ${spv_suffix} + COMMAND ${llvm-spirv_exe} ${spvflags} -o ${spv_suffix} ${builtins_link_lib} + DEPENDS ${llvm-spirv_target} ${builtins_link_lib} ${builtins_link_lib_tgt} + ) + add_custom_target( "prepare-${spv_suffix}" ALL DEPENDS "${spv_suffix}" ) + set_target_properties( "prepare-${spv_suffix}" PROPERTIES FOLDER "libclc/Device IR/Prepare" ) + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${spv_suffix} + DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) + + return() + endif() + + set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + + # Add opt target + add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc + COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc + ${builtins_link_lib} + DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} + ) + add_custom_target( ${builtins_opt_lib_tgt} + ALL DEPENDS ${builtins_opt_lib_tgt}.bc + ) + set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES + TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc + FOLDER "libclc/Device IR/Opt" + ) + + set( builtins_opt_lib $ ) + + # Add prepare target + set( obj_suffix ${ARG_ARCH_SUFFIX}.bc ) + add_custom_command( OUTPUT ${obj_suffix} + COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_opt_lib} + DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target} ) + add_custom_target( prepare-${obj_suffix} ALL DEPENDS ${obj_suffix} ) + set_target_properties( "prepare-${obj_suffix}" PROPERTIES FOLDER "libclc/Device IR/Prepare" ) + + # nvptx-- targets don't include workitem builtins, and clspv targets don't + # include all OpenCL builtins + if( NOT ARG_ARCH MATCHES "^(nvptx|clspv)(64)?$" ) + add_test( NAME external-calls-${obj_suffix} + COMMAND ./check_external_calls.sh ${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} ${LLVM_TOOLS_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) + endif() + + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) + foreach( a ${ARG_ALIASES} ) + set( alias_suffix "${a}-${ARG_TRIPLE}.bc" ) + add_custom_command( + OUTPUT ${alias_suffix} + COMMAND ${CMAKE_COMMAND} -E create_symlink ${obj_suffix} ${alias_suffix} + DEPENDS prepare-${obj_suffix} ) + add_custom_target( alias-${alias_suffix} ALL DEPENDS ${alias_suffix} ) + set_target_properties( alias-${alias_suffix} PROPERTIES FOLDER "libclc/Device IR/Aliases" ) + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${alias_suffix} + DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) + endforeach( a ) +endfunction(add_libclc_builtin_set) + +# Produces a list of libclc source files by walking over SOURCES files in a +# given directory. Outputs the list of files in LIB_FILE_LIST. +# +# LIB_FILE_LIST may be pre-populated and is appended to. +# +# Arguments: +# * LIB_ROOT_DIR +# Root directory containing target's lib files, relative to libclc root +# directory. If not provided, is set to '.'. +# * DIRS ... +# List of directories under LIB_ROOT_DIR to walk over searching for SOURCES +# files. Directories earlier in the list have lower priority than +# subsequent ones. +function(libclc_configure_lib_source LIB_FILE_LIST) + cmake_parse_arguments(ARG + "" + "LIB_ROOT_DIR" + "DIRS" + ${ARGN} + ) + + if( NOT ARG_LIB_ROOT_DIR ) + set(ARG_LIB_ROOT_DIR ".") + endif() + + # Enumerate SOURCES* files + set( source_list ) + foreach( l IN LISTS ARG_DIRS ) + foreach( s "SOURCES" "SOURCES_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}" ) + file( TO_CMAKE_PATH ${ARG_LIB_ROOT_DIR}/lib/${l}/${s} file_loc ) + file( TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${file_loc} loc ) + # Prepend the location to give higher priority to the specialized + # implementation + if( EXISTS ${loc} ) + list( PREPEND source_list ${file_loc} ) + endif() + endforeach() + endforeach() + + ## Add the generated convert files here to prevent adding the ones listed in + ## SOURCES + set( rel_files ${${LIB_FILE_LIST}} ) # Source directory input files, relative to the root dir + # A "set" of already-added input files + set( objects ) + foreach( f ${${LIB_FILE_LIST}} ) + get_filename_component( name ${f} NAME ) + list( APPEND objects ${name} ) + endforeach() + + foreach( l ${source_list} ) + file( READ ${l} file_list ) + string( REPLACE "\n" ";" file_list ${file_list} ) + get_filename_component( dir ${l} DIRECTORY ) + foreach( f ${file_list} ) + get_filename_component( name ${f} NAME ) + # Only add each file once, so that targets can 'specialize' builtins + if( NOT ${name} IN_LIST objects ) + list( APPEND objects ${name} ) + list( APPEND rel_files ${dir}/${f} ) + endif() + endforeach() + endforeach() + + set( ${LIB_FILE_LIST} ${rel_files} PARENT_SCOPE ) +endfunction(libclc_configure_lib_source LIB_FILE_LIST) diff --git a/local/recipes/dev/libclc/source/compile-test.sh b/local/recipes/dev/libclc/source/compile-test.sh new file mode 100755 index 0000000000..47c7f385bb --- /dev/null +++ b/local/recipes/dev/libclc/source/compile-test.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +clang -target nvptx--nvidiacl -Iptx-nvidiacl/include -Igeneric/include -Xclang -mlink-bitcode-file -Xclang nvptx--nvidiacl/lib/builtins.bc -include clc/clc.h -Dcl_clang_storage_class_specifiers -Dcl_khr_fp64 "$@" diff --git a/local/recipes/dev/libclc/source/libclc.pc.in b/local/recipes/dev/libclc/source/libclc.pc.in new file mode 100644 index 0000000000..3a9e58b3ef --- /dev/null +++ b/local/recipes/dev/libclc/source/libclc.pc.in @@ -0,0 +1,6 @@ +libexecdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/clc + +Name: libclc +Description: Library requirements of the OpenCL C programming language +Version: @PROJECT_VERSION@ +Libs: -L${libexecdir} diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/as_type.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/as_type.h new file mode 100644 index 0000000000..abe643df81 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/as_type.h @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_AS_TYPE_H__ +#define __CLC_OPENCL_AS_TYPE_H__ + +#include + +#define as_char(x) __builtin_astype(x, char) +#define as_uchar(x) __builtin_astype(x, uchar) +#define as_short(x) __builtin_astype(x, short) +#define as_ushort(x) __builtin_astype(x, ushort) +#define as_int(x) __builtin_astype(x, int) +#define as_uint(x) __builtin_astype(x, uint) +#define as_long(x) __builtin_astype(x, long) +#define as_ulong(x) __builtin_astype(x, ulong) +#define as_float(x) __builtin_astype(x, float) + +#define as_char2(x) __builtin_astype(x, char2) +#define as_uchar2(x) __builtin_astype(x, uchar2) +#define as_short2(x) __builtin_astype(x, short2) +#define as_ushort2(x) __builtin_astype(x, ushort2) +#define as_int2(x) __builtin_astype(x, int2) +#define as_uint2(x) __builtin_astype(x, uint2) +#define as_long2(x) __builtin_astype(x, long2) +#define as_ulong2(x) __builtin_astype(x, ulong2) +#define as_float2(x) __builtin_astype(x, float2) + +#define as_char3(x) __builtin_astype(x, char3) +#define as_uchar3(x) __builtin_astype(x, uchar3) +#define as_short3(x) __builtin_astype(x, short3) +#define as_ushort3(x) __builtin_astype(x, ushort3) +#define as_int3(x) __builtin_astype(x, int3) +#define as_uint3(x) __builtin_astype(x, uint3) +#define as_long3(x) __builtin_astype(x, long3) +#define as_ulong3(x) __builtin_astype(x, ulong3) +#define as_float3(x) __builtin_astype(x, float3) + +#define as_char4(x) __builtin_astype(x, char4) +#define as_uchar4(x) __builtin_astype(x, uchar4) +#define as_short4(x) __builtin_astype(x, short4) +#define as_ushort4(x) __builtin_astype(x, ushort4) +#define as_int4(x) __builtin_astype(x, int4) +#define as_uint4(x) __builtin_astype(x, uint4) +#define as_long4(x) __builtin_astype(x, long4) +#define as_ulong4(x) __builtin_astype(x, ulong4) +#define as_float4(x) __builtin_astype(x, float4) + +#define as_char8(x) __builtin_astype(x, char8) +#define as_uchar8(x) __builtin_astype(x, uchar8) +#define as_short8(x) __builtin_astype(x, short8) +#define as_ushort8(x) __builtin_astype(x, ushort8) +#define as_int8(x) __builtin_astype(x, int8) +#define as_uint8(x) __builtin_astype(x, uint8) +#define as_long8(x) __builtin_astype(x, long8) +#define as_ulong8(x) __builtin_astype(x, ulong8) +#define as_float8(x) __builtin_astype(x, float8) + +#define as_char16(x) __builtin_astype(x, char16) +#define as_uchar16(x) __builtin_astype(x, uchar16) +#define as_short16(x) __builtin_astype(x, short16) +#define as_ushort16(x) __builtin_astype(x, ushort16) +#define as_int16(x) __builtin_astype(x, int16) +#define as_uint16(x) __builtin_astype(x, uint16) +#define as_long16(x) __builtin_astype(x, long16) +#define as_ulong16(x) __builtin_astype(x, ulong16) +#define as_float16(x) __builtin_astype(x, float16) + +#ifdef cl_khr_fp64 +#define as_double(x) __builtin_astype(x, double) +#define as_double2(x) __builtin_astype(x, double2) +#define as_double3(x) __builtin_astype(x, double3) +#define as_double4(x) __builtin_astype(x, double4) +#define as_double8(x) __builtin_astype(x, double8) +#define as_double16(x) __builtin_astype(x, double16) +#endif + +#ifdef cl_khr_fp16 +#define as_half(x) __builtin_astype(x, half) +#define as_half2(x) __builtin_astype(x, half2) +#define as_half3(x) __builtin_astype(x, half3) +#define as_half4(x) __builtin_astype(x, half4) +#define as_half8(x) __builtin_astype(x, half8) +#define as_half16(x) __builtin_astype(x, half16) +#endif + +#endif // __CLC_OPENCL_AS_TYPE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_copy.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_copy.h new file mode 100644 index 0000000000..1bd16a4115 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_copy.h @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ASYNC_ASYNC_WORK_GROUP_COPY_H__ +#define __CLC_OPENCL_ASYNC_ASYNC_WORK_GROUP_COPY_H__ + +#define __CLC_DST_ADDR_SPACE local +#define __CLC_SRC_ADDR_SPACE global +#define __CLC_BODY +#include +#define __CLC_BODY +#include +#undef __CLC_DST_ADDR_SPACE +#undef __CLC_SRC_ADDR_SPACE + +#define __CLC_DST_ADDR_SPACE global +#define __CLC_SRC_ADDR_SPACE local +#define __CLC_BODY +#include +#define __CLC_BODY +#include +#undef __CLC_DST_ADDR_SPACE +#undef __CLC_SRC_ADDR_SPACE + +#endif // __CLC_OPENCL_ASYNC_ASYNC_WORK_GROUP_COPY_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_copy.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_copy.inc new file mode 100644 index 0000000000..cc4174970c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_copy.inc @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL event_t +async_work_group_copy(__CLC_DST_ADDR_SPACE __CLC_GENTYPE *dst, + const __CLC_SRC_ADDR_SPACE __CLC_GENTYPE *src, + size_t num_gentypes, event_t event); diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_strided_copy.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_strided_copy.h new file mode 100644 index 0000000000..5929ce73a9 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_strided_copy.h @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ASYNC_ASYNC_WORK_GROUP_STRIDED_COPY_H__ +#define __CLC_OPENCL_ASYNC_ASYNC_WORK_GROUP_STRIDED_COPY_H__ + +#define __CLC_DST_ADDR_SPACE local +#define __CLC_SRC_ADDR_SPACE global +#define __CLC_BODY +#include +#define __CLC_BODY +#include +#undef __CLC_DST_ADDR_SPACE +#undef __CLC_SRC_ADDR_SPACE + +#define __CLC_DST_ADDR_SPACE global +#define __CLC_SRC_ADDR_SPACE local +#define __CLC_BODY +#include +#define __CLC_BODY +#include +#undef __CLC_DST_ADDR_SPACE +#undef __CLC_SRC_ADDR_SPACE + +#endif // __CLC_OPENCL_ASYNC_ASYNC_WORK_GROUP_STRIDED_COPY_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_strided_copy.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_strided_copy.inc new file mode 100644 index 0000000000..9df894e4fa --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/async_work_group_strided_copy.inc @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL event_t async_work_group_strided_copy( + __CLC_DST_ADDR_SPACE __CLC_GENTYPE *dst, + const __CLC_SRC_ADDR_SPACE __CLC_GENTYPE *src, size_t num_gentypes, + size_t stride, event_t event); diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/prefetch.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/prefetch.h new file mode 100644 index 0000000000..1ba4414d9e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/prefetch.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ASYNC_PREFETCH_H__ +#define __CLC_OPENCL_ASYNC_PREFETCH_H__ + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include + +#endif // __CLC_OPENCL_ASYNC_PREFETCH_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/prefetch.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/prefetch.inc new file mode 100644 index 0000000000..4a78778fa7 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/prefetch.inc @@ -0,0 +1,10 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL void prefetch(const global __CLC_GENTYPE *p, + size_t num_gentypes); diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/wait_group_events.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/wait_group_events.h new file mode 100644 index 0000000000..d3ace9c34a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/async/wait_group_events.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ASYNC_WAIT_GROUP_EVENTS_H__ +#define __CLC_OPENCL_ASYNC_WAIT_GROUP_EVENTS_H__ + +#include + +_CLC_DECL _CLC_OVERLOAD void wait_group_events(int num_events, + event_t *event_list); + +#endif // __CLC_OPENCL_ASYNC_WAIT_GROUP_EVENTS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_add.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_add.h new file mode 100644 index 0000000000..7f68fca0fc --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_add.h @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOM_ADD_H__ +#define __CLC_OPENCL_ATOMIC_ATOM_ADD_H__ + +#include + +#ifdef cl_khr_global_int32_base_atomics +#define FUNCTION atom_add +#define __CLC_ADDRESS_SPACE global +#include +#endif // cl_khr_global_int32_base_atomics + +#ifdef cl_khr_local_int32_base_atomics +#define FUNCTION atom_add +#define __CLC_ADDRESS_SPACE local +#include +#endif // cl_khr_local_int32_base_atomics + +#ifdef cl_khr_int64_base_atomics +#define FUNCTION atom_add +#include +#endif // cl_khr_int64_base_atomics + +#endif // __CLC_OPENCL_ATOMIC_ATOM_ADD_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_and.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_and.h new file mode 100644 index 0000000000..5c40aa4db7 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_and.h @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOM_AND_H__ +#define __CLC_OPENCL_ATOMIC_ATOM_AND_H__ + +#include + +#ifdef cl_khr_global_int32_extended_atomics +#define FUNCTION atom_and +#define __CLC_ADDRESS_SPACE global +#include +#endif // cl_khr_global_int32_extended_atomics + +#ifdef cl_khr_local_int32_extended_atomics +#define FUNCTION atom_and +#define __CLC_ADDRESS_SPACE local +#include +#endif // cl_khr_local_int32_extended_atomics + +#ifdef cl_khr_int64_extended_atomics +#define FUNCTION atom_and +#include +#endif // cl_khr_int64_extended_atomics + +#endif // __CLC_OPENCL_ATOMIC_ATOM_AND_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_cmpxchg.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_cmpxchg.h new file mode 100644 index 0000000000..83ee99f414 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_cmpxchg.h @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOM_CMPXCHG_H__ +#define __CLC_OPENCL_ATOMIC_ATOM_CMPXCHG_H__ + +#include + +#include +#include + +#ifdef cl_khr_global_int32_base_atomics +_CLC_OVERLOAD _CLC_DECL int atom_cmpxchg(volatile global int *p, int cmp, + int val); +_CLC_OVERLOAD _CLC_DECL unsigned int +atom_cmpxchg(volatile global unsigned int *p, unsigned int cmp, + unsigned int val); +#endif // cl_khr_global_int32_base_atomics + +#ifdef cl_khr_local_int32_base_atomics +_CLC_OVERLOAD _CLC_DECL int atom_cmpxchg(volatile local int *p, int cmp, + int val); +_CLC_OVERLOAD _CLC_DECL unsigned int +atom_cmpxchg(volatile local unsigned int *p, unsigned int cmp, + unsigned int val); +#endif // cl_khr_local_int32_base_atomics + +#ifdef cl_khr_int64_base_atomics +_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile global long *p, long cmp, + long val); +_CLC_OVERLOAD _CLC_DECL unsigned long +atom_cmpxchg(volatile global unsigned long *p, unsigned long cmp, + unsigned long val); +_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile local long *p, long cmp, + long val); +_CLC_OVERLOAD _CLC_DECL unsigned long +atom_cmpxchg(volatile local unsigned long *p, unsigned long cmp, + unsigned long val); +#endif // cl_khr_int64_base_atomics + +#endif // __CLC_OPENCL_ATOMIC_ATOM_CMPXCHG_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_dec.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_dec.h new file mode 100644 index 0000000000..f57d9c6afc --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_dec.h @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOM_DEC_H__ +#define __CLC_OPENCL_ATOMIC_ATOM_DEC_H__ + +#include + +#include +#include + +#ifdef cl_khr_global_int32_base_atomics +_CLC_OVERLOAD _CLC_DECL int atom_dec(volatile global int *p); +_CLC_OVERLOAD _CLC_DECL unsigned int atom_dec(volatile global unsigned int *p); +#endif // cl_khr_global_int32_base_atomics + +#ifdef cl_khr_local_int32_base_atomics +_CLC_OVERLOAD _CLC_DECL int atom_dec(volatile local int *p); +_CLC_OVERLOAD _CLC_DECL unsigned int atom_dec(volatile local unsigned int *p); +#endif // cl_khr_local_int32_base_atomics + +#ifdef cl_khr_int64_base_atomics +_CLC_OVERLOAD _CLC_DECL long atom_dec(volatile global long *p); +_CLC_OVERLOAD _CLC_DECL unsigned long +atom_dec(volatile global unsigned long *p); +_CLC_OVERLOAD _CLC_DECL long atom_dec(volatile local long *p); +_CLC_OVERLOAD _CLC_DECL unsigned long atom_dec(volatile local unsigned long *p); +#endif // cl_khr_int64_base_atomics + +#endif // __CLC_OPENCL_ATOMIC_ATOM_DEC_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_decl_int32.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_decl_int32.inc new file mode 100644 index 0000000000..b8631ceac3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_decl_int32.inc @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \ + _CLC_OVERLOAD _CLC_DECL TYPE FUNCTION(volatile ADDRSPACE TYPE *, TYPE); + +__CLC_DECLARE_ATOM(__CLC_ADDRESS_SPACE, int) +__CLC_DECLARE_ATOM(__CLC_ADDRESS_SPACE, uint) + +#undef __CLC_DECLARE_ATOM + +#undef FUNCTION +#undef __CLC_ADDRESS_SPACE diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_decl_int64.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_decl_int64.inc new file mode 100644 index 0000000000..3918a7cae0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_decl_int64.inc @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \ + _CLC_OVERLOAD _CLC_DECL TYPE FUNCTION(volatile ADDRSPACE TYPE *, TYPE); + +__CLC_DECLARE_ATOM(local, long) +__CLC_DECLARE_ATOM(local, ulong) +__CLC_DECLARE_ATOM(global, long) +__CLC_DECLARE_ATOM(global, ulong) + +#undef __CLC_DECLARE_ATOM + +#undef FUNCTION diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_inc.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_inc.h new file mode 100644 index 0000000000..96d3faa593 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_inc.h @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOM_INC_H__ +#define __CLC_OPENCL_ATOMIC_ATOM_INC_H__ + +#include + +#include +#include + +#ifdef cl_khr_global_int32_base_atomics +_CLC_OVERLOAD _CLC_DECL int atom_inc(volatile global int *p); +_CLC_OVERLOAD _CLC_DECL unsigned int atom_inc(volatile global unsigned int *p); +#endif // cl_khr_global_int32_base_atomics + +#ifdef cl_khr_local_int32_base_atomics +_CLC_OVERLOAD _CLC_DECL int atom_inc(volatile local int *p); +_CLC_OVERLOAD _CLC_DECL unsigned int atom_inc(volatile local unsigned int *p); +#endif // cl_khr_local_int32_base_atomics + +#ifdef cl_khr_int64_base_atomics +_CLC_OVERLOAD _CLC_DECL long atom_inc(volatile global long *p); +_CLC_OVERLOAD _CLC_DECL unsigned long +atom_inc(volatile global unsigned long *p); +_CLC_OVERLOAD _CLC_DECL long atom_inc(volatile local long *p); +_CLC_OVERLOAD _CLC_DECL unsigned long atom_inc(volatile local unsigned long *p); +#endif // cl_khr_int64_base_atomics + +#endif // __CLC_OPENCL_ATOMIC_ATOM_INC_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_max.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_max.h new file mode 100644 index 0000000000..87c70f2005 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_max.h @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOM_MAX_H__ +#define __CLC_OPENCL_ATOMIC_ATOM_MAX_H__ + +#include + +#ifdef cl_khr_global_int32_extended_atomics +#define FUNCTION atom_max +#define __CLC_ADDRESS_SPACE global +#include +#endif // cl_khr_global_int32_extended_atomics + +#ifdef cl_khr_local_int32_extended_atomics +#define FUNCTION atom_max +#define __CLC_ADDRESS_SPACE local +#include +#endif // cl_khr_local_int32_extended_atomics + +#ifdef cl_khr_int64_extended_atomics +#define FUNCTION atom_max +#include +#endif // cl_khr_int64_extended_atomics + +#endif // __CLC_OPENCL_ATOMIC_ATOM_MAX_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_min.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_min.h new file mode 100644 index 0000000000..487364c617 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_min.h @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOM_MIN_H__ +#define __CLC_OPENCL_ATOMIC_ATOM_MIN_H__ + +#include + +#ifdef cl_khr_global_int32_extended_atomics +#define FUNCTION atom_min +#define __CLC_ADDRESS_SPACE global +#include +#endif // cl_khr_global_int32_extended_atomics + +#ifdef cl_khr_local_int32_extended_atomics +#define FUNCTION atom_min +#define __CLC_ADDRESS_SPACE local +#include +#endif // cl_khr_local_int32_extended_atomics + +#ifdef cl_khr_int64_extended_atomics +#define FUNCTION atom_min +#include +#endif // cl_khr_int64_extended_atomics + +#endif // __CLC_OPENCL_ATOMIC_ATOM_MIN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_or.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_or.h new file mode 100644 index 0000000000..1c3ae6984e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_or.h @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOM_OR_H__ +#define __CLC_OPENCL_ATOMIC_ATOM_OR_H__ + +#include + +#ifdef cl_khr_global_int32_extended_atomics +#define FUNCTION atom_or +#define __CLC_ADDRESS_SPACE global +#include +#endif // cl_khr_global_int32_extended_atomics + +#ifdef cl_khr_local_int32_extended_atomics +#define FUNCTION atom_or +#define __CLC_ADDRESS_SPACE local +#include +#endif // cl_khr_local_int32_extended_atomics + +#ifdef cl_khr_int64_extended_atomics +#define FUNCTION atom_or +#include +#endif // cl_khr_int64_extended_atomics + +#endif // __CLC_OPENCL_ATOMIC_ATOM_OR_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_sub.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_sub.h new file mode 100644 index 0000000000..eb17aa8ce7 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_sub.h @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOM_SUB_H__ +#define __CLC_OPENCL_ATOMIC_ATOM_SUB_H__ + +#include + +#ifdef cl_khr_global_int32_base_atomics +#define FUNCTION atom_sub +#define __CLC_ADDRESS_SPACE global +#include +#endif // cl_khr_global_int32_base_atomics + +#ifdef cl_khr_local_int32_base_atomics +#define FUNCTION atom_sub +#define __CLC_ADDRESS_SPACE local +#include +#endif // cl_khr_local_int32_base_atomics + +#ifdef cl_khr_int64_base_atomics +#define FUNCTION atom_sub +#include +#endif // cl_khr_int64_base_atomics + +#endif // __CLC_OPENCL_ATOMIC_ATOM_SUB_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_xchg.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_xchg.h new file mode 100644 index 0000000000..df17d31d6e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_xchg.h @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOM_XCHG_H__ +#define __CLC_OPENCL_ATOMIC_ATOM_XCHG_H__ + +#include + +#ifdef cl_khr_global_int32_base_atomics +#define FUNCTION atom_xchg +#define __CLC_ADDRESS_SPACE global +#include +#endif // cl_khr_global_int32_base_atomics + +#ifdef cl_khr_local_int32_base_atomics +#define FUNCTION atom_xchg +#define __CLC_ADDRESS_SPACE local +#include +#endif // cl_khr_local_int32_base_atomics + +#ifdef cl_khr_int64_base_atomics +#define FUNCTION atom_xchg +#include +#endif // cl_khr_int64_base_atomics + +#endif // __CLC_OPENCL_ATOMIC_ATOM_XCHG_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_xor.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_xor.h new file mode 100644 index 0000000000..8a97818821 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atom_xor.h @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOM_XOR_H__ +#define __CLC_OPENCL_ATOMIC_ATOM_XOR_H__ + +#include + +#ifdef cl_khr_global_int32_extended_atomics +#define FUNCTION atom_xor +#define __CLC_ADDRESS_SPACE global +#include +#endif // cl_khr_global_int32_extended_atomics + +#ifdef cl_khr_local_int32_extended_atomics +#define FUNCTION atom_xor +#define __CLC_ADDRESS_SPACE local +#include +#endif // cl_khr_local_int32_extended_atomics + +#ifdef cl_khr_int64_extended_atomics +#define FUNCTION atom_xor +#include +#endif // cl_khr_int64_extended_atomics + +#endif // __CLC_OPENCL_ATOMIC_ATOM_XOR_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_add.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_add.h new file mode 100644 index 0000000000..821ae7aab0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_add.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_ADD_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_ADD_H__ + +#include + +#define FUNCTION atomic_add +#include + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_ADD_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_and.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_and.h new file mode 100644 index 0000000000..d10cfed9b5 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_and.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_AND_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_AND_H__ + +#include + +#define FUNCTION atomic_and +#include + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_AND_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_cmpxchg.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_cmpxchg.h new file mode 100644 index 0000000000..f784984299 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_cmpxchg.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_CMPXCHG_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_CMPXCHG_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL int atomic_cmpxchg(volatile local int *, int, int); +_CLC_OVERLOAD _CLC_DECL int atomic_cmpxchg(volatile global int *, int, int); +_CLC_OVERLOAD _CLC_DECL uint atomic_cmpxchg(volatile local uint *, uint, uint); +_CLC_OVERLOAD _CLC_DECL uint atomic_cmpxchg(volatile global uint *, uint, uint); + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_CMPXCHG_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_dec.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_dec.h new file mode 100644 index 0000000000..253a64f491 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_dec.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_DEC_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_DEC_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL int atomic_dec(volatile local int *); +_CLC_OVERLOAD _CLC_DECL int atomic_dec(volatile global int *); +_CLC_OVERLOAD _CLC_DECL uint atomic_dec(volatile local uint *); +_CLC_OVERLOAD _CLC_DECL uint atomic_dec(volatile global uint *); + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_DEC_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_decl.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_decl.inc new file mode 100644 index 0000000000..e060e3aaea --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_decl.inc @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#define __CLC_DECLARE_ATOMIC(ADDRSPACE, TYPE) \ + _CLC_OVERLOAD _CLC_DECL TYPE FUNCTION(volatile ADDRSPACE TYPE *, TYPE); + +#define __CLC_DECLARE_ATOMIC_ADDRSPACE(TYPE) \ + __CLC_DECLARE_ATOMIC(global, TYPE) \ + __CLC_DECLARE_ATOMIC(local, TYPE) + +__CLC_DECLARE_ATOMIC_ADDRSPACE(int) +__CLC_DECLARE_ATOMIC_ADDRSPACE(uint) + +#undef __CLC_DECLARE_ATOMIC_ADDRSPACE +#undef __CLC_DECLARE_ATOMIC + +#undef FUNCTION diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_inc.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_inc.h new file mode 100644 index 0000000000..75b3fe076c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_inc.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_INC_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_INC_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL int atomic_inc(volatile local int *); +_CLC_OVERLOAD _CLC_DECL int atomic_inc(volatile global int *); +_CLC_OVERLOAD _CLC_DECL uint atomic_inc(volatile local uint *); +_CLC_OVERLOAD _CLC_DECL uint atomic_inc(volatile global uint *); + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_INC_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_max.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_max.h new file mode 100644 index 0000000000..667fa36f16 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_max.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_MAX_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_MAX_H__ + +#include + +#define FUNCTION atomic_max +#include + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_MAX_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_min.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_min.h new file mode 100644 index 0000000000..91bb636eec --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_min.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_MIN_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_MIN_H__ + +#include + +#define FUNCTION atomic_min +#include + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_MIN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_or.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_or.h new file mode 100644 index 0000000000..5c03fd157a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_or.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_OR_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_OR_H__ + +#include + +#define FUNCTION atomic_or +#include + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_OR_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_sub.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_sub.h new file mode 100644 index 0000000000..25ffe9ff4a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_sub.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_SUB_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_SUB_H__ + +#include + +#define FUNCTION atomic_sub +#include + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_SUB_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_xchg.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_xchg.h new file mode 100644 index 0000000000..6b4206dedb --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_xchg.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_XCHG_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_XCHG_H__ + +#include + +#define FUNCTION atomic_xchg + +_CLC_OVERLOAD _CLC_DECL float FUNCTION(volatile local float *, float); +_CLC_OVERLOAD _CLC_DECL float FUNCTION(volatile global float *, float); +#include + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_XCHG_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_xor.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_xor.h new file mode 100644 index 0000000000..e94560cb6b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/atomic/atomic_xor.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_XOR_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_XOR_H__ + +#include + +#define FUNCTION atomic_xor +#include + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_XOR_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/degrees.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/degrees.h new file mode 100644 index 0000000000..5bd6f4e8f7 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/degrees.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_COMMON_DEGREES_H__ +#define __CLC_OPENCL_COMMON_DEGREES_H__ + +#define FUNCTION degrees +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_COMMON_DEGREES_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/mix.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/mix.h new file mode 100644 index 0000000000..75863cf699 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/mix.h @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_COMMON_MIX_H__ +#define __CLC_OPENCL_COMMON_MIX_H__ + +#define __CLC_BODY +#include + +#endif // __CLC_OPENCL_COMMON_MIX_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/mix.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/mix.inc new file mode 100644 index 0000000000..2b8350f5ba --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/mix.inc @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE mix(__CLC_GENTYPE a, __CLC_GENTYPE b, + __CLC_GENTYPE c); + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE mix(__CLC_GENTYPE a, __CLC_GENTYPE b, + __CLC_SCALAR_GENTYPE c); +#endif diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/radians.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/radians.h new file mode 100644 index 0000000000..3761a7e875 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/radians.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_COMMON_RADIANS_H__ +#define __CLC_OPENCL_COMMON_RADIANS_H__ + +#define FUNCTION radians +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_COMMON_RADIANS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/sign.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/sign.h new file mode 100644 index 0000000000..619e68ff1e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/sign.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_COMMON_SIGN_H__ +#define __CLC_OPENCL_COMMON_SIGN_H__ + +#define FUNCTION sign +#define __CLC_BODY +#include +#undef FUNCTION + +#endif // __CLC_OPENCL_COMMON_SIGN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/smoothstep.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/smoothstep.h new file mode 100644 index 0000000000..79fe7d37fc --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/smoothstep.h @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_COMMON_SMOOTHSTEP_H__ +#define __CLC_OPENCL_COMMON_SMOOTHSTEP_H__ + +#define __CLC_BODY +#include + +#endif // __CLC_OPENCL_COMMON_SMOOTHSTEP_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/smoothstep.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/smoothstep.inc new file mode 100644 index 0000000000..4547483364 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/smoothstep.inc @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE smoothstep(__CLC_GENTYPE edge0, + __CLC_GENTYPE edge1, + __CLC_GENTYPE x); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE smoothstep(float edge0, float edge1, + __CLC_GENTYPE x); + +#ifdef cl_khr_fp64 +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE smoothstep(double edge0, double edge1, + __CLC_GENTYPE x); +#endif diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/step.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/step.h new file mode 100644 index 0000000000..aa3882a9f1 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/step.h @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_COMMON_STEP_H__ +#define __CLC_OPENCL_COMMON_STEP_H__ + +#define __CLC_BODY +#include + +#endif // __CLC_OPENCL_COMMON_STEP_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/step.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/step.inc new file mode 100644 index 0000000000..86d4ed03db --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/common/step.inc @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE step(__CLC_GENTYPE edge, __CLC_GENTYPE x); + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE step(__CLC_SCALAR_GENTYPE edge, + __CLC_GENTYPE x); +#endif diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/convert.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/convert.h new file mode 100644 index 0000000000..1f71f67361 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/convert.h @@ -0,0 +1,108 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_CONVERT_H__ +#define __CLC_OPENCL_CONVERT_H__ + +#include + +#define _CLC_CONVERT_DECL(FROM_TYPE, TO_TYPE, SUFFIX) \ + _CLC_OVERLOAD _CLC_DECL TO_TYPE convert_##TO_TYPE##SUFFIX(FROM_TYPE x); + +#define _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, TO_TYPE, SUFFIX) \ + _CLC_CONVERT_DECL(FROM_TYPE, TO_TYPE, SUFFIX) \ + _CLC_CONVERT_DECL(FROM_TYPE##2, TO_TYPE##2, SUFFIX) \ + _CLC_CONVERT_DECL(FROM_TYPE##3, TO_TYPE##3, SUFFIX) \ + _CLC_CONVERT_DECL(FROM_TYPE##4, TO_TYPE##4, SUFFIX) \ + _CLC_CONVERT_DECL(FROM_TYPE##8, TO_TYPE##8, SUFFIX) \ + _CLC_CONVERT_DECL(FROM_TYPE##16, TO_TYPE##16, SUFFIX) + +#define _CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, char, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, uchar, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, int, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, uint, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, short, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, ushort, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, long, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, ulong, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, float, SUFFIX) + +#if defined(cl_khr_fp64) && defined(cl_khr_fp16) +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#define _CLC_VECTOR_CONVERT_FROM(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, double, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, half, SUFFIX) +#elif defined(cl_khr_fp64) +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#define _CLC_VECTOR_CONVERT_FROM(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, double, SUFFIX) +#elif defined(cl_khr_fp16) +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#define _CLC_VECTOR_CONVERT_FROM(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, half, SUFFIX) +#else +#define _CLC_VECTOR_CONVERT_FROM(FROM_TYPE, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) +#endif + +#define _CLC_VECTOR_CONVERT_TO1(SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(char, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(uchar, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(int, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(uint, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(short, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(ushort, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(long, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(ulong, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(float, SUFFIX) + +#if defined(cl_khr_fp64) && defined(cl_khr_fp16) +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#define _CLC_VECTOR_CONVERT_TO(SUFFIX) \ + _CLC_VECTOR_CONVERT_TO1(SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(double, SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(half, SUFFIX) +#elif defined(cl_khr_fp64) +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#define _CLC_VECTOR_CONVERT_TO(SUFFIX) \ + _CLC_VECTOR_CONVERT_TO1(SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(double, SUFFIX) +#elif defined(cl_khr_fp16) +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#define _CLC_VECTOR_CONVERT_TO(SUFFIX) \ + _CLC_VECTOR_CONVERT_TO1(SUFFIX) \ + _CLC_VECTOR_CONVERT_FROM(half, SUFFIX) +#else +#define _CLC_VECTOR_CONVERT_TO(SUFFIX) _CLC_VECTOR_CONVERT_TO1(SUFFIX) +#endif + +#define _CLC_VECTOR_CONVERT_TO_SUFFIX(ROUND) \ + _CLC_VECTOR_CONVERT_TO(_sat##ROUND) \ + _CLC_VECTOR_CONVERT_TO(ROUND) + +_CLC_VECTOR_CONVERT_TO_SUFFIX(_rtn) +_CLC_VECTOR_CONVERT_TO_SUFFIX(_rte) +_CLC_VECTOR_CONVERT_TO_SUFFIX(_rtz) +_CLC_VECTOR_CONVERT_TO_SUFFIX(_rtp) +_CLC_VECTOR_CONVERT_TO_SUFFIX() + +#undef _CLC_VECTOR_CONVERT_TO_SUFFIX +#undef _CLC_VECTOR_CONVERT_TO +#undef _CLC_VECTOR_CONVERT_TO1 +#undef _CLC_VECTOR_CONVERT_FROM +#undef _CLC_VECTOR_CONVERT_FROM1 +#undef _CLC_VECTOR_CONVERT_DECL +#undef _CLC_CONVERT_DECL + +#endif // __CLC_OPENCL_CONVERT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/explicit_fence/explicit_memory_fence.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/explicit_fence/explicit_memory_fence.h new file mode 100644 index 0000000000..3ade970a33 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/explicit_fence/explicit_memory_fence.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_EXPLICIT_FENCE_EXPLICIT_MEMORY_FENCE_H__ +#define __CLC_OPENCL_EXPLICIT_FENCE_EXPLICIT_MEMORY_FENCE_H__ + +#include +#include + +_CLC_DECL _CLC_OVERLOAD void mem_fence(cl_mem_fence_flags flags); +_CLC_DECL _CLC_OVERLOAD void read_mem_fence(cl_mem_fence_flags flags); +_CLC_DECL _CLC_OVERLOAD void write_mem_fence(cl_mem_fence_flags flags); + +#endif // __CLC_OPENCL_EXPLICIT_FENCE_EXPLICIT_MEMORY_FENCE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/cross.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/cross.h new file mode 100644 index 0000000000..be137965ae --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/cross.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_GEOMETRIC_CROSS_H__ +#define __CLC_OPENCL_GEOMETRIC_CROSS_H__ + +_CLC_OVERLOAD _CLC_DECL float3 cross(float3 p0, float3 p1); +_CLC_OVERLOAD _CLC_DECL float4 cross(float4 p0, float4 p1); + +#ifdef cl_khr_fp64 +_CLC_OVERLOAD _CLC_DECL double3 cross(double3 p0, double3 p1); +_CLC_OVERLOAD _CLC_DECL double4 cross(double4 p0, double4 p1); +#endif + +#endif // __CLC_OPENCL_GEOMETRIC_CROSS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/distance.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/distance.h new file mode 100644 index 0000000000..f9c219c44a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/distance.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_GEOMETRIC_DISTANCE_H__ +#define __CLC_OPENCL_GEOMETRIC_DISTANCE_H__ + +#define FUNCTION distance +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_GEOMETRIC_DISTANCE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/dot.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/dot.h new file mode 100644 index 0000000000..0b391a10aa --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/dot.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_GEOMETRIC_DOT_H__ +#define __CLC_OPENCL_GEOMETRIC_DOT_H__ + +#define FUNCTION dot +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_GEOMETRIC_DOT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/fast_distance.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/fast_distance.h new file mode 100644 index 0000000000..95b4966dfa --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/fast_distance.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_GEOMETRIC_FAST_DISTANCE_H__ +#define __CLC_OPENCL_GEOMETRIC_FAST_DISTANCE_H__ + +#define __FLOAT_ONLY +#define FUNCTION fast_distance +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_GEOMETRIC_FAST_DISTANCE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/fast_length.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/fast_length.h new file mode 100644 index 0000000000..78ad1fea98 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/fast_length.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_GEOMETRIC_FAST_LENGTH_H__ +#define __CLC_OPENCL_GEOMETRIC_FAST_LENGTH_H__ + +#define __FLOAT_ONLY +#define FUNCTION fast_length +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_GEOMETRIC_FAST_LENGTH_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/fast_normalize.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/fast_normalize.h new file mode 100644 index 0000000000..7a70dd5df5 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/fast_normalize.h @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_GEOMETRIC_FAST_NORMALIZE_H__ +#define __CLC_OPENCL_GEOMETRIC_FAST_NORMALIZE_H__ + +#define __FLOAT_ONLY +#define FUNCTION fast_normalize +#define __CLC_GEOMETRIC_RET_GENTYPE +#define __CLC_BODY + +#include + +#undef FUNCTION +#undef __CLC_GEOMETRIC_RET_GENTYPE + +#endif // __CLC_OPENCL_GEOMETRIC_FAST_NORMALIZE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/length.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/length.h new file mode 100644 index 0000000000..5dd6ff5a9c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/length.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_GEOMETRIC_LENGTH_H__ +#define __CLC_OPENCL_GEOMETRIC_LENGTH_H__ + +#define FUNCTION length +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_GEOMETRIC_LENGTH_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/normalize.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/normalize.h new file mode 100644 index 0000000000..7d3e8fa98f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/geometric/normalize.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_GEOMETRIC_NORMALIZE_H__ +#define __CLC_OPENCL_GEOMETRIC_NORMALIZE_H__ + +#define FUNCTION normalize +#define __CLC_GEOMETRIC_RET_GENTYPE +#define __CLC_BODY + +#include + +#undef __CLC_GEOMETRIC_RET_GENTYPE +#undef FUNCTION + +#endif // __CLC_OPENCL_GEOMETRIC_NORMALIZE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/image/image.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/image/image.h new file mode 100644 index 0000000000..7a248304ac --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/image/image.h @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_IMAGE_H__ +#define __CLC_OPENCL_IMAGE_H__ + +#include + +#if defined(__opencl_c_images) + +_CLC_OVERLOAD _CLC_DECL int get_image_width(image2d_t image); +_CLC_OVERLOAD _CLC_DECL int get_image_width(image3d_t image); + +_CLC_OVERLOAD _CLC_DECL int get_image_height(image2d_t image); +_CLC_OVERLOAD _CLC_DECL int get_image_height(image3d_t image); + +_CLC_OVERLOAD _CLC_DECL int get_image_depth(image3d_t image); + +_CLC_OVERLOAD _CLC_DECL int get_image_channel_data_type(image2d_t image); +_CLC_OVERLOAD _CLC_DECL int get_image_channel_data_type(image3d_t image); + +_CLC_OVERLOAD _CLC_DECL int get_image_channel_order(image2d_t image); +_CLC_OVERLOAD _CLC_DECL int get_image_channel_order(image3d_t image); + +_CLC_OVERLOAD _CLC_DECL int2 get_image_dim(image2d_t image); +_CLC_OVERLOAD _CLC_DECL int4 get_image_dim(image3d_t image); + +_CLC_OVERLOAD _CLC_DECL void write_imagef(image2d_t image, int2 coord, + float4 color); +_CLC_OVERLOAD _CLC_DECL void write_imagei(image2d_t image, int2 coord, + int4 color); +_CLC_OVERLOAD _CLC_DECL void write_imageui(image2d_t image, int2 coord, + uint4 color); + +_CLC_OVERLOAD _CLC_DECL float4 read_imagef(image2d_t image, sampler_t sampler, + int2 coord); +_CLC_OVERLOAD _CLC_DECL float4 read_imagef(image2d_t image, sampler_t sampler, + float2 coord); +_CLC_OVERLOAD _CLC_DECL int4 read_imagei(image2d_t image, sampler_t sampler, + int2 coord); +_CLC_OVERLOAD _CLC_DECL int4 read_imagei(image2d_t image, sampler_t sampler, + float2 coord); +_CLC_OVERLOAD _CLC_DECL uint4 read_imageui(image2d_t image, sampler_t sampler, + int2 coord); +_CLC_OVERLOAD _CLC_DECL uint4 read_imageui(image2d_t image, sampler_t sampler, + float2 coord); + +#endif + +#endif // __CLC_OPENCL_IMAGE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/image/image_defines.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/image/image_defines.h new file mode 100644 index 0000000000..75e08dec3f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/image/image_defines.h @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_IMAGE_IMAGE_DEFINES_H__ +#define __CLC_OPENCL_IMAGE_IMAGE_DEFINES_H__ + +/* get_image_channel_data_type flags */ +#define CLK_SNORM_INT8 0x10D0 +#define CLK_SNORM_INT16 0x10D1 +#define CLK_UNORM_INT8 0x10D2 +#define CLK_UNORM_INT16 0x10D3 +#define CLK_UNORM_SHORT_565 0x10D4 +#define CLK_UNORM_SHORT_555 0x10D5 +#define CLK_UNORM_SHORT_101010 0x10D6 +#define CLK_SIGNED_INT8 0x10D7 +#define CLK_SIGNED_INT16 0x10D8 +#define CLK_SIGNED_INT32 0x10D9 +#define CLK_UNSIGNED_INT8 0x10DA +#define CLK_UNSIGNED_INT16 0x10DB +#define CLK_UNSIGNED_INT32 0x10DC +#define CLK_HALF_FLOAT 0x10DD +#define CLK_FLOAT 0x10DE + +/* get_image_channel_order flags */ +#define CLK_R 0x10B0 +#define CLK_A 0x10B1 +#define CLK_RG 0x10B2 +#define CLK_RA 0x10B3 +#define CLK_RGB 0x10B4 +#define CLK_RGBA 0x10B5 +#define CLK_BGRA 0x10B6 +#define CLK_ARGB 0x10B7 +#define CLK_INTENSITY 0x10B8 +#define CLK_LUMINANCE 0x10B9 +#define CLK_Rx 0x10BA +#define CLK_RGx 0x10BB +#define CLK_RGBx 0x10BC + +/* sampler normalized coords */ +#define CLK_NORMALIZED_COORDS_FALSE 0x0000 +#define CLK_NORMALIZED_COORDS_TRUE 0x0001 +#define __CLC_NORMALIZED_COORDS_MASK 0x0001 + +/* sampler addressing mode */ +#define CLK_ADDRESS_NONE 0x0000 +#define CLK_ADDRESS_CLAMP_TO_EDGE 0x0002 +#define CLK_ADDRESS_CLAMP 0x0004 +#define CLK_ADDRESS_REPEAT 0x0006 +#define CLK_ADDRESS_MIRRORED_REPEAT 0x0008 +#define __CLC_ADDRESS_MASK 0x000E + +/* sampler filter mode */ +#define CLK_FILTER_NEAREST 0x0000 +#define CLK_FILTER_LINEAR 0x0010 +#define __CLC_FILTER_MASK 0x0010 + +#endif // __CLC_OPENCL_IMAGE_IMAGE_DEFINES_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs.h new file mode 100644 index 0000000000..3059bef9a7 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_ABS_H__ +#define __CLC_OPENCL_INTEGER_ABS_H__ + +#include + +#define __CLC_BODY +#include + +#endif // __CLC_OPENCL_INTEGER_ABS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs.inc new file mode 100644 index 0000000000..6620ce36f8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs.inc @@ -0,0 +1,9 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_U_GENTYPE abs(__CLC_GENTYPE x); diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs_diff.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs_diff.h new file mode 100644 index 0000000000..9e8fe2b31f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs_diff.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_ABS_DIFF_H__ +#define __CLC_OPENCL_INTEGER_ABS_DIFF_H__ + +#include + +#define __CLC_BODY +#include + +#endif // __CLC_OPENCL_INTEGER_ABS_DIFF_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs_diff.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs_diff.inc new file mode 100644 index 0000000000..4187385402 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/abs_diff.inc @@ -0,0 +1,10 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_U_GENTYPE abs_diff(__CLC_GENTYPE x, + __CLC_GENTYPE y); diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/add_sat.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/add_sat.h new file mode 100644 index 0000000000..cd2c17a096 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/add_sat.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_ADD_SAT_H__ +#define __CLC_OPENCL_INTEGER_ADD_SAT_H__ + +#include + +#define FUNCTION add_sat +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_INTEGER_ADD_SAT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/clz.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/clz.h new file mode 100644 index 0000000000..77032ceeaf --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/clz.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_CLZ_H__ +#define __CLC_OPENCL_INTEGER_CLZ_H__ + +#include + +#define FUNCTION clz +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_INTEGER_CLZ_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/ctz.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/ctz.h new file mode 100644 index 0000000000..b861225846 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/ctz.h @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_CTZ_H__ +#define __CLC_OPENCL_INTEGER_CTZ_H__ + +#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 + +#include + +#define FUNCTION ctz +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __OPENCL_C_VERSION__ >= CL_VERSION_2_0 + +#endif // __CLC_OPENCL_INTEGER_CTZ_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/hadd.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/hadd.h new file mode 100644 index 0000000000..c4c8f7daf4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/hadd.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_HADD_H__ +#define __CLC_OPENCL_INTEGER_HADD_H__ + +#include + +#define FUNCTION hadd +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_INTEGER_HADD_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mad24.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mad24.h new file mode 100644 index 0000000000..daee9a0383 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mad24.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_MAD24_H__ +#define __CLC_OPENCL_INTEGER_MAD24_H__ + +#include + +#define FUNCTION mad24 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_INTEGER_MAD24_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mad_hi.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mad_hi.h new file mode 100644 index 0000000000..bbcdcd9c82 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mad_hi.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_MAD_HI_H__ +#define __CLC_OPENCL_INTEGER_MAD_HI_H__ + +#include + +#define FUNCTION mad_hi +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_INTEGER_MAD_HI_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mad_sat.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mad_sat.h new file mode 100644 index 0000000000..2804547797 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mad_sat.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_MAD_SAT_H__ +#define __CLC_OPENCL_INTEGER_MAD_SAT_H__ + +#include + +#define FUNCTION mad_sat +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_INTEGER_MAD_SAT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mul24.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mul24.h new file mode 100644 index 0000000000..6aa799a28b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mul24.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_MUL24_H__ +#define __CLC_OPENCL_INTEGER_MUL24_H__ + +#include + +#define FUNCTION mul24 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_INTEGER_MUL24_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mul_hi.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mul_hi.h new file mode 100644 index 0000000000..ed7ac7319c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/mul_hi.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_MUL_HI_H__ +#define __CLC_OPENCL_INTEGER_MUL_HI_H__ + +#include + +#define FUNCTION mul_hi +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_INTEGER_MUL_HI_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/popcount.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/popcount.h new file mode 100644 index 0000000000..43d5bc0f0b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/popcount.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_POPCOUNT_H__ +#define __CLC_OPENCL_INTEGER_POPCOUNT_H__ + +#include + +#define FUNCTION popcount +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_INTEGER_POPCOUNT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/rhadd.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/rhadd.h new file mode 100644 index 0000000000..2c93c100cf --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/rhadd.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_RHADD_H__ +#define __CLC_OPENCL_INTEGER_RHADD_H__ + +#define FUNCTION rhadd +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_INTEGER_RHADD_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/rotate.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/rotate.h new file mode 100644 index 0000000000..156155ae06 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/rotate.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_ROTATE_H__ +#define __CLC_OPENCL_INTEGER_ROTATE_H__ + +#include + +#define FUNCTION rotate +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_INTEGER_ROTATE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/sub_sat.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/sub_sat.h new file mode 100644 index 0000000000..a7861ee1ac --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/sub_sat.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_SUB_SAT_H__ +#define __CLC_OPENCL_INTEGER_SUB_SAT_H__ + +#define FUNCTION sub_sat +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_INTEGER_SUB_SAT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/upsample.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/upsample.h new file mode 100644 index 0000000000..a713f2b392 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/integer/upsample.h @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_INTEGER_UPSAMPLE_H__ +#define __CLC_OPENCL_INTEGER_UPSAMPLE_H__ + +#include + +#define __CLC_UPSAMPLE_DECL(BGENTYPE, GENTYPE, UGENTYPE) \ + _CLC_OVERLOAD _CLC_DECL BGENTYPE upsample(GENTYPE hi, UGENTYPE lo); + +#define __CLC_UPSAMPLE_VEC(BGENTYPE, GENTYPE, UGENTYPE) \ + __CLC_UPSAMPLE_DECL(BGENTYPE, GENTYPE, UGENTYPE) \ + __CLC_UPSAMPLE_DECL(BGENTYPE##2, GENTYPE##2, UGENTYPE##2) \ + __CLC_UPSAMPLE_DECL(BGENTYPE##3, GENTYPE##3, UGENTYPE##3) \ + __CLC_UPSAMPLE_DECL(BGENTYPE##4, GENTYPE##4, UGENTYPE##4) \ + __CLC_UPSAMPLE_DECL(BGENTYPE##8, GENTYPE##8, UGENTYPE##8) \ + __CLC_UPSAMPLE_DECL(BGENTYPE##16, GENTYPE##16, UGENTYPE##16) + +#define __CLC_UPSAMPLE_TYPES() \ + __CLC_UPSAMPLE_VEC(short, char, uchar) \ + __CLC_UPSAMPLE_VEC(ushort, uchar, uchar) \ + __CLC_UPSAMPLE_VEC(int, short, ushort) \ + __CLC_UPSAMPLE_VEC(uint, ushort, ushort) \ + __CLC_UPSAMPLE_VEC(long, int, uint) \ + __CLC_UPSAMPLE_VEC(ulong, uint, uint) + +__CLC_UPSAMPLE_TYPES() + +#undef __CLC_UPSAMPLE_TYPES +#undef __CLC_UPSAMPLE_DECL +#undef __CLC_UPSAMPLE_VEC + +#endif // __CLC_OPENCL_INTEGER_UPSAMPLE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/acos.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/acos.h new file mode 100644 index 0000000000..f9e9b44bb9 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/acos.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ACOS_H__ +#define __CLC_OPENCL_MATH_ACOS_H__ + +#define __CLC_BODY +#define FUNCTION acos + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ACOS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/acosh.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/acosh.h new file mode 100644 index 0000000000..241b305e6b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/acosh.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ACOSH_H__ +#define __CLC_OPENCL_MATH_ACOSH_H__ + +#define __CLC_BODY +#define FUNCTION acosh + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ACOSH_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/acospi.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/acospi.h new file mode 100644 index 0000000000..7014889dfb --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/acospi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ACOSPI_H__ +#define __CLC_OPENCL_MATH_ACOSPI_H__ + +#define __CLC_BODY +#define FUNCTION acospi + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ACOSPI_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/asin.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/asin.h new file mode 100644 index 0000000000..1ba1f459a9 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/asin.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ASIN_H__ +#define __CLC_OPENCL_MATH_ASIN_H__ + +#define __CLC_BODY +#define FUNCTION asin + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ASIN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/asinh.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/asinh.h new file mode 100644 index 0000000000..9a530a51fa --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/asinh.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ASINH_H__ +#define __CLC_OPENCL_MATH_ASINH_H__ + +#define __CLC_BODY +#define FUNCTION asinh + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ASINH_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/asinpi.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/asinpi.h new file mode 100644 index 0000000000..844848fff0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/asinpi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ASINPI_H__ +#define __CLC_OPENCL_MATH_ASINPI_H__ + +#define __CLC_BODY +#define FUNCTION asinpi + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ASINPI_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atan.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atan.h new file mode 100644 index 0000000000..f2312b8fb0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atan.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ATAN_H__ +#define __CLC_OPENCL_MATH_ATAN_H__ + +#define __CLC_BODY +#define FUNCTION atan + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ATAN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atan2.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atan2.h new file mode 100644 index 0000000000..72412d44aa --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atan2.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ATAN2_H__ +#define __CLC_OPENCL_MATH_ATAN2_H__ + +#define FUNCTION atan2 +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ATAN2_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atan2pi.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atan2pi.h new file mode 100644 index 0000000000..f12a19776e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atan2pi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ATAN2PI_H__ +#define __CLC_OPENCL_MATH_ATAN2PI_H__ + +#define FUNCTION atan2pi +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ATAN2PI_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atanh.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atanh.h new file mode 100644 index 0000000000..147a76b543 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atanh.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ATANH_H__ +#define __CLC_OPENCL_MATH_ATANH_H__ + +#define __CLC_BODY +#define FUNCTION atanh + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ATANH_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atanpi.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atanpi.h new file mode 100644 index 0000000000..12e9ea2501 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/atanpi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ATANPI_H__ +#define __CLC_OPENCL_MATH_ATANPI_H__ + +#define __CLC_BODY +#define FUNCTION atanpi + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ATANPI_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cbrt.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cbrt.h new file mode 100644 index 0000000000..fdb408ac96 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cbrt.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_CBRT_H__ +#define __CLC_OPENCL_MATH_CBRT_H__ + +#define __CLC_BODY +#define FUNCTION cbrt + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_CBRT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ceil.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ceil.h new file mode 100644 index 0000000000..dad2ea4f69 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ceil.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_CEIL_H__ +#define __CLC_OPENCL_MATH_CEIL_H__ + +#define __CLC_BODY +#define FUNCTION ceil + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_CEIL_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/copysign.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/copysign.h new file mode 100644 index 0000000000..10d6c90edf --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/copysign.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_COPYSIGN_H__ +#define __CLC_OPENCL_MATH_COPYSIGN_H__ + +#define FUNCTION copysign +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_COPYSIGN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cos.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cos.h new file mode 100644 index 0000000000..4e3aec6c69 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cos.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_COS_H__ +#define __CLC_OPENCL_MATH_COS_H__ + +#define __CLC_BODY +#define FUNCTION cos + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_COS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cosh.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cosh.h new file mode 100644 index 0000000000..f316433a23 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cosh.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_COSH_H__ +#define __CLC_OPENCL_MATH_COSH_H__ + +#define __CLC_BODY +#define FUNCTION cosh + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_COSH_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cospi.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cospi.h new file mode 100644 index 0000000000..b7dfb0dbaf --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/cospi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_COSPI_H__ +#define __CLC_OPENCL_MATH_COSPI_H__ + +#define __CLC_BODY +#define FUNCTION cospi + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_COSPI_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/erf.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/erf.h new file mode 100644 index 0000000000..8ce262f276 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/erf.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ERF_H__ +#define __CLC_OPENCL_MATH_ERF_H__ + +#undef erfc + +#define __CLC_BODY +#define FUNCTION erf + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ERF_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/erfc.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/erfc.h new file mode 100644 index 0000000000..26afe1315d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/erfc.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ERFC_H__ +#define __CLC_OPENCL_MATH_ERFC_H__ + +#undef erfc + +#define __CLC_BODY +#define FUNCTION erfc + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ERFC_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/exp.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/exp.h new file mode 100644 index 0000000000..fb8f674a8c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/exp.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_EXP_H__ +#define __CLC_OPENCL_MATH_EXP_H__ + +#undef exp + +#define __CLC_BODY +#define FUNCTION exp + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_EXP_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/exp10.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/exp10.h new file mode 100644 index 0000000000..cfd5c6df9d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/exp10.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_EXP10_H__ +#define __CLC_OPENCL_MATH_EXP10_H__ + +#undef exp10 + +#define __CLC_BODY +#define FUNCTION exp10 + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_EXP10_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/exp2.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/exp2.h new file mode 100644 index 0000000000..db0405eb13 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/exp2.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_EXP2_H__ +#define __CLC_OPENCL_MATH_EXP2_H__ + +#define __CLC_BODY +#define FUNCTION exp2 + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_EXP2_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/expm1.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/expm1.h new file mode 100644 index 0000000000..0b3628d484 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/expm1.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_EXPM1_H__ +#define __CLC_OPENCL_MATH_EXPM1_H__ + +#undef exp + +#define __CLC_BODY +#define FUNCTION expm1 + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_EXPM1_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fabs.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fabs.h new file mode 100644 index 0000000000..f20016f4eb --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fabs.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_FABS_H__ +#define __CLC_OPENCL_MATH_FABS_H__ + +#define __CLC_BODY +#define FUNCTION fabs + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_FABS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fdim.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fdim.h new file mode 100644 index 0000000000..82f70fd832 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fdim.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_FDIM_H__ +#define __CLC_OPENCL_MATH_FDIM_H__ + +#define FUNCTION fdim +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_FDIM_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/floor.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/floor.h new file mode 100644 index 0000000000..1930aeca74 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/floor.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_FLOOR_H__ +#define __CLC_OPENCL_MATH_FLOOR_H__ + +#define __CLC_BODY +#define FUNCTION floor + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_FLOOR_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fma.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fma.h new file mode 100644 index 0000000000..6fed3fc9b2 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fma.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_FMA_H__ +#define __CLC_OPENCL_MATH_FMA_H__ + +#define __CLC_BODY +#define FUNCTION fma + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_FMA_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fmax.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fmax.h new file mode 100644 index 0000000000..84c754e2c0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fmax.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_FMAX_H__ +#define __CLC_OPENCL_MATH_FMAX_H__ + +#define __CLC_BODY +#define FUNCTION fmax + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_FMAX_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fmin.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fmin.h new file mode 100644 index 0000000000..b35573e4f6 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fmin.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_FMIN_H__ +#define __CLC_OPENCL_MATH_FMIN_H__ + +#define __CLC_BODY +#define FUNCTION fmin + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_FMIN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fmod.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fmod.h new file mode 100644 index 0000000000..13515006fd --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fmod.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_FMOD_H__ +#define __CLC_OPENCL_MATH_FMOD_H__ + +#define FUNCTION fmod +#define __CLC_BODY +#include +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_FMOD_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fract.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fract.h new file mode 100644 index 0000000000..de953f78c5 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/fract.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_FRACT_H__ +#define __CLC_OPENCL_MATH_FRACT_H__ + +#define FUNCTION fract +#define __CLC_BODY +#include +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_FRACT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/frexp.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/frexp.h new file mode 100644 index 0000000000..c7ed7cbd1c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/frexp.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_FREXP_H__ +#define __CLC_OPENCL_MATH_FREXP_H__ + +#define FUNCTION frexp +#define __CLC_BODY +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_FREXP_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_cos.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_cos.h new file mode 100644 index 0000000000..5ab0b69ca4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_cos.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_COS_H__ +#define __CLC_OPENCL_MATH_HALF_COS_H__ + +#define __CLC_BODY +#define FUNCTION half_cos +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_COS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_divide.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_divide.h new file mode 100644 index 0000000000..ff506d0c9f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_divide.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_DIVIDE_H__ +#define __CLC_OPENCL_MATH_HALF_DIVIDE_H__ + +#define __CLC_BODY +#define FUNCTION half_divide + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_DIVIDE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_exp.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_exp.h new file mode 100644 index 0000000000..22780c1449 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_exp.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_EXP_H__ +#define __CLC_OPENCL_MATH_HALF_EXP_H__ + +#define __CLC_BODY +#define FUNCTION half_exp +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_EXP_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_exp10.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_exp10.h new file mode 100644 index 0000000000..1a8195e67e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_exp10.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_EXP10_H__ +#define __CLC_OPENCL_MATH_HALF_EXP10_H__ + +#define __CLC_BODY +#define FUNCTION half_exp10 +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_EXP10_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_exp2.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_exp2.h new file mode 100644 index 0000000000..2ca69aa1ea --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_exp2.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_EXP2_H__ +#define __CLC_OPENCL_MATH_HALF_EXP2_H__ + +#define __CLC_BODY +#define FUNCTION half_exp2 +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_EXP2_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_log.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_log.h new file mode 100644 index 0000000000..d2eef86879 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_log.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_LOG_H__ +#define __CLC_OPENCL_MATH_HALF_LOG_H__ + +#define __CLC_BODY +#define FUNCTION half_log +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_LOG_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_log10.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_log10.h new file mode 100644 index 0000000000..e0f85fff3f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_log10.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_LOG10_H__ +#define __CLC_OPENCL_MATH_HALF_LOG10_H__ + +#define __CLC_BODY +#define FUNCTION half_log10 +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_LOG10_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_log2.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_log2.h new file mode 100644 index 0000000000..ba0105d883 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_log2.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_LOG2_H__ +#define __CLC_OPENCL_MATH_HALF_LOG2_H__ + +#define __CLC_BODY +#define FUNCTION half_log2 +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_LOG2_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_powr.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_powr.h new file mode 100644 index 0000000000..4b792c0c6c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_powr.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_POWR_H__ +#define __CLC_OPENCL_MATH_HALF_POWR_H__ + +#define __CLC_BODY +#define FUNCTION half_powr + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_POWR_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_recip.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_recip.h new file mode 100644 index 0000000000..3425df4e47 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_recip.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_RECIP_H__ +#define __CLC_OPENCL_MATH_HALF_RECIP_H__ + +#define __CLC_BODY +#define FUNCTION half_recip +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_RECIP_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_rsqrt.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_rsqrt.h new file mode 100644 index 0000000000..e22a7375ca --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_rsqrt.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_RSQRT_H__ +#define __CLC_OPENCL_MATH_HALF_RSQRT_H__ + +#define __CLC_BODY +#define FUNCTION half_rsqrt +#define __FLOAT_ONLY +#include +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_RSQRT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_sin.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_sin.h new file mode 100644 index 0000000000..cb0462c454 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_sin.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_SIN_H__ +#define __CLC_OPENCL_MATH_HALF_SIN_H__ + +#define __CLC_BODY +#define FUNCTION half_sin +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_SIN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_sqrt.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_sqrt.h new file mode 100644 index 0000000000..f755fee7b4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_sqrt.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_SQRT_H__ +#define __CLC_OPENCL_MATH_HALF_SQRT_H__ + +#define __CLC_BODY +#define FUNCTION half_sqrt +#define __FLOAT_ONLY +#include +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_SQRT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_tan.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_tan.h new file mode 100644 index 0000000000..91b5b11ae1 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/half_tan.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HALF_TAN_H__ +#define __CLC_OPENCL_MATH_HALF_TAN_H__ + +#define __CLC_BODY +#define FUNCTION half_tan +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HALF_TAN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/hypot.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/hypot.h new file mode 100644 index 0000000000..76ff6ef065 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/hypot.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_HYPOT_H__ +#define __CLC_OPENCL_MATH_HYPOT_H__ + +#define FUNCTION hypot +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_HYPOT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ilogb.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ilogb.h new file mode 100644 index 0000000000..d9752a644b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ilogb.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ILOGB_H__ +#define __CLC_OPENCL_MATH_ILOGB_H__ + +#define FUNCTION ilogb +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ILOGB_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ldexp.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ldexp.h new file mode 100644 index 0000000000..b0194d9c9a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ldexp.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_LDEXP_H__ +#define __CLC_OPENCL_MATH_LDEXP_H__ + +#define FUNCTION ldexp +#define __CLC_BODY +#include +#undef FUNCTION + +#define __CLC_BODY +#include + +#endif // __CLC_OPENCL_MATH_LDEXP_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ldexp.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ldexp.inc new file mode 100644 index 0000000000..b5a5cfcafd --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/ldexp.inc @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_SCALAR + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE ldexp(__CLC_GENTYPE x, int n); + +#endif diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/lgamma.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/lgamma.h new file mode 100644 index 0000000000..95ed07c353 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/lgamma.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_LGAMMA_H__ +#define __CLC_OPENCL_MATH_LGAMMA_H__ + +#define __CLC_BODY +#define FUNCTION lgamma + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_LGAMMA_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/lgamma_r.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/lgamma_r.h new file mode 100644 index 0000000000..4853d2dd5c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/lgamma_r.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_LGAMMA_R_H__ +#define __CLC_OPENCL_MATH_LGAMMA_R_H__ + +#define FUNCTION lgamma_r +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_LGAMMA_R_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log.h new file mode 100644 index 0000000000..2d536d6b09 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_LOG_H__ +#define __CLC_OPENCL_MATH_LOG_H__ + +#define __CLC_BODY +#define FUNCTION log + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_LOG_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log10.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log10.h new file mode 100644 index 0000000000..0f83b8c2a0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log10.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_LOG10_H__ +#define __CLC_OPENCL_MATH_LOG10_H__ + +#define __CLC_BODY +#define FUNCTION log10 + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_LOG10_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log1p.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log1p.h new file mode 100644 index 0000000000..bd8adeda88 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log1p.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_LOG1P_H__ +#define __CLC_OPENCL_MATH_LOG1P_H__ + +#define __CLC_BODY +#define FUNCTION log1p + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_LOG1P_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log2.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log2.h new file mode 100644 index 0000000000..e4f6cb619a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/log2.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_LOG2_H__ +#define __CLC_OPENCL_MATH_LOG2_H__ + +#define __CLC_BODY +#define FUNCTION log2 + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_LOG2_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/logb.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/logb.h new file mode 100644 index 0000000000..3bbc8476d2 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/logb.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_LOGB_H__ +#define __CLC_OPENCL_MATH_LOGB_H__ + +#define __CLC_BODY +#define FUNCTION logb + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_LOGB_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/mad.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/mad.h new file mode 100644 index 0000000000..18732eb7be --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/mad.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_MAD_H__ +#define __CLC_OPENCL_MATH_MAD_H__ + +#define __CLC_BODY +#define FUNCTION mad + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_MAD_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/maxmag.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/maxmag.h new file mode 100644 index 0000000000..c8f3d5700f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/maxmag.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_MAXMAG_H__ +#define __CLC_OPENCL_MATH_MAXMAG_H__ + +#define __CLC_BODY +#define FUNCTION maxmag + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_MAXMAG_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/minmag.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/minmag.h new file mode 100644 index 0000000000..c90a9d9bdb --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/minmag.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_MINMAG_H__ +#define __CLC_OPENCL_MATH_MINMAG_H__ + +#define __CLC_BODY +#define FUNCTION minmag + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_MINMAG_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/modf.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/modf.h new file mode 100644 index 0000000000..a336c9e242 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/modf.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_MODF_H__ +#define __CLC_OPENCL_MATH_MODF_H__ + +#define FUNCTION modf +#define __CLC_BODY +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_MODF_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/nan.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/nan.h new file mode 100644 index 0000000000..d98ac56603 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/nan.h @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NAN_H__ +#define __CLC_OPENCL_MATH_NAN_H__ + +#define __CLC_BODY +#include + +#endif // __CLC_OPENCL_MATH_NAN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/nan.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/nan.inc new file mode 100644 index 0000000000..45b96f81d7 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/nan.inc @@ -0,0 +1,9 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE nan(__CLC_U_GENTYPE code); diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_cos.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_cos.h new file mode 100644 index 0000000000..566c32e95b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_cos.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_COS_H__ +#define __CLC_OPENCL_MATH_NATIVE_COS_H__ + +#define __CLC_BODY +#define FUNCTION native_cos +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_COS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_divide.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_divide.h new file mode 100644 index 0000000000..23360b4bde --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_divide.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_DIVIDE_H__ +#define __CLC_OPENCL_MATH_NATIVE_DIVIDE_H__ + +#define __CLC_BODY +#define FUNCTION native_divide + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_DIVIDE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_exp.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_exp.h new file mode 100644 index 0000000000..5133469509 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_exp.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_EXP_H__ +#define __CLC_OPENCL_MATH_NATIVE_EXP_H__ + +#define __CLC_BODY +#define FUNCTION native_exp +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_EXP_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_exp10.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_exp10.h new file mode 100644 index 0000000000..8a2788cd3b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_exp10.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_EXP10_H__ +#define __CLC_OPENCL_MATH_NATIVE_EXP10_H__ + +#define __CLC_BODY +#define FUNCTION native_exp10 +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_EXP10_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_exp2.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_exp2.h new file mode 100644 index 0000000000..5a6aed09a8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_exp2.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_EXP2_H__ +#define __CLC_OPENCL_MATH_NATIVE_EXP2_H__ + +#define __CLC_BODY +#define FUNCTION native_exp2 +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_EXP2_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_log.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_log.h new file mode 100644 index 0000000000..5816496064 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_log.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_LOG_H__ +#define __CLC_OPENCL_MATH_NATIVE_LOG_H__ + +#define __CLC_BODY +#define FUNCTION native_log +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_LOG_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_log10.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_log10.h new file mode 100644 index 0000000000..c215c733c0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_log10.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_LOG10_H__ +#define __CLC_OPENCL_MATH_NATIVE_LOG10_H__ + +#define __CLC_BODY +#define FUNCTION native_log10 +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_LOG10_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_log2.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_log2.h new file mode 100644 index 0000000000..783abe6cd8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_log2.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_LOG2_H__ +#define __CLC_OPENCL_MATH_NATIVE_LOG2_H__ + +#define __CLC_BODY +#define FUNCTION native_log2 +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_LOG2_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_powr.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_powr.h new file mode 100644 index 0000000000..9c8e171afc --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_powr.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_POWR_H__ +#define __CLC_OPENCL_MATH_NATIVE_POWR_H__ + +#define __CLC_BODY +#define FUNCTION native_powr + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_POWR_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_recip.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_recip.h new file mode 100644 index 0000000000..1c88c076e0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_recip.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_RECIP_H__ +#define __CLC_OPENCL_MATH_NATIVE_RECIP_H__ + +#define __CLC_BODY +#define FUNCTION native_recip +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_RECIP_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_rsqrt.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_rsqrt.h new file mode 100644 index 0000000000..2806f9128d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_rsqrt.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_RSQRT_H__ +#define __CLC_OPENCL_MATH_NATIVE_RSQRT_H__ + +#define __CLC_BODY +#define FUNCTION native_rsqrt +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_RSQRT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_sin.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_sin.h new file mode 100644 index 0000000000..81f664153c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_sin.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_SIN_H__ +#define __CLC_OPENCL_MATH_NATIVE_SIN_H__ + +#define __CLC_BODY +#define FUNCTION native_sin +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_SIN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_sqrt.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_sqrt.h new file mode 100644 index 0000000000..dca0e542e0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_sqrt.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_SQRT_H__ +#define __CLC_OPENCL_MATH_NATIVE_SQRT_H__ + +#define __CLC_BODY +#define FUNCTION native_sqrt +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_SQRT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_tan.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_tan.h new file mode 100644 index 0000000000..cf942110e3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/native_tan.h @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NATIVE_TAN_H__ +#define __CLC_OPENCL_MATH_NATIVE_TAN_H__ + +#define __CLC_BODY +#define FUNCTION native_tan +#define __FLOAT_ONLY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NATIVE_TAN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/nextafter.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/nextafter.h new file mode 100644 index 0000000000..e338f5bf6c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/nextafter.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_NEXTAFTER_H__ +#define __CLC_OPENCL_MATH_NEXTAFTER_H__ + +#define FUNCTION nextafter +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_NEXTAFTER_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/pow.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/pow.h new file mode 100644 index 0000000000..3f4c1746fa --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/pow.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_POW_H__ +#define __CLC_OPENCL_MATH_POW_H__ + +#define FUNCTION pow +#define __CLC_BODY +#include +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_POW_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/pown.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/pown.h new file mode 100644 index 0000000000..fd97a705c8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/pown.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_POWN_H__ +#define __CLC_OPENCL_MATH_POWN_H__ + +#define FUNCTION pown +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_POWN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/powr.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/powr.h new file mode 100644 index 0000000000..47f653a73a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/powr.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_POWR_H__ +#define __CLC_OPENCL_MATH_POWR_H__ + +#define FUNCTION powr +#define __CLC_BODY +#include +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_POWR_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/remainder.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/remainder.h new file mode 100644 index 0000000000..416a0422c9 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/remainder.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_REMAINDER_H__ +#define __CLC_OPENCL_MATH_REMAINDER_H__ + +#define FUNCTION remainder +#define __CLC_BODY +#include +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_REMAINDER_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/remquo.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/remquo.h new file mode 100644 index 0000000000..3525c6bd0f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/remquo.h @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_REMQUO_H__ +#define __CLC_OPENCL_MATH_REMQUO_H__ + +#define FUNCTION remquo + +#define __CLC_BODY +#include + +#if _CLC_GENERIC_AS_SUPPORTED +#define __CLC_BODY +#define __CLC_ADDRESS_SPACE generic +#include +#undef __CLC_ADDRESS_SPACE +#endif + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_REMQUO_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/rint.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/rint.h new file mode 100644 index 0000000000..8f08fd20c3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/rint.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_RINT_H__ +#define __CLC_OPENCL_MATH_RINT_H__ + +#define __CLC_BODY +#define FUNCTION rint + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_RINT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/rootn.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/rootn.h new file mode 100644 index 0000000000..20b52e7c01 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/rootn.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ROOTN_H__ +#define __CLC_OPENCL_MATH_ROOTN_H__ + +#define __CLC_BODY +#define FUNCTION rootn + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ROOTN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/round.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/round.h new file mode 100644 index 0000000000..65bfc265ce --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/round.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_ROUND_H__ +#define __CLC_OPENCL_MATH_ROUND_H__ + +#define __CLC_BODY +#define FUNCTION round + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_ROUND_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/rsqrt.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/rsqrt.h new file mode 100644 index 0000000000..41fb54ea9b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/rsqrt.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_RSQRT_H__ +#define __CLC_OPENCL_MATH_RSQRT_H__ + +#define __CLC_BODY +#define FUNCTION rsqrt + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_RSQRT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sin.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sin.h new file mode 100644 index 0000000000..fc7741e164 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sin.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_SIN_H__ +#define __CLC_OPENCL_MATH_SIN_H__ + +#define __CLC_BODY +#define FUNCTION sin + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_SIN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sincos.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sincos.h new file mode 100644 index 0000000000..0231560a6b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sincos.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_SINCOS_H__ +#define __CLC_OPENCL_MATH_SINCOS_H__ + +#define __CLC_BODY +#define FUNCTION sincos +#include +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_SINCOS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sinh.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sinh.h new file mode 100644 index 0000000000..cbe30551ec --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sinh.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_SINH_H__ +#define __CLC_OPENCL_MATH_SINH_H__ + +#define __CLC_BODY +#define FUNCTION sinh + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_SINH_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sinpi.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sinpi.h new file mode 100644 index 0000000000..3ef55a1cd4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sinpi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_SINPI_H__ +#define __CLC_OPENCL_MATH_SINPI_H__ + +#define __CLC_BODY +#define FUNCTION sinpi + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_SINPI_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sqrt.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sqrt.h new file mode 100644 index 0000000000..8da37e94e7 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/sqrt.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_SQRT_H__ +#define __CLC_OPENCL_MATH_SQRT_H__ + +#define __CLC_BODY +#define FUNCTION sqrt + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_SQRT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tan.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tan.h new file mode 100644 index 0000000000..b7bab825c9 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tan.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_TAN_H__ +#define __CLC_OPENCL_MATH_TAN_H__ + +#define __CLC_BODY +#define FUNCTION tan + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_TAN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tanh.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tanh.h new file mode 100644 index 0000000000..168c06d50c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tanh.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_TANH_H__ +#define __CLC_OPENCL_MATH_TANH_H__ + +#define __CLC_BODY +#define FUNCTION tanh + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_TANH_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tanpi.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tanpi.h new file mode 100644 index 0000000000..0475027086 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tanpi.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_TANPI_H__ +#define __CLC_OPENCL_MATH_TANPI_H__ + +#define __CLC_BODY +#define FUNCTION tanpi + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_TANPI_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tgamma.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tgamma.h new file mode 100644 index 0000000000..6629c02002 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/tgamma.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_TGAMMA_H__ +#define __CLC_OPENCL_MATH_TGAMMA_H__ + +#define __CLC_BODY +#define FUNCTION tgamma + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_TGAMMA_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/trunc.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/trunc.h new file mode 100644 index 0000000000..0e61f6e167 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/math/trunc.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MATH_TRUNC_H__ +#define __CLC_OPENCL_MATH_TRUNC_H__ + +#define __CLC_BODY +#define FUNCTION trunc + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MATH_TRUNC_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/misc/shuffle.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/misc/shuffle.h new file mode 100644 index 0000000000..03c2718b0c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/misc/shuffle.h @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MISC_SHUFFLE_H__ +#define __CLC_OPENCL_MISC_SHUFFLE_H__ + +#define FUNCTION shuffle + +// Integer-type decls +#define __CLC_BODY +#include + +// Floating-point decls +#define __CLC_BODY +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MISC_SHUFFLE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/misc/shuffle2.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/misc/shuffle2.h new file mode 100644 index 0000000000..5b6ba99686 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/misc/shuffle2.h @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_MISC_SHUFFLE2_H__ +#define __CLC_OPENCL_MISC_SHUFFLE2_H__ + +#define FUNCTION shuffle2 + +// Integer-type decls +#define __CLC_BODY +#include + +// Floating-point decls +#define __CLC_BODY +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_MISC_SHUFFLE2_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/opencl-base.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/opencl-base.h new file mode 100644 index 0000000000..ac0dd0f129 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/opencl-base.h @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_OPENCL_BASE_H__ +#define __CLC_OPENCL_OPENCL_BASE_H__ + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#endif + +/* Function Attributes */ +#include + +/* 6.1 Supported Data Types */ +#include + +#endif // __CLC_OPENCL_OPENCL_BASE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/all.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/all.h new file mode 100644 index 0000000000..6c19d83e25 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/all.h @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ALL_H__ +#define __CLC_OPENCL_RELATIONAL_ALL_H__ + +#include + +#define _CLC_ALL_DECL(TYPE) _CLC_OVERLOAD _CLC_DECL int all(TYPE v); + +#define _CLC_VECTOR_ALL_DECL(TYPE) \ + _CLC_ALL_DECL(TYPE) \ + _CLC_ALL_DECL(TYPE##2) \ + _CLC_ALL_DECL(TYPE##3) \ + _CLC_ALL_DECL(TYPE##4) \ + _CLC_ALL_DECL(TYPE##8) \ + _CLC_ALL_DECL(TYPE##16) + +_CLC_VECTOR_ALL_DECL(char) +_CLC_VECTOR_ALL_DECL(short) +_CLC_VECTOR_ALL_DECL(int) +_CLC_VECTOR_ALL_DECL(long) + +#undef _CLC_ALL_DECL +#undef _CLC_VECTOR_ALL_DECL + +#endif // __CLC_OPENCL_RELATIONAL_ALL_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/any.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/any.h new file mode 100644 index 0000000000..4f6b2e2246 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/any.h @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ANY_H__ +#define __CLC_OPENCL_RELATIONAL_ANY_H__ + +#include + +#define _CLC_ANY_DECL(TYPE) _CLC_OVERLOAD _CLC_DECL int any(TYPE v); + +#define _CLC_VECTOR_ANY_DECL(TYPE) \ + _CLC_ANY_DECL(TYPE) \ + _CLC_ANY_DECL(TYPE##2) \ + _CLC_ANY_DECL(TYPE##3) \ + _CLC_ANY_DECL(TYPE##4) \ + _CLC_ANY_DECL(TYPE##8) \ + _CLC_ANY_DECL(TYPE##16) + +_CLC_VECTOR_ANY_DECL(char) +_CLC_VECTOR_ANY_DECL(short) +_CLC_VECTOR_ANY_DECL(int) +_CLC_VECTOR_ANY_DECL(long) + +#undef _CLC_ANY_DECL +#undef _CLC_VECTOR_ANY_DECL + +#endif // __CLC_OPENCL_RELATIONAL_ANY_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/bitselect.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/bitselect.h new file mode 100644 index 0000000000..9e967c6e2d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/bitselect.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_BITSELECT_H__ +#define __CLC_OPENCL_RELATIONAL_BITSELECT_H__ + +#include + +#define __CLC_BODY +#include +#define __CLC_BODY +#include + +#endif // __CLC_OPENCL_RELATIONAL_BITSELECT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/bitselect.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/bitselect.inc new file mode 100644 index 0000000000..d821bb86a1 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/bitselect.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE bitselect(__CLC_GENTYPE x, + __CLC_GENTYPE y, + __CLC_GENTYPE z); diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isequal.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isequal.h new file mode 100644 index 0000000000..c679b2cfc3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isequal.h @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISEQUAL_H__ +#define __CLC_OPENCL_RELATIONAL_ISEQUAL_H__ + +#include + +#define _CLC_ISEQUAL_DECL(TYPE, RETTYPE) \ + _CLC_OVERLOAD _CLC_DECL RETTYPE isequal(TYPE x, TYPE y); + +#define _CLC_VECTOR_ISEQUAL_DECL(TYPE, RETTYPE) \ + _CLC_ISEQUAL_DECL(TYPE##2, RETTYPE##2) \ + _CLC_ISEQUAL_DECL(TYPE##3, RETTYPE##3) \ + _CLC_ISEQUAL_DECL(TYPE##4, RETTYPE##4) \ + _CLC_ISEQUAL_DECL(TYPE##8, RETTYPE##8) \ + _CLC_ISEQUAL_DECL(TYPE##16, RETTYPE##16) + +_CLC_ISEQUAL_DECL(float, int) +_CLC_VECTOR_ISEQUAL_DECL(float, int) + +#ifdef cl_khr_fp64 +_CLC_ISEQUAL_DECL(double, int) +_CLC_VECTOR_ISEQUAL_DECL(double, long) +#endif +#ifdef cl_khr_fp16 +_CLC_ISEQUAL_DECL(half, int) +_CLC_VECTOR_ISEQUAL_DECL(half, short) +#endif + +#undef _CLC_ISEQUAL_DECL +#undef _CLC_VECTOR_ISEQUAL_DEC + +#endif // __CLC_OPENCL_RELATIONAL_ISEQUAL_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isfinite.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isfinite.h new file mode 100644 index 0000000000..2548e6acf5 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isfinite.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISFINITE_H__ +#define __CLC_OPENCL_RELATIONAL_ISFINITE_H__ + +#include + +#define FUNCTION isfinite +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_RELATIONAL_ISFINITE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isgreater.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isgreater.h new file mode 100644 index 0000000000..6dfe6eb810 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isgreater.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISGREATER_H__ +#define __CLC_OPENCL_RELATIONAL_ISGREATER_H__ + +#include + +#define FUNCTION isgreater +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_RELATIONAL_ISGREATER_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isgreaterequal.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isgreaterequal.h new file mode 100644 index 0000000000..1db2c5d58d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isgreaterequal.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISGREATEREQUAL_H__ +#define __CLC_OPENCL_RELATIONAL_ISGREATEREQUAL_H__ + +#include + +#define FUNCTION isgreaterequal +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_RELATIONAL_ISGREATEREQUAL_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isinf.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isinf.h new file mode 100644 index 0000000000..561cb1cda4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isinf.h @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISINF_H__ +#define __CLC_OPENCL_RELATIONAL_ISINF_H__ + +#include + +#define _CLC_ISINF_DECL(RET_TYPE, ARG_TYPE) \ + _CLC_OVERLOAD _CLC_DECL RET_TYPE isinf(ARG_TYPE); + +#define _CLC_VECTOR_ISINF_DECL(RET_TYPE, ARG_TYPE) \ + _CLC_ISINF_DECL(RET_TYPE##2, ARG_TYPE##2) \ + _CLC_ISINF_DECL(RET_TYPE##3, ARG_TYPE##3) \ + _CLC_ISINF_DECL(RET_TYPE##4, ARG_TYPE##4) \ + _CLC_ISINF_DECL(RET_TYPE##8, ARG_TYPE##8) \ + _CLC_ISINF_DECL(RET_TYPE##16, ARG_TYPE##16) + +_CLC_ISINF_DECL(int, float) +_CLC_VECTOR_ISINF_DECL(int, float) + +#ifdef cl_khr_fp64 +_CLC_ISINF_DECL(int, double) +_CLC_VECTOR_ISINF_DECL(long, double) +#endif + +#ifdef cl_khr_fp16 +_CLC_ISINF_DECL(int, half) +_CLC_VECTOR_ISINF_DECL(short, half) +#endif + +#undef _CLC_ISINF_DECL +#undef _CLC_VECTOR_ISINF_DECL + +#endif // __CLC_OPENCL_RELATIONAL_ISINF_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isless.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isless.h new file mode 100644 index 0000000000..3e2afb32cd --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isless.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISLESS_H__ +#define __CLC_OPENCL_RELATIONAL_ISLESS_H__ + +#include + +#define FUNCTION isless +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_RELATIONAL_ISLESS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/islessequal.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/islessequal.h new file mode 100644 index 0000000000..978e6a9052 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/islessequal.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISLESSEQUAL_H__ +#define __CLC_OPENCL_RELATIONAL_ISLESSEQUAL_H__ + +#include + +#define FUNCTION islessequal +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_RELATIONAL_ISLESSEQUAL_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/islessgreater.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/islessgreater.h new file mode 100644 index 0000000000..56cce7db20 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/islessgreater.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISLESSGREATER_H__ +#define __CLC_OPENCL_RELATIONAL_ISLESSGREATER_H__ + +#include + +#define FUNCTION islessgreater +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_RELATIONAL_ISLESSGREATER_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isnan.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isnan.h new file mode 100644 index 0000000000..fe1e5721c1 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isnan.h @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISNAN_H__ +#define __CLC_OPENCL_RELATIONAL_ISNAN_H__ + +#include + +#define _CLC_ISNAN_DECL(RET_TYPE, ARG_TYPE) \ + _CLC_OVERLOAD _CLC_DECL RET_TYPE isnan(ARG_TYPE); + +#define _CLC_VECTOR_ISNAN_DECL(RET_TYPE, ARG_TYPE) \ + _CLC_ISNAN_DECL(RET_TYPE##2, ARG_TYPE##2) \ + _CLC_ISNAN_DECL(RET_TYPE##3, ARG_TYPE##3) \ + _CLC_ISNAN_DECL(RET_TYPE##4, ARG_TYPE##4) \ + _CLC_ISNAN_DECL(RET_TYPE##8, ARG_TYPE##8) \ + _CLC_ISNAN_DECL(RET_TYPE##16, ARG_TYPE##16) + +_CLC_ISNAN_DECL(int, float) +_CLC_VECTOR_ISNAN_DECL(int, float) + +#ifdef cl_khr_fp64 +_CLC_ISNAN_DECL(int, double) +_CLC_VECTOR_ISNAN_DECL(long, double) +#endif + +#ifdef cl_khr_fp16 +_CLC_ISNAN_DECL(int, half) +_CLC_VECTOR_ISNAN_DECL(short, half) +#endif + +#undef _CLC_ISNAN_DECL +#undef _CLC_VECTOR_ISNAN_DECL + +#endif // __CLC_OPENCL_RELATIONAL_ISNAN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isnormal.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isnormal.h new file mode 100644 index 0000000000..ee74a990b5 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isnormal.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISNORMAL_H__ +#define __CLC_OPENCL_RELATIONAL_ISNORMAL_H__ + +#include + +#define FUNCTION isnormal +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_RELATIONAL_ISNORMAL_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isnotequal.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isnotequal.h new file mode 100644 index 0000000000..7cf94e3cee --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isnotequal.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISNOTEQUAL_H__ +#define __CLC_OPENCL_RELATIONAL_ISNOTEQUAL_H__ + +#include + +#define FUNCTION isnotequal +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_RELATIONAL_ISNOTEQUAL_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isordered.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isordered.h new file mode 100644 index 0000000000..ad9770bd62 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isordered.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISORDERED_H__ +#define __CLC_OPENCL_RELATIONAL_ISORDERED_H__ + +#include + +#define FUNCTION isordered +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_RELATIONAL_ISORDERED_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isunordered.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isunordered.h new file mode 100644 index 0000000000..01d2f53837 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/isunordered.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_ISUNORDERED_H__ +#define __CLC_OPENCL_RELATIONAL_ISUNORDERED_H__ + +#include + +#define FUNCTION isunordered +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_RELATIONAL_ISUNORDERED_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/select.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/select.h new file mode 100644 index 0000000000..e4cefd8bcd --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/select.h @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_SELECT_H__ +#define __CLC_OPENCL_RELATIONAL_SELECT_H__ + +#include + +#define __CLC_SELECT_FN select + +#define __CLC_BODY +#include +#define __CLC_BODY +#include + +#undef __CLC_SELECT_FN + +#endif // __CLC_OPENCL_RELATIONAL_SELECT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/signbit.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/signbit.h new file mode 100644 index 0000000000..29591c0c12 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/relational/signbit.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_RELATIONAL_SIGNBIT_H__ +#define __CLC_OPENCL_RELATIONAL_SIGNBIT_H__ + +#include + +#define FUNCTION signbit +#define __CLC_BODY + +#include + +#undef FUNCTION + +#endif // __CLC_OPENCL_RELATIONAL_SIGNBIT_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/clamp.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/clamp.h new file mode 100644 index 0000000000..4bd365e9dd --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/clamp.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_SHARED_CLAMP_H__ +#define __CLC_OPENCL_SHARED_CLAMP_H__ + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include + +#endif // __CLC_OPENCL_SHARED_CLAMP_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/clamp.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/clamp.inc new file mode 100644 index 0000000000..75dec9c258 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/clamp.inc @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE clamp(__CLC_GENTYPE x, __CLC_GENTYPE y, + __CLC_GENTYPE z); + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE clamp(__CLC_GENTYPE x, + __CLC_SCALAR_GENTYPE y, + __CLC_SCALAR_GENTYPE z); +#endif diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/max.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/max.h new file mode 100644 index 0000000000..512e696885 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/max.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_SHARED_MAX_H__ +#define __CLC_OPENCL_SHARED_MAX_H__ + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include + +#endif // __CLC_OPENCL_SHARED_MAX_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/max.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/max.inc new file mode 100644 index 0000000000..98610dfdb1 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/max.inc @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE max(__CLC_GENTYPE a, __CLC_GENTYPE b); + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE max(__CLC_GENTYPE a, + __CLC_SCALAR_GENTYPE b); +#endif diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/min.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/min.h new file mode 100644 index 0000000000..e20545210d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/min.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_SHARED_MIN_H__ +#define __CLC_OPENCL_SHARED_MIN_H__ + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include + +#endif // __CLC_OPENCL_SHARED_MIN_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/min.inc b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/min.inc new file mode 100644 index 0000000000..3140b637f3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/min.inc @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE min(__CLC_GENTYPE a, __CLC_GENTYPE b); + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE min(__CLC_GENTYPE a, + __CLC_SCALAR_GENTYPE b); +#endif diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/vload.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/vload.h new file mode 100644 index 0000000000..2ec087d4f3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/vload.h @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_SHARED_VLOAD_H__ +#define __CLC_OPENCL_SHARED_VLOAD_H__ + +#include + +#define _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, VEC_TYPE, WIDTH, ADDR_SPACE) \ + _CLC_OVERLOAD _CLC_DECL VEC_TYPE vload##SUFFIX##WIDTH( \ + size_t offset, const ADDR_SPACE MEM_TYPE *x); + +#define _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, ADDR_SPACE) \ + _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##2, 2, ADDR_SPACE) \ + _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##3, 3, ADDR_SPACE) \ + _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##4, 4, ADDR_SPACE) \ + _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE) \ + _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE) + +#if _CLC_GENERIC_AS_SUPPORTED +#define _CLC_VECTOR_VLOAD_GENERIC_DECL _CLC_VECTOR_VLOAD_DECL +#else +// The generic address space isn't available, so make the macro do nothing +#define _CLC_VECTOR_VLOAD_GENERIC_DECL(X, Y, Z, W) +#endif + +#define _CLC_VECTOR_VLOAD_PRIM3(SUFFIX, MEM_TYPE, PRIM_TYPE) \ + _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __private) \ + _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __local) \ + _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __constant) \ + _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __global) \ + _CLC_VECTOR_VLOAD_GENERIC_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __generic) + +#define _CLC_VECTOR_VLOAD_PRIM1(PRIM_TYPE) \ + _CLC_VECTOR_VLOAD_PRIM3(, PRIM_TYPE, PRIM_TYPE) + +// Declare vector load prototypes +_CLC_VECTOR_VLOAD_PRIM1(char) +_CLC_VECTOR_VLOAD_PRIM1(uchar) +_CLC_VECTOR_VLOAD_PRIM1(short) +_CLC_VECTOR_VLOAD_PRIM1(ushort) +_CLC_VECTOR_VLOAD_PRIM1(int) +_CLC_VECTOR_VLOAD_PRIM1(uint) +_CLC_VECTOR_VLOAD_PRIM1(long) +_CLC_VECTOR_VLOAD_PRIM1(ulong) +_CLC_VECTOR_VLOAD_PRIM1(float) +_CLC_VECTOR_VLOAD_PRIM3(_half, half, float) +// Use suffix to declare aligned vloada_halfN +_CLC_VECTOR_VLOAD_PRIM3(a_half, half, float) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +_CLC_VECTOR_VLOAD_PRIM1(double) +#endif +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +_CLC_VECTOR_VLOAD_PRIM1(half) +#endif + +// Scalar vload_half also needs to be declared +_CLC_VLOAD_DECL(_half, half, float, , __constant) +_CLC_VLOAD_DECL(_half, half, float, , __global) +_CLC_VLOAD_DECL(_half, half, float, , __local) +_CLC_VLOAD_DECL(_half, half, float, , __private) + +// Scalar vloada_half is not part of the specs but CTS expects it +_CLC_VLOAD_DECL(a_half, half, float, , __constant) +_CLC_VLOAD_DECL(a_half, half, float, , __global) +_CLC_VLOAD_DECL(a_half, half, float, , __local) +_CLC_VLOAD_DECL(a_half, half, float, , __private) + +#if _CLC_GENERIC_AS_SUPPORTED +_CLC_VLOAD_DECL(_half, half, float, , __generic) +_CLC_VLOAD_DECL(a_half, half, float, , __generic) +#endif + +#undef _CLC_VLOAD_DECL +#undef _CLC_VECTOR_VLOAD_DECL +#undef _CLC_VECTOR_VLOAD_PRIM3 +#undef _CLC_VECTOR_VLOAD_PRIM1 +#undef _CLC_VECTOR_VLOAD_GENERIC_DECL + +#endif // __CLC_OPENCL_SHARED_VLOAD_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/vstore.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/vstore.h new file mode 100644 index 0000000000..00eaff41f7 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/shared/vstore.h @@ -0,0 +1,91 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_SHARED_VSTORE_H__ +#define __CLC_OPENCL_SHARED_VSTORE_H__ + +#include + +#define _CLC_VSTORE_DECL(SUFFIX, PRIM_TYPE, VEC_TYPE, WIDTH, ADDR_SPACE, RND) \ + _CLC_OVERLOAD _CLC_DECL void vstore##SUFFIX##WIDTH##RND( \ + VEC_TYPE vec, size_t offset, ADDR_SPACE PRIM_TYPE *out); + +#define _CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, ADDR_SPACE, RND) \ + _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##2, 2, ADDR_SPACE, RND) \ + _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##3, 3, ADDR_SPACE, RND) \ + _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##4, 4, ADDR_SPACE, RND) \ + _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE, RND) \ + _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE, RND) + +#if _CLC_GENERIC_AS_SUPPORTED +#define _CLC_VSTORE_GENERIC_DECL _CLC_VSTORE_DECL +#define _CLC_VECTOR_VSTORE_GENERIC_DECL _CLC_VECTOR_VSTORE_DECL +#else +// The generic address space isn't available, so make the macros do nothing +#define _CLC_VSTORE_GENERIC_DECL(X, Y, Z, W, V, U) +#define _CLC_VECTOR_VSTORE_GENERIC_DECL(X, Y, Z, W, V) +#endif + +#define _CLC_VECTOR_VSTORE_PRIM3(SUFFIX, MEM_TYPE, PRIM_TYPE, RND) \ + _CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __private, RND) \ + _CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __local, RND) \ + _CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __global, RND) \ + _CLC_VECTOR_VSTORE_GENERIC_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __generic, RND) + +#define _CLC_VECTOR_VSTORE_PRIM1(PRIM_TYPE) \ + _CLC_VECTOR_VSTORE_PRIM3(, PRIM_TYPE, PRIM_TYPE, ) + +#define _CLC_VECTOR_VSTORE_HALF_PRIM1(PRIM_TYPE, RND) \ + _CLC_VSTORE_DECL(_half, half, PRIM_TYPE, , __private, RND) \ + _CLC_VSTORE_DECL(_half, half, PRIM_TYPE, , __local, RND) \ + _CLC_VSTORE_DECL(_half, half, PRIM_TYPE, , __global, RND) \ + _CLC_VSTORE_GENERIC_DECL(_half, half, PRIM_TYPE, , __generic, RND) \ + _CLC_VECTOR_VSTORE_PRIM3(_half, half, PRIM_TYPE, RND) \ + _CLC_VSTORE_DECL(a_half, half, PRIM_TYPE, , __private, RND) \ + _CLC_VSTORE_DECL(a_half, half, PRIM_TYPE, , __local, RND) \ + _CLC_VSTORE_DECL(a_half, half, PRIM_TYPE, , __global, RND) \ + _CLC_VSTORE_GENERIC_DECL(a_half, half, PRIM_TYPE, , __generic, RND) \ + _CLC_VECTOR_VSTORE_PRIM3(a_half, half, PRIM_TYPE, RND) + +_CLC_VECTOR_VSTORE_PRIM1(char) +_CLC_VECTOR_VSTORE_PRIM1(uchar) +_CLC_VECTOR_VSTORE_PRIM1(short) +_CLC_VECTOR_VSTORE_PRIM1(ushort) +_CLC_VECTOR_VSTORE_PRIM1(int) +_CLC_VECTOR_VSTORE_PRIM1(uint) +_CLC_VECTOR_VSTORE_PRIM1(long) +_CLC_VECTOR_VSTORE_PRIM1(ulong) +_CLC_VECTOR_VSTORE_PRIM1(float) + +_CLC_VECTOR_VSTORE_HALF_PRIM1(float, ) +_CLC_VECTOR_VSTORE_HALF_PRIM1(float, _rtz) +_CLC_VECTOR_VSTORE_HALF_PRIM1(float, _rtn) +_CLC_VECTOR_VSTORE_HALF_PRIM1(float, _rtp) +_CLC_VECTOR_VSTORE_HALF_PRIM1(float, _rte) + +#ifdef cl_khr_fp64 +_CLC_VECTOR_VSTORE_PRIM1(double) +_CLC_VECTOR_VSTORE_HALF_PRIM1(double, ) +_CLC_VECTOR_VSTORE_HALF_PRIM1(double, _rtz) +_CLC_VECTOR_VSTORE_HALF_PRIM1(double, _rtn) +_CLC_VECTOR_VSTORE_HALF_PRIM1(double, _rtp) +_CLC_VECTOR_VSTORE_HALF_PRIM1(double, _rte) +#endif + +#ifdef cl_khr_fp16 +_CLC_VECTOR_VSTORE_PRIM1(half) +#endif + +#undef _CLC_VSTORE_DECL +#undef _CLC_VSTORE_GENERIC_DECL +#undef _CLC_VECTOR_VSTORE_DECL +#undef _CLC_VECTOR_VSTORE_PRIM3 +#undef _CLC_VECTOR_VSTORE_PRIM1 +#undef _CLC_VECTOR_VSTORE_GENERIC_DECL + +#endif // __CLC_OPENCL_SHARED_VSTORE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/synchronization/barrier.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/synchronization/barrier.h new file mode 100644 index 0000000000..728ba4ae8a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/synchronization/barrier.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_SYNCHRONIZATION_BARRIER_H__ +#define __CLC_OPENCL_SYNCHRONIZATION_BARRIER_H__ + +#include +#include + +_CLC_DECL _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags); + +#endif // __CLC_OPENCL_SYNCHRONIZATION_BARRIER_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/synchronization/cl_mem_fence_flags.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/synchronization/cl_mem_fence_flags.h new file mode 100644 index 0000000000..6636515fca --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/synchronization/cl_mem_fence_flags.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_SYNCHRONIZATION_CL_MEM_FENCE_FLAGS_H__ +#define __CLC_OPENCL_SYNCHRONIZATION_CL_MEM_FENCE_FLAGS_H__ + +typedef uint cl_mem_fence_flags; + +#define CLK_LOCAL_MEM_FENCE 1 +#define CLK_GLOBAL_MEM_FENCE 2 + +#endif // __CLC_OPENCL_SYNCHRONIZATION_CL_MEM_FENCE_FLAGS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_global_id.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_global_id.h new file mode 100644 index 0000000000..98217c0ba6 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_global_id.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_GLOBAL_ID_H__ +#define __CLC_OPENCL_WORKITEM_GET_GLOBAL_ID_H__ + +#include + +_CLC_DECL _CLC_OVERLOAD size_t get_global_id(uint dim); + +#endif // __CLC_OPENCL_WORKITEM_GET_GLOBAL_ID_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_global_offset.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_global_offset.h new file mode 100644 index 0000000000..8c820331e6 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_global_offset.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_GLOBAL_OFFSET_H__ +#define __CLC_OPENCL_WORKITEM_GET_GLOBAL_OFFSET_H__ + +#include + +_CLC_DECL _CLC_OVERLOAD size_t get_global_offset(uint dim); + +#endif // __CLC_OPENCL_WORKITEM_GET_GLOBAL_OFFSET_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_global_size.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_global_size.h new file mode 100644 index 0000000000..5c7426047d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_global_size.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_GLOBAL_SIZE_H__ +#define __CLC_OPENCL_WORKITEM_GET_GLOBAL_SIZE_H__ + +#include + +_CLC_DECL _CLC_OVERLOAD size_t get_global_size(uint dim); + +#endif // __CLC_OPENCL_WORKITEM_GET_GLOBAL_SIZE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_group_id.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_group_id.h new file mode 100644 index 0000000000..3d0f51aeb8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_group_id.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_GROUP_ID_H__ +#define __CLC_OPENCL_WORKITEM_GET_GROUP_ID_H__ + +#include + +_CLC_DECL _CLC_OVERLOAD size_t get_group_id(uint dim); + +#endif // __CLC_OPENCL_WORKITEM_GET_GROUP_ID_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_local_id.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_local_id.h new file mode 100644 index 0000000000..31fe9d2943 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_local_id.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_LOCAL_ID_H__ +#define __CLC_OPENCL_WORKITEM_GET_LOCAL_ID_H__ + +#include + +_CLC_DECL _CLC_OVERLOAD size_t get_local_id(uint dim); + +#endif // __CLC_OPENCL_WORKITEM_GET_LOCAL_ID_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_local_linear_id.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_local_linear_id.h new file mode 100644 index 0000000000..9a32aa46b8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_local_linear_id.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_LOCAL_LINEAR_ID_H__ +#define __CLC_OPENCL_WORKITEM_GET_LOCAL_LINEAR_ID_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL size_t get_local_linear_id(); + +#endif // __CLC_OPENCL_WORKITEM_GET_LOCAL_LINEAR_ID_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_local_size.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_local_size.h new file mode 100644 index 0000000000..c93a7a27bd --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_local_size.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_LOCAL_SIZE_H__ +#define __CLC_OPENCL_WORKITEM_GET_LOCAL_SIZE_H__ + +#include + +_CLC_DECL _CLC_OVERLOAD size_t get_local_size(uint dim); + +#endif // __CLC_OPENCL_WORKITEM_GET_LOCAL_SIZE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_max_sub_group_size.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_max_sub_group_size.h new file mode 100644 index 0000000000..140f22426e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_max_sub_group_size.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_MAX_SUB_GROUP_SIZE_H__ +#define __CLC_OPENCL_WORKITEM_GET_MAX_SUB_GROUP_SIZE_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL uint get_max_sub_group_size(); + +#endif // __CLC_OPENCL_WORKITEM_GET_MAX_SUB_GROUP_SIZE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_num_groups.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_num_groups.h new file mode 100644 index 0000000000..0c47a5ef46 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_num_groups.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_NUM_GROUPS_H__ +#define __CLC_OPENCL_WORKITEM_GET_NUM_GROUPS_H__ + +#include + +_CLC_DECL _CLC_OVERLOAD size_t get_num_groups(uint dim); + +#endif // __CLC_OPENCL_WORKITEM_GET_NUM_GROUPS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_num_sub_groups.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_num_sub_groups.h new file mode 100644 index 0000000000..5c72db0b40 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_num_sub_groups.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_NUM_SUB_GROUPS_H__ +#define __CLC_OPENCL_WORKITEM_GET_NUM_SUB_GROUPS_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL uint get_num_sub_groups(); + +#endif // __CLC_OPENCL_WORKITEM_GET_NUM_SUB_GROUPS_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_sub_group_id.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_sub_group_id.h new file mode 100644 index 0000000000..3dbf39b8cf --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_sub_group_id.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_SUB_GROUP_ID_H__ +#define __CLC_OPENCL_WORKITEM_GET_SUB_GROUP_ID_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL uint get_sub_group_id(); + +#endif // __CLC_OPENCL_WORKITEM_GET_SUB_GROUP_ID_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_sub_group_local_id.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_sub_group_local_id.h new file mode 100644 index 0000000000..7e139a857a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_sub_group_local_id.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_SUB_GROUP_LOCAL_ID_H__ +#define __CLC_OPENCL_WORKITEM_GET_SUB_GROUP_LOCAL_ID_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL uint get_sub_group_local_id(); + +#endif // __CLC_OPENCL_WORKITEM_GET_SUB_GROUP_LOCAL_ID_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_sub_group_size.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_sub_group_size.h new file mode 100644 index 0000000000..dd4f89da18 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_sub_group_size.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_SUB_GROUP_SIZE_H__ +#define __CLC_OPENCL_WORKITEM_GET_SUB_GROUP_SIZE_H__ + +#include + +_CLC_OVERLOAD _CLC_DECL uint get_sub_group_size(); + +#endif // __CLC_OPENCL_WORKITEM_GET_SUB_GROUP_SIZE_H__ diff --git a/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_work_dim.h b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_work_dim.h new file mode 100644 index 0000000000..c4c3c1b224 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/include/clc/opencl/workitem/get_work_dim.h @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_OPENCL_WORKITEM_GET_WORK_DIM_H__ +#define __CLC_OPENCL_WORKITEM_GET_WORK_DIM_H__ + +#include + +_CLC_DECL _CLC_OVERLOAD uint get_work_dim(void); + +#endif // __CLC_OPENCL_WORKITEM_GET_WORK_DIM_H__ diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/SOURCES b/local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/SOURCES new file mode 100644 index 0000000000..8224b7721b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/SOURCES @@ -0,0 +1,3 @@ +workitem/get_global_size.cl +workitem/get_local_size.cl +workitem/get_num_groups.cl diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/workitem/get_global_size.cl b/local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/workitem/get_global_size.cl new file mode 100644 index 0000000000..8f9b47978c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/workitem/get_global_size.cl @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#if __clang_major__ >= 8 +#define CONST_AS __constant +#elif __clang_major__ >= 7 +#define CONST_AS __attribute__((address_space(4))) +#else +#define CONST_AS __attribute__((address_space(2))) +#endif + +#if __clang_major__ >= 6 +#define __dispatch_ptr __builtin_amdgcn_dispatch_ptr +#else +#define __dispatch_ptr __clc_amdgcn_dispatch_ptr +CONST_AS uchar * +__clc_amdgcn_dispatch_ptr(void) __asm("llvm.amdgcn.dispatch.ptr"); +#endif + +_CLC_DEF _CLC_OVERLOAD size_t get_global_size(uint dim) { + CONST_AS uint *ptr = (CONST_AS uint *)__dispatch_ptr(); + if (dim < 3) + return ptr[3 + dim]; + return 1; +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/workitem/get_local_size.cl b/local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/workitem/get_local_size.cl new file mode 100644 index 0000000000..fd30e6ab7a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/workitem/get_local_size.cl @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#if __clang_major__ >= 8 +#define CONST_AS __constant +#elif __clang_major__ >= 7 +#define CONST_AS __attribute__((address_space(4))) +#else +#define CONST_AS __attribute__((address_space(2))) +#endif + +#if __clang_major__ >= 6 +#define __dispatch_ptr __builtin_amdgcn_dispatch_ptr +#else +#define __dispatch_ptr __clc_amdgcn_dispatch_ptr +CONST_AS char * +__clc_amdgcn_dispatch_ptr(void) __asm("llvm.amdgcn.dispatch.ptr"); +#endif + +_CLC_DEF _CLC_OVERLOAD size_t get_local_size(uint dim) { + CONST_AS uint *ptr = (CONST_AS uint *)__dispatch_ptr(); + switch (dim) { + case 0: + return ptr[1] & 0xffffu; + case 1: + return ptr[1] >> 16; + case 2: + return ptr[2] & 0xffffu; + } + return 1; +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/workitem/get_num_groups.cl b/local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/workitem/get_num_groups.cl new file mode 100644 index 0000000000..a88dae97c7 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn-amdhsa/workitem/get_num_groups.cl @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +_CLC_DEF _CLC_OVERLOAD size_t get_num_groups(uint dim) { + size_t global_size = get_global_size(dim); + size_t local_size = get_local_size(dim); + size_t num_groups = global_size / local_size; + if (global_size % local_size != 0) { + num_groups++; + } + return num_groups; +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn/SOURCES b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/SOURCES new file mode 100644 index 0000000000..213f62cc73 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/SOURCES @@ -0,0 +1,10 @@ +cl_khr_int64_extended_atomics/minmax_helpers.ll +mem_fence/fence.cl +synchronization/barrier.cl +workitem/get_global_offset.cl +workitem/get_group_id.cl +workitem/get_global_size.cl +workitem/get_local_id.cl +workitem/get_local_size.cl +workitem/get_num_groups.cl +workitem/get_work_dim.cl diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn/cl_khr_int64_extended_atomics/minmax_helpers.ll b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/cl_khr_int64_extended_atomics/minmax_helpers.ll new file mode 100644 index 0000000000..3ed5e99be3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/cl_khr_int64_extended_atomics/minmax_helpers.ll @@ -0,0 +1,55 @@ +;;===----------------------------------------------------------------------===;; +; +; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +; See https://llvm.org/LICENSE.txt for license information. +; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +; +;;===----------------------------------------------------------------------===;; + +define i64 @__clc__sync_fetch_and_min_global_8(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile min i64 addrspace(1)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_umin_global_8(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile umin i64 addrspace(1)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_min_local_8(i64 addrspace(3)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile min i64 addrspace(3)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_umin_local_8(i64 addrspace(3)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile umin i64 addrspace(3)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_max_global_8(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile max i64 addrspace(1)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_umax_global_8(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile umax i64 addrspace(1)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_max_local_8(i64 addrspace(3)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile max i64 addrspace(3)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_umax_local_8(i64 addrspace(3)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile umax i64 addrspace(3)* %ptr, i64 %value seq_cst + ret i64 %0 +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn/mem_fence/fence.cl b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/mem_fence/fence.cl new file mode 100644 index 0000000000..88b953005a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/mem_fence/fence.cl @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +void __clc_amdgcn_s_waitcnt(unsigned flags); + +// s_waitcnt takes 16bit argument with a combined number of maximum allowed +// pending operations: +// [12:8] LGKM -- LDS, GDS, Konstant (SMRD), Messages +// [7] -- undefined +// [6:4] -- exports, GDS, and mem write +// [3:0] -- vector memory operations + +// Newer clang supports __builtin_amdgcn_s_waitcnt +#if __clang_major__ >= 5 +#define __waitcnt(x) __builtin_amdgcn_s_waitcnt(x) +#else +#define __waitcnt(x) __clc_amdgcn_s_waitcnt(x) +_CLC_DEF void __clc_amdgcn_s_waitcnt(unsigned) __asm("llvm.amdgcn.s.waitcnt"); +#endif + +_CLC_DEF _CLC_OVERLOAD void mem_fence(cl_mem_fence_flags flags) { + if (flags & CLK_GLOBAL_MEM_FENCE) { + // scalar loads are counted with LGKM but we don't know whether + // the compiler turned any loads to scalar + __waitcnt(0); + } else if (flags & CLK_LOCAL_MEM_FENCE) + __waitcnt(0xff); // LGKM is [12:8] +} +#undef __waitcnt + +// We don't have separate mechanism for read and write fences +_CLC_DEF _CLC_OVERLOAD void read_mem_fence(cl_mem_fence_flags flags) { + mem_fence(flags); +} + +_CLC_DEF _CLC_OVERLOAD void write_mem_fence(cl_mem_fence_flags flags) { + mem_fence(flags); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn/synchronization/barrier.cl b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/synchronization/barrier.cl new file mode 100644 index 0000000000..5203db72f4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/synchronization/barrier.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEF _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags) { + mem_fence(flags); + __builtin_amdgcn_s_barrier(); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_global_offset.cl b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_global_offset.cl new file mode 100644 index 0000000000..68a37f5f8f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_global_offset.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEF _CLC_OVERLOAD size_t get_global_offset(uint dim) { + return __clc_get_global_offset(dim); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_global_size.cl b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_global_size.cl new file mode 100644 index 0000000000..94dd886ea8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_global_size.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEF _CLC_OVERLOAD size_t get_global_size(uint dim) { + return __clc_get_global_size(dim); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_group_id.cl b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_group_id.cl new file mode 100644 index 0000000000..fb466aa125 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_group_id.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEF _CLC_OVERLOAD size_t get_group_id(uint dim) { + return __clc_get_group_id(dim); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_local_id.cl b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_local_id.cl new file mode 100644 index 0000000000..bdaf202ac0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_local_id.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEF _CLC_OVERLOAD size_t get_local_id(uint dim) { + return __clc_get_local_id(dim); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_local_size.cl b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_local_size.cl new file mode 100644 index 0000000000..aeaa383ce2 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_local_size.cl @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +uint __clc_amdgcn_get_local_size_x(void) __asm("llvm.r600.read.local.size.x"); +uint __clc_amdgcn_get_local_size_y(void) __asm("llvm.r600.read.local.size.y"); +uint __clc_amdgcn_get_local_size_z(void) __asm("llvm.r600.read.local.size.z"); + +_CLC_DEF _CLC_OVERLOAD size_t get_local_size(uint dim) { + switch (dim) { + case 0: + return __clc_amdgcn_get_local_size_x(); + case 1: + return __clc_amdgcn_get_local_size_y(); + case 2: + return __clc_amdgcn_get_local_size_z(); + default: + return 1; + } +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_num_groups.cl b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_num_groups.cl new file mode 100644 index 0000000000..3d602fb821 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_num_groups.cl @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +uint __clc_amdgcn_get_num_groups_x(void) __asm("llvm.r600.read.ngroups.x"); +uint __clc_amdgcn_get_num_groups_y(void) __asm("llvm.r600.read.ngroups.y"); +uint __clc_amdgcn_get_num_groups_z(void) __asm("llvm.r600.read.ngroups.z"); + +_CLC_DEF _CLC_OVERLOAD size_t get_num_groups(uint dim) { + switch (dim) { + case 0: + return __clc_amdgcn_get_num_groups_x(); + case 1: + return __clc_amdgcn_get_num_groups_y(); + case 2: + return __clc_amdgcn_get_num_groups_z(); + default: + return 1; + } +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_work_dim.cl b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_work_dim.cl new file mode 100644 index 0000000000..d3477a5e95 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/amdgcn/workitem/get_work_dim.cl @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEF _CLC_OVERLOAD uint get_work_dim() { return __clc_get_work_dim(); } diff --git a/local/recipes/dev/libclc/source/opencl/lib/clspv/SOURCES b/local/recipes/dev/libclc/source/opencl/lib/clspv/SOURCES new file mode 100644 index 0000000000..0a142ed3e6 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/clspv/SOURCES @@ -0,0 +1,73 @@ +math/fma.cl +shared/vstore_half.cl +subnormal_config.cl +../generic/geometric/distance.cl +../generic/geometric/length.cl +../generic/math/acos.cl +../generic/math/acosh.cl +../generic/math/asinh.cl +../generic/math/acospi.cl +../generic/math/asin.cl +../generic/math/atan.cl +../generic/math/asinh.cl +../generic/math/asinpi.cl +../generic/math/atan2.cl +../generic/math/atan2pi.cl +../generic/math/atanh.cl +../generic/math/atanpi.cl +../generic/math/cbrt.cl +../generic/math/cos.cl +../generic/math/cosh.cl +../generic/math/cospi.cl +../generic/math/erf.cl +../generic/math/erfc.cl +../generic/math/exp.cl +../generic/math/exp10.cl +../generic/math/exp2.cl +../generic/math/expm1.cl +../generic/math/fdim.cl +../generic/math/fmod.cl +../generic/math/fract.cl +../generic/math/frexp.cl +../generic/math/half_cos.cl +../generic/math/half_divide.cl +../generic/math/half_exp.cl +../generic/math/half_exp10.cl +../generic/math/half_exp2.cl +../generic/math/half_log.cl +../generic/math/half_log10.cl +../generic/math/half_log2.cl +../generic/math/half_powr.cl +../generic/math/half_recip.cl +../generic/math/half_sin.cl +../generic/math/half_sqrt.cl +../generic/math/half_tan.cl +../generic/math/hypot.cl +../generic/math/ilogb.cl +../generic/math/ldexp.cl +../generic/math/lgamma.cl +../generic/math/lgamma_r.cl +../generic/math/log.cl +../generic/math/log10.cl +../generic/math/log1p.cl +../generic/math/log2.cl +../generic/math/logb.cl +../generic/math/maxmag.cl +../generic/math/minmag.cl +../generic/math/modf.cl +../generic/math/nan.cl +../generic/math/nextafter.cl +../generic/math/pow.cl +../generic/math/pown.cl +../generic/math/powr.cl +../generic/math/remainder.cl +../generic/math/remquo.cl +../generic/math/rootn.cl +../generic/math/sin.cl +../generic/math/sincos.cl +../generic/math/sinh.cl +../generic/math/sinpi.cl +../generic/math/tan.cl +../generic/math/tanh.cl +../generic/math/tanpi.cl +../generic/math/tgamma.cl diff --git a/local/recipes/dev/libclc/source/opencl/lib/clspv/math/fma.cl b/local/recipes/dev/libclc/source/opencl/lib/clspv/math/fma.cl new file mode 100644 index 0000000000..83504f6377 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/clspv/math/fma.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION fma +#define __IMPL_FUNCTION(x) __clc_sw_fma +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/clspv/shared/vstore_half.cl b/local/recipes/dev/libclc/source/opencl/lib/clspv/shared/vstore_half.cl new file mode 100644 index 0000000000..df5f30a711 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/clspv/shared/vstore_half.cl @@ -0,0 +1,150 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable + +#define ROUND_VEC1(out, in, ROUNDF) out = ROUNDF(in); +#define ROUND_VEC2(out, in, ROUNDF) \ + ROUND_VEC1(out.lo, in.lo, ROUNDF); \ + ROUND_VEC1(out.hi, in.hi, ROUNDF); +#define ROUND_VEC3(out, in, ROUNDF) \ + ROUND_VEC1(out.s0, in.s0, ROUNDF); \ + ROUND_VEC1(out.s1, in.s1, ROUNDF); \ + ROUND_VEC1(out.s2, in.s2, ROUNDF); +#define ROUND_VEC4(out, in, ROUNDF) \ + ROUND_VEC2(out.lo, in.lo, ROUNDF); \ + ROUND_VEC2(out.hi, in.hi, ROUNDF); +#define ROUND_VEC8(out, in, ROUNDF) \ + ROUND_VEC4(out.lo, in.lo, ROUNDF); \ + ROUND_VEC4(out.hi, in.hi, ROUNDF); +#define ROUND_VEC16(out, in, ROUNDF) \ + ROUND_VEC8(out.lo, in.lo, ROUNDF); \ + ROUND_VEC8(out.hi, in.hi, ROUNDF); + +#define __FUNC(SUFFIX, VEC_SIZE, TYPE, AS, ROUNDF) \ + void _CLC_OVERLOAD vstore_half_##VEC_SIZE(TYPE, size_t, AS half *); \ + _CLC_OVERLOAD _CLC_DEF void vstore_half##SUFFIX(TYPE vec, size_t offset, \ + AS half *mem) { \ + TYPE rounded_vec; \ + ROUND_VEC##VEC_SIZE(rounded_vec, vec, ROUNDF); \ + vstore_half_##VEC_SIZE(rounded_vec, offset, mem); \ + } \ + void _CLC_OVERLOAD vstorea_half_##VEC_SIZE(TYPE, size_t, AS half *); \ + _CLC_OVERLOAD _CLC_DEF void vstorea_half##SUFFIX(TYPE vec, size_t offset, \ + AS half *mem) { \ + TYPE rounded_vec; \ + ROUND_VEC##VEC_SIZE(rounded_vec, vec, ROUNDF); \ + vstorea_half_##VEC_SIZE(rounded_vec, offset, mem); \ + } + +_CLC_DEF _CLC_OVERLOAD float __clc_rtz(float x) { + /* Handle nan corner case */ + if (isnan(x)) + return x; + /* RTZ does not produce Inf for large numbers */ + if (fabs(x) > 65504.0f && !isinf(x)) + return copysign(65504.0f, x); + + const int exp = (as_uint(x) >> 23 & 0xff) - 127; + /* Manage range rounded to +- zero explicitely */ + if (exp < -24) + return copysign(0.0f, x); + + /* Remove lower 13 bits to make sure the number is rounded down */ + int mask = 0xffffe000; + /* Denormals cannot be flushed, and they use different bit for rounding */ + if (exp < -14) + mask <<= min(-(exp + 14), 10); + + return as_float(as_uint(x) & mask); +} + +_CLC_DEF _CLC_OVERLOAD float __clc_rti(float x) { + /* Handle nan corner case */ + if (isnan(x)) + return x; + + const float inf = copysign(INFINITY, x); + uint ux = as_uint(x); + + /* Manage +- infinity explicitely */ + if (as_float(ux & 0x7fffffff) > 0x1.ffcp+15f) { + return inf; + } + /* Manage +- zero explicitely */ + if ((ux & 0x7fffffff) == 0) { + return copysign(0.0f, x); + } + + const int exp = (as_uint(x) >> 23 & 0xff) - 127; + /* Manage range rounded to smallest half denormal explicitely */ + if (exp < -24) { + return copysign(0x1.0p-24f, x); + } + + /* Set lower 13 bits */ + int mask = (1 << 13) - 1; + /* Denormals cannot be flushed, and they use different bit for rounding */ + if (exp < -14) { + mask = (1 << (13 + min(-(exp + 14), 10))) - 1; + } + + const float next = nextafter(as_float(ux | mask), inf); + return ((ux & mask) == 0) ? as_float(ux) : next; +} +_CLC_DEF _CLC_OVERLOAD float __clc_rtn(float x) { + return ((as_uint(x) & 0x80000000) == 0) ? __clc_rtz(x) : __clc_rti(x); +} +_CLC_DEF _CLC_OVERLOAD float __clc_rtp(float x) { + return ((as_uint(x) & 0x80000000) == 0) ? __clc_rti(x) : __clc_rtz(x); +} +_CLC_DEF _CLC_OVERLOAD float __clc_rte(float x) { + /* Mantisa + implicit bit */ + const uint mantissa = (as_uint(x) & 0x7fffff) | (1u << 23); + const int exp = (as_uint(x) >> 23 & 0xff) - 127; + int shift = 13; + if (exp < -14) { + /* The default assumes lower 13 bits are rounded, + * but it might be more for denormals. + * Shifting beyond last == 0b, and qr == 00b is not necessary */ + shift += min(-(exp + 14), 15); + } + int mask = (1 << shift) - 1; + const uint grs = mantissa & mask; + const uint last = mantissa & (1 << shift); + /* IEEE round up rule is: grs > 101b or grs == 100b and last == 1. + * exp > 15 should round to inf. */ + bool roundup = (grs > (1 << (shift - 1))) || + (grs == (1 << (shift - 1)) && last != 0) || (exp > 15); + return roundup ? __clc_rti(x) : __clc_rtz(x); +} + +#define __XFUNC(SUFFIX, VEC_SIZE, TYPE, AS) \ + __FUNC(SUFFIX, VEC_SIZE, TYPE, AS, __clc_rte) \ + __FUNC(SUFFIX##_rtz, VEC_SIZE, TYPE, AS, __clc_rtz) \ + __FUNC(SUFFIX##_rtn, VEC_SIZE, TYPE, AS, __clc_rtn) \ + __FUNC(SUFFIX##_rtp, VEC_SIZE, TYPE, AS, __clc_rtp) \ + __FUNC(SUFFIX##_rte, VEC_SIZE, TYPE, AS, __clc_rte) + +#define FUNC(SUFFIX, VEC_SIZE, TYPE, AS) __XFUNC(SUFFIX, VEC_SIZE, TYPE, AS) + +#define __CLC_BODY "vstore_half.inc" +#include +#undef FUNC +#undef __XFUNC +#undef __FUNC diff --git a/local/recipes/dev/libclc/source/opencl/lib/clspv/shared/vstore_half.inc b/local/recipes/dev/libclc/source/opencl/lib/clspv/shared/vstore_half.inc new file mode 100644 index 0000000000..f2c0274824 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/clspv/shared/vstore_half.inc @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// This does exist only for fp32 +#if __CLC_FPSIZE == 32 +#ifndef __CLC_SCALAR + +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __private); +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __local); +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __global); +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __generic); +#endif + +#undef __CLC_OFFSET +#else +FUNC(, 1, __CLC_GENTYPE, __private); +FUNC(, 1, __CLC_GENTYPE, __local); +FUNC(, 1, __CLC_GENTYPE, __global); +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +FUNC(, 1, __CLC_GENTYPE, __generic); +#endif +#endif +#endif diff --git a/local/recipes/dev/libclc/source/opencl/lib/clspv/subnormal_config.cl b/local/recipes/dev/libclc/source/opencl/lib/clspv/subnormal_config.cl new file mode 100644 index 0000000000..114aabb2e9 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/clspv/subnormal_config.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEF bool __clc_fp16_subnormals_supported() { return false; } + +_CLC_DEF bool __clc_fp32_subnormals_supported() { return false; } + +_CLC_DEF bool __clc_fp64_subnormals_supported() { return false; } diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/SOURCES b/local/recipes/dev/libclc/source/opencl/lib/generic/SOURCES new file mode 100644 index 0000000000..46ce6d6e36 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/SOURCES @@ -0,0 +1,180 @@ +subnormal_config.cl +subnormal_helper_func.ll +async/async_work_group_copy.cl +async/async_work_group_strided_copy.cl +async/prefetch.cl +async/wait_group_events.cl +atomic/atom_add.cl +atomic/atom_and.cl +atomic/atom_cmpxchg.cl +atomic/atom_dec.cl +atomic/atom_inc.cl +atomic/atom_max.cl +atomic/atom_min.cl +atomic/atom_or.cl +atomic/atom_sub.cl +atomic/atom_xchg.cl +atomic/atom_xor.cl +atomic/atomic_add.cl +atomic/atomic_and.cl +atomic/atomic_cmpxchg.cl +atomic/atomic_dec.cl +atomic/atomic_inc.cl +atomic/atomic_max.cl +atomic/atomic_min.cl +atomic/atomic_or.cl +atomic/atomic_sub.cl +atomic/atomic_xchg.cl +atomic/atomic_xor.cl +common/degrees.cl +common/mix.cl +common/radians.cl +common/sign.cl +common/smoothstep.cl +common/step.cl +geometric/cross.cl +geometric/distance.cl +geometric/dot.cl +geometric/fast_distance.cl +geometric/fast_length.cl +geometric/fast_normalize.cl +geometric/length.cl +geometric/normalize.cl +integer/abs.cl +integer/abs_diff.cl +integer/add_sat.cl +integer/clz.cl +integer/ctz.cl +integer/hadd.cl +integer/mad24.cl +integer/mad_hi.cl +integer/mad_sat.cl +integer/mul24.cl +integer/mul_hi.cl +integer/popcount.cl +integer/rhadd.cl +integer/rotate.cl +integer/sub_sat.cl +integer/upsample.cl +math/acos.cl +math/acosh.cl +math/acospi.cl +math/asin.cl +math/asinh.cl +math/asinpi.cl +math/atan.cl +math/atan2.cl +math/atan2pi.cl +math/atanh.cl +math/atanpi.cl +math/cbrt.cl +math/ceil.cl +math/copysign.cl +math/cos.cl +math/cosh.cl +math/cospi.cl +math/erf.cl +math/erfc.cl +math/exp.cl +math/expm1.cl +math/exp2.cl +math/exp10.cl +math/fabs.cl +math/fdim.cl +math/floor.cl +math/fma.cl +math/fmax.cl +math/fmin.cl +math/fmod.cl +math/fract.cl +math/frexp.cl +math/half_cos.cl +math/half_divide.cl +math/half_exp.cl +math/half_exp10.cl +math/half_exp2.cl +math/half_log.cl +math/half_log10.cl +math/half_log2.cl +math/half_powr.cl +math/half_recip.cl +math/half_rsqrt.cl +math/half_sin.cl +math/half_sqrt.cl +math/half_tan.cl +math/hypot.cl +math/ilogb.cl +math/ldexp.cl +math/lgamma.cl +math/lgamma_r.cl +math/log.cl +math/log10.cl +math/log1p.cl +math/log2.cl +math/logb.cl +math/mad.cl +math/maxmag.cl +math/minmag.cl +math/modf.cl +math/nan.cl +math/native_cos.cl +math/native_divide.cl +math/native_exp.cl +math/native_exp10.cl +math/native_exp2.cl +math/native_log.cl +math/native_log10.cl +math/native_log2.cl +math/native_powr.cl +math/native_recip.cl +math/native_rsqrt.cl +math/native_sin.cl +math/native_sqrt.cl +math/native_tan.cl +math/nextafter.cl +math/pow.cl +math/pown.cl +math/powr.cl +math/remainder.cl +math/remquo.cl +math/rint.cl +math/rootn.cl +math/round.cl +math/rsqrt.cl +math/sin.cl +math/sincos.cl +math/sinh.cl +math/sinpi.cl +math/sqrt.cl +math/tan.cl +math/tanh.cl +math/tanpi.cl +math/tgamma.cl +math/trunc.cl +misc/shuffle.cl +misc/shuffle2.cl +relational/all.cl +relational/any.cl +relational/bitselect.cl +relational/isequal.cl +relational/isfinite.cl +relational/isgreater.cl +relational/isgreaterequal.cl +relational/isinf.cl +relational/isless.cl +relational/islessequal.cl +relational/islessgreater.cl +relational/isnan.cl +relational/isnormal.cl +relational/isnotequal.cl +relational/isordered.cl +relational/isunordered.cl +relational/select.cl +relational/signbit.cl +shared/clamp.cl +shared/max.cl +shared/min.cl +shared/vload.cl +shared/vstore.cl +workitem/get_global_id.cl +workitem/get_global_size.cl diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_copy.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_copy.cl new file mode 100644 index 0000000000..67eadf5e25 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_copy.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_copy.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_copy.inc new file mode 100644 index 0000000000..f238ae6684 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_copy.inc @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF event_t +async_work_group_copy(local __CLC_GENTYPE *dst, const global __CLC_GENTYPE *src, + size_t num_gentypes, event_t event) { + + return async_work_group_strided_copy(dst, src, num_gentypes, 1, event); +} + +_CLC_OVERLOAD _CLC_DEF event_t +async_work_group_copy(global __CLC_GENTYPE *dst, const local __CLC_GENTYPE *src, + size_t num_gentypes, event_t event) { + + return async_work_group_strided_copy(dst, src, num_gentypes, 1, event); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_strided_copy.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_strided_copy.cl new file mode 100644 index 0000000000..2c17e2a685 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_strided_copy.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_strided_copy.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_strided_copy.inc new file mode 100644 index 0000000000..3a3f36a7d0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/async/async_work_group_strided_copy.inc @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#define STRIDED_COPY(dst, src, num_gentypes, dst_stride, src_stride) \ + size_t size = get_local_size(0) * get_local_size(1) * get_local_size(2); \ + size_t id = (get_local_size(1) * get_local_size(2) * get_local_id(0)) + \ + (get_local_size(2) * get_local_id(1)) + get_local_id(2); \ + size_t i; \ + \ + for (i = id; i < num_gentypes; i += size) { \ + dst[i * dst_stride] = src[i * src_stride]; \ + } + +_CLC_OVERLOAD _CLC_DEF event_t async_work_group_strided_copy( + local __CLC_GENTYPE *dst, const global __CLC_GENTYPE *src, + size_t num_gentypes, size_t src_stride, event_t event) { + + STRIDED_COPY(dst, src, num_gentypes, 1, src_stride); + return event; +} + +_CLC_OVERLOAD _CLC_DEF event_t async_work_group_strided_copy( + global __CLC_GENTYPE *dst, const local __CLC_GENTYPE *src, + size_t num_gentypes, size_t dst_stride, event_t event) { + + STRIDED_COPY(dst, src, num_gentypes, dst_stride, 1); + return event; +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/async/prefetch.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/async/prefetch.cl new file mode 100644 index 0000000000..8ab2101205 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/async/prefetch.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/async/prefetch.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/async/prefetch.inc new file mode 100644 index 0000000000..61be19bbfb --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/async/prefetch.inc @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF void prefetch(const global __CLC_GENTYPE *p, + size_t num_gentypes) { + __clc_prefetch(p, num_gentypes); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/async/wait_group_events.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/async/wait_group_events.cl new file mode 100644 index 0000000000..00b8ddf334 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/async/wait_group_events.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEF _CLC_OVERLOAD void wait_group_events(int num_events, + event_t *event_list) { + barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_add.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_add.cl new file mode 100644 index 0000000000..65d7ad595a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_add.cl @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#ifdef cl_khr_global_int32_base_atomics +#define __CLC_ATOMIC_OP add +#define __CLC_ATOMIC_ADDRESS_SPACE global +#include "atom_int32_binary.inc" +#endif // cl_khr_global_int32_base_atomics + +#ifdef cl_khr_local_int32_base_atomics +#define __CLC_ATOMIC_OP add +#define __CLC_ATOMIC_ADDRESS_SPACE local +#include "atom_int32_binary.inc" +#endif // cl_khr_local_int32_base_atomics + +#ifdef cl_khr_int64_base_atomics + +#define IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_add(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_add_8(p, val); \ + } + +IMPL(global, long) +IMPL(global, unsigned long) +IMPL(local, long) +IMPL(local, unsigned long) +#undef IMPL + +#endif // cl_khr_int64_base_atomics diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_and.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_and.cl new file mode 100644 index 0000000000..371e5f0aa4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_and.cl @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#ifdef cl_khr_global_int32_extended_atomics +#define __CLC_ATOMIC_OP and +#define __CLC_ATOMIC_ADDRESS_SPACE global +#include "atom_int32_binary.inc" +#endif // cl_khr_global_int32_extended_atomics + +#ifdef cl_khr_local_int32_extended_atomics +#define __CLC_ATOMIC_OP and +#define __CLC_ATOMIC_ADDRESS_SPACE local +#include "atom_int32_binary.inc" +#endif // cl_khr_local_int32_extended_atomics + +#ifdef cl_khr_int64_extended_atomics + +#define IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_and(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_and_8(p, val); \ + } + +IMPL(global, long) +IMPL(global, unsigned long) +IMPL(local, long) +IMPL(local, unsigned long) +#undef IMPL + +#endif // cl_khr_int64_extended_atomics diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_cmpxchg.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_cmpxchg.cl new file mode 100644 index 0000000000..f129be9809 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_cmpxchg.cl @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_cmpxchg(volatile AS TYPE *p, TYPE cmp, \ + TYPE val) { \ + return atomic_cmpxchg(p, cmp, val); \ + } + +#ifdef cl_khr_global_int32_base_atomics +IMPL(global, int) +IMPL(global, unsigned int) +#endif // cl_khr_global_int32_base_atomics +#ifdef cl_khr_local_int32_base_atomics +IMPL(local, int) +IMPL(local, unsigned int) +#endif // cl_khr_local_int32_base_atomics + +#undef IMPL + +#ifdef cl_khr_int64_base_atomics + +#define IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_cmpxchg(volatile AS TYPE *p, TYPE cmp, \ + TYPE val) { \ + return __sync_val_compare_and_swap_8(p, cmp, val); \ + } + +IMPL(global, long) +IMPL(global, unsigned long) +IMPL(local, long) +IMPL(local, unsigned long) +#undef IMPL + +#endif // cl_khr_int64_base_atomics diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_dec.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_dec.cl new file mode 100644 index 0000000000..2df721cae3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_dec.cl @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_dec(volatile AS TYPE *p) { \ + return atomic_dec(p); \ + } + +#ifdef cl_khr_global_int32_base_atomics +IMPL(global, int) +IMPL(global, unsigned int) +#endif // cl_khr_global_int32_base_atomics +#ifdef cl_khr_local_int32_base_atomics +IMPL(local, int) +IMPL(local, unsigned int) +#endif // cl_khr_local_int32_base_atomics + +#undef IMPL + +#ifdef cl_khr_int64_base_atomics + +#define IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_dec(volatile AS TYPE *p) { \ + return atom_sub(p, (TYPE)1); \ + } + +IMPL(global, long) +IMPL(global, unsigned long) +IMPL(local, long) +IMPL(local, unsigned long) +#undef IMPL + +#endif // cl_khr_int64_base_atomics diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_inc.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_inc.cl new file mode 100644 index 0000000000..dc7699a478 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_inc.cl @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_inc(volatile AS TYPE *p) { \ + return atomic_inc(p); \ + } + +#ifdef cl_khr_global_int32_base_atomics +IMPL(global, int) +IMPL(global, unsigned int) +#endif // cl_khr_global_int32_base_atomics +#ifdef cl_khr_local_int32_base_atomics +IMPL(local, int) +IMPL(local, unsigned int) +#endif // cl_khr_local_int32_base_atomics + +#undef IMPL + +#ifdef cl_khr_int64_base_atomics + +#define IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_inc(volatile AS TYPE *p) { \ + return atom_add(p, (TYPE)1); \ + } + +IMPL(global, long) +IMPL(global, unsigned long) +IMPL(local, long) +IMPL(local, unsigned long) +#undef IMPL + +#endif // cl_khr_int64_base_atomics diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_int32_binary.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_int32_binary.inc new file mode 100644 index 0000000000..0afc219026 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_int32_binary.inc @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_ATOM_IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE __CLC_XCONCAT(atom_, __CLC_ATOMIC_OP)( \ + volatile AS TYPE * p, TYPE val) { \ + return __CLC_XCONCAT(atomic_, __CLC_ATOMIC_OP)(p, val); \ + } + +__CLC_ATOM_IMPL(__CLC_ATOMIC_ADDRESS_SPACE, int) +__CLC_ATOM_IMPL(__CLC_ATOMIC_ADDRESS_SPACE, uint) + +#undef __CLC_ATOM_IMPL +#undef __CLC_ATOMIC_OP +#undef __CLC_ATOMIC_ADDRESS_SPACE diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_max.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_max.cl new file mode 100644 index 0000000000..2542191d04 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_max.cl @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#ifdef cl_khr_global_int32_extended_atomics +#define __CLC_ATOMIC_OP max +#define __CLC_ATOMIC_ADDRESS_SPACE global +#include "atom_int32_binary.inc" +#endif // cl_khr_global_int32_extended_atomics + +#ifdef cl_khr_local_int32_extended_atomics +#define __CLC_ATOMIC_OP max +#define __CLC_ATOMIC_ADDRESS_SPACE local +#include "atom_int32_binary.inc" +#endif // cl_khr_local_int32_extended_atomics + +#ifdef cl_khr_int64_extended_atomics + +unsigned long __clc__sync_fetch_and_max_local_8(volatile local long *, long); +unsigned long __clc__sync_fetch_and_max_global_8(volatile global long *, long); +unsigned long __clc__sync_fetch_and_umax_local_8(volatile local unsigned long *, + unsigned long); +unsigned long +__clc__sync_fetch_and_umax_global_8(volatile global unsigned long *, + unsigned long); + +#define IMPL(AS, TYPE, OP) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_max(volatile AS TYPE *p, TYPE val) { \ + return __clc__sync_fetch_and_##OP##_##AS##_8(p, val); \ + } + +IMPL(global, long, max) +IMPL(global, unsigned long, umax) +IMPL(local, long, max) +IMPL(local, unsigned long, umax) +#undef IMPL + +#endif // cl_khr_int64_extended_atomics diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_min.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_min.cl new file mode 100644 index 0000000000..4e62804824 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_min.cl @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#ifdef cl_khr_global_int32_extended_atomics +#define __CLC_ATOMIC_OP min +#define __CLC_ATOMIC_ADDRESS_SPACE global +#include "atom_int32_binary.inc" +#endif // cl_khr_global_int32_extended_atomics + +#ifdef cl_khr_local_int32_extended_atomics +#define __CLC_ATOMIC_OP min +#define __CLC_ATOMIC_ADDRESS_SPACE local +#include "atom_int32_binary.inc" +#endif // cl_khr_local_int32_extended_atomics + +#ifdef cl_khr_int64_extended_atomics + +unsigned long __clc__sync_fetch_and_min_local_8(volatile local long *, long); +unsigned long __clc__sync_fetch_and_min_global_8(volatile global long *, long); +unsigned long __clc__sync_fetch_and_umin_local_8(volatile local unsigned long *, + unsigned long); +unsigned long +__clc__sync_fetch_and_umin_global_8(volatile global unsigned long *, + unsigned long); + +#define IMPL(AS, TYPE, OP) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_min(volatile AS TYPE *p, TYPE val) { \ + return __clc__sync_fetch_and_##OP##_##AS##_8(p, val); \ + } + +IMPL(global, long, min) +IMPL(global, unsigned long, umin) +IMPL(local, long, min) +IMPL(local, unsigned long, umin) +#undef IMPL + +#endif // cl_khr_int64_extended_atomics diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_or.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_or.cl new file mode 100644 index 0000000000..30ad8e52ca --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_or.cl @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#ifdef cl_khr_global_int32_extended_atomics +#define __CLC_ATOMIC_OP or +#define __CLC_ATOMIC_ADDRESS_SPACE global +#include "atom_int32_binary.inc" +#endif // cl_khr_global_int32_extended_atomics + +#ifdef cl_khr_local_int32_extended_atomics +#define __CLC_ATOMIC_OP or +#define __CLC_ATOMIC_ADDRESS_SPACE local +#include "atom_int32_binary.inc" +#endif // cl_khr_local_int32_extended_atomics + +#ifdef cl_khr_int64_extended_atomics + +#define IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_or(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_or_8(p, val); \ + } + +IMPL(global, long) +IMPL(global, unsigned long) +IMPL(local, long) +IMPL(local, unsigned long) +#undef IMPL + +#endif // cl_khr_int64_extended_atomics diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_sub.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_sub.cl new file mode 100644 index 0000000000..f6ee94db74 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_sub.cl @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#ifdef cl_khr_global_int32_base_atomics +#define __CLC_ATOMIC_OP sub +#define __CLC_ATOMIC_ADDRESS_SPACE global +#include "atom_int32_binary.inc" +#endif // cl_khr_global_int32_base_atomics + +#ifdef cl_khr_local_int32_base_atomics +#define __CLC_ATOMIC_OP sub +#define __CLC_ATOMIC_ADDRESS_SPACE local +#include "atom_int32_binary.inc" +#endif // cl_khr_local_int32_base_atomics + +#ifdef cl_khr_int64_base_atomics + +#define IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_sub(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_sub_8(p, val); \ + } + +IMPL(global, long) +IMPL(global, unsigned long) +IMPL(local, long) +IMPL(local, unsigned long) +#undef IMPL + +#endif // cl_khr_int64_base_atomics diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_xchg.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_xchg.cl new file mode 100644 index 0000000000..3fa17c950a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_xchg.cl @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#ifdef cl_khr_global_int32_base_atomics +#define __CLC_ATOMIC_OP xchg +#define __CLC_ATOMIC_ADDRESS_SPACE global +#include "atom_int32_binary.inc" +#endif // cl_khr_global_int32_base_atomics + +#ifdef cl_khr_local_int32_base_atomics +#define __CLC_ATOMIC_OP xchg +#define __CLC_ATOMIC_ADDRESS_SPACE local +#include "atom_int32_binary.inc" +#endif // cl_khr_local_int32_base_atomics + +#ifdef cl_khr_int64_base_atomics + +#define IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_xchg(volatile AS TYPE *p, TYPE val) { \ + return __sync_swap_8(p, val); \ + } + +IMPL(global, long) +IMPL(global, unsigned long) +IMPL(local, long) +IMPL(local, unsigned long) +#undef IMPL + +#endif // cl_khr_int64_base_atomics diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_xor.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_xor.cl new file mode 100644 index 0000000000..ac08ef63b1 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atom_xor.cl @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#ifdef cl_khr_global_int32_extended_atomics +#define __CLC_ATOMIC_OP xor +#define __CLC_ATOMIC_ADDRESS_SPACE global +#include "atom_int32_binary.inc" +#endif // cl_khr_global_int32_extended_atomics + +#ifdef cl_khr_local_int32_extended_atomics +#define __CLC_ATOMIC_OP xor +#define __CLC_ATOMIC_ADDRESS_SPACE local +#include "atom_int32_binary.inc" +#endif // cl_khr_local_int32_extended_atomics + +#ifdef cl_khr_int64_extended_atomics + +#define IMPL(AS, TYPE) \ + _CLC_OVERLOAD _CLC_DEF TYPE atom_xor(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_xor_8(p, val); \ + } + +IMPL(global, long) +IMPL(global, unsigned long) +IMPL(local, long) +IMPL(local, unsigned long) +#undef IMPL + +#endif // cl_khr_int64_extended_atomics diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_add.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_add.cl new file mode 100644 index 0000000000..a0effced7d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_add.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define IMPL(TYPE, AS) \ + _CLC_OVERLOAD _CLC_DEF TYPE atomic_add(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_add(p, val); \ + } + +IMPL(int, global) +IMPL(unsigned int, global) +IMPL(int, local) +IMPL(unsigned int, local) +#undef IMPL diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_and.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_and.cl new file mode 100644 index 0000000000..629e6638d3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_and.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define IMPL(TYPE, AS) \ + _CLC_OVERLOAD _CLC_DEF TYPE atomic_and(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_and(p, val); \ + } + +IMPL(int, global) +IMPL(unsigned int, global) +IMPL(int, local) +IMPL(unsigned int, local) +#undef IMPL diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_cmpxchg.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_cmpxchg.cl new file mode 100644 index 0000000000..db0495b004 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_cmpxchg.cl @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define IMPL(TYPE, AS) \ + _CLC_OVERLOAD _CLC_DEF TYPE atomic_cmpxchg(volatile AS TYPE *p, TYPE cmp, \ + TYPE val) { \ + return __sync_val_compare_and_swap(p, cmp, val); \ + } + +IMPL(int, global) +IMPL(unsigned int, global) +IMPL(int, local) +IMPL(unsigned int, local) +#undef IMPL diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_dec.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_dec.cl new file mode 100644 index 0000000000..6f18cdf134 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_dec.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define IMPL(TYPE, AS) \ + _CLC_OVERLOAD _CLC_DEF TYPE atomic_dec(volatile AS TYPE *p) { \ + return __sync_fetch_and_sub(p, (TYPE)1); \ + } + +IMPL(int, global) +IMPL(unsigned int, global) +IMPL(int, local) +IMPL(unsigned int, local) +#undef IMPL diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_inc.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_inc.cl new file mode 100644 index 0000000000..13349e5432 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_inc.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define IMPL(TYPE, AS) \ + _CLC_OVERLOAD _CLC_DEF TYPE atomic_inc(volatile AS TYPE *p) { \ + return __sync_fetch_and_add(p, (TYPE)1); \ + } + +IMPL(int, global) +IMPL(unsigned int, global) +IMPL(int, local) +IMPL(unsigned int, local) +#undef IMPL diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_max.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_max.cl new file mode 100644 index 0000000000..ae929f0523 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_max.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define IMPL(TYPE, AS, OP) \ + _CLC_OVERLOAD _CLC_DEF TYPE atomic_max(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_##OP(p, val); \ + } + +IMPL(int, global, max) +IMPL(unsigned int, global, umax) +IMPL(int, local, max) +IMPL(unsigned int, local, umax) +#undef IMPL diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_min.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_min.cl new file mode 100644 index 0000000000..c7ebe71ee8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_min.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define IMPL(TYPE, AS, OP) \ + _CLC_OVERLOAD _CLC_DEF TYPE atomic_min(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_##OP(p, val); \ + } + +IMPL(int, global, min) +IMPL(unsigned int, global, umin) +IMPL(int, local, min) +IMPL(unsigned int, local, umin) +#undef IMPL diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_or.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_or.cl new file mode 100644 index 0000000000..45fb865689 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_or.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define IMPL(TYPE, AS) \ + _CLC_OVERLOAD _CLC_DEF TYPE atomic_or(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_or(p, val); \ + } + +IMPL(int, global) +IMPL(unsigned int, global) +IMPL(int, local) +IMPL(unsigned int, local) +#undef IMPL diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_sub.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_sub.cl new file mode 100644 index 0000000000..74977f1515 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_sub.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define IMPL(TYPE, AS) \ + _CLC_OVERLOAD _CLC_DEF TYPE atomic_sub(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_sub(p, val); \ + } + +IMPL(int, global) +IMPL(unsigned int, global) +IMPL(int, local) +IMPL(unsigned int, local) +#undef IMPL diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_xchg.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_xchg.cl new file mode 100644 index 0000000000..883132caf9 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_xchg.cl @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF float atomic_xchg(volatile global float *p, float val) { + return as_float(atomic_xchg((volatile global uint *)p, as_uint(val))); +} + +_CLC_OVERLOAD _CLC_DEF float atomic_xchg(volatile local float *p, float val) { + return as_float(atomic_xchg((volatile local uint *)p, as_uint(val))); +} + +#define IMPL(TYPE, AS) \ + _CLC_OVERLOAD _CLC_DEF TYPE atomic_xchg(volatile AS TYPE *p, TYPE val) { \ + return __sync_swap_4(p, val); \ + } + +IMPL(int, global) +IMPL(unsigned int, global) +IMPL(int, local) +IMPL(unsigned int, local) +#undef IMPL diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_xor.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_xor.cl new file mode 100644 index 0000000000..246752c258 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/atomic/atomic_xor.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define IMPL(TYPE, AS) \ + _CLC_OVERLOAD _CLC_DEF TYPE atomic_xor(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_xor(p, val); \ + } + +IMPL(int, global) +IMPL(unsigned int, global) +IMPL(int, local) +IMPL(unsigned int, local) +#undef IMPL diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/common/degrees.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/common/degrees.cl new file mode 100644 index 0000000000..d989fa6382 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/common/degrees.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION degrees +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/common/mix.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/common/mix.cl new file mode 100644 index 0000000000..014cc1a742 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/common/mix.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/common/mix.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/common/mix.inc new file mode 100644 index 0000000000..d9df9d78f4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/common/mix.inc @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE mix(__CLC_GENTYPE x, __CLC_GENTYPE y, + __CLC_GENTYPE a) { + return __clc_mad(y - x, a, x); +} + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE mix(__CLC_GENTYPE x, __CLC_GENTYPE y, + __CLC_SCALAR_GENTYPE a) { + return mix(x, y, (__CLC_GENTYPE)a); +} +#endif diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/common/radians.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/common/radians.cl new file mode 100644 index 0000000000..1da38920d4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/common/radians.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION radians +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/common/sign.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/common/sign.cl new file mode 100644 index 0000000000..9afcb7375e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/common/sign.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define FUNCTION sign +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/common/smoothstep.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/common/smoothstep.cl new file mode 100644 index 0000000000..fdf9a89dcb --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/common/smoothstep.cl @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define SMOOTHSTEP_SINGLE_DEF(X_TYPE) \ + _CLC_OVERLOAD _CLC_DEF X_TYPE smoothstep(X_TYPE edge0, X_TYPE edge1, \ + X_TYPE x) { \ + return __clc_smoothstep(edge0, edge1, x); \ + } + +#define SMOOTHSTEP_S_S_V_DEFS(X_TYPE) \ + _CLC_OVERLOAD _CLC_DEF X_TYPE##2 smoothstep(X_TYPE x, X_TYPE y, \ + X_TYPE##2 z) { \ + return __clc_smoothstep((X_TYPE##2)x, (X_TYPE##2)y, z); \ + } \ + \ + _CLC_OVERLOAD _CLC_DEF X_TYPE##3 smoothstep(X_TYPE x, X_TYPE y, \ + X_TYPE##3 z) { \ + return __clc_smoothstep((X_TYPE##3)x, (X_TYPE##3)y, z); \ + } \ + \ + _CLC_OVERLOAD _CLC_DEF X_TYPE##4 smoothstep(X_TYPE x, X_TYPE y, \ + X_TYPE##4 z) { \ + return __clc_smoothstep((X_TYPE##4)x, (X_TYPE##4)y, z); \ + } \ + \ + _CLC_OVERLOAD _CLC_DEF X_TYPE##8 smoothstep(X_TYPE x, X_TYPE y, \ + X_TYPE##8 z) { \ + return __clc_smoothstep((X_TYPE##8)x, (X_TYPE##8)y, z); \ + } \ + \ + _CLC_OVERLOAD _CLC_DEF X_TYPE##16 smoothstep(X_TYPE x, X_TYPE y, \ + X_TYPE##16 z) { \ + return __clc_smoothstep((X_TYPE##16)x, (X_TYPE##16)y, z); \ + } + +#define SMOOTHSTEP_DEF(type) \ + SMOOTHSTEP_SINGLE_DEF(type) \ + SMOOTHSTEP_SINGLE_DEF(type##2) \ + SMOOTHSTEP_SINGLE_DEF(type##3) \ + SMOOTHSTEP_SINGLE_DEF(type##4) \ + SMOOTHSTEP_SINGLE_DEF(type##8) \ + SMOOTHSTEP_SINGLE_DEF(type##16) \ + SMOOTHSTEP_S_S_V_DEFS(type) + +SMOOTHSTEP_DEF(float) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +SMOOTHSTEP_DEF(double); + +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +SMOOTHSTEP_DEF(half); + +#endif diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/common/step.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/common/step.cl new file mode 100644 index 0000000000..d946771698 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/common/step.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/common/step.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/common/step.inc new file mode 100644 index 0000000000..b1e9411792 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/common/step.inc @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE step(__CLC_GENTYPE edge, __CLC_GENTYPE x) { + return __clc_step(edge, x); +} + +#if !defined(__CLC_SCALAR) + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE step(__CLC_SCALAR_GENTYPE edge, + __CLC_GENTYPE x) { + return __clc_step((__CLC_GENTYPE)edge, x); +} + +#endif diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/cross.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/cross.cl new file mode 100644 index 0000000000..7553c80e6b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/cross.cl @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF float3 cross(float3 p0, float3 p1) { + return __clc_cross(p0, p1); +} + +_CLC_OVERLOAD _CLC_DEF float4 cross(float4 p0, float4 p1) { + return __clc_cross(p0, p1); +} + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF double3 cross(double3 p0, double3 p1) { + return __clc_cross(p0, p1); +} + +_CLC_OVERLOAD _CLC_DEF double4 cross(double4 p0, double4 p1) { + return __clc_cross(p0, p1); +} + +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DEF half3 cross(half3 p0, half3 p1) { + return __clc_cross(p0, p1); +} + +_CLC_OVERLOAD _CLC_DEF half4 cross(half4 p0, half4 p1) { + return __clc_cross(p0, p1); +} + +#endif diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/distance.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/distance.cl new file mode 100644 index 0000000000..54c78d3609 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/distance.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION distance +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/dot.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/dot.cl new file mode 100644 index 0000000000..05425aafb0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/dot.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION dot +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/fast_distance.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/fast_distance.cl new file mode 100644 index 0000000000..bc30c298a2 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/fast_distance.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION fast_distance +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/fast_length.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/fast_length.cl new file mode 100644 index 0000000000..407080900c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/fast_length.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION fast_length +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/fast_normalize.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/fast_normalize.cl new file mode 100644 index 0000000000..195081371a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/fast_normalize.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION fast_normalize +#define __FLOAT_ONLY +#define __CLC_GEOMETRIC_RET_GENTYPE +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/length.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/length.cl new file mode 100644 index 0000000000..0b0ebaa74d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/length.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION length +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/normalize.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/normalize.cl new file mode 100644 index 0000000000..eb84ffd382 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/geometric/normalize.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION normalize +#define __CLC_GEOMETRIC_RET_GENTYPE +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs.cl new file mode 100644 index 0000000000..0771ec7934 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs.inc new file mode 100644 index 0000000000..7344e39d32 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_U_GENTYPE abs(__CLC_GENTYPE x) { + return __clc_abs(x); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs_diff.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs_diff.cl new file mode 100644 index 0000000000..d65b0468a7 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs_diff.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs_diff.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs_diff.inc new file mode 100644 index 0000000000..0f515202cd --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/abs_diff.inc @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_U_GENTYPE abs_diff(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return __clc_abs_diff(x, y); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/add_sat.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/add_sat.cl new file mode 100644 index 0000000000..50d989a472 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/add_sat.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION add_sat +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/clz.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/clz.cl new file mode 100644 index 0000000000..58110df1ee --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/clz.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION clz +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/ctz.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/ctz.cl new file mode 100644 index 0000000000..cbb167275a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/ctz.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 + +#include +#include + +#define FUNCTION ctz +#define __CLC_BODY + +#include + +#endif // __OPENCL_C_VERSION__ >= CL_VERSION_2_0 diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/hadd.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/hadd.cl new file mode 100644 index 0000000000..e9edc88bce --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/hadd.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION hadd +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mad24.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mad24.cl new file mode 100644 index 0000000000..5e9dfb3b30 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mad24.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION mad24 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mad_hi.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mad_hi.cl new file mode 100644 index 0000000000..786614e42b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mad_hi.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION mad_hi +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mad_sat.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mad_sat.cl new file mode 100644 index 0000000000..54ddc0eed2 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mad_sat.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION mad_sat +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mul24.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mul24.cl new file mode 100644 index 0000000000..e6db6b89c5 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mul24.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION mul24 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mul_hi.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mul_hi.cl new file mode 100644 index 0000000000..4c7b8c2caa --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/mul_hi.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION mul_hi +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/popcount.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/popcount.cl new file mode 100644 index 0000000000..3c33c82302 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/popcount.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION popcount +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/rhadd.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/rhadd.cl new file mode 100644 index 0000000000..f835511899 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/rhadd.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION rhadd +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/rotate.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/rotate.cl new file mode 100644 index 0000000000..282270f3b3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/rotate.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION rotate +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/sub_sat.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/sub_sat.cl new file mode 100644 index 0000000000..0b45df1118 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/sub_sat.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION sub_sat +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/integer/upsample.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/upsample.cl new file mode 100644 index 0000000000..5f95c811e0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/integer/upsample.cl @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_UPSAMPLE_IMPL(BGENTYPE, GENTYPE, UGENTYPE) \ + _CLC_OVERLOAD _CLC_DEF BGENTYPE upsample(GENTYPE hi, UGENTYPE lo) { \ + return __clc_upsample(hi, lo); \ + } \ + _CLC_OVERLOAD _CLC_DEF BGENTYPE##2 upsample(GENTYPE##2 hi, UGENTYPE##2 lo) { \ + return __clc_upsample(hi, lo); \ + } \ + _CLC_OVERLOAD _CLC_DEF BGENTYPE##3 upsample(GENTYPE##3 hi, UGENTYPE##3 lo) { \ + return __clc_upsample(hi, lo); \ + } \ + _CLC_OVERLOAD _CLC_DEF BGENTYPE##4 upsample(GENTYPE##4 hi, UGENTYPE##4 lo) { \ + return __clc_upsample(hi, lo); \ + } \ + _CLC_OVERLOAD _CLC_DEF BGENTYPE##8 upsample(GENTYPE##8 hi, UGENTYPE##8 lo) { \ + return __clc_upsample(hi, lo); \ + } \ + _CLC_OVERLOAD _CLC_DEF BGENTYPE##16 upsample(GENTYPE##16 hi, \ + UGENTYPE##16 lo) { \ + return __clc_upsample(hi, lo); \ + } + +#define __CLC_UPSAMPLE_TYPES() \ + __CLC_UPSAMPLE_IMPL(short, char, uchar) \ + __CLC_UPSAMPLE_IMPL(ushort, uchar, uchar) \ + __CLC_UPSAMPLE_IMPL(int, short, ushort) \ + __CLC_UPSAMPLE_IMPL(uint, ushort, ushort) \ + __CLC_UPSAMPLE_IMPL(long, int, uint) \ + __CLC_UPSAMPLE_IMPL(ulong, uint, uint) + +__CLC_UPSAMPLE_TYPES() + +#undef __CLC_UPSAMPLE_TYPES +#undef __CLC_UPSAMPLE_IMPL diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/acos.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/acos.cl new file mode 100644 index 0000000000..040b2b82f6 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/acos.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION acos +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/acosh.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/acosh.cl new file mode 100644 index 0000000000..55b60bc996 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/acosh.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION acosh +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/acospi.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/acospi.cl new file mode 100644 index 0000000000..2537c992e2 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/acospi.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION acospi +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/asin.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/asin.cl new file mode 100644 index 0000000000..08dde12013 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/asin.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION asin +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/asinh.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/asinh.cl new file mode 100644 index 0000000000..189392f50b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/asinh.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION asinh +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/asinpi.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/asinpi.cl new file mode 100644 index 0000000000..b9327faacc --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/asinpi.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION asinpi +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/atan.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/atan.cl new file mode 100644 index 0000000000..e2b1530f9e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/atan.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION atan +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/atan2.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/atan2.cl new file mode 100644 index 0000000000..9f3d4a965e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/atan2.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define FUNCTION atan2 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/atan2pi.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/atan2pi.cl new file mode 100644 index 0000000000..9b3fea163f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/atan2pi.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define FUNCTION atan2pi +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/atanh.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/atanh.cl new file mode 100644 index 0000000000..5e4564d347 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/atanh.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION atanh +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/atanpi.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/atanpi.cl new file mode 100644 index 0000000000..ddeb38e64e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/atanpi.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION atanpi +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/cbrt.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/cbrt.cl new file mode 100644 index 0000000000..dccb49a47d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/cbrt.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION cbrt +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/ceil.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/ceil.cl new file mode 100644 index 0000000000..e312281b98 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/ceil.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION ceil +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/copysign.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/copysign.cl new file mode 100644 index 0000000000..7aa4cb2da0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/copysign.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION copysign +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/cos.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/cos.cl new file mode 100644 index 0000000000..fb40b6c00e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/cos.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION cos +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/cosh.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/cosh.cl new file mode 100644 index 0000000000..7106fc9f18 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/cosh.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION cosh +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/cospi.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/cospi.cl new file mode 100644 index 0000000000..0e242ad0d4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/cospi.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION cospi +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/erf.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/erf.cl new file mode 100644 index 0000000000..83c38867e0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/erf.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION erf +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/erfc.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/erfc.cl new file mode 100644 index 0000000000..1c473999bb --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/erfc.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION erfc +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/exp.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/exp.cl new file mode 100644 index 0000000000..8125ce314e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/exp.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION exp +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/exp10.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/exp10.cl new file mode 100644 index 0000000000..f8c0f94a99 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/exp10.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION exp10 +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/exp2.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/exp2.cl new file mode 100644 index 0000000000..dc75c2201a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/exp2.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION exp2 +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/expm1.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/expm1.cl new file mode 100644 index 0000000000..7507786c2a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/expm1.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION expm1 +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/fabs.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fabs.cl new file mode 100644 index 0000000000..0d3128f3b2 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fabs.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION fabs +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/fdim.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fdim.cl new file mode 100644 index 0000000000..ecdcd3aef3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fdim.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION fdim +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/floor.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/floor.cl new file mode 100644 index 0000000000..cda8363f91 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/floor.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION floor +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/fma.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fma.cl new file mode 100644 index 0000000000..867b975069 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fma.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define FUNCTION fma +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmax.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmax.cl new file mode 100644 index 0000000000..7dbd6fe0bd --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmax.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION fmax +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmax.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmax.inc new file mode 100644 index 0000000000..a0d5d6255c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmax.inc @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if !defined(__CLC_SCALAR) + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE fmax(__CLC_GENTYPE x, float y) { + return fmax(x, (__CLC_GENTYPE)((__CLC_SCALAR_GENTYPE)y)); +} + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE fmax(__CLC_GENTYPE x, double y) { + return fmax(x, (__CLC_GENTYPE)((__CLC_SCALAR_GENTYPE)y)); +} + +#endif // ifdef cl_khr_fp64 + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE fmax(__CLC_GENTYPE x, half y) { + return fmax(x, (__CLC_GENTYPE)((__CLC_SCALAR_GENTYPE)y)); +} + +#endif // ifdef cl_khr_fp16 + +#endif // !defined(__CLC_SCALAR) diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmin.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmin.cl new file mode 100644 index 0000000000..ee0dca4800 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmin.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION fmin +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmin.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmin.inc new file mode 100644 index 0000000000..112097337a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmin.inc @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if !defined(__CLC_SCALAR) + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE fmin(__CLC_GENTYPE x, float y) { + return fmin(x, (__CLC_GENTYPE)((__CLC_SCALAR_GENTYPE)y)); +} + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE fmin(__CLC_GENTYPE x, double y) { + return fmin(x, (__CLC_GENTYPE)((__CLC_SCALAR_GENTYPE)y)); +} + +#endif // ifdef cl_khr_fp64 + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE fmin(__CLC_GENTYPE x, half y) { + return fmin(x, (__CLC_GENTYPE)((__CLC_SCALAR_GENTYPE)y)); +} + +#endif // ifdef cl_khr_fp16 + +#endif // !defined(__CLC_SCALAR) diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmod.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmod.cl new file mode 100644 index 0000000000..ec1904d213 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fmod.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION fmod +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/fract.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fract.cl new file mode 100644 index 0000000000..9567072bf4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/fract.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION fract +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/frexp.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/frexp.cl new file mode 100644 index 0000000000..3ac9be792a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/frexp.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION frexp +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_cos.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_cos.cl new file mode 100644 index 0000000000..377c4d1642 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_cos.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_cos +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_divide.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_divide.cl new file mode 100644 index 0000000000..730617ba67 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_divide.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_divide +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_exp.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_exp.cl new file mode 100644 index 0000000000..05b8753b2f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_exp.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_exp +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_exp10.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_exp10.cl new file mode 100644 index 0000000000..b4e46aaa77 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_exp10.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_exp10 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_exp2.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_exp2.cl new file mode 100644 index 0000000000..51fe9f7247 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_exp2.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_exp2 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_log.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_log.cl new file mode 100644 index 0000000000..b21835204a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_log.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_log +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_log10.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_log10.cl new file mode 100644 index 0000000000..acb50f99af --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_log10.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_log10 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_log2.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_log2.cl new file mode 100644 index 0000000000..c97e9e0938 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_log2.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_log2 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_powr.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_powr.cl new file mode 100644 index 0000000000..d61a18ab91 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_powr.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_powr +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_recip.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_recip.cl new file mode 100644 index 0000000000..1917448c4e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_recip.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_recip +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_rsqrt.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_rsqrt.cl new file mode 100644 index 0000000000..d6ffa651fb --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_rsqrt.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_rsqrt +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_sin.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_sin.cl new file mode 100644 index 0000000000..baba0cca49 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_sin.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_sin +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_sqrt.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_sqrt.cl new file mode 100644 index 0000000000..7a59744ab1 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_sqrt.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_sqrt +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_tan.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_tan.cl new file mode 100644 index 0000000000..acd4b01117 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/half_tan.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION half_tan +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/hypot.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/hypot.cl new file mode 100644 index 0000000000..4c59e4696e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/hypot.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION hypot +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/ilogb.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/ilogb.cl new file mode 100644 index 0000000000..3829ce68fb --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/ilogb.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION ilogb +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/ldexp.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/ldexp.cl new file mode 100644 index 0000000000..88c60716d7 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/ldexp.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION ldexp +#define __IMPL_FUNCTION(x) __clc_ldexp +#define __CLC_BODY + +#include + +// This defines all the ldexp(GENTYPE, int) variants +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/ldexp.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/math/ldexp.inc new file mode 100644 index 0000000000..f62341f636 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/ldexp.inc @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLC_SCALAR + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE ldexp(__CLC_GENTYPE x, int n) { + return __clc_ldexp(x, (__CLC_INTN)n); +} + +#endif diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/lgamma.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/lgamma.cl new file mode 100644 index 0000000000..253ce31c15 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/lgamma.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION lgamma +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/lgamma_r.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/lgamma_r.cl new file mode 100644 index 0000000000..8753f6c75d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/lgamma_r.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION lgamma_r +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/log.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/log.cl new file mode 100644 index 0000000000..dbe3e35727 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/log.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define FUNCTION log +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/log10.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/log10.cl new file mode 100644 index 0000000000..d5137a7cab --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/log10.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define FUNCTION log10 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/log1p.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/log1p.cl new file mode 100644 index 0000000000..d389ab7290 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/log1p.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION log1p +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/log2.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/log2.cl new file mode 100644 index 0000000000..d1433bc825 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/log2.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define FUNCTION log2 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/logb.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/logb.cl new file mode 100644 index 0000000000..037380a26a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/logb.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION logb +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/mad.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/mad.cl new file mode 100644 index 0000000000..3fe2dd9bed --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/mad.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION mad +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/maxmag.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/maxmag.cl new file mode 100644 index 0000000000..4f9dbeb8d2 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/maxmag.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION maxmag +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/minmag.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/minmag.cl new file mode 100644 index 0000000000..efe72b6f54 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/minmag.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION minmag +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/modf.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/modf.cl new file mode 100644 index 0000000000..de6524e02f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/modf.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION modf +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/nan.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/nan.cl new file mode 100644 index 0000000000..5597df8b2a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/nan.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/nan.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/math/nan.inc new file mode 100644 index 0000000000..e3fa535297 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/nan.inc @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE nan(__CLC_U_GENTYPE code) { + return __clc_nan(code); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_cos.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_cos.cl new file mode 100644 index 0000000000..85944a03c5 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_cos.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_cos +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_divide.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_divide.cl new file mode 100644 index 0000000000..8efd8cc21b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_divide.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_divide +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_exp.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_exp.cl new file mode 100644 index 0000000000..42208371e1 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_exp.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_exp +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_exp10.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_exp10.cl new file mode 100644 index 0000000000..aa2585ff43 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_exp10.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_exp10 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_exp2.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_exp2.cl new file mode 100644 index 0000000000..8955b28b36 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_exp2.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_exp2 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_log.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_log.cl new file mode 100644 index 0000000000..334f7c04e3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_log.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_log +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_log10.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_log10.cl new file mode 100644 index 0000000000..a65938ee4c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_log10.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_log10 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_log2.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_log2.cl new file mode 100644 index 0000000000..f10b533f91 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_log2.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_log2 +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_powr.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_powr.cl new file mode 100644 index 0000000000..8301443cfb --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_powr.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_powr +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_recip.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_recip.cl new file mode 100644 index 0000000000..145845b455 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_recip.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_recip +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_rsqrt.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_rsqrt.cl new file mode 100644 index 0000000000..cbb5a754fc --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_rsqrt.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_rsqrt +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_sin.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_sin.cl new file mode 100644 index 0000000000..dfcc882614 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_sin.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_sin +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_sqrt.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_sqrt.cl new file mode 100644 index 0000000000..a0be41d33f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_sqrt.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_sqrt +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_tan.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_tan.cl new file mode 100644 index 0000000000..86eee4f591 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/native_tan.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION native_tan +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/nextafter.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/nextafter.cl new file mode 100644 index 0000000000..9c30e5668a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/nextafter.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION nextafter +#define __IMPL_FUNCTION(x) __clc_nextafter +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/pow.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/pow.cl new file mode 100644 index 0000000000..2fddb7e889 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/pow.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION pow +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/pown.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/pown.cl new file mode 100644 index 0000000000..0a5ee893a4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/pown.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION pown +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/powr.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/powr.cl new file mode 100644 index 0000000000..13af03ff13 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/powr.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION powr +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/remainder.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/remainder.cl new file mode 100644 index 0000000000..224a66bc9b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/remainder.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION remainder +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/remquo.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/remquo.cl new file mode 100644 index 0000000000..de102af58f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/remquo.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/remquo.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/math/remquo.inc new file mode 100644 index 0000000000..a139c1dfa8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/remquo.inc @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE remquo(__CLC_GENTYPE x, __CLC_GENTYPE y, + private __CLC_INTN *q) { + return __clc_remquo(x, y, q); +} + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE remquo(__CLC_GENTYPE x, __CLC_GENTYPE y, + global __CLC_INTN *q) { + return __clc_remquo(x, y, q); +} + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE remquo(__CLC_GENTYPE x, __CLC_GENTYPE y, + local __CLC_INTN *q) { + return __clc_remquo(x, y, q); +} + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE remquo(__CLC_GENTYPE x, __CLC_GENTYPE y, + generic __CLC_INTN *q) { + return __clc_remquo(x, y, q); +} +#endif diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/rint.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/rint.cl new file mode 100644 index 0000000000..489883c97c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/rint.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION rint +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/rootn.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/rootn.cl new file mode 100644 index 0000000000..e8dba17b93 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/rootn.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION rootn +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/round.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/round.cl new file mode 100644 index 0000000000..c45e681b1c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/round.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION round +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/rsqrt.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/rsqrt.cl new file mode 100644 index 0000000000..47e4f450ed --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/rsqrt.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION rsqrt +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/sin.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/sin.cl new file mode 100644 index 0000000000..ff7db2a5b3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/sin.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION sin +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/sincos.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/sincos.cl new file mode 100644 index 0000000000..c8871fd2b0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/sincos.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION sincos +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/sinh.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/sinh.cl new file mode 100644 index 0000000000..bd6ea20e7e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/sinh.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION sinh +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/sinpi.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/sinpi.cl new file mode 100644 index 0000000000..badecd0909 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/sinpi.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION sinpi +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/sqrt.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/sqrt.cl new file mode 100644 index 0000000000..3b05b25864 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/sqrt.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION sqrt +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/tan.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/tan.cl new file mode 100644 index 0000000000..95409fc5b0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/tan.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION tan +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/tanh.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/tanh.cl new file mode 100644 index 0000000000..a77878bb79 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/tanh.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION tanh +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/tanpi.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/tanpi.cl new file mode 100644 index 0000000000..6b5805ec3c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/tanpi.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION tanpi +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/tgamma.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/tgamma.cl new file mode 100644 index 0000000000..8f35d22426 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/tgamma.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION tgamma +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/math/trunc.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/math/trunc.cl new file mode 100644 index 0000000000..ea56329bc8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/math/trunc.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION trunc +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/misc/shuffle.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/misc/shuffle.cl new file mode 100644 index 0000000000..15295bf7d9 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/misc/shuffle.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION shuffle + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/misc/shuffle2.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/misc/shuffle2.cl new file mode 100644 index 0000000000..7e4c5f0922 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/misc/shuffle2.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION shuffle2 + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/all.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/all.cl new file mode 100644 index 0000000000..5ac4a46536 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/all.cl @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define ALL_ID(TYPE) _CLC_OVERLOAD _CLC_DEF int all(TYPE v) + +#define ALL_VECTORIZE(TYPE) \ + ALL_ID(TYPE) { return __clc_all(v); } \ + ALL_ID(TYPE##2) { return __clc_all(v); } \ + ALL_ID(TYPE##3) { return __clc_all(v); } \ + ALL_ID(TYPE##4) { return __clc_all(v); } \ + ALL_ID(TYPE##8) { return __clc_all(v); } \ + ALL_ID(TYPE##16) { return __clc_all(v); } + +ALL_VECTORIZE(char) +ALL_VECTORIZE(short) +ALL_VECTORIZE(int) +ALL_VECTORIZE(long) diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/any.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/any.cl new file mode 100644 index 0000000000..507f2b1706 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/any.cl @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define ANY_ID(TYPE) _CLC_OVERLOAD _CLC_DEF int any(TYPE v) + +#define ANY_VECTORIZE(TYPE) \ + ANY_ID(TYPE) { return __clc_any(v); } \ + ANY_ID(TYPE##2) { return __clc_any(v); } \ + ANY_ID(TYPE##3) { return __clc_any(v); } \ + ANY_ID(TYPE##4) { return __clc_any(v); } \ + ANY_ID(TYPE##8) { return __clc_any(v); } \ + ANY_ID(TYPE##16) { return __clc_any(v); } + +ANY_VECTORIZE(char) +ANY_VECTORIZE(short) +ANY_VECTORIZE(int) +ANY_VECTORIZE(long) diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/binary_def.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/binary_def.inc new file mode 100644 index 0000000000..54bb237b8f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/binary_def.inc @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) + +_CLC_OVERLOAD _CLC_DEF __CLC_INTN FUNCTION(__CLC_FLOATN a, __CLC_FLOATN b) { + return __IMPL_FUNCTION(FUNCTION)(a, b); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/bitselect.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/bitselect.cl new file mode 100644 index 0000000000..0be7e5321c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/bitselect.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/bitselect.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/bitselect.inc new file mode 100644 index 0000000000..d4a87dbe80 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/bitselect.inc @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE bitselect(__CLC_GENTYPE x, __CLC_GENTYPE y, + __CLC_GENTYPE z) { + return __clc_bitselect(x, y, z); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isequal.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isequal.cl new file mode 100644 index 0000000000..94f83f9452 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isequal.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION isequal +#define __CLC_BODY "binary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isfinite.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isfinite.cl new file mode 100644 index 0000000000..695ffea806 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isfinite.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION isfinite +#define __CLC_BODY "unary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isgreater.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isgreater.cl new file mode 100644 index 0000000000..fb46ff20ac --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isgreater.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION isgreater +#define __CLC_BODY "binary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isgreaterequal.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isgreaterequal.cl new file mode 100644 index 0000000000..b8edde2a05 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isgreaterequal.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION isgreaterequal +#define __CLC_BODY "binary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isinf.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isinf.cl new file mode 100644 index 0000000000..2c15f1f826 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isinf.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION isinf +#define __CLC_BODY "unary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isless.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isless.cl new file mode 100644 index 0000000000..0af1f53e71 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isless.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION isless +#define __CLC_BODY "binary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/islessequal.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/islessequal.cl new file mode 100644 index 0000000000..9e32afc718 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/islessequal.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION islessequal +#define __CLC_BODY "binary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/islessgreater.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/islessgreater.cl new file mode 100644 index 0000000000..c36a857dc3 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/islessgreater.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION islessgreater +#define __CLC_BODY "binary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isnan.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isnan.cl new file mode 100644 index 0000000000..8b03930c53 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isnan.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION isnan +#define __CLC_BODY "unary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isnormal.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isnormal.cl new file mode 100644 index 0000000000..4ba21cc3e1 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isnormal.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION isnormal +#define __CLC_BODY "unary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isnotequal.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isnotequal.cl new file mode 100644 index 0000000000..928923b9b2 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isnotequal.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION isnotequal +#define __CLC_BODY "binary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isordered.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isordered.cl new file mode 100644 index 0000000000..60ca4d67ff --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isordered.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION isordered +#define __CLC_BODY "binary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isunordered.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isunordered.cl new file mode 100644 index 0000000000..3392d77856 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/isunordered.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION isunordered +#define __CLC_BODY "binary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/select.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/select.cl new file mode 100644 index 0000000000..47a7b8e5ad --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/select.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#define __CLC_SELECT_FN select +#define __CLC_SELECT_DEF(x, y, z) return __clc_select(x, y, z) + +#define __CLC_BODY +#include +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/signbit.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/signbit.cl new file mode 100644 index 0000000000..26feb8d43f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/signbit.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define FUNCTION signbit +#define __CLC_BODY "unary_def.inc" + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/relational/unary_def.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/unary_def.inc new file mode 100644 index 0000000000..47bb33ef2d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/relational/unary_def.inc @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x) + +_CLC_OVERLOAD _CLC_DEF __CLC_INTN FUNCTION(__CLC_FLOATN a) { + return __IMPL_FUNCTION(FUNCTION)(a); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/shared/clamp.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/clamp.cl new file mode 100644 index 0000000000..6e2bedc070 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/clamp.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/shared/clamp.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/clamp.inc new file mode 100644 index 0000000000..f79a4da67f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/clamp.inc @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE clamp(__CLC_GENTYPE x, __CLC_GENTYPE y, + __CLC_GENTYPE z) { + return __clc_clamp(x, y, z); +} + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE clamp(__CLC_GENTYPE x, + __CLC_SCALAR_GENTYPE y, + __CLC_SCALAR_GENTYPE z) { + return __clc_clamp(x, y, z); +} +#endif diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/shared/max.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/max.cl new file mode 100644 index 0000000000..5cb5ff124b --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/max.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/shared/max.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/max.inc new file mode 100644 index 0000000000..263cc15a32 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/max.inc @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE max(__CLC_GENTYPE a, __CLC_GENTYPE b) { + return __clc_max(a, b); +} + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE max(__CLC_GENTYPE a, + __CLC_SCALAR_GENTYPE b) { + return __clc_max(a, b); +} +#endif diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/shared/min.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/min.cl new file mode 100644 index 0000000000..2a1ded3aa0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/min.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY +#include + +#define __CLC_BODY +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/shared/min.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/min.inc new file mode 100644 index 0000000000..d2c722c753 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/min.inc @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE min(__CLC_GENTYPE a, __CLC_GENTYPE b) { + return __clc_min(a, b); +} + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE min(__CLC_GENTYPE a, + __CLC_SCALAR_GENTYPE b) { + return __clc_min(a, b); +} +#endif diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/shared/vload.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/vload.cl new file mode 100644 index 0000000000..6f1ca06ccb --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/vload.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY "vload.inc" +#include + +#define __CLC_BODY "vload.inc" +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/shared/vload.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/vload.inc new file mode 100644 index 0000000000..62cb040aad --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/vload.inc @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#define CLC_VLOAD_NAME(x) __CLC_XCONCAT(__CLC_XCONCAT(x, vload), __CLC_VECSIZE) +#define CLC_VLOAD_HALF_NAME(x) \ + __CLC_XCONCAT(__CLC_XCONCAT(x, vload_half), __CLC_VECSIZE) +#define CLC_VLOADA_HALF_NAME(x) \ + __CLC_XCONCAT(__CLC_XCONCAT(x, vloada_half), __CLC_VECSIZE) + +#ifndef __CLC_SCALAR + +#define CLC_VLOAD_TY __CLC_XCONCAT(less_aligned_, __CLC_GENTYPE) + +#define VLOAD_DEF(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DEF CLC_VLOAD_TY CLC_VLOAD_NAME()( \ + size_t offset, const ADDRSPACE __CLC_SCALAR_GENTYPE *x) { \ + return CLC_VLOAD_NAME(__clc_)(offset, x); \ + } + +VLOAD_DEF(__private) +VLOAD_DEF(__local) +VLOAD_DEF(__constant) +VLOAD_DEF(__global) + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +VLOAD_DEF(__generic) +#endif + +#undef VLOAD_DEF +#undef CLC_VLOAD_TY + +#endif + +// vload_half and vloada_half are available even if cl_khr_fp16 is unavailable. +// Declare these functions when working on float types, which we know are +// always available. +#ifdef __CLC_FPSIZE +#if __CLC_FPSIZE == 32 + +#define VLOAD_HALF_DEF(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE CLC_VLOAD_HALF_NAME()( \ + size_t offset, const ADDRSPACE half *mem) { \ + return CLC_VLOAD_HALF_NAME(__clc_)(offset, mem); \ + } \ + \ + _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE CLC_VLOADA_HALF_NAME()( \ + size_t offset, const ADDRSPACE half *mem) { \ + return CLC_VLOADA_HALF_NAME(__clc_)(offset, mem); \ + } + +VLOAD_HALF_DEF(__private) +VLOAD_HALF_DEF(__local) +VLOAD_HALF_DEF(__constant) +VLOAD_HALF_DEF(__global) + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +VLOAD_HALF_DEF(__generic) +#endif + +#undef VLOAD_HALF_DEF +#endif +#endif + +#undef CLC_VLOAD_NAME +#undef CLC_VLOAD_HALF_NAME +#undef CLC_VLOADA_HALF_NAME diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/shared/vstore.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/vstore.cl new file mode 100644 index 0000000000..1d62de810f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/vstore.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __CLC_BODY "vstore.inc" +#include + +#define __CLC_BODY "vstore.inc" +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/shared/vstore.inc b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/vstore.inc new file mode 100644 index 0000000000..4bdce07199 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/shared/vstore.inc @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#define CLC_VSTORE_TY __CLC_XCONCAT(less_aligned_, __CLC_GENTYPE) +#define CLC_VSTORE_NAME(x) \ + __CLC_XCONCAT(__CLC_XCONCAT(x, vstore), __CLC_VECSIZE) +#define CLC_VSTORE_HALF_NAME(x, y) \ + __CLC_XCONCAT(__CLC_XCONCAT(__CLC_XCONCAT(x, vstore_half), __CLC_VECSIZE), y) +#define CLC_VSTOREA_HALF_NAME(x, y) \ + __CLC_XCONCAT(__CLC_XCONCAT(__CLC_XCONCAT(x, vstorea_half), __CLC_VECSIZE), y) + +#ifndef __CLC_SCALAR + +#define CLC_VSTORE_DEF(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DEF void CLC_VSTORE_NAME()( \ + CLC_VSTORE_TY data, size_t offset, ADDRSPACE __CLC_SCALAR_GENTYPE *p) { \ + return CLC_VSTORE_NAME(__clc_)(data, offset, p); \ + } + +CLC_VSTORE_DEF(__private) +CLC_VSTORE_DEF(__local) +CLC_VSTORE_DEF(__global) + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +CLC_VSTORE_DEF(__generic) +#endif + +#undef CLC_VSTORE_DEF + +#endif // __CLC_SCALAR + +// vstore_half and vstorea_half are available even if cl_khr_fp16 is +// unavailable. +#ifdef __CLC_FPSIZE +#if __CLC_FPSIZE == 32 || __CLC_FPSIZE == 64 + +#define CLC_VSTORE_HALF_DEF(ADDRSPACE, SUFFIX) \ + _CLC_OVERLOAD _CLC_DEF void CLC_VSTORE_HALF_NAME(, SUFFIX)( \ + CLC_VSTORE_TY data, size_t offset, ADDRSPACE half *p) { \ + CLC_VSTORE_HALF_NAME(__clc_, SUFFIX)(data, offset, p); \ + } \ + \ + _CLC_OVERLOAD _CLC_DEF void CLC_VSTOREA_HALF_NAME(, SUFFIX)( \ + CLC_VSTORE_TY data, size_t offset, ADDRSPACE half *p) { \ + CLC_VSTOREA_HALF_NAME(__clc_, SUFFIX)(data, offset, p); \ + } + +#define CLC_VSTORE_HALF_DEF_ALL_MODES(ADDRSPACE) \ + CLC_VSTORE_HALF_DEF(ADDRSPACE, ) \ + CLC_VSTORE_HALF_DEF(ADDRSPACE, _rtz) \ + CLC_VSTORE_HALF_DEF(ADDRSPACE, _rtn) \ + CLC_VSTORE_HALF_DEF(ADDRSPACE, _rtp) \ + CLC_VSTORE_HALF_DEF(ADDRSPACE, _rte) + +CLC_VSTORE_HALF_DEF_ALL_MODES(__private) +CLC_VSTORE_HALF_DEF_ALL_MODES(__local) +CLC_VSTORE_HALF_DEF_ALL_MODES(__global) + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +CLC_VSTORE_HALF_DEF_ALL_MODES(__generic) +#endif + +#undef CLC_VSTORE_HALF_DEF +#undef CLC_VSTORE_HALF_DEF_ALL_MODES + +#endif +#endif + +#undef CLC_VSTORE_TY +#undef CLC_VSTORE_NAME +#undef CLC_VSTORE_HALF_NAME +#undef CLC_VSTOREA_HALF_NAME diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_config.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_config.cl new file mode 100644 index 0000000000..aa2e30935e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_config.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEF bool __clc_fp16_subnormals_supported() { return false; } + +_CLC_DEF bool __clc_fp32_subnormals_supported() { return false; } + +_CLC_DEF bool __clc_fp64_subnormals_supported() { + return !__clc_subnormals_disabled(); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_disable.ll b/local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_disable.ll new file mode 100644 index 0000000000..732d09ff09 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_disable.ll @@ -0,0 +1,9 @@ +;;===----------------------------------------------------------------------===;; +; +; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +; See https://llvm.org/LICENSE.txt for license information. +; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +; +;;===----------------------------------------------------------------------===;; + +@__CLC_SUBNORMAL_DISABLE = unnamed_addr constant i1 true diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_helper_func.ll b/local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_helper_func.ll new file mode 100644 index 0000000000..03beecf979 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_helper_func.ll @@ -0,0 +1,16 @@ +;;===----------------------------------------------------------------------===;; +; +; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +; See https://llvm.org/LICENSE.txt for license information. +; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +; +;;===----------------------------------------------------------------------===;; + +@__CLC_SUBNORMAL_DISABLE = external global i1 + +define i1 @__clc_subnormals_disabled() #0 { + %disable = load i1, i1* @__CLC_SUBNORMAL_DISABLE + ret i1 %disable +} + +attributes #0 = { alwaysinline } diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_use_default.ll b/local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_use_default.ll new file mode 100644 index 0000000000..c648cc0a8a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/subnormal_use_default.ll @@ -0,0 +1,9 @@ +;;===----------------------------------------------------------------------===;; +; +; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +; See https://llvm.org/LICENSE.txt for license information. +; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +; +;;===----------------------------------------------------------------------===;; + +@__CLC_SUBNORMAL_DISABLE = unnamed_addr constant i1 false diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/workitem/get_global_id.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/workitem/get_global_id.cl new file mode 100644 index 0000000000..5e417bef0d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/workitem/get_global_id.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include + +_CLC_DEF _CLC_OVERLOAD size_t get_global_id(uint dim) { + return get_group_id(dim) * get_local_size(dim) + get_local_id(dim) + + get_global_offset(dim); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/generic/workitem/get_global_size.cl b/local/recipes/dev/libclc/source/opencl/lib/generic/workitem/get_global_size.cl new file mode 100644 index 0000000000..d62e9e9188 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/generic/workitem/get_global_size.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +_CLC_DEF _CLC_OVERLOAD size_t get_global_size(uint dim) { + return get_num_groups(dim) * get_local_size(dim); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/SOURCES b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/SOURCES new file mode 100644 index 0000000000..eb28570a61 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/SOURCES @@ -0,0 +1,13 @@ +mem_fence/fence.cl +synchronization/barrier.cl +workitem/get_global_id.cl +workitem/get_group_id.cl +workitem/get_local_id.cl +workitem/get_local_linear_id.cl +workitem/get_local_size.cl +workitem/get_max_sub_group_size.cl +workitem/get_num_groups.cl +workitem/get_num_sub_groups.cl +workitem/get_sub_group_id.cl +workitem/get_sub_group_local_id.cl +workitem/get_sub_group_size.cl diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/mem_fence/fence.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/mem_fence/fence.cl new file mode 100644 index 0000000000..d24569ecda --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/mem_fence/fence.cl @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DEF _CLC_OVERLOAD void mem_fence(cl_mem_fence_flags flags) { + if (flags & (CLK_GLOBAL_MEM_FENCE | CLK_LOCAL_MEM_FENCE)) + __nvvm_membar_cta(); +} + +// We do not have separate mechanism for read and write fences. +_CLC_DEF _CLC_OVERLOAD void read_mem_fence(cl_mem_fence_flags flags) { + mem_fence(flags); +} + +_CLC_DEF _CLC_OVERLOAD void write_mem_fence(cl_mem_fence_flags flags) { + mem_fence(flags); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/synchronization/barrier.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/synchronization/barrier.cl new file mode 100644 index 0000000000..7c57478795 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/synchronization/barrier.cl @@ -0,0 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DEF _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags) { + __syncthreads(); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_global_id.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_global_id.cl new file mode 100644 index 0000000000..f09fa92dbe --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_global_id.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF size_t get_global_id(uint dim) { + return __clc_get_global_id(dim); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_group_id.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_group_id.cl new file mode 100644 index 0000000000..1bcd756bdd --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_group_id.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF size_t get_group_id(uint dim) { + return __clc_get_group_id(dim); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_local_id.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_local_id.cl new file mode 100644 index 0000000000..f355b757b8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_local_id.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF size_t get_local_id(uint dim) { + return __clc_get_local_id(dim); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_local_linear_id.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_local_linear_id.cl new file mode 100644 index 0000000000..8c7637b4fe --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_local_linear_id.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF size_t get_local_linear_id() { + return __clc_get_local_linear_id(); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_local_size.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_local_size.cl new file mode 100644 index 0000000000..b146c1ea19 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_local_size.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF size_t get_local_size(uint dim) { + return __clc_get_local_size(dim); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_max_sub_group_size.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_max_sub_group_size.cl new file mode 100644 index 0000000000..fd76f7c5d0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_max_sub_group_size.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF uint get_max_sub_group_size() { + return __clc_get_max_sub_group_size(); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_num_groups.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_num_groups.cl new file mode 100644 index 0000000000..87e285d502 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_num_groups.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF size_t get_num_groups(uint dim) { + return __clc_get_num_groups(dim); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_num_sub_groups.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_num_sub_groups.cl new file mode 100644 index 0000000000..1be77a325c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_num_sub_groups.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF uint get_num_sub_groups() { + return __clc_get_num_sub_groups(); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_sub_group_id.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_sub_group_id.cl new file mode 100644 index 0000000000..e538b86f12 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_sub_group_id.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF uint get_sub_group_id() { + return __clc_get_sub_group_id(); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_sub_group_local_id.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_sub_group_local_id.cl new file mode 100644 index 0000000000..2a8cfd57d8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_sub_group_local_id.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF uint get_sub_group_local_id() { + return __clc_get_sub_group_local_id(); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_sub_group_size.cl b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_sub_group_size.cl new file mode 100644 index 0000000000..f32d820d64 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/ptx-nvidiacl/workitem/get_sub_group_size.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_OVERLOAD _CLC_DEF uint get_sub_group_size() { + return __clc_get_sub_group_size(); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/SOURCES b/local/recipes/dev/libclc/source/opencl/lib/r600/SOURCES new file mode 100644 index 0000000000..c4561274d8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/SOURCES @@ -0,0 +1,8 @@ +synchronization/barrier.cl +workitem/get_global_offset.cl +workitem/get_group_id.cl +workitem/get_global_size.cl +workitem/get_local_id.cl +workitem/get_local_size.cl +workitem/get_num_groups.cl +workitem/get_work_dim.cl diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/SOURCES_3.9 b/local/recipes/dev/libclc/source/opencl/lib/r600/SOURCES_3.9 new file mode 100644 index 0000000000..a44a9ce807 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/SOURCES_3.9 @@ -0,0 +1,15 @@ +image/get_image_dim.cl +image/get_image_width.cl +image/get_image_height.cl +image/get_image_depth.cl +image/get_image_channel_data_type.cl +image/get_image_channel_order.cl +image/get_image_attributes_impl.ll +image/read_imagef.cl +image/read_imagei.cl +image/read_imageui.cl +image/read_image_impl.ll +image/write_imagef.cl +image/write_imagei.cl +image/write_imageui.cl +image/write_image_impl.ll diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_attributes_impl.ll b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_attributes_impl.ll new file mode 100644 index 0000000000..e7b605df62 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_attributes_impl.ll @@ -0,0 +1,95 @@ +;;===----------------------------------------------------------------------===;; +; +; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +; See https://llvm.org/LICENSE.txt for license information. +; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +; +;;===----------------------------------------------------------------------===;; + +%opencl.image2d_t = type opaque +%opencl.image3d_t = type opaque + +declare i32 @llvm.OpenCL.image.get.resource.id.2d( + %opencl.image2d_t addrspace(1)*) nounwind readnone +declare i32 @llvm.OpenCL.image.get.resource.id.3d( + %opencl.image3d_t addrspace(1)*) nounwind readnone + +declare [3 x i32] @llvm.OpenCL.image.get.size.2d( + %opencl.image2d_t addrspace(1)*) nounwind readnone +declare [3 x i32] @llvm.OpenCL.image.get.size.3d( + %opencl.image3d_t addrspace(1)*) nounwind readnone + +declare [2 x i32] @llvm.OpenCL.image.get.format.2d( + %opencl.image2d_t addrspace(1)*) nounwind readnone +declare [2 x i32] @llvm.OpenCL.image.get.format.3d( + %opencl.image3d_t addrspace(1)*) nounwind readnone + +define i32 @__clc_get_image_width_2d( + %opencl.image2d_t addrspace(1)* nocapture %img) #0 { + %1 = tail call [3 x i32] @llvm.OpenCL.image.get.size.2d( + %opencl.image2d_t addrspace(1)* %img) + %2 = extractvalue [3 x i32] %1, 0 + ret i32 %2 +} +define i32 @__clc_get_image_width_3d( + %opencl.image3d_t addrspace(1)* nocapture %img) #0 { + %1 = tail call [3 x i32] @llvm.OpenCL.image.get.size.3d( + %opencl.image3d_t addrspace(1)* %img) + %2 = extractvalue [3 x i32] %1, 0 + ret i32 %2 +} + +define i32 @__clc_get_image_height_2d( + %opencl.image2d_t addrspace(1)* nocapture %img) #0 { + %1 = tail call [3 x i32] @llvm.OpenCL.image.get.size.2d( + %opencl.image2d_t addrspace(1)* %img) + %2 = extractvalue [3 x i32] %1, 1 + ret i32 %2 +} +define i32 @__clc_get_image_height_3d( + %opencl.image3d_t addrspace(1)* nocapture %img) #0 { + %1 = tail call [3 x i32] @llvm.OpenCL.image.get.size.3d( + %opencl.image3d_t addrspace(1)* %img) + %2 = extractvalue [3 x i32] %1, 1 + ret i32 %2 +} + +define i32 @__clc_get_image_depth_3d( + %opencl.image3d_t addrspace(1)* nocapture %img) #0 { + %1 = tail call [3 x i32] @llvm.OpenCL.image.get.size.3d( + %opencl.image3d_t addrspace(1)* %img) + %2 = extractvalue [3 x i32] %1, 2 + ret i32 %2 +} + +define i32 @__clc_get_image_channel_data_type_2d( + %opencl.image2d_t addrspace(1)* nocapture %img) #0 { + %1 = tail call [2 x i32] @llvm.OpenCL.image.get.format.2d( + %opencl.image2d_t addrspace(1)* %img) + %2 = extractvalue [2 x i32] %1, 0 + ret i32 %2 +} +define i32 @__clc_get_image_channel_data_type_3d( + %opencl.image3d_t addrspace(1)* nocapture %img) #0 { + %1 = tail call [2 x i32] @llvm.OpenCL.image.get.format.3d( + %opencl.image3d_t addrspace(1)* %img) + %2 = extractvalue [2 x i32] %1, 0 + ret i32 %2 +} + +define i32 @__clc_get_image_channel_order_2d( + %opencl.image2d_t addrspace(1)* nocapture %img) #0 { + %1 = tail call [2 x i32] @llvm.OpenCL.image.get.format.2d( + %opencl.image2d_t addrspace(1)* %img) + %2 = extractvalue [2 x i32] %1, 1 + ret i32 %2 +} +define i32 @__clc_get_image_channel_order_3d( + %opencl.image3d_t addrspace(1)* nocapture %img) #0 { + %1 = tail call [2 x i32] @llvm.OpenCL.image.get.format.3d( + %opencl.image3d_t addrspace(1)* %img) + %2 = extractvalue [2 x i32] %1, 1 + ret i32 %2 +} + +attributes #0 = { nounwind readnone alwaysinline } diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_channel_data_type.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_channel_data_type.cl new file mode 100644 index 0000000000..f28b7d458c --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_channel_data_type.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DECL int __clc_get_image_channel_data_type_2d(image2d_t); +_CLC_DECL int __clc_get_image_channel_data_type_3d(image3d_t); + +_CLC_OVERLOAD _CLC_DEF int get_image_channel_data_type(image2d_t image) { + return __clc_get_image_channel_data_type_2d(image); +} +_CLC_OVERLOAD _CLC_DEF int get_image_channel_data_type(image3d_t image) { + return __clc_get_image_channel_data_type_3d(image); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_channel_order.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_channel_order.cl new file mode 100644 index 0000000000..da6d783e7f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_channel_order.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DECL int __clc_get_image_channel_order_2d(image2d_t); +_CLC_DECL int __clc_get_image_channel_order_3d(image3d_t); + +_CLC_OVERLOAD _CLC_DEF int get_image_channel_order(image2d_t image) { + return __clc_get_image_channel_order_2d(image); +} +_CLC_OVERLOAD _CLC_DEF int get_image_channel_order(image3d_t image) { + return __clc_get_image_channel_order_3d(image); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_depth.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_depth.cl new file mode 100644 index 0000000000..1731d85dc4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_depth.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DECL int __clc_get_image_depth_3d(image3d_t); + +_CLC_OVERLOAD _CLC_DEF int get_image_depth(image3d_t image) { + return __clc_get_image_depth_3d(image); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_dim.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_dim.cl new file mode 100644 index 0000000000..6929d12ad1 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_dim.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_OVERLOAD _CLC_DEF int2 get_image_dim(image2d_t image) { + return (int2)(get_image_width(image), get_image_height(image)); +} +_CLC_OVERLOAD _CLC_DEF int4 get_image_dim(image3d_t image) { + return (int4)(get_image_width(image), get_image_height(image), + get_image_depth(image), 0); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_height.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_height.cl new file mode 100644 index 0000000000..14a21823a8 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_height.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DECL int __clc_get_image_height_2d(image2d_t); +_CLC_DECL int __clc_get_image_height_3d(image3d_t); + +_CLC_OVERLOAD _CLC_DEF int get_image_height(image2d_t image) { + return __clc_get_image_height_2d(image); +} +_CLC_OVERLOAD _CLC_DEF int get_image_height(image3d_t image) { + return __clc_get_image_height_3d(image); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_width.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_width.cl new file mode 100644 index 0000000000..fa54ec3628 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/get_image_width.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DECL int __clc_get_image_width_2d(image2d_t); +_CLC_DECL int __clc_get_image_width_3d(image3d_t); + +_CLC_OVERLOAD _CLC_DEF int get_image_width(image2d_t image) { + return __clc_get_image_width_2d(image); +} +_CLC_OVERLOAD _CLC_DEF int get_image_width(image3d_t image) { + return __clc_get_image_width_3d(image); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/read_image_impl.ll b/local/recipes/dev/libclc/source/opencl/lib/r600/image/read_image_impl.ll new file mode 100644 index 0000000000..00b80b63f4 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/read_image_impl.ll @@ -0,0 +1,54 @@ +;;===----------------------------------------------------------------------===;; +; +; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +; See https://llvm.org/LICENSE.txt for license information. +; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +; +;;===----------------------------------------------------------------------===;; + +%opencl.image2d_t = type opaque + +declare <4 x float> @llvm.R600.tex(<4 x float>, i32, i32, i32, i32, i32, i32, + i32, i32, i32) readnone +declare i32 @llvm.OpenCL.image.get.resource.id.2d( + %opencl.image2d_t addrspace(1)*) nounwind readnone +declare i32 @llvm.OpenCL.sampler.get.resource.id(i32) readnone + +define <4 x float> @__clc_v4f_from_v2f(<2 x float> %v) alwaysinline { + %e0 = extractelement <2 x float> %v, i32 0 + %e1 = extractelement <2 x float> %v, i32 1 + %res.0 = insertelement <4 x float> poison, float %e0, i32 0 + %res.1 = insertelement <4 x float> %res.0, float %e1, i32 1 + %res.2 = insertelement <4 x float> %res.1, float 0.0, i32 2 + %res.3 = insertelement <4 x float> %res.2, float 0.0, i32 3 + ret <4 x float> %res.3 +} + +define <4 x float> @__clc_read_imagef_tex( + %opencl.image2d_t addrspace(1)* nocapture %img, + i32 %sampler, <2 x float> %coord) alwaysinline { +entry: + %coord_v4 = call <4 x float> @__clc_v4f_from_v2f(<2 x float> %coord) + %smp_id = call i32 @llvm.OpenCL.sampler.get.resource.id(i32 %sampler) + %img_id = call i32 @llvm.OpenCL.image.get.resource.id.2d( + %opencl.image2d_t addrspace(1)* %img) + %tex_id = add i32 %img_id, 2 ; First 2 IDs are reserved. + + %coord_norm = and i32 %sampler, 1 + %is_norm = icmp eq i32 %coord_norm, 1 + br i1 %is_norm, label %NormCoord, label %UnnormCoord +NormCoord: + %data.norm = call <4 x float> @llvm.R600.tex( + <4 x float> %coord_v4, + i32 0, i32 0, i32 0, ; Offset. + i32 2, i32 %smp_id, + i32 1, i32 1, i32 1, i32 1) ; Normalized coords. + ret <4 x float> %data.norm +UnnormCoord: + %data.unnorm = call <4 x float> @llvm.R600.tex( + <4 x float> %coord_v4, + i32 0, i32 0, i32 0, ; Offset. + i32 %tex_id, i32 %smp_id, + i32 0, i32 0, i32 0, i32 0) ; Unnormalized coords. + ret <4 x float> %data.unnorm +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/read_imagef.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/image/read_imagef.cl new file mode 100644 index 0000000000..fc597b762e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/read_imagef.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DECL float4 __clc_read_imagef_tex(image2d_t, sampler_t, float2); + +_CLC_OVERLOAD _CLC_DEF float4 read_imagef(image2d_t image, sampler_t sampler, + int2 coord) { + float2 coord_float = (float2)(coord.x, coord.y); + return __clc_read_imagef_tex(image, sampler, coord_float); +} + +_CLC_OVERLOAD _CLC_DEF float4 read_imagef(image2d_t image, sampler_t sampler, + float2 coord) { + return __clc_read_imagef_tex(image, sampler, coord); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/read_imagei.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/image/read_imagei.cl new file mode 100644 index 0000000000..bc54a631ea --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/read_imagei.cl @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DECL float4 __clc_read_imagef_tex(image2d_t, sampler_t, float2); + +int4 __clc_reinterpret_v4f_to_v4i(float4 v) { + union { + int4 v4i; + float4 v4f; + } res = {.v4f = v}; + return res.v4i; +} + +_CLC_OVERLOAD _CLC_DEF int4 read_imagei(image2d_t image, sampler_t sampler, + int2 coord) { + float2 coord_float = (float2)(coord.x, coord.y); + return __clc_reinterpret_v4f_to_v4i( + __clc_read_imagef_tex(image, sampler, coord_float)); +} +_CLC_OVERLOAD _CLC_DEF int4 read_imagei(image2d_t image, sampler_t sampler, + float2 coord) { + return __clc_reinterpret_v4f_to_v4i( + __clc_read_imagef_tex(image, sampler, coord)); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/read_imageui.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/image/read_imageui.cl new file mode 100644 index 0000000000..8c266b9f2f --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/read_imageui.cl @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DECL float4 __clc_read_imagef_tex(image2d_t, sampler_t, float2); + +uint4 __clc_reinterpret_v4f_to_v4ui(float4 v) { + union { + uint4 v4ui; + float4 v4f; + } res = {.v4f = v}; + return res.v4ui; +} + +_CLC_OVERLOAD _CLC_DEF uint4 read_imageui(image2d_t image, sampler_t sampler, + int2 coord) { + float2 coord_float = (float2)(coord.x, coord.y); + return __clc_reinterpret_v4f_to_v4ui( + __clc_read_imagef_tex(image, sampler, coord_float)); +} +_CLC_OVERLOAD _CLC_DEF uint4 read_imageui(image2d_t image, sampler_t sampler, + float2 coord) { + return __clc_reinterpret_v4f_to_v4ui( + __clc_read_imagef_tex(image, sampler, coord)); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/write_image_impl.ll b/local/recipes/dev/libclc/source/opencl/lib/r600/image/write_image_impl.ll new file mode 100644 index 0000000000..0759f0e2f9 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/write_image_impl.ll @@ -0,0 +1,60 @@ +;;===----------------------------------------------------------------------===;; +; +; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +; See https://llvm.org/LICENSE.txt for license information. +; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +; +;;===----------------------------------------------------------------------===;; + +%opencl.image2d_t = type opaque +%opencl.image3d_t = type opaque + +declare i32 @llvm.OpenCL.image.get.resource.id.2d( + %opencl.image2d_t addrspace(1)*) nounwind readnone +declare i32 @llvm.OpenCL.image.get.resource.id.3d( + %opencl.image3d_t addrspace(1)*) nounwind readnone + +declare void @llvm.r600.rat.store.typed(<4 x i32> %color, <4 x i32> %coord, i32 %rat_id) + +define void @__clc_write_imageui_2d( + %opencl.image2d_t addrspace(1)* nocapture %img, + <2 x i32> %coord, <4 x i32> %color) #0 { + + ; Coordinate int2 -> int4. + %e0 = extractelement <2 x i32> %coord, i32 0 + %e1 = extractelement <2 x i32> %coord, i32 1 + %coord.0 = insertelement <4 x i32> poison, i32 %e0, i32 0 + %coord.1 = insertelement <4 x i32> %coord.0, i32 %e1, i32 1 + %coord.2 = insertelement <4 x i32> %coord.1, i32 0, i32 2 + %coord.3 = insertelement <4 x i32> %coord.2, i32 0, i32 3 + + ; Get RAT ID. + %img_id = call i32 @llvm.OpenCL.image.get.resource.id.2d( + %opencl.image2d_t addrspace(1)* %img) + %rat_id = add i32 %img_id, 1 + + ; Call store intrinsic. + call void @llvm.r600.rat.store.typed(<4 x i32> %color, <4 x i32> %coord.3, i32 %rat_id) + ret void +} + +define void @__clc_write_imagei_2d( + %opencl.image2d_t addrspace(1)* nocapture %img, + <2 x i32> %coord, <4 x i32> %color) #0 { + call void @__clc_write_imageui_2d( + %opencl.image2d_t addrspace(1)* nocapture %img, + <2 x i32> %coord, <4 x i32> %color) + ret void +} + +define void @__clc_write_imagef_2d( + %opencl.image2d_t addrspace(1)* nocapture %img, + <2 x i32> %coord, <4 x float> %color) #0 { + %color.i32 = bitcast <4 x float> %color to <4 x i32> + call void @__clc_write_imageui_2d( + %opencl.image2d_t addrspace(1)* nocapture %img, + <2 x i32> %coord, <4 x i32> %color.i32) + ret void +} + +attributes #0 = { alwaysinline } diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/write_imagef.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/image/write_imagef.cl new file mode 100644 index 0000000000..0e828acad0 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/write_imagef.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DECL void __clc_write_imagef_2d(image2d_t image, int2 coord, float4 color); + +_CLC_OVERLOAD _CLC_DEF void write_imagef(image2d_t image, int2 coord, + float4 color) { + __clc_write_imagef_2d(image, coord, color); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/write_imagei.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/image/write_imagei.cl new file mode 100644 index 0000000000..88ea35634a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/write_imagei.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DECL void __clc_write_imagei_2d(image2d_t image, int2 coord, int4 color); + +_CLC_OVERLOAD _CLC_DEF void write_imagei(image2d_t image, int2 coord, + int4 color) { + __clc_write_imagei_2d(image, coord, color); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/image/write_imageui.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/image/write_imageui.cl new file mode 100644 index 0000000000..40f3f33345 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/image/write_imageui.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DECL void __clc_write_imageui_2d(image2d_t image, int2 coord, uint4 color); + +_CLC_OVERLOAD _CLC_DEF void write_imageui(image2d_t image, int2 coord, + uint4 color) { + __clc_write_imageui_2d(image, coord, color); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/synchronization/barrier.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/synchronization/barrier.cl new file mode 100644 index 0000000000..69e87d9497 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/synchronization/barrier.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DEF void __clc_r600_barrier(void) __asm("llvm.r600.group.barrier"); + +_CLC_DEF _CLC_OVERLOAD void barrier(uint flags) { + // We should call mem_fence here, but that is not implemented for r600 yet + __clc_r600_barrier(); +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_global_offset.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_global_offset.cl new file mode 100644 index 0000000000..988e482de2 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_global_offset.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DEF _CLC_OVERLOAD uint get_global_offset(uint dim) { + __attribute__((address_space(7))) uint *ptr = + (__attribute__((address_space(7))) + uint *)__builtin_r600_implicitarg_ptr(); + if (dim < 3) + return ptr[dim + 1]; + return 0; +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_global_size.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_global_size.cl new file mode 100644 index 0000000000..298487f87d --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_global_size.cl @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +uint __clc_r600_get_global_size_x(void) __asm("llvm.r600.read.global.size.x"); +uint __clc_r600_get_global_size_y(void) __asm("llvm.r600.read.global.size.y"); +uint __clc_r600_get_global_size_z(void) __asm("llvm.r600.read.global.size.z"); + +_CLC_DEF _CLC_OVERLOAD size_t get_global_size(uint dim) { + switch (dim) { + case 0: + return __clc_r600_get_global_size_x(); + case 1: + return __clc_r600_get_global_size_y(); + case 2: + return __clc_r600_get_global_size_z(); + default: + return 1; + } +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_group_id.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_group_id.cl new file mode 100644 index 0000000000..196f0f2124 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_group_id.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DEF _CLC_OVERLOAD uint get_group_id(uint dim) { + switch (dim) { + case 0: + return __builtin_r600_read_tgid_x(); + case 1: + return __builtin_r600_read_tgid_y(); + case 2: + return __builtin_r600_read_tgid_z(); + default: + return 1; + } +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_local_id.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_local_id.cl new file mode 100644 index 0000000000..1321e1e836 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_local_id.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DEF _CLC_OVERLOAD uint get_local_id(uint dim) { + switch (dim) { + case 0: + return __builtin_r600_read_tidig_x(); + case 1: + return __builtin_r600_read_tidig_y(); + case 2: + return __builtin_r600_read_tidig_z(); + default: + return 1; + } +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_local_size.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_local_size.cl new file mode 100644 index 0000000000..c0e4e15542 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_local_size.cl @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +uint __clc_r600_get_local_size_x(void) __asm("llvm.r600.read.local.size.x"); +uint __clc_r600_get_local_size_y(void) __asm("llvm.r600.read.local.size.y"); +uint __clc_r600_get_local_size_z(void) __asm("llvm.r600.read.local.size.z"); + +_CLC_DEF _CLC_OVERLOAD size_t get_local_size(uint dim) { + switch (dim) { + case 0: + return __clc_r600_get_local_size_x(); + case 1: + return __clc_r600_get_local_size_y(); + case 2: + return __clc_r600_get_local_size_z(); + default: + return 1; + } +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_num_groups.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_num_groups.cl new file mode 100644 index 0000000000..098a9cb86a --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_num_groups.cl @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +uint __clc_r600_get_num_groups_x(void) __asm("llvm.r600.read.ngroups.x"); +uint __clc_r600_get_num_groups_y(void) __asm("llvm.r600.read.ngroups.y"); +uint __clc_r600_get_num_groups_z(void) __asm("llvm.r600.read.ngroups.z"); + +_CLC_DEF _CLC_OVERLOAD size_t get_num_groups(uint dim) { + switch (dim) { + case 0: + return __clc_r600_get_num_groups_x(); + case 1: + return __clc_r600_get_num_groups_y(); + case 2: + return __clc_r600_get_num_groups_z(); + default: + return 1; + } +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_work_dim.cl b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_work_dim.cl new file mode 100644 index 0000000000..a7917b864e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/r600/workitem/get_work_dim.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +_CLC_DEF _CLC_OVERLOAD uint get_work_dim(void) { + __attribute__((address_space(7))) uint *ptr = + (__attribute__((address_space(7))) + uint *)__builtin_r600_implicitarg_ptr(); + return ptr[0]; +} diff --git a/local/recipes/dev/libclc/source/opencl/lib/spirv/SOURCES b/local/recipes/dev/libclc/source/opencl/lib/spirv/SOURCES new file mode 100644 index 0000000000..0aa923978e --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/spirv/SOURCES @@ -0,0 +1,73 @@ +subnormal_config.cl +../generic/async/async_work_group_strided_copy.cl +../generic/async/wait_group_events.cl +../generic/common/degrees.cl +../generic/common/mix.cl +../generic/common/radians.cl +../generic/common/sign.cl +../generic/common/smoothstep.cl +../generic/common/step.cl +../generic/geometric/cross.cl +../generic/geometric/distance.cl +../generic/geometric/dot.cl +../generic/geometric/fast_distance.cl +../generic/geometric/fast_length.cl +../generic/geometric/fast_normalize.cl +../generic/geometric/length.cl +../generic/geometric/normalize.cl +../generic/integer/rotate.cl +../generic/integer/mad_sat.cl +../generic/math/acos.cl +../generic/math/acosh.cl +../generic/math/acospi.cl +../generic/math/asin.cl +../generic/math/asinh.cl +../generic/math/asinpi.cl +../generic/math/atan.cl +../generic/math/atan2.cl +../generic/math/atan2pi.cl +../generic/math/atanh.cl +../generic/math/atanpi.cl +../generic/math/cbrt.cl +../generic/math/cos.cl +../generic/math/cosh.cl +../generic/math/cospi.cl +../generic/math/erf.cl +../generic/math/erfc.cl +../generic/math/exp.cl +../generic/math/expm1.cl +../generic/math/exp2.cl +../generic/math/exp10.cl +math/fma.cl +../generic/math/fmod.cl +../generic/math/fract.cl +../generic/math/frexp.cl +../generic/math/half_rsqrt.cl +../generic/math/half_sqrt.cl +../generic/math/hypot.cl +../generic/math/ilogb.cl +../generic/math/ldexp.cl +../generic/math/lgamma.cl +../generic/math/lgamma_r.cl +../generic/math/log.cl +../generic/math/log10.cl +../generic/math/log1p.cl +../generic/math/log2.cl +../generic/math/logb.cl +../generic/math/modf.cl +../generic/math/pow.cl +../generic/math/pown.cl +../generic/math/powr.cl +../generic/math/remainder.cl +../generic/math/remquo.cl +../generic/math/rootn.cl +../generic/math/sin.cl +../generic/math/sincos.cl +../generic/math/sinh.cl +../generic/math/sinpi.cl +../generic/math/tan.cl +../generic/math/tanh.cl +../generic/math/tanpi.cl +../generic/math/tgamma.cl +../generic/shared/vload.cl +../generic/shared/vstore.cl diff --git a/local/recipes/dev/libclc/source/opencl/lib/spirv/math/fma.cl b/local/recipes/dev/libclc/source/opencl/lib/spirv/math/fma.cl new file mode 100644 index 0000000000..83504f6377 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/spirv/math/fma.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +#define __FLOAT_ONLY +#define FUNCTION fma +#define __IMPL_FUNCTION(x) __clc_sw_fma +#define __CLC_BODY + +#include diff --git a/local/recipes/dev/libclc/source/opencl/lib/spirv/subnormal_config.cl b/local/recipes/dev/libclc/source/opencl/lib/spirv/subnormal_config.cl new file mode 100644 index 0000000000..114aabb2e9 --- /dev/null +++ b/local/recipes/dev/libclc/source/opencl/lib/spirv/subnormal_config.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include + +_CLC_DEF bool __clc_fp16_subnormals_supported() { return false; } + +_CLC_DEF bool __clc_fp32_subnormals_supported() { return false; } + +_CLC_DEF bool __clc_fp64_subnormals_supported() { return false; } diff --git a/local/recipes/dev/libclc/source/test/add_sat.cl b/local/recipes/dev/libclc/source/test/add_sat.cl new file mode 100644 index 0000000000..87c3d39df3 --- /dev/null +++ b/local/recipes/dev/libclc/source/test/add_sat.cl @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +__kernel void foo(__global char *a, __global char *b, __global char *c) { + *a = add_sat(*b, *c); +} diff --git a/local/recipes/dev/libclc/source/test/as_type.cl b/local/recipes/dev/libclc/source/test/as_type.cl new file mode 100644 index 0000000000..a926f48c4e --- /dev/null +++ b/local/recipes/dev/libclc/source/test/as_type.cl @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +__kernel void foo(int4 *x, float4 *y) { + *x = as_int4(*y); +} diff --git a/local/recipes/dev/libclc/source/test/convert.cl b/local/recipes/dev/libclc/source/test/convert.cl new file mode 100644 index 0000000000..8eba608dc5 --- /dev/null +++ b/local/recipes/dev/libclc/source/test/convert.cl @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +__kernel void foo(int4 *x, float4 *y) { + *x = convert_int4(*y); +} diff --git a/local/recipes/dev/libclc/source/test/cos.cl b/local/recipes/dev/libclc/source/test/cos.cl new file mode 100644 index 0000000000..92a998b3ba --- /dev/null +++ b/local/recipes/dev/libclc/source/test/cos.cl @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +__kernel void foo(float4 *f) { + *f = cos(*f); +} diff --git a/local/recipes/dev/libclc/source/test/cross.cl b/local/recipes/dev/libclc/source/test/cross.cl new file mode 100644 index 0000000000..90762d0d07 --- /dev/null +++ b/local/recipes/dev/libclc/source/test/cross.cl @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +__kernel void foo(float4 *f) { + *f = cross(f[0], f[1]); +} diff --git a/local/recipes/dev/libclc/source/test/fabs.cl b/local/recipes/dev/libclc/source/test/fabs.cl new file mode 100644 index 0000000000..3f5a964e04 --- /dev/null +++ b/local/recipes/dev/libclc/source/test/fabs.cl @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +__kernel void foo(float *f) { + *f = fabs(*f); +} diff --git a/local/recipes/dev/libclc/source/test/get_group_id.cl b/local/recipes/dev/libclc/source/test/get_group_id.cl new file mode 100644 index 0000000000..c2349a0076 --- /dev/null +++ b/local/recipes/dev/libclc/source/test/get_group_id.cl @@ -0,0 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +__kernel void foo(int *i) { + i[get_group_id(0)] = 1; +} diff --git a/local/recipes/dev/libclc/source/test/rsqrt.cl b/local/recipes/dev/libclc/source/test/rsqrt.cl new file mode 100644 index 0000000000..4eebfe8ecf --- /dev/null +++ b/local/recipes/dev/libclc/source/test/rsqrt.cl @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +__kernel void foo(float4 *x, double4 *y) { + x[1] = rsqrt(x[0]); + y[1] = rsqrt(y[0]); +} diff --git a/local/recipes/dev/libclc/source/test/subsat.cl b/local/recipes/dev/libclc/source/test/subsat.cl new file mode 100644 index 0000000000..5e6fbdcfbe --- /dev/null +++ b/local/recipes/dev/libclc/source/test/subsat.cl @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +__kernel void test_subsat_char(char *a, char x, char y) { + *a = sub_sat(x, y); + return; +} + +__kernel void test_subsat_uchar(uchar *a, uchar x, uchar y) { + *a = sub_sat(x, y); + return; +} + +__kernel void test_subsat_long(long *a, long x, long y) { + *a = sub_sat(x, y); + return; +} + +__kernel void test_subsat_ulong(ulong *a, ulong x, ulong y) { + *a = sub_sat(x, y); + return; +} \ No newline at end of file diff --git a/local/recipes/dev/libclc/source/utils/gen_convert.py b/local/recipes/dev/libclc/source/utils/gen_convert.py new file mode 100644 index 0000000000..737ab9d1a5 --- /dev/null +++ b/local/recipes/dev/libclc/source/utils/gen_convert.py @@ -0,0 +1,550 @@ +##===----------------------------------------------------------------------===## +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +##===----------------------------------------------------------------------===## +# +# This script generates OpenCL type conversion builtins, which are all of the +# OpenCL functions in the form: +# +# convert_<_sat><_roundingMode>() +# +# The internal "CLC" versions of these builtins, with the '__clc_' +# contain the actual implementations. These are generated by passing the +# '--clc' flag to the script. +# +# The OpenCL builtins, without any prefix, forward on to the CLC versions. +# +##===----------------------------------------------------------------------===## + +import argparse +from sys import stderr +from os import path + +parser = argparse.ArgumentParser() +parser.add_argument( + "--clc", action="store_true", help="Generate clc internal conversions" +) +parser.add_argument( + "--clspv", action="store_true", help="Generate the clspv variant of the code" +) +args = parser.parse_args() + +clc = args.clc +clspv = args.clspv + + +# We don't generate clspv-specific code for clc conversions - don't allow this +# accidentally (later checks rely on mutual exclusivity) +if clc and clspv: + print("Error: clc and clspv conversions are mutually exclusive", file=stderr) + exit(1) + + +types = [ + "char", + "uchar", + "short", + "ushort", + "int", + "uint", + "long", + "ulong", + "half", + "float", + "double", +] +int_types = ["char", "uchar", "short", "ushort", "int", "uint", "long", "ulong"] +unsigned_types = ["uchar", "ushort", "uint", "ulong"] +float_types = ["half", "float", "double"] +int64_types = ["long", "ulong"] +float64_types = ["double"] +float16_types = ["half"] +vector_sizes = ["", "2", "3", "4", "8", "16"] +half_sizes = [("2", ""), ("4", "2"), ("8", "4"), ("16", "8")] + +saturation = ["", "_sat"] +rounding_modes = ["_rtz", "_rte", "_rtp", "_rtn"] + +bool_type = { + "char": "char", + "uchar": "char", + "short": "short", + "ushort": "short", + "int": "int", + "uint": "int", + "long": "long", + "ulong": "long", + "half": "short", + "float": "int", + "double": "long", +} + +unsigned_type = { + "char": "uchar", + "uchar": "uchar", + "short": "ushort", + "ushort": "ushort", + "int": "uint", + "uint": "uint", + "long": "ulong", + "ulong": "ulong", +} + +sizeof_type = { + "char": 1, + "uchar": 1, + "short": 2, + "ushort": 2, + "int": 4, + "uint": 4, + "long": 8, + "ulong": 8, + "half": 2, + "float": 4, + "double": 8, +} + +limit_max = { + "char": "CHAR_MAX", + "uchar": "UCHAR_MAX", + "short": "SHRT_MAX", + "ushort": "USHRT_MAX", + "int": "INT_MAX", + "uint": "UINT_MAX", + "long": "LONG_MAX", + "ulong": "ULONG_MAX", + "half": "0x1.ffcp+15", +} + +limit_min = { + "char": "CHAR_MIN", + "uchar": "0", + "short": "SHRT_MIN", + "ushort": "0", + "int": "INT_MIN", + "uint": "0", + "long": "LONG_MIN", + "ulong": "0", + "half": "-0x1.ffcp+15", +} + + +def conditional_guard(src, dst): + int64_count = 0 + float64_count = 0 + float16_count = 0 + if src in int64_types: + int64_count = int64_count + 1 + elif src in float64_types: + float64_count = float64_count + 1 + elif src in float16_types: + float16_count = float16_count + 1 + if dst in int64_types: + int64_count = int64_count + 1 + elif dst in float64_types: + float64_count = float64_count + 1 + elif dst in float16_types: + float16_count = float16_count + 1 + if float64_count > 0 and float16_count > 0: + print("#if defined(cl_khr_fp16) && defined(cl_khr_fp64)") + return True + elif float64_count > 0: + # In embedded profile, if cl_khr_fp64 is supported cles_khr_int64 has to be + print("#ifdef cl_khr_fp64") + return True + elif float16_count > 0: + print("#if defined cl_khr_fp16") + return True + elif int64_count > 0: + print("#if defined cles_khr_int64 || !defined(__EMBEDDED_PROFILE__)") + return True + return False + + +nl = "\n" +includes = [] +if not clc: + includes = [""] +else: + includes = sorted( + [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + ] + ) + +print( + f"""//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Automatically generated from {path.basename(__file__)}, do not edit! +// +// OpenCL type conversion functions +// +//===----------------------------------------------------------------------===// + +{nl.join(['#include ' + f for f in includes])} +#include + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#endif + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +#if defined(__EMBEDDED_PROFILE__) && !defined(cles_khr_int64) +#error Embedded profile that supports cl_khr_fp64 also has to support cles_khr_int64 +#endif + +#endif + +#ifdef cles_khr_int64 +#pragma OPENCL EXTENSION cles_khr_int64 : enable +#endif + +""" +) + + +# +# Default Conversions +# +# All conversions are in accordance with the OpenCL specification, +# which cites the C99 conversion rules. +# +# Casting from floating point to integer results in conversions +# with truncation, so it should be suitable for the default convert +# functions. +# +# Conversions from integer to floating-point, and floating-point to +# floating-point through casting is done with the default rounding +# mode. While C99 allows dynamically changing the rounding mode +# during runtime, it is not a supported feature in OpenCL according +# to Section 7.1 - Rounding Modes in the OpenCL 1.2 specification. +# +# Therefore, we can assume for optimization purposes that the +# rounding mode is fixed to round-to-nearest-even. Platform target +# authors should ensure that the rounding-control registers remain +# in this state, and that this invariant holds. +# +# Also note, even though the OpenCL specification isn't entirely +# clear on this matter, we implement all rounding mode combinations +# even for integer-to-integer conversions. When such a conversion +# is used, the rounding mode is ignored. +# +def print_passthru_conversion(src_ty, dst_ty, fn_name): + print( + f"""_CLC_DEF _CLC_OVERLOAD {dst_ty} {fn_name}({src_ty} x) {{ + return __clc_{fn_name}(x); +}} +""" + ) + + +def generate_default_conversion(src, dst, mode): + close_conditional = conditional_guard(src, dst) + + for size in vector_sizes: + if not size: + if clc: + print( + f"""_CLC_DEF _CLC_OVERLOAD {dst} __clc_convert_{dst}{mode}({src} x) {{ + return ({dst})x; +}} +""" + ) + else: + print_passthru_conversion(src, dst, f"convert_{dst}{mode}") + else: + if clc: + print( + f"""_CLC_DEF _CLC_OVERLOAD {dst}{size} __clc_convert_{dst}{size}{mode}({src}{size} x) {{ + return __builtin_convertvector(x, {dst}{size}); +}} +""" + ) + else: + print_passthru_conversion( + f"{src}{size}", f"{dst}{size}", f"convert_{dst}{size}{mode}" + ) + + if close_conditional: + print("#endif") + + +# Do not generate user-facing default conversions for clspv as they are handled +# natively +if not clspv: + for src in types: + for dst in types: + generate_default_conversion(src, dst, "") + +for src in int_types: + for dst in int_types: + for mode in rounding_modes: + # Do not generate user-facing "_rte" conversions for clspv as they + # are handled natively + if clspv and mode == "_rte": + continue + generate_default_conversion(src, dst, mode) + +# +# Saturated Conversions To Integers + + +# These functions are dependent on the unsaturated conversion functions +# generated above, and use clamp, max, min, and select to eliminate +# branching and vectorize the conversions. +# +# Again, as above, we allow all rounding modes for integer-to-integer +# conversions with saturation. +# +def generate_saturated_conversion(src, dst, size): + # Header + close_conditional = conditional_guard(src, dst) + + dstn = f"{dst}{size}" + srcn = f"{src}{size}" + + if not clc: + print_passthru_conversion(f"{srcn}", f"{dstn}", f"convert_{dstn}_sat") + if close_conditional: + print("#endif") + return + + print(f"_CLC_DEF _CLC_OVERLOAD {dstn} __clc_convert_{dstn}_sat({srcn} x) {{") + + # FIXME: This is a work around for lack of select function with signed + # third argument when the first two arguments are unsigned types. We cast + # to the signed type for sign-extension, then do a bitcast to the unsigned + # type. + if dst in unsigned_types: + bool_prefix = f"__clc_as_{dstn}(__clc_convert_{bool_type[dst]}{size}" + bool_suffix = ")" + else: + bool_prefix = f"__clc_convert_{bool_type[dst]}{size}" + bool_suffix = "" + + dst_max = limit_max[dst] + dst_min = limit_min[dst] + + # Body + if src == dst: + # Conversion between same types + print(" return x;") + + elif src in float_types: + # Conversion from float to int + print( + f""" {dstn} y = __clc_convert_{dstn}(x); + y = __clc_select(y, ({dstn}){dst_min}, {bool_prefix}(x <= ({srcn}){dst_min}){bool_suffix}); + y = __clc_select(y, ({dstn}){dst_max}, {bool_prefix}(x >= ({srcn}){dst_max}){bool_suffix}); + return y;""" + ) + else: + # Integer to integer convesion with sizeof(src) == sizeof(dst) + if sizeof_type[src] == sizeof_type[dst]: + if src in unsigned_types: + print(f" x = __clc_min(x, ({src}){dst_max});") + else: + print(f" x = __clc_max(x, ({src})0);") + + # Integer to integer conversion where sizeof(src) > sizeof(dst) + elif sizeof_type[src] > sizeof_type[dst]: + if src in unsigned_types: + print(f" x = __clc_min(x, ({src}){dst_max});") + else: + print(f" x = __clc_clamp(x, ({src}){dst_min}, ({src}){dst_max});") + + # Integer to integer conversion where sizeof(src) < sizeof(dst) + elif src not in unsigned_types and dst in unsigned_types: + print(f" x = __clc_max(x, ({src})0);") + + print(f" return __clc_convert_{dstn}(x);") + + # Footer + print("}") + if close_conditional: + print("#endif") + + +for src in types: + for dst in int_types: + for size in vector_sizes: + generate_saturated_conversion(src, dst, size) + + +def generate_saturated_conversion_with_rounding(src, dst, size, mode): + # Header + close_conditional = conditional_guard(src, dst) + + dstn = f"{dst}{size}" + srcn = f"{src}{size}" + + if not clc: + print_passthru_conversion(f"{srcn}", f"{dstn}", f"convert_{dstn}_sat{mode}") + else: + # Body + print( + f"""_CLC_DEF _CLC_OVERLOAD {dstn} __clc_convert_{dstn}_sat{mode}({srcn} x) {{ + return __clc_convert_{dstn}_sat(x); +}} +""" + ) + + # Footer + if close_conditional: + print("#endif") + + +for src in int_types: + for dst in int_types: + for size in vector_sizes: + for mode in rounding_modes: + generate_saturated_conversion_with_rounding(src, dst, size, mode) + + +# +# Conversions To/From Floating-Point With Rounding +# +# Note that we assume as above that casts from floating-point to +# integer are done with truncation, and that the default rounding +# mode is fixed to round-to-nearest-even, as per C99 and OpenCL +# rounding rules. +# +# These functions rely on the use of abs, ceil, fabs, floor, +# nextafter, sign, rint and the above generated conversion functions. +# +# Only conversions to integers can have saturation. +# +def generate_float_conversion(src, dst, size, mode, sat): + # Header + close_conditional = conditional_guard(src, dst) + + dstn = f"{dst}{size}" + srcn = f"{src}{size}" + booln = f"{bool_type[dst]}{size}" + src_max = limit_max[src] if src in limit_max else "" + dst_min = limit_min[dst] if dst in limit_min else "" + + if not clc: + print_passthru_conversion(f"{srcn}", f"{dstn}", f"convert_{dstn}{sat}{mode}") + # Footer + if close_conditional: + print("#endif") + return + + print(f"_CLC_DEF _CLC_OVERLOAD {dstn} __clc_convert_{dstn}{sat}{mode}({srcn} x) {{") + + # Perform conversion + if dst in int_types: + if mode == "_rte": + print(" x = __clc_rint(x);") + elif mode == "_rtp": + print(" x = __clc_ceil(x);") + elif mode == "_rtn": + print(" x = __clc_floor(x);") + print(f" return __clc_convert_{dstn}{sat}(x);") + elif mode == "_rte": + print(f" return __clc_convert_{dstn}(x);") + else: + print(f" {dstn} r = __clc_convert_{dstn}(x);") + if src in int_types: + print(f" {srcn} y = __clc_convert_{srcn}_sat(r);") + else: + print(f" {srcn} y = __clc_convert_{srcn}(r);") + if mode == "_rtz": + if src in int_types: + usrcn = f"{unsigned_type[src]}{size}" + print(f" {usrcn} abs_x = __clc_abs(x);") + print(f" {usrcn} abs_y = __clc_abs(y);") + else: + print(f" {srcn} abs_x = __clc_fabs(x);") + print(f" {srcn} abs_y = __clc_fabs(y);") + print(f" {booln} c = __clc_convert_{booln}(abs_y > abs_x);") + if sizeof_type[src] >= sizeof_type[dst] and src in int_types: + print(f" c = c || __clc_convert_{booln}(({srcn}){src_max} == x);") + print( + f" {dstn} sel = __clc_select(r, __clc_nextafter(r, __clc_sign(r) * ({dstn})-INFINITY), c);" + ) + if dst == "half" and src in int_types and sizeof_type[src] >= 2: + dst_max = limit_max[dst] + # short is 16 bits signed, so the maximum value rounded to zero + # is 0x1.ffcp+14 (0x1p+15 == 32768 > 0x7fff == 32767) + if src == "short": + dst_max = "0x1.ffcp+14" + print( + f" return __clc_clamp(sel, ({dstn}){dst_min}, ({dstn}){dst_max});" + ) + else: + print(" return sel;") + if mode == "_rtp": + print( + f" {dstn} sel = __clc_select(r, __clc_nextafter(r, ({dstn})INFINITY), __clc_convert_{booln}(y < x));" + ) + if dst == "half" and src in int_types and sizeof_type[src] >= 2: + print(f" return __clc_max(sel, ({dstn}){dst_min});") + else: + print(" return sel;") + if mode == "_rtn": + print(f" {booln} c = __clc_convert_{booln}(y > x);") + if sizeof_type[src] >= sizeof_type[dst] and src in int_types: + print(f" c = c || __clc_convert_{booln}(({srcn}){src_max} == x);") + print( + f" {dstn} sel = __clc_select(r, __clc_nextafter(r, ({dstn})-INFINITY), c);" + ) + if dst == "half" and src in int_types and sizeof_type[src] >= 2: + dst_max = limit_max[dst] + # short is 16 bits signed, so the maximum value rounded to + # negative infinity is 0x1.ffcp+14 (0x1p+15 == 32768 > 0x7fff + # == 32767) + if src == "short": + dst_max = "0x1.ffcp+14" + print(f" return __clc_min(sel, ({dstn}){dst_max});") + else: + print(" return sel;") + + # Footer + print("}") + if close_conditional: + print("#endif") + + +for src in float_types: + for dst in int_types: + for size in vector_sizes: + for mode in rounding_modes: + for sat in saturation: + generate_float_conversion(src, dst, size, mode, sat) + + +for src in types: + for dst in float_types: + for size in vector_sizes: + for mode in rounding_modes: + # Do not generate user-facing "_rte" conversions for clspv as + # they are handled natively + if clspv and mode == "_rte": + continue + generate_float_conversion(src, dst, size, mode, "") diff --git a/local/recipes/dev/libclc/source/utils/prepare-builtins.cpp b/local/recipes/dev/libclc/source/utils/prepare-builtins.cpp new file mode 100644 index 0000000000..b10dfccc6d --- /dev/null +++ b/local/recipes/dev/libclc/source/utils/prepare-builtins.cpp @@ -0,0 +1,133 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if HAVE_LLVM > 0x0390 +#include "llvm/Bitcode/BitcodeReader.h" +#include "llvm/Bitcode/BitcodeWriter.h" +#else +#include "llvm/Bitcode/ReaderWriter.h" +#endif + +#include "llvm/Config/llvm-config.h" +#include "llvm/IR/Function.h" +#include "llvm/IR/GlobalVariable.h" +#include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Module.h" +#include "llvm/IRReader/IRReader.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorOr.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/SourceMgr.h" +#include "llvm/Support/ToolOutputFile.h" +#include "llvm/Support/raw_ostream.h" + +#include + +using namespace llvm; + +static ExitOnError ExitOnErr; + +static cl::opt +InputFilename(cl::Positional, cl::desc(""), cl::init("-")); + +static cl::opt +OutputFilename("o", cl::desc("Output filename"), + cl::value_desc("filename")); + +static cl::opt TextualOut("S", cl::desc("Emit LLVM textual assembly"), + cl::init(false)); + +int main(int argc, char **argv) { + LLVMContext Context; + llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. + + cl::ParseCommandLineOptions(argc, argv, "libclc builtin preparation tool\n"); + + std::string ErrorMessage; + Module *M = nullptr; + + { + ErrorOr> BufferOrErr = + MemoryBuffer::getFile(InputFilename); + if (std::error_code ec = BufferOrErr.getError()) { + ErrorMessage = ec.message(); + } else { + std::unique_ptr &BufferPtr = BufferOrErr.get(); + SMDiagnostic Err; + std::unique_ptr MPtr = +#if HAVE_LLVM > 0x0390 + ExitOnErr(Expected>( + parseIR(BufferPtr.get()->getMemBufferRef(), Err, Context))); +#else + parseIR(BufferPtr.get()->getMemBufferRef(), Err, Context); +#endif + M = MPtr.release(); + } + } + + if (!M) { + errs() << argv[0] << ": "; + if (ErrorMessage.size()) + errs() << ErrorMessage << "\n"; + else + errs() << "bitcode didn't read correctly.\n"; + return 1; + } + + // Strip the OpenCL version metadata. There are a lot of linked + // modules in the library build, each spamming the same + // version. This may also report a different version than the user + // program is using. This should probably be uniqued when linking. + if (NamedMDNode *OCLVersion = M->getNamedMetadata("opencl.ocl.version")) + M->eraseNamedMetadata(OCLVersion); + + // Set linkage of every external definition to linkonce_odr. + for (Module::iterator i = M->begin(), e = M->end(); i != e; ++i) { + if (!i->isDeclaration() && i->getLinkage() == GlobalValue::ExternalLinkage) + i->setLinkage(GlobalValue::LinkOnceODRLinkage); + } + + for (Module::global_iterator i = M->global_begin(), e = M->global_end(); + i != e; ++i) { + if (!i->isDeclaration() && i->getLinkage() == GlobalValue::ExternalLinkage) + i->setLinkage(GlobalValue::LinkOnceODRLinkage); + } + + if (OutputFilename.empty()) { + errs() << "no output file\n"; + return 1; + } + + std::error_code EC; +#if HAVE_LLVM >= 0x0600 + std::unique_ptr Out( + new ToolOutputFile(OutputFilename, EC, sys::fs::OF_None)); +#else + std::unique_ptr Out( + new tool_output_file(OutputFilename, EC, sys::fs::OF_None)); +#endif + if (EC) { + errs() << EC.message() << '\n'; + exit(1); + } + + if (TextualOut) + M->print(Out->os(), nullptr, true); + else +#if HAVE_LLVM >= 0x0700 + WriteBitcodeToFile(*M, Out->os()); +#else + WriteBitcodeToFile(M, Out->os()); +#endif + + // Declare success. + Out->keep(); + return 0; +} diff --git a/local/recipes/dev/libclc/source/www/index.html b/local/recipes/dev/libclc/source/www/index.html new file mode 100644 index 0000000000..cf02a0a7f3 --- /dev/null +++ b/local/recipes/dev/libclc/source/www/index.html @@ -0,0 +1,53 @@ + + +libclc + + +

libclc

+

+libclc is an open source, BSD/MIT dual licensed +implementation of the library requirements of the +OpenCL C programming language, as specified by the OpenCL +1.1 Specification. The following sections of the specification +impose library requirements: +

    +
  • 6.1: Supported Data Types +
  • 6.2.3: Explicit Conversions +
  • 6.2.4.2: Reinterpreting Types Using as_type() and as_typen() +
  • 6.9: Preprocessor Directives and Macros +
  • 6.11: Built-in Functions +
  • 9.3: Double Precision Floating-Point +
  • 9.4: 64-bit Atomics +
  • 9.5: Writing to 3D image memory objects +
  • 9.6: Half Precision Floating-Point +
+

+ +

+libclc is intended to be used with the Clang +compiler's OpenCL frontend. +

+ +

+libclc is designed to be portable and extensible. To this end, +it provides generic implementations of most library requirements, +allowing the target to override the generic implementation at the +granularity of individual functions. +

+ +

+libclc currently supports the AMDGCN, and R600 and NVPTX targets, but +support for more targets is welcome. +

+ +

Download

+ +git clone https://github.com/llvm/llvm-project.git (View sources) + +

Discourse forums

+ +Runtimes - OpenCL category + + + diff --git a/recipes/dev/libclc b/recipes/dev/libclc new file mode 120000 index 0000000000..0619decf13 --- /dev/null +++ b/recipes/dev/libclc @@ -0,0 +1 @@ +../../local/recipes/dev/libclc \ No newline at end of file