1/* 2 * Copyright (c) 2014,2015 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to deal 6 * in the Software without restriction, including without limitation the rights 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 * copies of the Software, and to permit persons to whom the Software is 9 * furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 * THE SOFTWARE. 21 */ 22 23#include <clc/clc.h> 24#include <clc/clcmacro.h> 25#include <clc/common/clc_smoothstep.h> 26 27#define SMOOTHSTEP_SINGLE_DEF(X_TYPE) \ 28 _CLC_OVERLOAD _CLC_DEF X_TYPE smoothstep(X_TYPE edge0, X_TYPE edge1, \ 29 X_TYPE x) { \ 30 return __clc_smoothstep(edge0, edge1, x); \ 31 } 32 33#define SMOOTHSTEP_S_S_V_DEFS(X_TYPE) \ 34 _CLC_OVERLOAD _CLC_DEF X_TYPE##2 smoothstep(X_TYPE x, X_TYPE y, \ 35 X_TYPE##2 z) { \ 36 return __clc_smoothstep((X_TYPE##2)x, (X_TYPE##2)y, z); \ 37 } \ 38 \ 39 _CLC_OVERLOAD _CLC_DEF X_TYPE##3 smoothstep(X_TYPE x, X_TYPE y, \ 40 X_TYPE##3 z) { \ 41 return __clc_smoothstep((X_TYPE##3)x, (X_TYPE##3)y, z); \ 42 } \ 43 \ 44 _CLC_OVERLOAD _CLC_DEF X_TYPE##4 smoothstep(X_TYPE x, X_TYPE y, \ 45 X_TYPE##4 z) { \ 46 return __clc_smoothstep((X_TYPE##4)x, (X_TYPE##4)y, z); \ 47 } \ 48 \ 49 _CLC_OVERLOAD _CLC_DEF X_TYPE##8 smoothstep(X_TYPE x, X_TYPE y, \ 50 X_TYPE##8 z) { \ 51 return __clc_smoothstep((X_TYPE##8)x, (X_TYPE##8)y, z); \ 52 } \ 53 \ 54 _CLC_OVERLOAD _CLC_DEF X_TYPE##16 smoothstep(X_TYPE x, X_TYPE y, \ 55 X_TYPE##16 z) { \ 56 return __clc_smoothstep((X_TYPE##16)x, (X_TYPE##16)y, z); \ 57 } 58 59#define SMOOTHSTEP_DEF(type) \ 60 SMOOTHSTEP_SINGLE_DEF(type) \ 61 SMOOTHSTEP_SINGLE_DEF(type##2) \ 62 SMOOTHSTEP_SINGLE_DEF(type##3) \ 63 SMOOTHSTEP_SINGLE_DEF(type##4) \ 64 SMOOTHSTEP_SINGLE_DEF(type##8) \ 65 SMOOTHSTEP_SINGLE_DEF(type##16) \ 66 SMOOTHSTEP_S_S_V_DEFS(type) 67 68SMOOTHSTEP_DEF(float) 69 70#ifdef cl_khr_fp64 71#pragma OPENCL EXTENSION cl_khr_fp64 : enable 72 73SMOOTHSTEP_DEF(double); 74 75#endif 76 77#ifdef cl_khr_fp16 78#pragma OPENCL EXTENSION cl_khr_fp16 : enable 79 80SMOOTHSTEP_DEF(half); 81 82#endif 83