Restore the remaining utests (#1462)

* Restore the remaining utests

* Try fork test on Cygwin and Linux only, it hangs on at least ARMv8/Android as well

* Use generic sswap/dswap kernels for NEHALEM 32bit to fix fault found by the restored swap utest

* Disable zdotu test for MS cl to work around runtime error -1073741819 on AppVeyor for now
(probably coding error in the initialization of the complex numbers or wrong choice of zdotu API)
This commit is contained in:
Martin Kroeker 2018-02-20 10:07:17 +01:00 committed by GitHub
parent 6c0f79b787
commit e7366a4161
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 465 additions and 151 deletions

View File

@ -1 +1,3 @@
include $(KERNELDIR)/KERNEL.PENRYN
SSWAPKERNEL = ../arm/swap.c
DSWAPKERNEL = ../arm/swap.c

View File

@ -8,9 +8,32 @@ else ()
utest_main.c
test_amax.c
test_rotmg.c
test_rot.c
test_axpy.c
test_dsdot.c
test_swap.c
)
endif ()
# crashing on travis cl with an error code suggesting resource not found
if (NOT MSVC)
set(OpenBLAS_utest_src
${OpenBLAS_utest_src}
test_dotu.c
)
endif ()
# known to hang with the native Windows and Android threads
# FIXME needs checking if this works on any of the other platforms
if (NOT USE_OPENMP)
if (OS_CYGWIN_NT OR OS_LINUX)
set(OpenBLAS_utest_src
${OpenBLAS_utest_src}
test_fork.c
)
endif()
endif()
if (NOT NO_LAPACK)
set(OpenBLAS_utest_src
${OpenBLAS_utest_src}

View File

@ -8,20 +8,18 @@ UTESTBIN=openblas_utest
include $(TOPDIR)/Makefile.system
OBJS=utest_main.o test_amax.o test_rotmg.o
OBJS=utest_main.o test_amax.o test_rotmg.o test_axpy.o test_dotu.o test_dsdot.o test_swap.o test_rot.o
#test_rot.o test_swap.o test_axpy.o test_dotu.o test_dsdot.o test_fork.o
ifneq ($(NO_LAPACK), 1)
#OBJS += test_potrs.o
OBJS += test_potrs.o
endif
#this does not work with OpenMP nor with native Windows or Android threads
# FIXME TBD if this works on OSX, SunOS, POWER and zarch
ifndef USE_OPENMP
ifndef OS_WINDOWS
ifeq ($(OSNAME), $(filter $(OSNAME),Linux CYGWIN_NT))
OBJS += test_fork.o
else
ifdef OS_CYGWIN_NT
OBJS += test_fork.o
endif
endif
endif

View File

@ -31,88 +31,81 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#include "common_utest.h"
#include "openblas_utest.h"
void test_daxpy_inc_0(void)
CTEST(axpy,daxpy_inc_0)
{
int i;
int N=8,incX=0,incY=0;
blasint i;
blasint N=8,incX=0,incY=0;
double a=0.25;
double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
double x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y2[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
double y2[]={4.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(daxpy)(&N,&a,x1,&incX,y1,&incY);
//reference
BLASFUNC_REF(daxpy)(&N,&a,x2,&incX,y2,&incY);
for(i=0; i<N; i++){
CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
void test_zaxpy_inc_0(void)
CTEST(axpy,zaxpy_inc_0)
{
int i;
int N=4,incX=0,incY=0;
blasint i;
blasint N=4,incX=0,incY=0;
double a[2]={0.25,0.5};
double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
double x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y2[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
double y2[]={-3.0,9.0,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(zaxpy)(&N,a,x1,&incX,y1,&incY);
//reference
BLASFUNC_REF(zaxpy)(&N,a,x2,&incX,y2,&incY);
for(i=0; i<2*N; i++){
CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
void test_saxpy_inc_0(void)
CTEST(axpy,saxpy_inc_0)
{
int i;
int N=8,incX=0,incY=0;
blasint i;
blasint N=8,incX=0,incY=0;
float a=0.25;
float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
float x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y2[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
float y2[]={4.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(saxpy)(&N,&a,x1,&incX,y1,&incY);
//reference
BLASFUNC_REF(saxpy)(&N,&a,x2,&incX,y2,&incY);
for(i=0; i<N; i++){
CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
void test_caxpy_inc_0(void)
CTEST(axpy,caxpy_inc_0)
{
int i;
int N=4,incX=0,incY=0;
blasint i;
blasint N=4,incX=0,incY=0;
float a[2]={0.25,0.5};
float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
float x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y2[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
float y2[]={-3.0,9.0,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(caxpy)(&N,a,x1,&incX,y1,&incY);
//reference
BLASFUNC_REF(caxpy)(&N,a,x2,&incX,y2,&incY);
for(i=0; i<2*N; i++){
CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}

View File

@ -31,46 +31,54 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#include "common_utest.h"
#include "openblas_utest.h"
#include <complex.h>
#include <stdio.h>
void test_zdotu_n_1(void)
CTEST( zdotu,zdotu_n_1)
{
int N=1,incX=1,incY=1;
blasint N=1,incX=1,incY=1;
double x1[]={1.0,1.0};
double y1[]={1.0,2.0};
double x2[]={1.0,1.0};
double y2[]={1.0,2.0};
double _Complex result1=0.0;
double _Complex result2=0.0;
//OpenBLAS
openblas_complex_double result1=openblas_make_complex_double(0.0,0.0);
openblas_complex_double result2=openblas_make_complex_double(-1.0000,3.0000);
#ifdef RETURN_BY_STACK
BLASFUNC(zdotu)(&result1,&N,x1,&incX,y1,&incY);
#else
result1=BLASFUNC(zdotu)(&N,x1,&incX,y1,&incY);
//reference
result2=BLASFUNC_REF(zdotu)(&N,x2,&incX,y2,&incY);
CU_ASSERT_DOUBLE_EQUAL(creal(result1), creal(result2), CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(cimag(result1), cimag(result2), CHECK_EPS);
// printf("\%lf,%lf\n",creal(result1),cimag(result1));
#endif
#ifdef OPENBLAS_COMPLEX_STRUCT
ASSERT_DBL_NEAR_TOL(result1.real, result2.real, DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(result1.imag, result2.imag, DOUBLE_EPS);
#else
ASSERT_DBL_NEAR_TOL(creal(result1), creal(result2), DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(cimag(result1), cimag(result2), DOUBLE_EPS);
#endif
}
void test_zdotu_offset_1(void)
CTEST(zdotu, zdotu_offset_1)
{
int N=1,incX=1,incY=1;
blasint N=1,incX=1,incY=1;
double x1[]={1.0,2.0,3.0,4.0};
double y1[]={5.0,6.0,7.0,8.0};
double x2[]={1.0,2.0,3.0,4.0};
double y2[]={5.0,6.0,7.0,8.0};
double _Complex result1=0.0;
double _Complex result2=0.0;
//OpenBLAS
openblas_complex_double result1=openblas_make_complex_double(0.0,0.0);
openblas_complex_double result2=openblas_make_complex_double(-9.0,32.0);
#ifdef RETURN_BY_STACK
BLASFUNC(zdotu)(&result1,&N,x1+1,&incX,y1+1,&incY);
#else
result1=BLASFUNC(zdotu)(&N,x1+1,&incX,y1+1,&incY);
//reference
result2=BLASFUNC_REF(zdotu)(&N,x2+1,&incX,y2+1,&incY);
CU_ASSERT_DOUBLE_EQUAL(creal(result1), creal(result2), CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(cimag(result1), cimag(result2), CHECK_EPS);
// printf("\%lf,%lf\n",creal(result1),cimag(result1));
#endif
#ifdef OPENBLAS_COMPLEX_STRUCT
ASSERT_DBL_NEAR_TOL(result1.real, result2.real, DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(result1.imag, result2.imag, DOUBLE_EPS);
#else
ASSERT_DBL_NEAR_TOL(creal(result1), creal(result2), DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(cimag(result1), cimag(result2), DOUBLE_EPS);
#endif
}

View File

@ -31,21 +31,19 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#include "common_utest.h"
#include "openblas_utest.h"
void test_dsdot_n_1()
CTEST(dsdot,dsdot_n_1)
{
float x= 0.172555164;
float y= -0.0138700781;
int incx=1;
int incy=1;
int n=1;
float x= 0.172555164F;
float y= -0.0138700781F;
blasint incx=1;
blasint incy=1;
blasint n=1;
double res1=0.0f, res2=0.0f;
double res1=0.0f, res2=-0.00239335360107;
res1=BLASFUNC(dsdot)(&n, &x, &incx, &y, &incy);
res2=BLASFUNC_REF(dsdot)(&n, &x, &incx, &y, &incy);
CU_ASSERT_DOUBLE_EQUAL(res1, res2, CHECK_EPS);
ASSERT_DBL_NEAR_TOL(res1, res2, DOUBLE_EPS);
}

View File

@ -31,88 +31,82 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#include "common_utest.h"
#include "openblas_utest.h"
void test_drot_inc_0(void)
CTEST(rot,drot_inc_0)
{
int i=0;
int N=4,incX=0,incY=0;
blasint i=0;
blasint N=4,incX=0,incY=0;
double c=0.25,s=0.5;
double x1[]={1.0,3.0,5.0,7.0};
double y1[]={2.0,4.0,6.0,8.0};
double x2[]={1.0,3.0,5.0,7.0};
double y2[]={2.0,4.0,6.0,8.0};
double x2[]={-0.21484375000000,3.0,5.0,7.0};
double y2[]={ 0.03906250000000,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(drot)(&N,x1,&incX,y1,&incY,&c,&s);
//reference
BLASFUNC_REF(drot)(&N,x2,&incX,y2,&incY,&c,&s);
for(i=0; i<N; i++){
CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
void test_zdrot_inc_0(void)
CTEST(rot,zdrot_inc_0)
{
int i=0;
int N=4,incX=0,incY=0;
blasint i=0;
blasint N=4,incX=0,incY=0;
double c=0.25,s=0.5;
double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
double x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y2[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
double x2[]={-0.21484375000000,-0.45703125000000 ,5.0,7.0,1.0,3.0,5.0,7.0};
double y2[]={ 0.03906250000000, 0.17187500000000 ,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(zdrot)(&N,x1,&incX,y1,&incY,&c,&s);
//reference
BLASFUNC_REF(zdrot)(&N,x2,&incX,y2,&incY,&c,&s);
for(i=0; i<2*N; i++){
CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
void test_srot_inc_0(void)
CTEST(rot,srot_inc_0)
{
int i=0;
int N=4,incX=0,incY=0;
blasint i=0;
blasint N=4,incX=0,incY=0;
float c=0.25,s=0.5;
float x1[]={1.0,3.0,5.0,7.0};
float y1[]={2.0,4.0,6.0,8.0};
float x2[]={1.0,3.0,5.0,7.0};
float y2[]={2.0,4.0,6.0,8.0};
float x2[]={-0.21484375000000,3.0,5.0,7.0};
float y2[]={ 0.03906250000000,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(srot)(&N,x1,&incX,y1,&incY,&c,&s);
//reference
BLASFUNC_REF(srot)(&N,x2,&incX,y2,&incY,&c,&s);
for(i=0; i<N; i++){
CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], SINGLE_EPS);
}
}
void test_csrot_inc_0(void)
CTEST(rot, csrot_inc_0)
{
int i=0;
int N=4,incX=0,incY=0;
blasint i=0;
blasint N=4,incX=0,incY=0;
float c=0.25,s=0.5;
float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
float x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y2[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
float x2[]={-0.21484375000000,-0.45703125000000 ,5.0,7.0,1.0,3.0,5.0,7.0};
float y2[]={ 0.03906250000000, 0.17187500000000 ,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(csrot)(&N,x1,&incX,y1,&incY,&c,&s);
//reference
BLASFUNC_REF(csrot)(&N,x2,&incX,y2,&incY,&c,&s);
for(i=0; i<2*N; i++){
CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], SINGLE_EPS);
}
}

View File

@ -31,32 +31,30 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#include "common_utest.h"
#include "openblas_utest.h"
void test_dswap_inc_0(void)
CTEST(swap,dswap_inc_0)
{
int i=0;
int N=4,incX=0,incY=0;
blasint i=0;
blasint N=4,incX=0,incY=0;
double x1[]={1.0,3.0,5.0,7.0};
double y1[]={2.0,4.0,6.0,8.0};
double x2[]={1.0,3.0,5.0,7.0};
double y2[]={2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(dswap)(&N,x1,&incX,y1,&incY);
//reference
BLASFUNC_REF(dswap)(&N,x2,&incX,y2,&incY);
for(i=0; i<N; i++){
CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
void test_zswap_inc_0(void)
CTEST(swap,zswap_inc_0)
{
int i=0;
int N=4,incX=0,incY=0;
blasint i=0;
blasint N=4,incX=0,incY=0;
double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
double x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
@ -64,19 +62,17 @@ void test_zswap_inc_0(void)
//OpenBLAS
BLASFUNC(zswap)(&N,x1,&incX,y1,&incY);
//reference
BLASFUNC_REF(zswap)(&N,x2,&incX,y2,&incY);
for(i=0; i<2*N; i++){
CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
void test_sswap_inc_0(void)
CTEST(swap,sswap_inc_0)
{
int i=0;
int N=4,incX=0,incY=0;
blasint i=0;
blasint N=4,incX=0,incY=0;
float x1[]={1.0,3.0,5.0,7.0};
float y1[]={2.0,4.0,6.0,8.0};
float x2[]={1.0,3.0,5.0,7.0};
@ -84,19 +80,17 @@ void test_sswap_inc_0(void)
//OpenBLAS
BLASFUNC(sswap)(&N,x1,&incX,y1,&incY);
//reference
BLASFUNC_REF(sswap)(&N,x2,&incX,y2,&incY);
for(i=0; i<N; i++){
CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], SINGLE_EPS);
}
}
void test_cswap_inc_0(void)
CTEST(swap,cswap_inc_0)
{
int i=0;
int N=4,incX=0,incY=0;
blasint i=0;
blasint N=4,incX=0,incY=0;
float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
float x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
@ -104,11 +98,9 @@ void test_cswap_inc_0(void)
//OpenBLAS
BLASFUNC(cswap)(&N,x1,&incX,y1,&incY);
//reference
BLASFUNC_REF(cswap)(&N,x2,&incX,y2,&incY);
for(i=0; i<2*N; i++){
CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], SINGLE_EPS);
}
}

View File

@ -32,6 +32,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#include <stdio.h>
#include <complex.h>
#define CTEST_MAIN
#define CTEST_SEGFAULT
@ -56,7 +57,7 @@ CTEST (drotmg,rotmg){
double te_y1, tr_y1;
double te_param[5];
double tr_param[5];
int i=0;
blasint i=0;
// original test case for libGoto bug fixed by feb2014 rewrite
te_d1= 0.21149573940783739;
te_d2= 0.046892057172954082;
@ -103,7 +104,7 @@ CTEST (drotmg,rotmg_issue1452){
double te_y1, tr_y1;
double te_param[5];
double tr_param[5];
int i=0;
blasint i=0;
// from issue #1452, buggy version returned 0.000244 for param[3]
te_d1 = 5.9e-8;
@ -148,7 +149,7 @@ CTEST(drotmg, rotmg_D1eqD2_X1eqX2){
double te_y1, tr_y1;
double te_param[5];
double tr_param[5];
int i=0;
blasint i=0;
te_d1= tr_d1=2.;
te_d2= tr_d2=2.;
te_x1= tr_x1=8.;
@ -183,9 +184,314 @@ CTEST(drotmg, rotmg_D1eqD2_X1eqX2){
}
}
CTEST(axpy,daxpy_inc_0)
{
blasint i;
blasint N=8,incX=0,incY=0;
double a=0.25;
double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
double x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y2[]={4.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(daxpy)(&N,&a,x1,&incX,y1,&incY);
for(i=0; i<N; i++){
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
CTEST(axpy,zaxpy_inc_0)
{
blasint i;
blasint N=4,incX=0,incY=0;
double a[2]={0.25,0.5};
double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
double x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y2[]={-3.0,9.0,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(zaxpy)(&N,a,x1,&incX,y1,&incY);
for(i=0; i<2*N; i++){
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
CTEST(axpy,saxpy_inc_0)
{
blasint i;
blasint N=8,incX=0,incY=0;
float a=0.25;
float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
float x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y2[]={4.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(saxpy)(&N,&a,x1,&incX,y1,&incY);
for(i=0; i<N; i++){
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
CTEST(axpy,caxpy_inc_0)
{
blasint i;
blasint N=4,incX=0,incY=0;
float a[2]={0.25,0.5};
float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
float x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y2[]={-3.0,9.0,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(caxpy)(&N,a,x1,&incX,y1,&incY);
for(i=0; i<2*N; i++){
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
CTEST( zdotu,zdotu_n_1)
{
blasint N=1,incX=1,incY=1;
double x1[]={1.0,1.0};
double y1[]={1.0,2.0};
openblas_complex_double result1=openblas_make_complex_double(0.0,0.0);
openblas_complex_double result2=openblas_make_complex_double(-1.0,3.0);
#ifdef RETURN_BY_STACK
BLASFUNC(zdotu)(&result1,&N,x1,&incX,y1,&incY);
#else
result1=BLASFUNC(zdotu)(&N,x1,&incX,y1,&incY);
#endif
#ifdef OPENBLAS_COMPLEX_STRUCT
ASSERT_DBL_NEAR_TOL(result1.real, result2.real, DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(result1.imag, result2.imag, DOUBLE_EPS);
#else
ASSERT_DBL_NEAR_TOL(creal(result1), creal(result2), DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(cimag(result1), cimag(result2), DOUBLE_EPS);
#endif
}
CTEST(zdotu, zdotu_offset_1)
{
blasint N=1,incX=1,incY=1;
double x1[]={1.0,2.0,3.0,4.0};
double y1[]={5.0,6.0,7.0,8.0};
openblas_complex_double result1=openblas_make_complex_double(0.0,0.0);
openblas_complex_double result2=openblas_make_complex_double(-9.0,32.0);
#ifdef RETURN_BY_STACK
BLASFUNC(zdotu)(&result1,&N,x1+1,&incX,y1+1,&incY);
#else
result1=BLASFUNC(zdotu)(&N,x1+1,&incX,y1+1,&incY);
#endif
#ifdef OPENBLAS_COMPLEX_STRUCT
ASSERT_DBL_NEAR_TOL(result1.real, result2.real, DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(result1.imag, result2.imag, DOUBLE_EPS);
#else
ASSERT_DBL_NEAR_TOL(creal(result1), creal(result2), DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(cimag(result1), cimag(result2), DOUBLE_EPS);
#endif
}
CTEST(dsdot,dsdot_n_1)
{
float x= 0.172555164F;
float y= -0.0138700781F;
blasint incx=1;
blasint incy=1;
blasint n=1;
double res1=0.0f, res2=-0.00239335360107;
res1=BLASFUNC(dsdot)(&n, &x, &incx, &y, &incy);
ASSERT_DBL_NEAR_TOL(res1, res2, DOUBLE_EPS);
}
CTEST(rot,drot_inc_0)
{
blasint i=0;
blasint N=4,incX=0,incY=0;
double c=0.25,s=0.5;
double x1[]={1.0,3.0,5.0,7.0};
double y1[]={2.0,4.0,6.0,8.0};
double x2[]={-0.21484375000000,3.0,5.0,7.0};
double y2[]={ 0.03906250000000,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(drot)(&N,x1,&incX,y1,&incY,&c,&s);
for(i=0; i<N; i++){
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
CTEST(rot,zdrot_inc_0)
{
blasint i=0;
blasint N=4,incX=0,incY=0;
double c=0.25,s=0.5;
double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
double x2[]={-0.21484375000000,-0.45703125000000 ,5.0,7.0,1.0,3.0,5.0,7.0};
double y2[]={ 0.03906250000000, 0.17187500000000 ,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(zdrot)(&N,x1,&incX,y1,&incY,&c,&s);
for(i=0; i<2*N; i++){
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
CTEST(rot,srot_inc_0)
{
blasint i=0;
blasint N=4,incX=0,incY=0;
float c=0.25,s=0.5;
float x1[]={1.0,3.0,5.0,7.0};
float y1[]={2.0,4.0,6.0,8.0};
float x2[]={-0.21484375000000,3.0,5.0,7.0};
float y2[]={ 0.03906250000000,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(srot)(&N,x1,&incX,y1,&incY,&c,&s);
for(i=0; i<N; i++){
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], SINGLE_EPS);
}
}
CTEST(rot, csrot_inc_0)
{
blasint i=0;
blasint N=4,incX=0,incY=0;
float c=0.25,s=0.5;
float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
float x2[]={-0.21484375000000,-0.45703125000000 ,5.0,7.0,1.0,3.0,5.0,7.0};
float y2[]={ 0.03906250000000, 0.17187500000000 ,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(csrot)(&N,x1,&incX,y1,&incY,&c,&s);
for(i=0; i<2*N; i++){
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], SINGLE_EPS);
}
}
CTEST(swap,dswap_inc_0)
{
blasint i=0;
blasint N=4,incX=0,incY=0;
double x1[]={1.0,3.0,5.0,7.0};
double y1[]={2.0,4.0,6.0,8.0};
double x2[]={1.0,3.0,5.0,7.0};
double y2[]={2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(dswap)(&N,x1,&incX,y1,&incY);
for(i=0; i<N; i++){
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
CTEST(swap,zswap_inc_0)
{
blasint i=0;
blasint N=4,incX=0,incY=0;
double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
double x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
double y2[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(zswap)(&N,x1,&incX,y1,&incY);
for(i=0; i<2*N; i++){
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], DOUBLE_EPS);
}
}
CTEST(swap,sswap_inc_0)
{
blasint i=0;
blasint N=4,incX=0,incY=0;
float x1[]={1.0,3.0,5.0,7.0};
float y1[]={2.0,4.0,6.0,8.0};
float x2[]={1.0,3.0,5.0,7.0};
float y2[]={2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(sswap)(&N,x1,&incX,y1,&incY);
for(i=0; i<N; i++){
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], SINGLE_EPS);
}
}
CTEST(swap,cswap_inc_0)
{
blasint i=0;
blasint N=4,incX=0,incY=0;
float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
float x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
float y2[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
//OpenBLAS
BLASFUNC(cswap)(&N,x1,&incX,y1,&incY);
for(i=0; i<2*N; i++){
ASSERT_DBL_NEAR_TOL(x1[i], x2[i], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(y1[i], y2[i], SINGLE_EPS);
}
}
int main(int argc, const char ** argv){
CTEST_ADD(amax, samax);
CTEST_ADD (drotmg,rotmg);
CTEST_ADD (drotmg,rotmg_issue1452);
CTEST_ADD (drotmg, rotmg_D1eqD2_X1eqX2);
CTEST_ADD (axpy,daxpy_inc_0);
CTEST_ADD (axpy,zaxpy_inc_0);
CTEST_ADD (axpy,saxpy_inc_0);
CTEST_ADD (axpy,caxpy_inc_0);
CTEST_ADD (zdotu,zdotu_n_1);
CTEST_ADD (zdotu, zdotu_offset_1);
CTEST_ADD (dsdot,dsdot_n_1);
CTEST_ADD (rot,drot_inc_0);
CTEST_ADD (rot,zdrot_inc_0);
CTEST_ADD (rot,srot_inc_0);
CTEST_ADD (rot, csrot_inc_0);
CTEST_ADD (swap,dswap_inc_0);
CTEST_ADD (swap,zswap_inc_0);
CTEST_ADD (swap,sswap_inc_0);
CTEST_ADD (swap,cswap_inc_0);
int num_fail=0;
num_fail=ctest_main(argc, argv);