diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2015-07-24 18:07:06 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2015-07-24 18:07:06 +0000 |
commit | 3eeded30be057275441b6515d928b27a1a35c24a (patch) | |
tree | 2a7b680d8d4d42fad4089ab7ce32852d0ba423a8 | |
parent | dd1ea7f502d6e55659bc6b8796f7bf4a1a3331e5 (diff) |
Use llvm intrinsics for native_log and native_log2
git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@243130 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | generic/include/clc/math/native_log.h | 28 | ||||
-rw-r--r-- | generic/include/clc/math/native_log.inc | 23 | ||||
-rw-r--r-- | generic/include/clc/math/native_log2.h | 28 | ||||
-rw-r--r-- | generic/include/clc/math/native_log2.inc | 23 | ||||
-rw-r--r-- | generic/lib/SOURCES | 2 | ||||
-rw-r--r-- | generic/lib/math/native_log.cl | 32 | ||||
-rw-r--r-- | generic/lib/math/native_log.inc | 25 | ||||
-rw-r--r-- | generic/lib/math/native_log2.cl | 32 | ||||
-rw-r--r-- | generic/lib/math/native_log2.inc | 25 |
9 files changed, 216 insertions, 2 deletions
diff --git a/generic/include/clc/math/native_log.h b/generic/include/clc/math/native_log.h index 7805a39..ed3398b 100644 --- a/generic/include/clc/math/native_log.h +++ b/generic/include/clc/math/native_log.h @@ -1 +1,27 @@ -#define native_log log +/* + * Copyright (c) 2015 Advanced Micro Devices, Inc. + * + * 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. + */ + +#define __CLC_BODY <clc/math/native_log.inc> +#define __FLOAT_ONLY +#include <clc/math/gentype.inc> +#undef __CLC_BODY +#undef __FLOAT_ONLY diff --git a/generic/include/clc/math/native_log.inc b/generic/include/clc/math/native_log.inc new file mode 100644 index 0000000..b6b3d1f --- /dev/null +++ b/generic/include/clc/math/native_log.inc @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2015 Advanced Micro Devices, Inc. + * + * 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. + */ + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE native_log(__CLC_GENTYPE a); diff --git a/generic/include/clc/math/native_log2.h b/generic/include/clc/math/native_log2.h index 0c692ee..99fd7e3 100644 --- a/generic/include/clc/math/native_log2.h +++ b/generic/include/clc/math/native_log2.h @@ -1 +1,27 @@ -#define native_log2 log2 +/* + * Copyright (c) 2015 Advanced Micro Devices, Inc. + * + * 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. + */ + +#define __CLC_BODY <clc/math/native_log2.inc> +#define __FLOAT_ONLY +#include <clc/math/gentype.inc> +#undef __CLC_BODY +#undef __FLOAT_ONLY diff --git a/generic/include/clc/math/native_log2.inc b/generic/include/clc/math/native_log2.inc new file mode 100644 index 0000000..99ff9d6 --- /dev/null +++ b/generic/include/clc/math/native_log2.inc @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2015 Advanced Micro Devices, Inc. + * + * 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. + */ + +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE native_log2(__CLC_GENTYPE a); diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES index 565404b..ef02aca 100644 --- a/generic/lib/SOURCES +++ b/generic/lib/SOURCES @@ -94,6 +94,8 @@ math/ldexp.cl math/log10.cl math/log1p.cl math/mad.cl +math/native_log.cl +math/native_log2.cl math/tables.cl math/clc_nextafter.cl math/nextafter.cl diff --git a/generic/lib/math/native_log.cl b/generic/lib/math/native_log.cl new file mode 100644 index 0000000..f64f012 --- /dev/null +++ b/generic/lib/math/native_log.cl @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc. + * + * 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. + */ + +#include <clc/clc.h> + +#define __CLC_FUNCTION __clc_native_log +#define __CLC_INTRINSIC "llvm.log" +#undef cl_khr_fp64 +#include <clc/math/unary_intrin.inc> + +#define __CLC_BODY <native_log.inc> +#define __FLOAT_ONLY +#include <clc/math/gentype.inc> diff --git a/generic/lib/math/native_log.inc b/generic/lib/math/native_log.inc new file mode 100644 index 0000000..cb4db3f --- /dev/null +++ b/generic/lib/math/native_log.inc @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc. + * + * 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. + */ + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_log(__CLC_GENTYPE val) { + return __clc_native_log(val); +} diff --git a/generic/lib/math/native_log2.cl b/generic/lib/math/native_log2.cl new file mode 100644 index 0000000..35ed18b --- /dev/null +++ b/generic/lib/math/native_log2.cl @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc. + * + * 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. + */ + +#include <clc/clc.h> + +#define __CLC_FUNCTION __clc_native_log2 +#define __CLC_INTRINSIC "llvm.log2" +#undef cl_khr_fp64 +#include <clc/math/unary_intrin.inc> + +#define __CLC_BODY <native_log2.inc> +#define __FLOAT_ONLY +#include <clc/math/gentype.inc> diff --git a/generic/lib/math/native_log2.inc b/generic/lib/math/native_log2.inc new file mode 100644 index 0000000..0f6a509 --- /dev/null +++ b/generic/lib/math/native_log2.inc @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc. + * + * 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. + */ + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_log2(__CLC_GENTYPE val) { + return __clc_native_log2(val); +} |