Add exp for real numbers.

This commit is contained in:
Zhang Xianyi 2015-01-08 14:48:21 +08:00
parent 90e9c3f456
commit 40d5f98efc
7 changed files with 102 additions and 4 deletions

View File

@ -47,4 +47,10 @@ void OpenVML_FUNCNAME(dpow_k)(VMLLONG n, double * a, double * b, double * y, dou
void OpenVML_FUNCNAME(cpow_k)(VMLLONG n, float * a, float * b, float * y, float * z, float * other_params); void OpenVML_FUNCNAME(cpow_k)(VMLLONG n, float * a, float * b, float * y, float * z, float * other_params);
void OpenVML_FUNCNAME(zpow_k)(VMLLONG n, double * a, double * b, double * y, double * z, double * other_params); void OpenVML_FUNCNAME(zpow_k)(VMLLONG n, double * a, double * b, double * y, double * z, double * other_params);
void OpenVML_FUNCNAME(sexp_k)(VMLLONG n, float * a, float * b, float * y, float * z, float * other_params);
void OpenVML_FUNCNAME(dexp_k)(VMLLONG n, double * a, double * b, double * y, double * z, double * other_params);
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);
#endif #endif

View File

@ -48,25 +48,34 @@
#define CPOW_K OpenVML_FUNCNAME(cpow_k) #define CPOW_K OpenVML_FUNCNAME(cpow_k)
#define ZPOW_K OpenVML_FUNCNAME(zpow_k) #define ZPOW_K OpenVML_FUNCNAME(zpow_k)
#define SEXP_K OpenVML_FUNCNAME(sexp_k)
#define DEXP_K OpenVML_FUNCNAME(dexp_k)
#define CEXP_K OpenVML_FUNCNAME(cexp_k)
#define ZEXP_K OpenVML_FUNCNAME(zexp_k)
#ifndef COMPLEX #ifndef COMPLEX
#ifndef DOUBLE #ifndef DOUBLE
#define ADD_K SADD_K #define ADD_K SADD_K
#define SUB_K SSUB_K #define SUB_K SSUB_K
#define POW_K SPOW_K #define POW_K SPOW_K
#define EXP_K SEXP_K
#else #else
#define ADD_K DADD_K #define ADD_K DADD_K
#define SUB_K DSUB_K #define SUB_K DSUB_K
#define POW_K DPOW_K #define POW_K DPOW_K
#define EXP_K DEXP_K
#endif #endif
#else #else
#ifndef DOUBLE #ifndef DOUBLE
#define ADD_K CADD_K #define ADD_K CADD_K
#define SUB_K CSUB_K #define SUB_K CSUB_K
#define POW_K CPOW_K #define POW_K CPOW_K
#define EXP_K CEXP_K
#else #else
#define ADD_K ZADD_K #define ADD_K ZADD_K
#define SUB_K ZSUB_K #define SUB_K ZSUB_K
#define POW_K ZPOW_K #define POW_K ZPOW_K
#define EXP_K ZEXP_K
#endif #endif
#endif #endif

View File

@ -5,7 +5,7 @@ set(OpenVML_LIBSRC_D "")
set(OpenVML_LIBSRC_C "") set(OpenVML_LIBSRC_C "")
set(OpenVML_LIBSRC_Z "") set(OpenVML_LIBSRC_Z "")
set(REAL_INTERFACE_LIST add sub pow) set(REAL_INTERFACE_LIST add sub pow exp)
set(COMPLEX_INTERFACE_LIST add sub) set(COMPLEX_INTERFACE_LIST add sub)
function(cap_string var_name var_name_cap) function(cap_string var_name var_name_cap)

39
interface/exp.c Normal file
View File

@ -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 <openvml.h>
#include <openvml_driver.h>
#include <openvml_kernel.h>
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, EXP_K, n, (VML_FLOAT*)a, NULL, y, NULL, NULL);
}

View File

@ -6,7 +6,7 @@ set(OpenVML_LIBSRC_D "")
set(OpenVML_LIBSRC_C "") set(OpenVML_LIBSRC_C "")
set(OpenVML_LIBSRC_Z "") set(OpenVML_LIBSRC_Z "")
set(KERNEL_LIST add sub pow) #s,d set(KERNEL_LIST add sub pow exp) #s,d
set(Z_KERNEL_LIST add sub) #c,z set(Z_KERNEL_LIST add sub) #c,z
######## s,d kernels ######## s,d kernels

View File

@ -10,5 +10,9 @@ set(sub_Z_KERNEL_SOURCE ${OpenVML_ARCH}/sub_kernel.c)
set(pow_S_KERNEL_SOURCE ${OpenVML_ARCH}/pow_kernel.c) set(pow_S_KERNEL_SOURCE ${OpenVML_ARCH}/pow_kernel.c)
set(pow_D_KERNEL_SOURCE ${OpenVML_ARCH}/pow_kernel.c) set(pow_D_KERNEL_SOURCE ${OpenVML_ARCH}/pow_kernel.c)
#set(sub_C_KERNEL_SOURCE ${OpenVML_ARCH}/pow_kernel.c) #set(pow_C_KERNEL_SOURCE ${OpenVML_ARCH}/pow_kernel.c)
#set(sub_Z_KERNEL_SOURCE ${OpenVML_ARCH}/pow_kernel.c) #set(pow_Z_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)

View File

@ -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 <math.h>
#include "openvml_kernel.h"
#ifndef DOUBLE
#define EXP expf
#else
#define EXP exp
#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<n; i++){
y[i]=EXP(a[i]);
}
}