diff --git a/include/openvml_kernel.h b/include/openvml_kernel.h index 14f50ab..a397185 100644 --- a/include/openvml_kernel.h +++ b/include/openvml_kernel.h @@ -53,4 +53,10 @@ void OpenVML_FUNCNAME(dexp_k)(VMLLONG n, double * a, double * b, double * y, dou void OpenVML_FUNCNAME(cexp_k)(VMLLONG n, float * a, float * b, float * y, float * z, float * other_params); void OpenVML_FUNCNAME(zexp_k)(VMLLONG n, double * a, double * b, double * y, double * z, double * other_params); + +void OpenVML_FUNCNAME(stanh_k)(VMLLONG n, float * a, float * b, float * y, float * z, float * other_params); +void OpenVML_FUNCNAME(dtanh_k)(VMLLONG n, double * a, double * b, double * y, double * z, double * other_params); +void OpenVML_FUNCNAME(ctanh_k)(VMLLONG n, float * a, float * b, float * y, float * z, float * other_params); +void OpenVML_FUNCNAME(ztanh_k)(VMLLONG n, double * a, double * b, double * y, double * z, double * other_params); + #endif \ No newline at end of file diff --git a/include/openvml_macros.h b/include/openvml_macros.h index 9f38e68..7c42a94 100644 --- a/include/openvml_macros.h +++ b/include/openvml_macros.h @@ -53,17 +53,26 @@ #define CEXP_K OpenVML_FUNCNAME(cexp_k) #define ZEXP_K OpenVML_FUNCNAME(zexp_k) + +#define STANH_K OpenVML_FUNCNAME(stanh_k) +#define DTANH_K OpenVML_FUNCNAME(dtanh_k) +#define CTANH_K OpenVML_FUNCNAME(ctanh_k) +#define ZTANH_K OpenVML_FUNCNAME(ztanh_k) + + #ifndef COMPLEX #ifndef DOUBLE #define ADD_K SADD_K #define SUB_K SSUB_K #define POW_K SPOW_K #define EXP_K SEXP_K +#define TANH_K STANH_K #else #define ADD_K DADD_K #define SUB_K DSUB_K #define POW_K DPOW_K #define EXP_K DEXP_K +#define TANH_K DTANH_K #endif #else #ifndef DOUBLE @@ -71,11 +80,13 @@ #define SUB_K CSUB_K #define POW_K CPOW_K #define EXP_K CEXP_K +#define TANH_K CTANH_K #else #define ADD_K ZADD_K #define SUB_K ZSUB_K #define POW_K ZPOW_K #define EXP_K ZEXP_K +#define TANH_K ZTANH_K #endif #endif diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 701766a..29475ed 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -5,7 +5,7 @@ set(OpenVML_LIBSRC_D "") set(OpenVML_LIBSRC_C "") set(OpenVML_LIBSRC_Z "") -set(REAL_INTERFACE_LIST add sub pow exp) +set(REAL_INTERFACE_LIST add sub pow exp tanh) set(COMPLEX_INTERFACE_LIST add sub) function(cap_string var_name var_name_cap) diff --git a/interface/tanh.c b/interface/tanh.c new file mode 100644 index 0000000..401b659 --- /dev/null +++ b/interface/tanh.c @@ -0,0 +1,39 @@ +/* * Copyright (c) 2014, 2015 Zhang Xianyi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + + +void CNAME(VML_INT n, const VML_FLOAT * a, VML_FLOAT * y) { + + if (n<=0) return; + if (a==NULL || y==NULL) return; + + + EXEC_VML(0, TANH_K, n, (VML_FLOAT*)a, NULL, y, NULL, NULL); + +} diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index cc49eda..b7218b7 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -6,7 +6,7 @@ set(OpenVML_LIBSRC_D "") set(OpenVML_LIBSRC_C "") set(OpenVML_LIBSRC_Z "") -set(KERNEL_LIST add sub pow exp) #s,d +set(KERNEL_LIST add sub pow exp tanh) #s,d set(Z_KERNEL_LIST add sub) #c,z ######## s,d kernels diff --git a/kernel/generic/Kernel_generic.txt b/kernel/generic/Kernel_generic.txt index a1a546e..1fc1e91 100644 --- a/kernel/generic/Kernel_generic.txt +++ b/kernel/generic/Kernel_generic.txt @@ -16,3 +16,6 @@ set(pow_D_KERNEL_SOURCE ${OpenVML_ARCH}/pow_kernel.c) set(exp_S_KERNEL_SOURCE ${OpenVML_ARCH}/exp_kernel.c) set(exp_D_KERNEL_SOURCE ${OpenVML_ARCH}/exp_kernel.c) +set(tanh_S_KERNEL_SOURCE ${OpenVML_ARCH}/tanh_kernel.c) +set(tanh_D_KERNEL_SOURCE ${OpenVML_ARCH}/tanh_kernel.c) + diff --git a/kernel/generic/tanh_kernel.c b/kernel/generic/tanh_kernel.c new file mode 100644 index 0000000..f76383b --- /dev/null +++ b/kernel/generic/tanh_kernel.c @@ -0,0 +1,40 @@ +/* * Copyright (c) 2014, 2015 Zhang Xianyi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "openvml_kernel.h" + +#ifndef DOUBLE +#define TANH tanhf +#else +#define TANH tanh +#endif + +void KERNEL_NAME(VMLLONG n, VML_FLOAT * a, VML_FLOAT * b, VML_FLOAT * y, VML_FLOAT * z, VML_FLOAT * other_params) { + VMLLONG i=0; + for(i=0; i