• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, log_inv_tbl_ep);
44 TABLE_FUNCTION_DECL(float2, log2_tbl);
45 TABLE_FUNCTION_DECL(float2, log10_tbl);
46 TABLE_FUNCTION_DECL(uint4,  pibits_tbl);
47 TABLE_FUNCTION_DECL(float2, sinhcosh_tbl);
48 TABLE_FUNCTION_DECL(float2, cbrt_tbl);
49 TABLE_FUNCTION_DECL(float, exp_tbl);
50 TABLE_FUNCTION_DECL(float2, exp_tbl_ep);
51 
52 #ifdef cl_khr_fp64
53 
54 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
55 
56 TABLE_FUNCTION_DECL(double2, ln_tbl);
57 TABLE_FUNCTION_DECL(double2, atan_jby256_tbl);
58 TABLE_FUNCTION_DECL(double2, two_to_jby64_ep_tbl);
59 TABLE_FUNCTION_DECL(double2, sinh_tbl);
60 TABLE_FUNCTION_DECL(double2, cosh_tbl);
61 TABLE_FUNCTION_DECL(double, cbrt_inv_tbl);
62 TABLE_FUNCTION_DECL(double2, cbrt_dbl_tbl);
63 TABLE_FUNCTION_DECL(double2, cbrt_rem_tbl);
64 TABLE_FUNCTION_DECL(double2, powlog_tbl);
65 TABLE_FUNCTION_DECL(double2, log_f_inv_tbl);
66 
67 #endif // cl_khr_fp64
68