1 /* 2 * Copyright (c) 2014 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 #define TABLE_SPACE __constant 24 25 #define TABLE_MANGLE(NAME) __clc_##NAME 26 27 #define DECLARE_TABLE(TYPE,NAME,LENGTH) \ 28 TABLE_SPACE TYPE NAME [ LENGTH ] 29 30 #define TABLE_FUNCTION(TYPE,TABLE,NAME) \ 31 TYPE TABLE_MANGLE(NAME)(size_t idx) { \ 32 return TABLE[idx]; \ 33 } 34 35 #define TABLE_FUNCTION_DECL(TYPE, NAME) \ 36 TYPE TABLE_MANGLE(NAME)(size_t idx); 37 38 #define USE_TABLE(NAME, IDX) \ 39 TABLE_MANGLE(NAME)(IDX) 40 41 TABLE_FUNCTION_DECL(float2, loge_tbl); 42 TABLE_FUNCTION_DECL(float, log_inv_tbl); 43 TABLE_FUNCTION_DECL(float2, log2_tbl); 44 TABLE_FUNCTION_DECL(uint4, pibits_tbl); 45 TABLE_FUNCTION_DECL(float2, sinhcosh_tbl); 46 TABLE_FUNCTION_DECL(float2, cbrt_tbl); 47 48 #ifdef cl_khr_fp64 49 50 #pragma OPENCL EXTENSION cl_khr_fp64 : enable 51 52 TABLE_FUNCTION_DECL(double2, ln_tbl); 53 TABLE_FUNCTION_DECL(double2, atan_jby256_tbl); 54 TABLE_FUNCTION_DECL(double2, two_to_jby64_ep_tbl); 55 TABLE_FUNCTION_DECL(double2, sinh_tbl); 56 TABLE_FUNCTION_DECL(double2, cosh_tbl); 57 TABLE_FUNCTION_DECL(double, cbrt_inv_tbl); 58 TABLE_FUNCTION_DECL(double2, cbrt_dbl_tbl); 59 TABLE_FUNCTION_DECL(double2, cbrt_rem_tbl); 60 61 #endif // cl_khr_fp64 62