mirror of
https://github.com/amd/blis.git
synced 2026-04-19 15:18:52 +00:00
CPP Templatee test files update
Change-Id: Ia9637556b50b10cb4409e18f369a3e7fc35569fb
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#
|
||||
#
|
||||
# BLIS
|
||||
# An object-based framework for developing high-performance BLAS-like
|
||||
# libraries.
|
||||
@@ -122,8 +120,8 @@ override CFLAGS += $(call get-user-cflags-for,$(CONFIG_NAME))
|
||||
# Add local header paths to CFLAGS
|
||||
#CFLAGS = -O0 -g -Wall
|
||||
#CFLAGS += -I$(INC_PATH)
|
||||
override CFLAGS += -I$(TEST_SRC_PATH)
|
||||
override CFLAGS += -I$(CPP_SRC_PATH)
|
||||
override CFLAGS += -g -I$(TEST_SRC_PATH)
|
||||
override CFLAGS += -g -I$(CPP_SRC_PATH)
|
||||
|
||||
LINKER = $(CXX)
|
||||
|
||||
@@ -143,7 +141,59 @@ LIBBLIS_LINK := $(LIB_PATH)/$(LIBBLIS_L)
|
||||
#all: blis
|
||||
all: blis
|
||||
|
||||
blis: test_gemm_blis.x
|
||||
#blis: test_gemm_blis.x \
|
||||
test_hemm_blis.x \
|
||||
test_herk_blis.x \
|
||||
test_her2k_blis.x \
|
||||
test_symm_blis.x \
|
||||
test_syr2k_blis.x \
|
||||
test_syrk_blis.x \
|
||||
test_trmm_blis.x \
|
||||
test_trsm_blis.x \
|
||||
|
||||
|
||||
blis: test_asum_blis.x \
|
||||
test_axpy_blis.x \
|
||||
test_copy_blis.x \
|
||||
test_dot_blis.x \
|
||||
test_dotc_blis.x \
|
||||
test_gbmv_blis.x \
|
||||
test_gemm_blis.x \
|
||||
test_gemv_blis.x \
|
||||
test_ger_blis.x \
|
||||
test_gerc_blis.x \
|
||||
test_geru_blis.x \
|
||||
test_hemm_blis.x \
|
||||
test_hemv_blis.x \
|
||||
test_her2_blis.x \
|
||||
test_her_blis.x \
|
||||
test_herk_blis.x \
|
||||
test_hpr2_blis.x \
|
||||
test_hpr_blis.x \
|
||||
test_nrm2_blis.x \
|
||||
test_rot_blis.x \
|
||||
test_rotg_blis.x \
|
||||
test_rotm_blis.x \
|
||||
test_rotmg_blis.x \
|
||||
test_scal_blis.x \
|
||||
test_sdsdot_blis.x \
|
||||
test_spr2_blis.x \
|
||||
test_spr_blis.x \
|
||||
test_swap_blis.x \
|
||||
test_symm_blis.x \
|
||||
test_syr2_blis.x \
|
||||
test_syr2k_blis.x \
|
||||
test_syr_blis.x \
|
||||
test_syrk_blis.x \
|
||||
test_tbmv_blis.x \
|
||||
test_tbsv_blis.x \
|
||||
test_tpmv_blis.x \
|
||||
test_tpsv_blis.x \
|
||||
test_trmm_blis.x \
|
||||
test_trsm_blis.x \
|
||||
test_trsv_blis.x
|
||||
|
||||
|
||||
|
||||
# --Object file rules --
|
||||
|
||||
|
||||
219
testcpp/test.hh
Normal file
219
testcpp/test.hh
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* BLISLAB
|
||||
* --------------------------------------------------------------------------
|
||||
* Copyright (C) 2016, The University of Texas at Austin
|
||||
*
|
||||
* 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.
|
||||
* - Neither the name of The University of Texas nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* test.hh
|
||||
*
|
||||
*
|
||||
* Purpose:
|
||||
* this header file contains all function prototypes.
|
||||
*
|
||||
* Todo:
|
||||
*
|
||||
*
|
||||
* Modification:
|
||||
*
|
||||
*
|
||||
* */
|
||||
|
||||
|
||||
#ifndef TEST_HH
|
||||
#define TEST_HH
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std;
|
||||
#define min( i, j ) ( (i)<(j) ? (i): (j) )
|
||||
|
||||
#define A( i, j ) A[ (j)*lda + (i) ]
|
||||
#define A_ref( i, j ) A_ref[ (j)*lda_ref + (i) ]
|
||||
|
||||
#define B( i, j ) B[ (j)*ldb + (i) ]
|
||||
#define B_ref( i, j ) B_ref[ (j)*ldb_ref + (i) ]
|
||||
|
||||
#define C( i, j ) C[ (j)*ldc + (i) ]
|
||||
#define C_ref( i, j ) C_ref[ (j)*ldc_ref + (i) ]
|
||||
|
||||
#define X( i ) X[ incx + (i) ]
|
||||
#define X_ref( i, j ) X_ref[ (j)*incx_ref + (i)
|
||||
|
||||
#define Y( i ) Y[ incy + (i) ]
|
||||
#define Y_ref( i ) Y_ref[ incy_ref + (i) ]\
|
||||
|
||||
// Allocate memory and initialise memory with random values
|
||||
void allocate_init_buffer(int *aIn, int m, int n)
|
||||
{
|
||||
aIn = new int [m*n];
|
||||
for ( int i = 0; i < m*n; i ++ ) {
|
||||
aIn[ i ] = ((int) rand() / ((int) RAND_MAX / 2.0)) - 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
void allocate_init_buffer(float *&aIn, int m, int n)
|
||||
{
|
||||
aIn = new float [m*n];
|
||||
for ( int i = 0; i < m*n; i ++ ) {
|
||||
aIn[ i ] = ((float) rand() / ((float) RAND_MAX / 2.0)) - 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
void allocate_init_buffer(double *&aIn, int m, int n)
|
||||
{
|
||||
aIn = new double [m*n];
|
||||
for ( int i = 0; i < m*n; i ++ ) {
|
||||
aIn[ i ] = ((double) rand() / ((double) RAND_MAX / 2.0)) - 1.0;
|
||||
}
|
||||
}
|
||||
void allocate_init_buffer(complex<float> *&aIn, int m, int n)
|
||||
{
|
||||
aIn = new complex<float> [m*n];
|
||||
for ( int i = 0; i < m*n; i ++ ) {
|
||||
float real = ((float) rand() / ((float) RAND_MAX / 2.0)) - 1.0;
|
||||
float imag = ((float) rand() / ((float) RAND_MAX / 2.0)) - 1.0;
|
||||
aIn[i] = {real,imag};
|
||||
}
|
||||
}
|
||||
void allocate_init_buffer(complex<double> *&aIn, int m, int n)
|
||||
{
|
||||
aIn = new complex<double> [m*n];
|
||||
for ( int i = 0; i < m*n; i ++ ) {
|
||||
double real = ((double) rand() / ((double) RAND_MAX / 2.0)) - 1.0;
|
||||
double imag = ((double) rand() / ((double) RAND_MAX / 2.0)) - 1.0;
|
||||
aIn[i] = {real,imag};
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void copy_buffer(T *aSrc, T *&aDest, int m, int n)
|
||||
{
|
||||
aDest = new T [m*n];
|
||||
for ( int i = 0; i < m*n; i ++ ) {
|
||||
aDest[i] = aSrc[i];
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
int computeErrorM(
|
||||
int lda,
|
||||
int lda_ref,
|
||||
int m,
|
||||
int n,
|
||||
T *A,
|
||||
T *A_ref
|
||||
)
|
||||
{
|
||||
|
||||
int i, j;
|
||||
int ret = 0;
|
||||
for ( i = 0; i < m; i ++ ) {
|
||||
for ( j = 0; j < n; j ++ ) {
|
||||
if ( (fabs (A( i, j )) - fabs( A_ref( i, j ))) > 0.0000001 ) {
|
||||
cout << A(i,j) << A_ref(i,j);
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
template< typename T >
|
||||
int computeErrorV(
|
||||
int incy,
|
||||
int incy_ref,
|
||||
int n,
|
||||
T *Y,
|
||||
T *Y_ref
|
||||
)
|
||||
{
|
||||
int i;
|
||||
int ret = 0;
|
||||
for ( i = 0; i < n; i ++ ) {
|
||||
if ( (fabs( Y[ i ]) - fabs(Y_ref[ i ] ) ) > 0.00001) {
|
||||
cout << Y[i] << Y_ref[i];
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
*printing matix and vector
|
||||
*
|
||||
*/
|
||||
|
||||
template <typename T>
|
||||
void printmatrix(
|
||||
T *A,
|
||||
int lda,
|
||||
int m,
|
||||
int n,
|
||||
char *func_str
|
||||
)
|
||||
{
|
||||
int i, j;
|
||||
cout << func_str <<"\n";
|
||||
for ( i = 0; i < m; i ++ ) {
|
||||
for ( j = 0; j < n; j ++ ) {
|
||||
cout<< A[j * lda + i]<<" ";
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void printvector(
|
||||
T *X,
|
||||
int m,
|
||||
char *func_str
|
||||
)
|
||||
{
|
||||
int i;
|
||||
cout << func_str <<"\n";
|
||||
for ( i = 0; i < m; i ++ ) {
|
||||
cout<< X[i]<<" ";
|
||||
cout<<"\n";
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
70
testcpp/test.sh
Executable file → Normal file
70
testcpp/test.sh
Executable file → Normal file
@@ -1,30 +1,46 @@
|
||||
CWD=$(pwd)
|
||||
echo $CWD
|
||||
make clean
|
||||
make blis CFLAGS+="-DFLOAT"
|
||||
numactl -C 1 ./test_gemm_blis.x
|
||||
numactl -C 1 ./test_trsm_blis.x
|
||||
numactl -C 1 ./test_hemm_blis.x
|
||||
numactl -C 1 ./test_symm_blis.x
|
||||
|
||||
echo Build BLIS CPP Template tests
|
||||
make clean
|
||||
make blis CFLAGS+="-DDOUBLE"
|
||||
numactl -C 1 ./test_gemm_blis.x
|
||||
numactl -C 1 ./test_trsm_blis.x
|
||||
numactl -C 1 ./test_hemm_blis.x
|
||||
numactl -C 1 ./test_symm_blis.x
|
||||
|
||||
make clean
|
||||
make blis CFLAGS+="-DSCOMPLEX"
|
||||
numactl -C 1 ./test_gemm_blis.x
|
||||
numactl -C 1 ./test_trsm_blis.x
|
||||
numactl -C 1 ./test_hemm_blis.x
|
||||
numactl -C 1 ./test_symm_blis.x
|
||||
|
||||
make clean
|
||||
make blis CFLAGS+="-DDCOMPLEX"
|
||||
numactl -C 1 ./test_gemm_blis.x
|
||||
numactl -C 1 ./test_trsm_blis.x
|
||||
numactl -C 1 ./test_hemm_blis.x
|
||||
numactl -C 1 ./test_symm_blis.x
|
||||
make
|
||||
|
||||
echo Run tests
|
||||
./test_asum_blis.x
|
||||
./test_axpy_blis.x
|
||||
./test_copy_blis.x
|
||||
./test_dot_blis.x
|
||||
./test_dotc_blis.x
|
||||
./test_gbmv_blis.x
|
||||
./test_gemm_blis.x
|
||||
./test_gemv_blis.x
|
||||
./test_ger_blis.x
|
||||
./test_gerc_blis.x
|
||||
./test_geru_blis.x
|
||||
./test_hemm_blis.x
|
||||
./test_hemv_blis.x
|
||||
./test_her2_blis.x
|
||||
./test_her_blis.x
|
||||
./test_herk_blis.x
|
||||
./test_hpr2_blis.x
|
||||
./test_hpr_blis.x
|
||||
./test_nrm2_blis.x
|
||||
./test_rot_blis.x
|
||||
./test_rotg_blis.x
|
||||
./test_rotm_blis.x
|
||||
./test_rotmg_blis.x
|
||||
./test_scal_blis.x
|
||||
./test_sdsdot_blis.x
|
||||
./test_spr2_blis.x
|
||||
./test_spr_blis.x
|
||||
./test_swap_blis.x
|
||||
./test_symm_blis.x
|
||||
./test_syr2_blis.x
|
||||
./test_syr2k_blis.x
|
||||
./test_syr_blis.x
|
||||
./test_syrk_blis.x
|
||||
./test_tbmv_blis.x
|
||||
./test_tbsv_blis.x
|
||||
./test_tpmv_blis.x
|
||||
./test_tpsv_blis.x
|
||||
./test_trmm_blis.x
|
||||
./test_trsm_blis.x
|
||||
./test_trsv_blis.x
|
||||
|
||||
127
testcpp/test_asum.cc
Normal file
127
testcpp/test_asum.cc
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP asum routine and reference blis asum routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 6
|
||||
#define ALPHA 0.5
|
||||
|
||||
template< typename T, typename TR>
|
||||
void ref_asum(int64_t n,
|
||||
T *X,
|
||||
TR *asum
|
||||
)
|
||||
{
|
||||
obj_t obj_x;
|
||||
obj_t obj_asum;
|
||||
num_t dt, dtR;
|
||||
|
||||
if(is_same<T , float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T , double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T , complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T , complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
if(is_same<TR , float>::value)
|
||||
dtR = BLIS_FLOAT;
|
||||
else if(is_same<TR , double>::value)
|
||||
dtR = BLIS_DOUBLE;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1, n,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dtR, 1, 1, asum, 1, 1,&obj_asum );
|
||||
|
||||
bli_asumv(&obj_x, &obj_asum);
|
||||
|
||||
}
|
||||
template< typename T, typename TR>
|
||||
void test_asum()
|
||||
{
|
||||
|
||||
T *X, *X_ref;
|
||||
TR asum, asum_ref;
|
||||
int n;
|
||||
int incx;
|
||||
|
||||
n = N;
|
||||
incx = 1;
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(X , n , 1);
|
||||
copy_buffer(X, X_ref , n ,1);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n,(char *) "X");
|
||||
#endif
|
||||
|
||||
asum = blis::asum<T>(
|
||||
n,
|
||||
X,
|
||||
incx
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
cout<< "Sum of all values in Vector X: " << asum << "\n";
|
||||
#endif
|
||||
|
||||
ref_asum(n, X_ref, &asum_ref );
|
||||
|
||||
#ifdef PRINT
|
||||
cout<< "Ref Sum of all values in Vector X: " << asum_ref << "\n";
|
||||
#endif
|
||||
if(computeErrorV(incx, incx, 1, &asum, &asum_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
delete[]( X );
|
||||
delete[]( X_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_asum<float, float>( );
|
||||
test_asum<double, double>( );
|
||||
test_asum<std::complex<float>, float>( );
|
||||
test_asum<std::complex<double>, double>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
138
testcpp/test_axpy.cc
Normal file
138
testcpp/test_axpy.cc
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 6
|
||||
#define ALPHA 1.0
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T>
|
||||
void ref_axpy(int64_t n,
|
||||
T * alpha,
|
||||
T *X,
|
||||
T *Y
|
||||
)
|
||||
|
||||
{
|
||||
obj_t obj_x, obj_y, obj_alpha;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1, n,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1, n,&obj_y );
|
||||
|
||||
bli_axpyv( &obj_alpha,
|
||||
&obj_x,
|
||||
&obj_y
|
||||
);
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_axpy( )
|
||||
{
|
||||
T *X, *Y,*Y_ref;
|
||||
T alpha = ALPHA;
|
||||
int n;
|
||||
int incx, incy;
|
||||
|
||||
n = N;
|
||||
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(X , n , 1);
|
||||
allocate_init_buffer(Y , n , 1);
|
||||
copy_buffer(Y, Y_ref , n ,1);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n,(char *) "X");
|
||||
printvector(Y, n, (char *) "Y");
|
||||
#endif
|
||||
blis::axpy(
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incx,
|
||||
Y,
|
||||
incy
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(Y, n,(char *) "Y output");
|
||||
#endif
|
||||
ref_axpy(n , &alpha , X, Y_ref );
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(Y_ref, n, (char *) "Y ref output");
|
||||
#endif
|
||||
if(computeErrorV(incy, incy , n, Y, Y_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( X );
|
||||
delete[]( Y );
|
||||
delete[]( Y_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_axpy<float>( );
|
||||
test_axpy<double>( );
|
||||
test_axpy<complex<float>>( );
|
||||
test_axpy<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
132
testcpp/test_copy.cc
Normal file
132
testcpp/test_copy.cc
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T>
|
||||
void ref_copy(int64_t n,
|
||||
T *X,
|
||||
T *Y
|
||||
)
|
||||
|
||||
{
|
||||
obj_t obj_x, obj_y;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1, n,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1, n,&obj_y );
|
||||
|
||||
bli_copyv( &obj_x,
|
||||
&obj_y
|
||||
);
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_copy( )
|
||||
{
|
||||
T *X, *X_ref, *Y,*Y_ref;
|
||||
int n;
|
||||
int incx, incy;
|
||||
|
||||
n = N;
|
||||
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
|
||||
Y = new T[n];
|
||||
Y_ref = new T[n];
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(X , n , 1);
|
||||
copy_buffer(X, X_ref , n ,1);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n,(char *) "X");
|
||||
#endif
|
||||
blis::copy(
|
||||
n,
|
||||
X,
|
||||
incx,
|
||||
Y,
|
||||
incy
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(Y, n,(char *) "Y output");
|
||||
#endif
|
||||
ref_copy(n , X_ref, Y_ref );
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(Y_ref, n,(char *) "Y ref output");
|
||||
#endif
|
||||
if(computeErrorV(incy , incy , n, Y, Y_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
delete[]( X );
|
||||
delete[]( X_ref );
|
||||
delete[]( Y );
|
||||
delete[]( Y_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_copy<float>( );
|
||||
test_copy<double>( );
|
||||
test_copy<std::complex<float>>();
|
||||
test_copy<std::complex<double>>();
|
||||
return 0;
|
||||
|
||||
}
|
||||
131
testcpp/test_dot.cc
Normal file
131
testcpp/test_dot.cc
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T, typename TR>
|
||||
void ref_dot(int64_t n,
|
||||
T *X,
|
||||
T *Y,
|
||||
TR *res_ref
|
||||
)
|
||||
|
||||
{
|
||||
obj_t obj_x;
|
||||
obj_t obj_y;
|
||||
obj_t obj_res;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T,double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1, n,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1, n,&obj_y );
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, res_ref, 1, 1,&obj_res );
|
||||
|
||||
bli_dotv(&obj_x,
|
||||
&obj_y,
|
||||
&obj_res );
|
||||
|
||||
}
|
||||
template< typename T, typename TR>
|
||||
void test_dot()
|
||||
{
|
||||
T *X, *Y;
|
||||
int n;
|
||||
int incx, incy;
|
||||
TR res = 0, res_ref = 0;
|
||||
|
||||
n = N;
|
||||
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(X , n , 1);
|
||||
allocate_init_buffer(Y , n , 1);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n, (char *)"X");
|
||||
printvector(Y, n, (char *)"Y");
|
||||
#endif
|
||||
res = blis::dot<T, TR>(
|
||||
n,
|
||||
X,
|
||||
incx,
|
||||
Y,
|
||||
incy
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printf("Dot product = %E \n", res);
|
||||
|
||||
#endif
|
||||
ref_dot(n, X, Y , &res_ref );
|
||||
|
||||
#ifdef PRINT
|
||||
printf("Dot product ref_dot %E \n", res_ref);
|
||||
|
||||
#endif
|
||||
if(res != res_ref )
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( X );
|
||||
delete[]( Y );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_dot<float , float>( );
|
||||
//test_dot<float , double>( );
|
||||
test_dot<double , double>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
127
testcpp/test_dotc.cc
Normal file
127
testcpp/test_dotc.cc
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP dotc routine and reference blis dotc routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 16
|
||||
|
||||
template< typename T >
|
||||
void ref_dotc(int64_t n,
|
||||
T *X,
|
||||
T *Y,
|
||||
T *res_ref
|
||||
)
|
||||
{
|
||||
obj_t obj_x;
|
||||
obj_t obj_y;
|
||||
obj_t obj_res;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1, n, &obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1, n, &obj_y );
|
||||
bli_obj_set_conj(BLIS_CONJUGATE,&obj_x);
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, res_ref, 1, 1,&obj_res );
|
||||
|
||||
bli_dotv(&obj_x,
|
||||
&obj_y,
|
||||
&obj_res );
|
||||
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void test_dotc()
|
||||
{
|
||||
T *X, *Y;
|
||||
int n;
|
||||
int incx, incy;
|
||||
T res = 0, res_ref = 0;
|
||||
|
||||
n = N;
|
||||
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(X , n , 1);
|
||||
allocate_init_buffer(Y , n , 1);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n,(char *) "X");
|
||||
printvector(Y, n,(char *) "Y");
|
||||
#endif
|
||||
|
||||
res = blis::dotc<T>(
|
||||
n,
|
||||
X,
|
||||
incx,
|
||||
Y,
|
||||
incy
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
cout<< "Dot product \n" << res << "\n";
|
||||
#endif
|
||||
ref_dotc(n, X, Y , &res_ref );
|
||||
|
||||
#ifdef PRINT
|
||||
cout<< "Dot product ref\n" << res_ref << "\n";;
|
||||
#endif
|
||||
|
||||
if(res != res_ref )
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
delete[]( X );
|
||||
delete[]( Y );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_dotc<complex<float>>( );
|
||||
test_dotc<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
109
testcpp/test_gbmv.cc
Normal file
109
testcpp/test_gbmv.cc
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA -1.0
|
||||
#define BETA -1.0
|
||||
#define M 3
|
||||
#define N 4
|
||||
|
||||
template< typename T >
|
||||
void test_gbmv( )
|
||||
{
|
||||
// int i, j, p;
|
||||
T alpha, beta;
|
||||
int m,n;
|
||||
int KL = 1;
|
||||
int KU = 1;
|
||||
int lda = 4;
|
||||
T A[] = { 0.423f, -0.143f, -0.182f, -0.076f, -0.855f, 0.599f, 0.389f, -0.473f, 0.493f, -0.902f, -0.889f, -0.256f, 0.112f, 0.128f, -0.277f, -0.777f };
|
||||
T X[] = { 0.488f, 0.029f, -0.633f, 0.84f };
|
||||
int incX = -1;
|
||||
T Y[] = { 0.874f, 0.322f, -0.477f };
|
||||
int incY = -1;
|
||||
T Y_ref[] = { -0.656261f, 0.19575f, 0.055905f };
|
||||
alpha = ALPHA;
|
||||
beta = BETA;
|
||||
m = M;
|
||||
n = N;
|
||||
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,m,n,(char *) "A");
|
||||
printvector(Y, m, (char *)"m");
|
||||
#endif
|
||||
blis::gbmv(
|
||||
CblasColMajor,
|
||||
CblasNoTrans,
|
||||
m,
|
||||
n,KL,KU,
|
||||
alpha,
|
||||
A,
|
||||
lda,
|
||||
X,
|
||||
incX,
|
||||
beta,
|
||||
Y,
|
||||
incY
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(Y, m,(char *)"Y blis:gbmv");
|
||||
printvector(Y_ref, m, (char *) "Y_ref blis:gbmv" );
|
||||
|
||||
#endif
|
||||
|
||||
if(computeErrorV(incY,incY, m, Y, Y_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__ );
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__ );
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_gbmv<double>( );
|
||||
test_gbmv<float>( );
|
||||
test_gbmv<complex<float>>( );
|
||||
test_gbmv<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -34,11 +34,11 @@
|
||||
#include <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test_gemm.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
#define PRINT
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define BETA 0.0
|
||||
#define M 5
|
||||
@@ -68,6 +68,7 @@ void ref_gemm(int64_t m, int64_t n, int64_t k,
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, beta, 1,1,&obj_beta );
|
||||
bli_obj_create_with_attached_buffer( dt, m, k, A, 1,m,&obj_a );
|
||||
@@ -86,7 +87,6 @@ void ref_gemm(int64_t m, int64_t n, int64_t k,
|
||||
template< typename T >
|
||||
void test_gemm( )
|
||||
{
|
||||
int i, j, p;
|
||||
T *A, *B, *C, *C_ref;
|
||||
T alpha, beta;
|
||||
int m,n,k;
|
||||
@@ -98,40 +98,20 @@ void test_gemm( )
|
||||
k = K;
|
||||
n = N;
|
||||
|
||||
A = new T[m * k];
|
||||
B = new T[k * n];
|
||||
|
||||
lda = m;
|
||||
ldb = k;
|
||||
ldc = m;
|
||||
ldc_ref = m;
|
||||
C = new T[ldc * n];
|
||||
C_ref= new T[m * n];
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , m , k);
|
||||
allocate_init_buffer(B , k , n);
|
||||
allocate_init_buffer(C , m , n);
|
||||
copy_buffer(C, C_ref , m ,n);
|
||||
|
||||
srand48 (time(NULL));
|
||||
|
||||
// Randonly generate points in [ 0, 1 ].
|
||||
for ( p = 0; p < k; p ++ ) {
|
||||
for ( i = 0; i < m; i ++ ) {
|
||||
A( i, p ) = (T)( drand48() );
|
||||
}
|
||||
}
|
||||
for ( j = 0; j < n; j ++ ) {
|
||||
for ( p = 0; p < k; p ++ ) {
|
||||
B( p, j ) = (T)( drand48() );
|
||||
}
|
||||
}
|
||||
|
||||
for ( j = 0; j < n; j ++ ) {
|
||||
for ( i = 0; i < m; i ++ ) {
|
||||
C_ref( i, j ) = (T)( 0.0 );
|
||||
C( i, j ) = (T)( 0.0 );
|
||||
}
|
||||
}
|
||||
#ifdef PRINT
|
||||
bl_dgemm_printmatrix(A, lda ,m,k);
|
||||
bl_dgemm_printmatrix(B, ldb ,k,n);
|
||||
bl_dgemm_printmatrix(C, ldc ,m,n);
|
||||
printmatrix(A, lda ,m,k , (char *)"A");
|
||||
printmatrix(B, ldb ,k,n, (char *)"B");
|
||||
printmatrix(C, ldc ,m,n, (char *)"C");
|
||||
#endif
|
||||
blis::gemm(
|
||||
CblasColMajor,
|
||||
@@ -151,14 +131,14 @@ void test_gemm( )
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
bl_dgemm_printmatrix(C, ldc ,m,n);
|
||||
printmatrix(C,ldc ,m,n , (char *)"C output");
|
||||
#endif
|
||||
ref_gemm(m, n, k, &alpha, A, B, &beta, C_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
bl_dgemm_printmatrix(C_ref, ldc_ref ,m,n);
|
||||
printmatrix(C_ref, ldc_ref ,m,n, (char *)"C ref output");
|
||||
#endif
|
||||
if(computeError(ldc, ldc_ref, m, n, C, C_ref )==1)
|
||||
if(computeErrorM(ldc, ldc_ref, m, n, C, C_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__ );
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__ );
|
||||
|
||||
162
testcpp/test_gemv.cc
Normal file
162
testcpp/test_gemv.cc
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define BETA 0.0
|
||||
#define M 5
|
||||
#define N 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_gemv(int64_t m, int64_t n,
|
||||
T * alpha,
|
||||
T *A,
|
||||
T *X,
|
||||
T * beta,
|
||||
T *Y )
|
||||
|
||||
{
|
||||
obj_t obj_a, obj_x, obj_y;
|
||||
obj_t obj_alpha, obj_beta;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, beta, 1,1,&obj_beta );
|
||||
bli_obj_create_with_attached_buffer( dt, m, n, A, 1,m,&obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1,n,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, m, 1, Y, 1,m,&obj_y );
|
||||
|
||||
bli_obj_set_conjtrans( BLIS_NO_TRANSPOSE, &obj_a );
|
||||
bli_obj_set_conjtrans( BLIS_NO_TRANSPOSE, &obj_x);
|
||||
bli_obj_set_conjtrans( BLIS_NO_TRANSPOSE, &obj_y);
|
||||
bli_gemv( &obj_alpha,
|
||||
&obj_a,
|
||||
&obj_x,
|
||||
&obj_beta,
|
||||
&obj_y );
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_gemv( )
|
||||
{
|
||||
T *A, *Y, *Y_ref, *X;
|
||||
T alpha, beta;
|
||||
int m,n;
|
||||
int lda, incx, incy, incy_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
beta = BETA;
|
||||
m = M;
|
||||
n = N;
|
||||
|
||||
lda = m;
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
incy_ref = 1;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , m , n);
|
||||
allocate_init_buffer(X , m , 1);
|
||||
allocate_init_buffer(Y , m , 1);
|
||||
copy_buffer(Y, Y_ref , m ,1);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,m,n,(char *) "A");
|
||||
printvector(X, m,(char *) "X");
|
||||
printvector(Y, m, (char *)"Y");
|
||||
#endif
|
||||
blis::gemv(
|
||||
CblasColMajor,
|
||||
CblasNoTrans,
|
||||
m,
|
||||
n,
|
||||
alpha,
|
||||
A,
|
||||
lda,
|
||||
X,
|
||||
incx,
|
||||
beta,
|
||||
Y,
|
||||
incy
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(Y, m, (char *)"Y output");
|
||||
#endif
|
||||
ref_gemv(m, n, &alpha, A, X, &beta, Y_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(Y_ref, m, (char *) "Y_Ref output");
|
||||
#endif
|
||||
if(computeErrorV(incy,incy_ref, m , Y, Y_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__ );
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__ );
|
||||
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( X );
|
||||
delete[]( Y );
|
||||
delete[]( Y_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_gemv<float>( );
|
||||
test_gemv<double>( );
|
||||
test_gemv<complex<float>>( );
|
||||
test_gemv<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
150
testcpp/test_ger.cc
Normal file
150
testcpp/test_ger.cc
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define M 5
|
||||
#define N 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_ger(int64_t m, int64_t n,
|
||||
T * alpha,
|
||||
T *X,
|
||||
T *Y,
|
||||
T *A )
|
||||
|
||||
{
|
||||
obj_t obj_a;
|
||||
obj_t obj_x;
|
||||
obj_t obj_y;
|
||||
obj_t obj_alpha;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, m, n, A, 1, m, &obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, m, 1, X, 1, m,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1, n,&obj_y );
|
||||
|
||||
//bli_obj_set_struc( BLIS_HERMITIAN, &obj_a );
|
||||
//bli_obj_set_uplo( BLIS_LOWER, &obj_a);
|
||||
bli_ger( &obj_alpha,
|
||||
&obj_x,
|
||||
&obj_y,
|
||||
&obj_a );
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_ger( )
|
||||
{
|
||||
T *A, *X, *Y, *A_ref;
|
||||
T alpha;
|
||||
int m,n;
|
||||
int lda, incx, incy, lda_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
m = M;
|
||||
n = N;
|
||||
|
||||
lda = m;
|
||||
lda_ref = m;
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , m , n);
|
||||
allocate_init_buffer(X , m , 1);
|
||||
allocate_init_buffer(Y , n , 1);
|
||||
copy_buffer(A, A_ref , m ,n);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,m,n,(char *) "A");
|
||||
printvector(X, m,(char *) "X");
|
||||
printvector(Y, n,(char *) "Y");
|
||||
#endif
|
||||
blis::ger(
|
||||
CblasColMajor,
|
||||
m,
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incx,
|
||||
Y,
|
||||
incy,
|
||||
A,
|
||||
lda
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda , m ,n ,(char *) "A output");
|
||||
#endif
|
||||
ref_ger(m, n, &alpha, X, Y, A_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A_ref, lda ,m,n, (char *)"A_ref output");
|
||||
#endif
|
||||
if(computeErrorM(lda, lda_ref, m, n, A, A_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( X );
|
||||
delete[]( Y );
|
||||
delete[]( A_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_ger<float>( );
|
||||
test_ger<double>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
174
testcpp/test_gerc.cc
Normal file
174
testcpp/test_gerc.cc
Normal file
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define M 5
|
||||
#define N 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_gerc(int64_t m, int64_t n,
|
||||
T * alpha,
|
||||
T *X,
|
||||
T *Y,
|
||||
T *A )
|
||||
|
||||
{
|
||||
obj_t obj_a;
|
||||
obj_t obj_x;
|
||||
obj_t obj_y;
|
||||
obj_t obj_alpha;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
|
||||
if(dt == BLIS_FLOAT){
|
||||
bli_obj_create_with_attached_buffer( BLIS_FLOAT, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
}
|
||||
else if(dt == BLIS_DOUBLE){
|
||||
bli_obj_create_with_attached_buffer( BLIS_DOUBLE, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
}
|
||||
|
||||
if(dt == BLIS_SCOMPLEX){
|
||||
bli_obj_create_with_attached_buffer( BLIS_SCOMPLEX, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
}
|
||||
else if(dt == BLIS_DCOMPLEX){
|
||||
bli_obj_create_with_attached_buffer( BLIS_DCOMPLEX, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
}
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, m, n, A, 1, m, &obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, m, 1, X, 1, m,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1, n,&obj_y );
|
||||
|
||||
bli_obj_set_conj(BLIS_CONJUGATE,&obj_y);
|
||||
bli_ger( &obj_alpha,
|
||||
&obj_x,
|
||||
&obj_y,
|
||||
&obj_a );
|
||||
}
|
||||
|
||||
|
||||
template< typename T >
|
||||
void test_gerc( )
|
||||
{
|
||||
T *A, *X, *Y, *A_ref;
|
||||
T alpha;
|
||||
int m,n;
|
||||
int lda, incx, incy, lda_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
m = M;
|
||||
n = N;
|
||||
|
||||
lda = m;
|
||||
lda_ref = m;
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , m , n);
|
||||
allocate_init_buffer(X , m , 1);
|
||||
allocate_init_buffer(Y , n , 1);
|
||||
copy_buffer(A, A_ref , m ,n);
|
||||
|
||||
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,m,n,(char *)"A");
|
||||
printvector(X, m, (char *)"X");
|
||||
|
||||
#endif
|
||||
blis::gerc(
|
||||
CblasColMajor,
|
||||
m,
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incx,
|
||||
Y,
|
||||
incy,
|
||||
A,
|
||||
lda
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix (A, lda ,m , n,(char *)"A blis::gerc\n");
|
||||
|
||||
#endif
|
||||
ref_gerc(m, n, &alpha, X, Y, A_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A_ref, lda_ref, m, n, (char *)"A_ref output\n");
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
if(computeErrorM(lda, lda_ref, m, n, A, A_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( X );
|
||||
delete[]( Y );
|
||||
delete[]( A_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_gerc<complex<float>>( );
|
||||
test_gerc<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
169
testcpp/test_geru.cc
Normal file
169
testcpp/test_geru.cc
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define M 5
|
||||
#define N 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_geru(int64_t m, int64_t n,
|
||||
T * alpha,
|
||||
T *X,
|
||||
T *Y,
|
||||
T *A )
|
||||
|
||||
{
|
||||
obj_t obj_a;
|
||||
obj_t obj_x;
|
||||
obj_t obj_y;
|
||||
obj_t obj_alpha;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
|
||||
if(dt == BLIS_FLOAT){
|
||||
bli_obj_create_with_attached_buffer( BLIS_FLOAT, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
}
|
||||
else if(dt == BLIS_DOUBLE){
|
||||
bli_obj_create_with_attached_buffer( BLIS_DOUBLE, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
}
|
||||
|
||||
if(dt == BLIS_SCOMPLEX){
|
||||
bli_obj_create_with_attached_buffer( BLIS_SCOMPLEX, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
}
|
||||
else if(dt == BLIS_DCOMPLEX){
|
||||
bli_obj_create_with_attached_buffer( BLIS_DCOMPLEX, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
}
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, m, n, A, 1, m, &obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, m, 1, X, 1, m,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1, n,&obj_y );
|
||||
|
||||
bli_ger( &obj_alpha,
|
||||
&obj_x,
|
||||
&obj_y,
|
||||
&obj_a );
|
||||
}
|
||||
|
||||
|
||||
template< typename T >
|
||||
void test_geru( )
|
||||
{
|
||||
T *A, *X, *Y, *A_ref;
|
||||
T alpha;
|
||||
int m,n;
|
||||
int lda, incx, incy, lda_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
m = M;
|
||||
n = N;
|
||||
|
||||
lda = m;
|
||||
lda_ref = m;
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , m , n);
|
||||
allocate_init_buffer(X , m , 1);
|
||||
allocate_init_buffer(Y , n , 1);
|
||||
copy_buffer(A, A_ref , m ,n);
|
||||
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,m,n,(char *)"A");
|
||||
printvector(X, m,(char *) "X");
|
||||
#endif
|
||||
blis::geru(
|
||||
CblasColMajor,
|
||||
m,
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incx,
|
||||
Y,
|
||||
incy,
|
||||
A,
|
||||
lda
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix (A, lda ,m,n,(char *)"A output");
|
||||
printvector (X, m,(char *) "X");
|
||||
|
||||
#endif
|
||||
ref_geru(m, n, &alpha, X, Y, A_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A_ref, lda_ref, m,n,(char *)"A_ref output" );
|
||||
|
||||
#endif
|
||||
if(computeErrorM(lda, lda_ref, m, n, A, A_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( X );
|
||||
delete[]( Y );
|
||||
delete[]( A_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_geru<complex<float>>( );
|
||||
test_geru<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
164
testcpp/test_hemm.cc
Normal file
164
testcpp/test_hemm.cc
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define BETA 0.0
|
||||
#define M 5
|
||||
#define N 5
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_hemm(int64_t m, int64_t n,
|
||||
T * alpha,
|
||||
T *A,
|
||||
T *B,
|
||||
T * beta,
|
||||
T *C )
|
||||
|
||||
{
|
||||
obj_t obj_a, obj_b, obj_c;
|
||||
obj_t obj_alpha, obj_beta;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, beta, 1,1,&obj_beta );
|
||||
bli_obj_create_with_attached_buffer( dt, m, m, A, 1,m,&obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, m, n, B, 1,n,&obj_b );
|
||||
bli_obj_create_with_attached_buffer( dt, m, n, C, 1,m,&obj_c );
|
||||
|
||||
bli_obj_set_struc( BLIS_HERMITIAN, &obj_a );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_a );
|
||||
bli_mkherm(&obj_a);
|
||||
bli_mktrim(&obj_a);
|
||||
bli_hemm( BLIS_LEFT,
|
||||
&obj_alpha,
|
||||
&obj_a,
|
||||
&obj_b,
|
||||
&obj_beta,
|
||||
&obj_c );
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_hemm( )
|
||||
{
|
||||
T *A, *B, *C, *C_ref;
|
||||
T alpha, beta;
|
||||
int m,n;
|
||||
int lda, ldb, ldc, ldc_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
beta = BETA;
|
||||
m = M;
|
||||
n = N;
|
||||
|
||||
lda = m;
|
||||
ldb = n;
|
||||
ldc = m;
|
||||
ldc_ref = m;
|
||||
|
||||
srand48 (time(NULL));
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , m , m);
|
||||
allocate_init_buffer(B , m , n);
|
||||
allocate_init_buffer(C , m , n);
|
||||
copy_buffer(C, C_ref , m ,n);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,m,m,(char *) "A");
|
||||
printmatrix(B, ldb ,m,n,(char *) "B");
|
||||
printmatrix(C, ldc ,m,n,(char *) "C");
|
||||
#endif
|
||||
blis::hemm(
|
||||
CblasColMajor,
|
||||
CblasLeft,
|
||||
CblasLower,
|
||||
m,
|
||||
n,
|
||||
alpha,
|
||||
A,
|
||||
lda,
|
||||
B,
|
||||
ldb,
|
||||
beta,
|
||||
C,
|
||||
ldc
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(C, ldc ,m,n,(char *) "C output");
|
||||
#endif
|
||||
ref_hemm(m, n, &alpha, A, B, &beta, C_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(C_ref, ldc_ref ,m,n,(char *) "C ref output");
|
||||
#endif
|
||||
if(computeErrorM(ldc, ldc_ref, m, n, C, C_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__ );
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__ );
|
||||
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( B );
|
||||
delete[]( C );
|
||||
delete[]( C_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_hemm<complex<float>>( );
|
||||
test_hemm<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
157
testcpp/test_hemv.cc
Normal file
157
testcpp/test_hemv.cc
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define BETA 0.0
|
||||
#define N 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_hemv(int64_t n,
|
||||
T * alpha,
|
||||
T *A,
|
||||
T *X,
|
||||
T * beta,
|
||||
T *Y )
|
||||
|
||||
{
|
||||
obj_t obj_a, obj_x, obj_y;
|
||||
obj_t obj_alpha, obj_beta;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, beta, 1,1,&obj_beta );
|
||||
bli_obj_create_with_attached_buffer( dt, n, n, A, 1,n,&obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1,n,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1,n,&obj_y );
|
||||
|
||||
bli_obj_set_struc( BLIS_HERMITIAN, &obj_a );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_a );
|
||||
|
||||
bli_hemv( &obj_alpha,
|
||||
&obj_a,
|
||||
&obj_x,
|
||||
&obj_beta,
|
||||
&obj_y );
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_hemv( )
|
||||
{
|
||||
T *A, *Y, *Y_ref, *X;
|
||||
T alpha, beta;
|
||||
int n;
|
||||
int lda, incx, incy, incy_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
beta = BETA;
|
||||
n = N;
|
||||
|
||||
lda = n;
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
incy_ref = 1;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , n , n);
|
||||
allocate_init_buffer(X , n , 1);
|
||||
allocate_init_buffer(Y , n , 1);
|
||||
copy_buffer(Y, Y_ref , n ,1);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,n, (char *)"A");
|
||||
printvector(X, n, (char *)"X");
|
||||
printvector(Y, n, (char *)"Y");
|
||||
#endif
|
||||
blis::hemv(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
n,
|
||||
alpha,
|
||||
A,
|
||||
lda,
|
||||
X,
|
||||
incx,
|
||||
beta,
|
||||
Y,
|
||||
incy
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(Y, n, (char *)"Y output");
|
||||
#endif
|
||||
ref_hemv(n, &alpha, A, X, &beta, Y_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(Y_ref, n,(char *) "Y_ref output");
|
||||
#endif
|
||||
if(computeErrorV(incy,incy_ref, n, Y, Y_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__ );
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__ );
|
||||
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( X );
|
||||
delete[]( Y );
|
||||
delete[]( Y_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_hemv<complex<float>>( );
|
||||
test_hemv<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
141
testcpp/test_her.cc
Normal file
141
testcpp/test_her.cc
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define N 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_her(int64_t n,
|
||||
real_type<T> * alpha,
|
||||
T *X,
|
||||
T *A )
|
||||
|
||||
{
|
||||
obj_t obj_a;
|
||||
obj_t obj_x;
|
||||
obj_t obj_alpha;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
if(dt == BLIS_SCOMPLEX){
|
||||
bli_obj_create_with_attached_buffer( BLIS_FLOAT, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
}
|
||||
else if(dt == BLIS_DCOMPLEX){
|
||||
bli_obj_create_with_attached_buffer( BLIS_DOUBLE, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
}
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, n, n, A, 1, n, &obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1, n,&obj_x );
|
||||
|
||||
bli_obj_set_struc( BLIS_HERMITIAN, &obj_a );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_a);
|
||||
bli_her( &obj_alpha,
|
||||
&obj_x,
|
||||
&obj_a );
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_her( )
|
||||
{
|
||||
T *A, *X, *A_ref;
|
||||
real_type<T> alpha;
|
||||
int n;
|
||||
int lda, incx, lda_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
n = N;
|
||||
|
||||
lda = n;
|
||||
lda_ref = n;
|
||||
incx = 1;
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , n , n);
|
||||
allocate_init_buffer(X , n , 1);
|
||||
copy_buffer(A, A_ref , n ,n);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,n,(char *) "A");
|
||||
printvector(X, n,(char *) "X");
|
||||
#endif
|
||||
blis::her(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incx,
|
||||
A,
|
||||
lda
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,n, (char *)"A output");
|
||||
#endif
|
||||
ref_her(n, &alpha, X, A_ref);
|
||||
#ifdef PRINT
|
||||
printmatrix(A_ref, lda_ref, n,n ,(char *) "A refoutput");
|
||||
#endif
|
||||
if(computeErrorM(lda, lda_ref, n, n, A, A_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( X );
|
||||
delete[]( A_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_her<complex<float>>( );
|
||||
test_her<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
147
testcpp/test_her2.cc
Normal file
147
testcpp/test_her2.cc
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define N 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_her2(int64_t n,
|
||||
T * alpha,
|
||||
T *X,
|
||||
T *Y,
|
||||
T *A )
|
||||
|
||||
{
|
||||
obj_t obj_a;
|
||||
obj_t obj_x, obj_y;
|
||||
obj_t obj_alpha;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer(dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, n, n, A, 1, n, &obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1, n,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1, n,&obj_y );
|
||||
|
||||
bli_obj_set_struc( BLIS_HERMITIAN, &obj_a );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_a);
|
||||
bli_her2( &obj_alpha,
|
||||
&obj_x,
|
||||
&obj_y,
|
||||
&obj_a );
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_her2( )
|
||||
{
|
||||
T *A, *X, *Y, *A_ref;
|
||||
T alpha;
|
||||
int n;
|
||||
int lda, incx, incy, lda_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
n = N;
|
||||
|
||||
lda = n;
|
||||
lda_ref = n;
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , n , n);
|
||||
allocate_init_buffer(X , n , 1);
|
||||
allocate_init_buffer(Y , n , 1);
|
||||
copy_buffer(A, A_ref , n ,n);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,n,(char *) "A");
|
||||
printvector(X, n,(char *) "X");
|
||||
printvector(Y, n, (char *)"Y");
|
||||
#endif
|
||||
blis::her2(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incx,
|
||||
Y,
|
||||
incy,
|
||||
A,
|
||||
lda
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda , n , n,(char *) "A output");
|
||||
#endif
|
||||
ref_her2(n, &alpha, X, Y, A_ref);
|
||||
#ifdef PRINT
|
||||
printmatrix(A_ref, lda , n, n, (char *)"A_ref output");
|
||||
#endif
|
||||
if(computeErrorM(lda, lda_ref, n, n, A, A_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( X );
|
||||
delete[]( Y );
|
||||
delete[]( A_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_her2<complex<float>>( );
|
||||
test_her2<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
155
testcpp/test_herk.cc
Normal file
155
testcpp/test_herk.cc
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP herk routine and reference blis herk routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define BETA 0.0
|
||||
#define N 6
|
||||
#define K 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_herk(int64_t n, int64_t k,
|
||||
real_type<T> * alpha,
|
||||
T *A,
|
||||
real_type<T> * beta,
|
||||
T *C )
|
||||
|
||||
{
|
||||
obj_t obj_a,obj_c;
|
||||
obj_t obj_alpha, obj_beta;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
if(dt == BLIS_SCOMPLEX){
|
||||
bli_obj_create_with_attached_buffer( BLIS_FLOAT, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( BLIS_FLOAT, 1, 1, beta, 1,1,&obj_beta );
|
||||
}
|
||||
else if(dt == BLIS_DCOMPLEX){
|
||||
bli_obj_create_with_attached_buffer( BLIS_DOUBLE, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( BLIS_DOUBLE, 1, 1, beta, 1,1,&obj_beta );
|
||||
}
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, n, k, A, 1,n,&obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, n, n, C, 1,n,&obj_c );
|
||||
|
||||
bli_obj_set_struc( BLIS_HERMITIAN, &obj_c );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_c );
|
||||
bli_obj_set_conjtrans( BLIS_NO_TRANSPOSE, &obj_c );
|
||||
bli_herk( &obj_alpha,
|
||||
&obj_a,
|
||||
&obj_beta,
|
||||
&obj_c );
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_herk( )
|
||||
{
|
||||
T *A, *C, *C_ref;
|
||||
real_type<T> alpha;
|
||||
real_type<T> beta;
|
||||
int n,k;
|
||||
int lda, ldc, ldc_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
beta = BETA;
|
||||
k = K;
|
||||
n = N;
|
||||
|
||||
|
||||
lda = k;
|
||||
ldc = n;
|
||||
ldc_ref = n;
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , n , k);
|
||||
allocate_init_buffer(C , n , n);
|
||||
copy_buffer(C, C_ref , n ,n);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,k, (char *)"A");
|
||||
printmatrix(C, ldc ,n,n, (char *)"C");
|
||||
#endif
|
||||
blis::herk(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
CblasNoTrans,
|
||||
n,
|
||||
k,
|
||||
alpha,
|
||||
A,
|
||||
lda,
|
||||
beta,
|
||||
C,
|
||||
ldc
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(C, ldc ,n,n, (char *)"C output");
|
||||
#endif
|
||||
ref_herk(n, k, &alpha, A, &beta, C_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(C_ref, ldc_ref ,n,n, (char *)"C ref output");
|
||||
#endif
|
||||
if(computeErrorM(ldc, ldc_ref, n, n, C, C_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( C );
|
||||
delete[]( C_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_herk<complex<float>>( );
|
||||
test_herk<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
112
testcpp/test_hpr.cc
Normal file
112
testcpp/test_hpr.cc
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 2
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
|
||||
template< typename T >
|
||||
void test_hpr( )
|
||||
{
|
||||
int n;
|
||||
real_type<T> alpha;
|
||||
int incX = -1;
|
||||
|
||||
alpha = 1.0;
|
||||
n = N;
|
||||
|
||||
|
||||
T A[4];
|
||||
A[0] = { 0.265, 0.362};
|
||||
A[1] = {-0.855, 0.035};
|
||||
A[2] = {0.136, 0.133 };
|
||||
A[3] = { 0.00, 0.00};
|
||||
|
||||
T X[2];
|
||||
X[0] = { -0.278, -0.686};
|
||||
X[1] = {-0.736, -0.918 };
|
||||
|
||||
T A_ref[4];
|
||||
A_ref[0] = { 1.64942, 0.0};
|
||||
A_ref[1] = {-0.020644, 0.284692};
|
||||
A_ref[2] = {0.68388, 0.0 };
|
||||
A_ref[3] = {0.00, 0.00 };
|
||||
|
||||
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, n,n, n,(char *) "A");
|
||||
printvector(X, n, (char *)"X");
|
||||
#endif
|
||||
blis::hpr(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incX,
|
||||
A
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, n , n, n,(char *)"A blis:hpr\n");
|
||||
|
||||
printmatrix(A_ref, n, n, n,(char *)"A_ref output\n");
|
||||
#endif
|
||||
|
||||
if(computeErrorM(n, n, n, n, A, A_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_hpr<complex<float>>( );
|
||||
test_hpr<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
106
testcpp/test_hpr2.cc
Normal file
106
testcpp/test_hpr2.cc
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 1
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
|
||||
template< typename T >
|
||||
void test_hpr2( )
|
||||
{
|
||||
int n,lda;
|
||||
int incX = -1;
|
||||
int incY = -1;
|
||||
n = N;
|
||||
|
||||
T alpha = {-0.3, 0.1};
|
||||
|
||||
T A[1];
|
||||
A[0] = { 0.772, 0.997 };
|
||||
T X[1];
|
||||
X[0] = { -0.173, -0.839 };
|
||||
T Y[1];
|
||||
Y[0] = { 0.941, -0.422 };
|
||||
T A_ref[1];
|
||||
A_ref[0] = { 0.829742, 0.0 };
|
||||
|
||||
#ifdef PRINT
|
||||
printf("Matrix A\n");
|
||||
printmatrix(A, lda, n, n,(char *) "A");
|
||||
printf("Vector X \n");
|
||||
printvector(X, n, (char *) "X");
|
||||
#endif
|
||||
blis::hpr2(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incX,
|
||||
Y,
|
||||
incY,
|
||||
A
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printf("Matrix A after blis:hpr2\n");
|
||||
printmatrix (A, lda, n, n, (char *) "A output");
|
||||
printf(" A_ref blis:hpr2\n");
|
||||
printmatrix(A_ref, lda, n, n,(char *)"A_refoutput");
|
||||
#endif
|
||||
|
||||
if(computeErrorM(1, 1, n, n, A, A_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_hpr2<complex<float>>( );
|
||||
printf("**************\n");
|
||||
test_hpr2<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
100
testcpp/test_nrm2.cc
Normal file
100
testcpp/test_nrm2.cc
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP nrm2 routine and reference blis nrm2 routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 2
|
||||
#define ALPHA 0.5
|
||||
|
||||
#define TOLERANCE 0.0000001
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T>
|
||||
void test_nrm2()
|
||||
{
|
||||
|
||||
T X[N];
|
||||
T nrm2, nrm2_ref;
|
||||
int n;
|
||||
int incx;
|
||||
|
||||
n = N;
|
||||
incx = 1;
|
||||
|
||||
if(is_same<T , float>::value)
|
||||
{
|
||||
X[0] = 0.14f;
|
||||
X[1] = -0.632f;
|
||||
nrm2_ref = 0.647320631527f;
|
||||
}
|
||||
else if(is_same<T , double>::value)
|
||||
{
|
||||
X[0] = 0.696;
|
||||
X[1] = -0.804;
|
||||
nrm2_ref = 1.06340584915;
|
||||
}
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n,(char *) "Vector X after blis::nrm2");
|
||||
#endif
|
||||
nrm2 = blis::nrm2<T>(
|
||||
n,
|
||||
X,
|
||||
incx
|
||||
);
|
||||
#ifdef PRINT
|
||||
printf("Norm of a Vector %E \n", nrm2);
|
||||
printf("Ref Norm of a Vector %E \n", nrm2_ref);
|
||||
#endif
|
||||
|
||||
if (fabs(nrm2 - nrm2_ref) > TOLERANCE)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_nrm2<float>( );
|
||||
test_nrm2<double>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
102
testcpp/test_rot.cc
Normal file
102
testcpp/test_rot.cc
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP rot routine and reference blis rot routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 1
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T>
|
||||
void test_rot()
|
||||
{
|
||||
|
||||
T c, s;
|
||||
T X[N], X_ref[N];
|
||||
T Y[N], Y_ref[N];
|
||||
int n;
|
||||
int incx, incy;
|
||||
|
||||
n = N;
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
if(is_same<T , float>::value){
|
||||
c = -1.0f;
|
||||
s = 0.0f;
|
||||
X[0] = { -0.314f };
|
||||
Y[0] = { -0.406f };
|
||||
X_ref[0] = { 0.314f };
|
||||
Y_ref[0] = { 0.406f };
|
||||
}else{
|
||||
c = -1;
|
||||
s = 0;
|
||||
X[0] = { -0.176 };
|
||||
Y[0] = { -0.165 };
|
||||
X_ref[0] = { 0.176 };
|
||||
Y_ref[0] = { 0.165 };
|
||||
}
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n, (char *)"Before blis::rot\nVector X");
|
||||
printvector(Y, n, (char *)"Vector Y");
|
||||
#endif
|
||||
blis::rot<T>( N, X, incx, Y, incy, c, s);
|
||||
#ifdef PRINT
|
||||
printvector(X, n, (char *)"After blis::rot\nVector X");
|
||||
printvector(Y, n, (char *) "Vector Y");
|
||||
printvector(X, n, (char *) "Expected Output from blis::rot\nVector X");
|
||||
printvector(Y, n, (char *)"Vector Y");
|
||||
#endif
|
||||
|
||||
if((computeErrorV(incx, incx , n, X, X_ref )==1) || (computeErrorV(incy, incy , n, Y, Y_ref )==1))
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_rot<float>( );
|
||||
test_rot<double>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
108
testcpp/test_rotg.cc
Normal file
108
testcpp/test_rotg.cc
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP rotg routine and reference blis rotg routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T>
|
||||
void test_rotg()
|
||||
{
|
||||
|
||||
T a, b, c, s;
|
||||
T a_ref, b_ref, c_ref, s_ref;
|
||||
|
||||
if(is_same<T , float>::value)
|
||||
{
|
||||
a = 1.0f;
|
||||
b = 1.0f;
|
||||
a_ref = 1.41421356237f;
|
||||
b_ref = 1.41421356237f;
|
||||
c_ref = 0.707106781187f;
|
||||
s_ref = 0.707106781187f;
|
||||
}else{
|
||||
a = 1;
|
||||
b = 0;
|
||||
a_ref = 1;
|
||||
b_ref = 0;
|
||||
c_ref = 1;
|
||||
s_ref = 0;
|
||||
}
|
||||
|
||||
#ifdef PRINT
|
||||
cout<< "Before blis::rotg \na Value : " << a << "\n" ;
|
||||
cout<< "b Value : " << b << "\n" ;
|
||||
#endif
|
||||
blis::rotg<T>(
|
||||
&a,
|
||||
&b,
|
||||
&c,
|
||||
&s
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
cout<< "After blis::rotg \na Value : " << a << "\n" ;
|
||||
cout<< "b Value : " << b << "\n" ;
|
||||
cout<< "c Value : " << c << "\n" ;
|
||||
cout<< "s Value : " << s << "\n" ;
|
||||
#endif
|
||||
|
||||
#ifdef PRINT
|
||||
cout<< "Expected Output\na Value : " << a_ref << "\n" ;
|
||||
cout<< "b Value : " << b_ref << "\n" ;
|
||||
cout<< "c Value : " << c_ref << "\n" ;
|
||||
cout<< "s Value : " << s_ref << "\n" ;
|
||||
#endif
|
||||
if( (a != a_ref ) || (b != b_ref ) || (c != c_ref ) || (s != s_ref ))
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_rotg<float>( );
|
||||
test_rotg<double>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
106
testcpp/test_rotm.cc
Normal file
106
testcpp/test_rotm.cc
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP rotm routine and reference blis rotm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 1
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T>
|
||||
void test_rotm()
|
||||
{
|
||||
|
||||
T X[N], X_ref[N];
|
||||
T Y[N], Y_ref[N];
|
||||
int n;
|
||||
int incx, incy;
|
||||
const T P[5] = { -1.0f, -4.44982e+03f, -15.5826f, 7.091334e+04f, 2.95912e+04f };
|
||||
const T P_double[5] = { 1.0, -1.244580625511e+03, 1.11154682624,
|
||||
2.269384716089e-05, -0.0143785338883 };
|
||||
n = N;
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
if(is_same<T , float>::value)
|
||||
{
|
||||
X[0] = { -0.034f };
|
||||
Y[0] = { -0.56f };
|
||||
X_ref[0] = { -3.956017e+04f };
|
||||
Y_ref[0] = { -1.657054e+04f };
|
||||
}else{
|
||||
X[0] = { 0.84 };
|
||||
Y[0] = { -0.711 };
|
||||
X_ref[0] = { -1.046158725429e+03 };
|
||||
Y_ref[0] = { -0.829776862405 };
|
||||
}
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n, (char *)"Before blis::rot\nVector X");
|
||||
printvector(Y, n, (char *)"Vector Y");
|
||||
#endif
|
||||
if(is_same<T , float>::value)
|
||||
{
|
||||
blis::rotm<T>( N, X, incx, Y, incy, P);
|
||||
}else{
|
||||
blis::rotm<T>( N, X, incx, Y, incy, P_double);
|
||||
}
|
||||
#ifdef PRINT
|
||||
printvector(X, n, (char *)"After blis::rot\nVector X");
|
||||
printvector(Y, n, (char *)"Vector Y");
|
||||
printvector(X, n, (char *)"Expected Output from blis::rot\nVector X");
|
||||
printvector(Y, n, (char *)"Vector Y");
|
||||
#endif
|
||||
|
||||
if((computeErrorV(incx, incx , n, X, X_ref )==1)
|
||||
|| (computeErrorV(incy, incy , n, Y, Y_ref )==1))
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_rotm<float>( );
|
||||
test_rotm<double>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
137
testcpp/test_rotmg.cc
Normal file
137
testcpp/test_rotmg.cc
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP rotmg routine and reference blis rotmg routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T>
|
||||
void test_rotmg()
|
||||
{
|
||||
T d1, d2, b1, b2;
|
||||
T d1_ref, d2_ref, b1_ref;
|
||||
T h[5] = { -999.0f, -999.1f, -999.2f, -999.3f, -999.4f };
|
||||
T h_ref[5] = {-1.0f, 0.0f, 0.0f, 0.0f,0.0f};
|
||||
T h_double[5] = { -999.0, -999.1, -999.2, -999.3, -999.4 };
|
||||
T h_ref_double[5] = { 1, 0, 0, 0};
|
||||
|
||||
if(is_same<T , float>::value)
|
||||
{
|
||||
d1 = -1630.28519312f;
|
||||
d2 = 44320.1964703f;
|
||||
b1 = 1274.7681352f;
|
||||
b2 = 0.983006912864f;
|
||||
d1_ref= 0.0f;
|
||||
d2_ref= 0.0f;
|
||||
b1_ref= 0.0f;
|
||||
}else{
|
||||
d1 = -49.1978123005;
|
||||
d2 = 0.228703451277;
|
||||
b1 = 1.8901039144;
|
||||
b2 = 7081.47754386;
|
||||
d1_ref= 0;
|
||||
d2_ref= 0;
|
||||
b1_ref= 0;
|
||||
}
|
||||
|
||||
#ifdef PRINT
|
||||
cout<< "Before blis::rotmg \nd1 Value : " << d1 << "\n" ;
|
||||
cout<< "d2 Value : " << d2 << "\n" ;
|
||||
cout<< "b1 Value : " << b1 << "\n" ;
|
||||
printvector(h, 5,(char *) "param");
|
||||
#endif
|
||||
if(is_same<T , float>::value)
|
||||
{
|
||||
blis::rotmg<T>(
|
||||
&d1,
|
||||
&d2,
|
||||
&b1,
|
||||
b2,
|
||||
h
|
||||
);
|
||||
}else{
|
||||
blis::rotmg<T>(
|
||||
&d1,
|
||||
&d2,
|
||||
&b1,
|
||||
b2,
|
||||
h_double
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef PRINT
|
||||
cout<< "After blis::rotmg \nd1 Value : " << d1 << "\n" ;
|
||||
cout<< "d2 Value : " << d2 << "\n" ;
|
||||
cout<< "b1 Value : " << b1 << "\n" ;
|
||||
printvector(h, 5,(char *) "param");
|
||||
#endif
|
||||
|
||||
#ifdef PRINT
|
||||
cout<< "Expected Output from blis::rotmg \nd1 Value : " << d1_ref << "\n" ;
|
||||
cout<< "d2 Value : " << d2_ref << "\n" ;
|
||||
cout<< "b1 Value : " << b1_ref << "\n" ;
|
||||
printvector(h_ref, 5,(char *) "param");
|
||||
#endif
|
||||
if( (d1 != d1_ref ) || (d2 != d2_ref ) || (b1 != b1_ref ) )
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else if(is_same<T , float>::value){
|
||||
if(computeErrorV(1, 1 , 5, h, h_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
}else if(is_same<T , float>::value){
|
||||
if(computeErrorV(1, 1 , 5, h_double, h_ref_double )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
}else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_rotmg<float>( );
|
||||
test_rotmg<double>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
138
testcpp/test_scal.cc
Normal file
138
testcpp/test_scal.cc
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 6
|
||||
#define ALPHA 0.5
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename TA,typename TB>
|
||||
void ref_scal(int64_t n,
|
||||
TA * alpha,
|
||||
TB *X
|
||||
)
|
||||
|
||||
{
|
||||
obj_t obj_x;
|
||||
obj_t obj_alpha;
|
||||
num_t dt_x , dt_alpha;
|
||||
if(is_same<TB , float>::value)
|
||||
dt_x = BLIS_FLOAT;
|
||||
else if(is_same<TB , double>::value)
|
||||
dt_x = BLIS_DOUBLE;
|
||||
else if(is_same<TB , complex<float>>::value)
|
||||
dt_x = BLIS_SCOMPLEX;
|
||||
else if(is_same<TB , complex<double>>::value)
|
||||
dt_x = BLIS_DCOMPLEX;
|
||||
|
||||
if(is_same<TA , float>::value)
|
||||
dt_alpha = BLIS_FLOAT;
|
||||
else if(is_same<TA , double>::value)
|
||||
dt_alpha = BLIS_DOUBLE;
|
||||
else if(is_same<TA , complex<float>>::value)
|
||||
dt_alpha = BLIS_SCOMPLEX;
|
||||
else if(is_same<TA , complex<double>>::value)
|
||||
dt_alpha = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt_alpha, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt_x, n, 1, X, 1, n,&obj_x );
|
||||
|
||||
bli_scalv(&obj_alpha,
|
||||
&obj_x
|
||||
);
|
||||
|
||||
}
|
||||
template< typename TA, typename TB>
|
||||
void test_scal()
|
||||
{
|
||||
TB *X, *X_ref;
|
||||
TA alpha = ALPHA;
|
||||
int n;
|
||||
int incx;
|
||||
|
||||
n = N;
|
||||
|
||||
incx = 1;
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(X , n , 1);
|
||||
copy_buffer(X, X_ref , n ,1);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n, (char *)"X");
|
||||
#endif
|
||||
blis::scal<TA, TB>(
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incx
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n, (char *)"X output");
|
||||
#endif
|
||||
ref_scal(n , &alpha , X_ref );
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X_ref, n, (char *)"X ref output");
|
||||
#endif
|
||||
if(computeErrorV(incx, incx , n, X, X_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( X );
|
||||
delete[]( X_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_scal<float , float>( );
|
||||
test_scal<double , double>( );
|
||||
test_scal<std::complex<float> , std::complex<float>>( );
|
||||
test_scal<std::complex<double> , std::complex<double>>( );
|
||||
test_scal<float , std::complex<float>>( );
|
||||
test_scal<double , std::complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
134
testcpp/test_sdsdot.cc
Normal file
134
testcpp/test_sdsdot.cc
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP sdsdot routine and reference blis sdsdot routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 1
|
||||
#define ALPHA 0
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
|
||||
#if 0
|
||||
template< typename T >
|
||||
void ref_sdsot(int64_t n,
|
||||
T alpha,
|
||||
T *X,
|
||||
T *Y,
|
||||
T *res_ref
|
||||
)
|
||||
|
||||
{
|
||||
obj_t obj_x;
|
||||
obj_t obj_y;
|
||||
obj_t obj_res;
|
||||
obj_t obj_alpha;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1, n,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1, n,&obj_y );
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, &alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, res_ref, 1, 1,&obj_res );
|
||||
|
||||
bli_ddots( &obj_x,
|
||||
&obj_y,
|
||||
&obj_res );
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
template< typename T >
|
||||
void test_sdsdot()
|
||||
{
|
||||
|
||||
T X[N], Y[N];
|
||||
int n;
|
||||
int incx, incy;
|
||||
T res = 0, res_ref = 0;
|
||||
|
||||
n = N;
|
||||
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
|
||||
//srand (time(NULL));
|
||||
//allocate_init_buffer(X , n , 1);
|
||||
//allocate_init_buffer(Y , n , 1);
|
||||
|
||||
X[0] = { 0.733f };
|
||||
Y[0] = { 0.825f };
|
||||
res_ref = 0.604725f;
|
||||
res = blis::sdsdot<T>(
|
||||
n,
|
||||
ALPHA,
|
||||
X,
|
||||
incx,
|
||||
Y,
|
||||
incy
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printf("Dot product = %E \n", res);
|
||||
|
||||
#endif
|
||||
//ref_sdsot(n, aplha, X, Y , &res_ref );
|
||||
|
||||
#ifdef PRINT
|
||||
printf("Ref Dot product %E \n", res_ref);
|
||||
#endif
|
||||
if(res != res_ref )
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_sdsdot<float>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
97
testcpp/test_spr.cc
Normal file
97
testcpp/test_spr.cc
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 2
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
|
||||
template< typename T >
|
||||
void test_spr( )
|
||||
{
|
||||
int n;
|
||||
int incX = -1;
|
||||
T alpha = -1;
|
||||
|
||||
n = N;
|
||||
|
||||
|
||||
T A[] = { 0.819, 0.175, -0.809 };
|
||||
T X[] = { -0.645, -0.222 };
|
||||
T A_ref[] = { 0.769716, 0.03181, -1.225025 };
|
||||
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, n, n, n,(char *) "A");
|
||||
printvector(X, n,(char *) "X");
|
||||
#endif
|
||||
blis::spr(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incX,
|
||||
A
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix (A, n ,n, n, (char *)"A blis:spr\n");
|
||||
printmatrix(A_ref, n, n, n,(char *)"A_ref blis:spr \n");
|
||||
#endif
|
||||
|
||||
if(computeErrorM(1, 1, n, n, A, A_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_spr<double>( );
|
||||
test_spr<float>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
107
testcpp/test_spr2.cc
Normal file
107
testcpp/test_spr2.cc
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA -1.0f
|
||||
#define N 2
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
|
||||
template< typename T >
|
||||
void test_spr2( )
|
||||
{
|
||||
int n;
|
||||
int incX = -1;
|
||||
int incY = -1;
|
||||
T alpha;
|
||||
|
||||
alpha = ALPHA;
|
||||
n = N;
|
||||
|
||||
T A[] = { 0.493f, -0.175f, -0.831f };
|
||||
T X[] = { -0.163f, 0.489f };
|
||||
T Y[] = { 0.154f, 0.769f };
|
||||
T A_ref[]= { -0.259082f, -0.124959f, -0.780796f };
|
||||
|
||||
|
||||
|
||||
#ifdef PRINT
|
||||
printf("Matrix A\n");
|
||||
printmatrix(A, incX, n,n,(char *)"A");
|
||||
printf("Vector X \n");
|
||||
printvector(X, n, (char *)"X");
|
||||
#endif
|
||||
blis::spr2(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incX,
|
||||
Y,
|
||||
incY,
|
||||
A
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printf("Matrix A after blis:spr2\n");
|
||||
printmatrix (A,1 ,n, n,(char *)"A");
|
||||
printf("A_ref \n");
|
||||
printmatrix(A_ref, 1, n,n,(char *)"A_ref output");
|
||||
#endif
|
||||
|
||||
if(computeErrorM(1, 1, n, n, A, A_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_spr2<double>( );
|
||||
test_spr2<float>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
136
testcpp/test_swap.cc
Normal file
136
testcpp/test_swap.cc
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define N 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T>
|
||||
void ref_swap(int64_t n,
|
||||
T *X,
|
||||
T *Y
|
||||
)
|
||||
|
||||
{
|
||||
obj_t obj_x, obj_y;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1, n,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1, n,&obj_y );
|
||||
|
||||
bli_swapv( &obj_x,
|
||||
&obj_y
|
||||
);
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_swap( )
|
||||
{
|
||||
T *X, *X_ref, *Y,*Y_ref;
|
||||
int n;
|
||||
int incx, incy;
|
||||
|
||||
n = N;
|
||||
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(X , n , 1);
|
||||
allocate_init_buffer(Y , n , 1);
|
||||
copy_buffer(X, X_ref , n ,1);
|
||||
copy_buffer(Y, Y_ref , n ,1);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n, (char *)"X");
|
||||
printvector(Y, n, (char *)"Y");
|
||||
#endif
|
||||
blis::swap(
|
||||
n,
|
||||
X,
|
||||
incx,
|
||||
Y,
|
||||
incy
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n, (char *)"X output");
|
||||
printvector(Y, n, (char *)"Y output");
|
||||
#endif
|
||||
ref_swap(n , X_ref, Y_ref );
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X_ref, n, (char *)"X ref output");
|
||||
printvector(Y_ref, n, (char *)"Y ref output");
|
||||
#endif
|
||||
if((computeErrorV(incy, incy,n, Y, Y_ref )==1)||(computeErrorV(incx, incx, n, X, X_ref )==1))
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( X );
|
||||
delete[]( Y );
|
||||
delete[]( Y_ref );
|
||||
delete[]( X_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_swap<float>( );
|
||||
test_swap<double>( );
|
||||
test_swap<complex<float>>( );
|
||||
test_swap<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
164
testcpp/test_symm.cc
Normal file
164
testcpp/test_symm.cc
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP symm routine and reference blis symm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define BETA 0.0
|
||||
#define M 5
|
||||
#define N 5
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_symm(int64_t m, int64_t n,
|
||||
// side_t side,
|
||||
T * alpha,
|
||||
T *A,
|
||||
T *B,
|
||||
T * beta,
|
||||
T *C )
|
||||
|
||||
{
|
||||
obj_t obj_a, obj_b, obj_c;
|
||||
obj_t obj_alpha, obj_beta;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, beta, 1,1,&obj_beta );
|
||||
bli_obj_create_with_attached_buffer( dt, m, m, A, 1,m,&obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, m, n, B, 1,n,&obj_b );
|
||||
bli_obj_create_with_attached_buffer( dt, m, n, C, 1,m,&obj_c );
|
||||
|
||||
bli_obj_set_struc( BLIS_SYMMETRIC, &obj_a );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_a );
|
||||
bli_symm( BLIS_LEFT,
|
||||
&obj_alpha,
|
||||
&obj_a,
|
||||
&obj_b,
|
||||
&obj_beta,
|
||||
&obj_c );
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_symm( )
|
||||
{
|
||||
T *A, *B, *C, *C_ref;
|
||||
T alpha, beta;
|
||||
int m,n;
|
||||
int lda, ldb, ldc, ldc_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
beta = BETA;
|
||||
m = M;
|
||||
n = N;
|
||||
|
||||
lda = m;
|
||||
ldb = n;
|
||||
ldc = m;
|
||||
ldc_ref = m;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , m , m);
|
||||
allocate_init_buffer(B , m , n);
|
||||
allocate_init_buffer(C , m , n);
|
||||
copy_buffer(C, C_ref , m ,n);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,m,m, (char *)"A");
|
||||
printmatrix(B, ldb ,m,n, (char *)"B");
|
||||
printmatrix(C, ldc ,m,n, (char *)"C");
|
||||
#endif
|
||||
blis::symm(
|
||||
CblasColMajor,
|
||||
CblasLeft,
|
||||
CblasLower,
|
||||
m,
|
||||
n,
|
||||
alpha,
|
||||
A,
|
||||
lda,
|
||||
B,
|
||||
ldb,
|
||||
beta,
|
||||
C,
|
||||
ldc
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(C, ldc ,m,n, (char *)"C output");
|
||||
#endif
|
||||
// ref_symm(m, n, side, &alpha, A, B, &beta, C_ref);
|
||||
ref_symm(m, n, &alpha, A, B, &beta, C_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(C_ref, ldc_ref ,m,n, (char *)"C ref output");
|
||||
#endif
|
||||
if(computeErrorM(ldc, ldc_ref, m, n, C, C_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__ );
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__ );
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( B );
|
||||
delete[]( C );
|
||||
delete[]( C_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_symm<double>( );
|
||||
test_symm<float>( );
|
||||
test_symm<complex<float>>( );
|
||||
test_symm<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
140
testcpp/test_syr.cc
Normal file
140
testcpp/test_syr.cc
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define N 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_syr(int64_t n,
|
||||
T * alpha,
|
||||
T *X,
|
||||
T *A )
|
||||
|
||||
{
|
||||
obj_t obj_a;
|
||||
obj_t obj_x;
|
||||
obj_t obj_alpha;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, n, n, A, 1, n, &obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1, n,&obj_x );
|
||||
|
||||
bli_obj_set_struc( BLIS_SYMMETRIC, &obj_a );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_a);
|
||||
bli_syr( &obj_alpha,
|
||||
&obj_x,
|
||||
&obj_a );
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_syr( )
|
||||
{
|
||||
T *A, *X, *A_ref;
|
||||
T alpha;
|
||||
int n;
|
||||
int lda, incx, lda_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
n = N;
|
||||
|
||||
lda = n;
|
||||
lda_ref = n;
|
||||
incx = 1;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , n , n);
|
||||
allocate_init_buffer(X , n , 1);
|
||||
copy_buffer(A, A_ref , n ,n);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,n, (char *)"A");
|
||||
printvector(X, n,(char *) "X");
|
||||
#endif
|
||||
blis::syr(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incx,
|
||||
A,
|
||||
lda
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda , n , n,(char *) "A output");
|
||||
#endif
|
||||
ref_syr(n, &alpha, X, A_ref);
|
||||
#ifdef PRINT
|
||||
printmatrix(A_ref, lda , n, n, (char *)"A ref output");
|
||||
#endif
|
||||
if(computeErrorM(lda, lda_ref, n, n, A, A_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( X );
|
||||
delete[]( A_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_syr<double>( );
|
||||
test_syr<float>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
149
testcpp/test_syr2.cc
Normal file
149
testcpp/test_syr2.cc
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define N 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_syr2(int64_t n,
|
||||
T * alpha,
|
||||
T *X,
|
||||
T *Y,
|
||||
T *A )
|
||||
|
||||
{
|
||||
obj_t obj_a;
|
||||
obj_t obj_x, obj_y;
|
||||
obj_t obj_alpha;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, n, n, A, 1, n, &obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1, n,&obj_x );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1, n,&obj_y );
|
||||
|
||||
bli_obj_set_struc( BLIS_SYMMETRIC, &obj_a );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_a);
|
||||
bli_syr2( &obj_alpha,
|
||||
&obj_x,
|
||||
&obj_y,
|
||||
&obj_a );
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_syr2( )
|
||||
{
|
||||
T *A, *X, *Y, *A_ref;
|
||||
T alpha;
|
||||
int n;
|
||||
int lda, incx, incy, lda_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
n = N;
|
||||
|
||||
lda = n;
|
||||
lda_ref = n;
|
||||
incx = 1;
|
||||
incy = 1;
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , n , n);
|
||||
allocate_init_buffer(X , n , 1);
|
||||
allocate_init_buffer(Y , n , 1);
|
||||
copy_buffer(A, A_ref , n ,n);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,n,(char *) "A");
|
||||
printvector(X, n, (char *)"X");
|
||||
printvector(Y, n, (char *)"Y");
|
||||
#endif
|
||||
blis::syr2(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
n,
|
||||
alpha,
|
||||
X,
|
||||
incx,
|
||||
Y,
|
||||
incy,
|
||||
A,
|
||||
lda
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda , n , n,(char *) "A output");
|
||||
#endif
|
||||
ref_syr2(n, &alpha, X, Y, A_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A_ref, lda , n, n, (char *)"A_ref output");
|
||||
#endif
|
||||
if(computeErrorM(lda, lda_ref, n, n, A, A_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( X );
|
||||
delete[]( Y );
|
||||
delete[]( A_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_syr2<double>( );
|
||||
test_syr2<float>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
163
testcpp/test_syr2k.cc
Normal file
163
testcpp/test_syr2k.cc
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP syr2k routine and reference blis syr2k routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define BETA 0.0
|
||||
#define N 6
|
||||
#define K 6
|
||||
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_syr2k(int64_t n, int64_t k,
|
||||
T * alpha,
|
||||
T *A,
|
||||
T *B,
|
||||
T * beta,
|
||||
T *C )
|
||||
|
||||
{
|
||||
obj_t obj_a, obj_b, obj_c;
|
||||
obj_t obj_alpha, obj_beta;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, beta, 1,1,&obj_beta );
|
||||
bli_obj_create_with_attached_buffer( dt, n, k, A, 1,n,&obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, k, n, B,1,k,&obj_b );
|
||||
bli_obj_create_with_attached_buffer( dt, n, n, C, 1,n,&obj_c );
|
||||
|
||||
bli_obj_set_struc( BLIS_SYMMETRIC, &obj_c );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_c );
|
||||
bli_obj_set_conjtrans( BLIS_NO_TRANSPOSE, &obj_c );
|
||||
bli_syr2k( &obj_alpha,
|
||||
&obj_a,
|
||||
&obj_b,
|
||||
&obj_beta,
|
||||
&obj_c );
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_syr2k( )
|
||||
{
|
||||
T *A, *B, *C, *C_ref;
|
||||
T alpha;
|
||||
T beta;
|
||||
int n,k;
|
||||
int ldb, lda, ldc, ldc_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
beta = BETA;
|
||||
k = K;
|
||||
n = N;
|
||||
|
||||
lda = n;
|
||||
ldb = k;
|
||||
ldc = n;
|
||||
ldc_ref = n;
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , n , k);
|
||||
allocate_init_buffer(B , k , n);
|
||||
allocate_init_buffer(C , n , n);
|
||||
copy_buffer(C, C_ref , n ,n);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,k,(char *) "A");
|
||||
printmatrix(B, ldb ,k,n,(char *) "B");
|
||||
printmatrix(C, ldc ,n,n,(char *) "C");
|
||||
#endif
|
||||
blis::syr2k(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
CblasNoTrans,
|
||||
n,
|
||||
k,
|
||||
alpha,
|
||||
A,
|
||||
lda,
|
||||
B,
|
||||
ldb,
|
||||
beta,
|
||||
C,
|
||||
ldc
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(C, ldc ,n,n,(char *) "C output");
|
||||
#endif
|
||||
ref_syr2k(n, k, &alpha, A, B, &beta, C_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(C_ref, ldc_ref ,n,n,(char *) "C ref output");
|
||||
#endif
|
||||
|
||||
if(computeErrorM(ldc, ldc_ref, n, n, C, C_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( B );
|
||||
delete[]( C );
|
||||
delete[]( C_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_syr2k<double>( );
|
||||
test_syr2k<float>( );
|
||||
test_syr2k<complex<float>>( );
|
||||
test_syr2k<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
152
testcpp/test_syrk.cc
Normal file
152
testcpp/test_syrk.cc
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define BETA 0.0
|
||||
#define N 6
|
||||
#define K 4
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_syrk(int64_t n, int64_t k,
|
||||
T * alpha,
|
||||
T *A,
|
||||
T * beta,
|
||||
T *C )
|
||||
|
||||
{
|
||||
obj_t obj_a,obj_c;
|
||||
obj_t obj_alpha, obj_beta;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, beta, 1,1,&obj_beta );
|
||||
bli_obj_create_with_attached_buffer( dt, n, k, A, 1,n,&obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, n, n, C, 1,n,&obj_c );
|
||||
|
||||
bli_obj_set_struc( BLIS_SYMMETRIC, &obj_c );
|
||||
bli_obj_set_conjtrans( BLIS_NO_TRANSPOSE, &obj_c );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_c );
|
||||
bli_syrk( &obj_alpha,
|
||||
&obj_a,
|
||||
&obj_beta,
|
||||
&obj_c );
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_syrk( )
|
||||
{
|
||||
T *A, *C, *C_ref;
|
||||
T alpha, beta;
|
||||
int n,k;
|
||||
int lda, ldc, ldc_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
beta = BETA;
|
||||
k = K;
|
||||
n = N;
|
||||
|
||||
lda = n;
|
||||
ldc = n;
|
||||
ldc_ref = n;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , n , k);
|
||||
allocate_init_buffer(C , n , n);
|
||||
copy_buffer(C, C_ref , n ,n);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,k, (char *)"A");
|
||||
printmatrix(C, ldc ,n,n, (char *)"C");
|
||||
#endif
|
||||
blis::syrk(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
CblasNoTrans,
|
||||
n,
|
||||
k,
|
||||
alpha,
|
||||
A,
|
||||
lda,
|
||||
beta,
|
||||
C,
|
||||
ldc
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(C, ldc ,n,n, (char *)"C output");
|
||||
#endif
|
||||
ref_syrk(n, k, &alpha, A, &beta, C_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(C_ref, ldc_ref ,n,n, (char *)"C ref output");
|
||||
#endif
|
||||
if(computeErrorM(ldc, ldc_ref, n, n, C, C_ref )==1)
|
||||
printf("%s TEST FAIL\n" ,__PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( C );
|
||||
delete[]( C_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_syrk<double>( );
|
||||
test_syrk<float>( );
|
||||
test_syrk<complex<float>>( );
|
||||
test_syrk<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
103
testcpp/test_tbmv.cc
Normal file
103
testcpp/test_tbmv.cc
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
//#define PRINT
|
||||
#define N 3
|
||||
#define K 1
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
|
||||
template< typename T >
|
||||
void test_tbmv( )
|
||||
{
|
||||
int n,k,lda;
|
||||
|
||||
k = K;
|
||||
n = N;
|
||||
|
||||
|
||||
lda = n;
|
||||
T A[] = { 0.439f, -0.484f, -0.952f, -0.508f, 0.381f, -0.889f, -0.192f, -0.279f, -0.155f };
|
||||
T X[] = { -0.089f, -0.688f, -0.203f };
|
||||
int incX = -1;
|
||||
T X_ref[] = { -0.24504f, 0.447756f, -0.089117f };
|
||||
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,n,(char *)"A");
|
||||
printvector(X, n,(char *)"X");
|
||||
#endif
|
||||
blis::tbmv(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
CblasNoTrans,
|
||||
CblasNonUnit,
|
||||
n,
|
||||
k,
|
||||
A,
|
||||
lda,
|
||||
X,
|
||||
incX
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n,(char *)"X");
|
||||
printvector(X_ref ,n,(char *) "X output");
|
||||
#endif
|
||||
if(computeErrorV(incX, incX, n, X, X_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_tbmv<double>( );
|
||||
test_tbmv<float>( );
|
||||
test_tbmv<complex<float>>( );
|
||||
test_tbmv<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
104
testcpp/test_tbsv.cc
Normal file
104
testcpp/test_tbsv.cc
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
//#define PRINT
|
||||
#define K 1
|
||||
#define N 3
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
|
||||
template< typename T >
|
||||
void test_tbsv( )
|
||||
{
|
||||
int n,k,lda;
|
||||
|
||||
k = K;
|
||||
n = N;
|
||||
lda = n;
|
||||
|
||||
T A[] = { -0.681f, 0.209f, 0.436f, -0.369f, 0.786f, -0.84f, 0.86f, -0.233f, 0.734f };
|
||||
T X[] = { -0.305f, 0.61f, -0.831f };
|
||||
int incX = -1;
|
||||
T X_ref[] = { 0.524539f, -0.961964f, 1.22026f };
|
||||
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,n,(char *)"A");
|
||||
printvector(X, n,(char *) "X");
|
||||
#endif
|
||||
blis::tbsv(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
CblasNoTrans,
|
||||
CblasNonUnit,
|
||||
n,
|
||||
k,
|
||||
A,
|
||||
lda,
|
||||
X,
|
||||
incX
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n, (char *)"X blis::tbsv\n");
|
||||
printvector(X_ref, n,(char *) "X_ref blis::tbsv output");
|
||||
|
||||
#endif
|
||||
|
||||
if(computeErrorV(1,1, n, X, X_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_tbsv<double>( );
|
||||
test_tbsv<float>( );
|
||||
test_tbsv<complex<float>>( );
|
||||
test_tbsv<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
97
testcpp/test_tpmv.cc
Normal file
97
testcpp/test_tpmv.cc
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
//#define PRINT
|
||||
#define N 2
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void test_tpmv( )
|
||||
{
|
||||
int n,lda;
|
||||
|
||||
n = N;
|
||||
lda = n;
|
||||
|
||||
T A[] = { -0.587f, 0.14f, 0.841f };
|
||||
T X[] = { -0.213f, 0.885f };
|
||||
int incX = -1;
|
||||
T X_ref[] = { -0.055233f, -0.519495f };
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n, n,(char *) "X");
|
||||
printvector(X, n,(char *) "X");
|
||||
#endif
|
||||
blis::tpmv(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
CblasNoTrans,
|
||||
CblasNonUnit,
|
||||
n,
|
||||
A,
|
||||
X,
|
||||
incX
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n, (char *)"X");
|
||||
printvector(X_ref, n,(char *) "X output");
|
||||
|
||||
|
||||
#endif
|
||||
if(computeErrorV(incX, incX, n, X, X_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_tpmv<double>( );
|
||||
test_tpmv<float>( );
|
||||
test_tpmv<complex<float>>( );
|
||||
test_tpmv<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
99
testcpp/test_tpsv.cc
Normal file
99
testcpp/test_tpsv.cc
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
//#define PRINT
|
||||
#define N 2
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void test_tpsv( )
|
||||
{
|
||||
int n,lda;
|
||||
n = N;
|
||||
lda = n;
|
||||
|
||||
T A[] = { -0.381f, 0.53f, 0.451f };
|
||||
T X[] = { 0.144f, 0.032f };
|
||||
int incX = -1;
|
||||
T X_ref[] = { 0.417992f, -0.0839895f };
|
||||
|
||||
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,n,(char *)"A");
|
||||
printvector(X, n,(char *)"X");
|
||||
#endif
|
||||
blis::tpsv(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
CblasNoTrans,
|
||||
CblasNonUnit,
|
||||
n,
|
||||
A,
|
||||
X,
|
||||
incX
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n,(char *) "X blis::tpsv\n");
|
||||
printvector(X_ref, n,(char *) "X_ref blis::tpsv output");
|
||||
|
||||
#endif
|
||||
|
||||
if(computeErrorV(1,1, n, X, X_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_tpsv<double>( );
|
||||
test_tpsv<float>( );
|
||||
test_tpsv<complex<float>>( );
|
||||
test_tpsv<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
153
testcpp/test_trmm.cc
Normal file
153
testcpp/test_trmm.cc
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP trmm routine and reference blis trmm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define M 6
|
||||
#define N 4
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_trmm(int64_t m, int64_t n,
|
||||
T * alpha,
|
||||
T *A,
|
||||
T *B
|
||||
)
|
||||
|
||||
{
|
||||
obj_t obj_a, obj_b;
|
||||
obj_t obj_alpha;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, m, m, A, 1,m,&obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, m, n, B, 1,m,&obj_b );
|
||||
|
||||
bli_obj_set_struc( BLIS_TRIANGULAR, &obj_a );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_a );
|
||||
bli_obj_set_conjtrans( BLIS_NO_TRANSPOSE, &obj_a );
|
||||
bli_obj_set_diag( BLIS_NONUNIT_DIAG, &obj_a );
|
||||
bli_trmm( BLIS_LEFT,
|
||||
&obj_alpha,
|
||||
&obj_a,
|
||||
&obj_b
|
||||
);
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_trmm( )
|
||||
{
|
||||
T *A, *B, *B_ref;
|
||||
T alpha;
|
||||
int m,n;
|
||||
int lda, ldb, ldb_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
m = M;
|
||||
n = N;
|
||||
|
||||
lda = m;
|
||||
ldb = m;
|
||||
ldb_ref = m;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , m , m);
|
||||
allocate_init_buffer(B , m , n);
|
||||
copy_buffer(B, B_ref , m ,n);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,m,m, (char *)"A");
|
||||
printmatrix(B, ldb ,m,n, (char *)"B");
|
||||
#endif
|
||||
blis::trmm(
|
||||
CblasColMajor,
|
||||
CblasLeft,
|
||||
CblasLower,
|
||||
CblasNoTrans,
|
||||
CblasNonUnit,
|
||||
m,
|
||||
n,
|
||||
alpha,
|
||||
A,
|
||||
lda,
|
||||
B,
|
||||
ldb
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(B, ldb ,m,n, (char *)"B output");
|
||||
#endif
|
||||
ref_trmm(m, n, &alpha, A, B_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(B_ref, ldb_ref ,m,n, (char *)"B ref output");
|
||||
#endif
|
||||
if(computeErrorM(ldb, ldb_ref, m, n, B, B_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( B );
|
||||
delete[]( B_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_trmm<double>( );
|
||||
test_trmm<float>( );
|
||||
test_trmm<complex<float>>( );
|
||||
test_trmm<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
154
testcpp/test_trsm.cc
Normal file
154
testcpp/test_trsm.cc
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP trsm routine and reference blis trsm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
#define ALPHA 1.0
|
||||
#define M 5
|
||||
#define N 4
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_trsm(int64_t m, int64_t n,
|
||||
T * alpha,
|
||||
T *A,
|
||||
T *B
|
||||
)
|
||||
|
||||
{
|
||||
obj_t obj_a, obj_b;
|
||||
obj_t obj_alpha;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
|
||||
bli_obj_create_with_attached_buffer( dt, m, m, A, 1,m,&obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, m, n, B, 1,m,&obj_b );
|
||||
|
||||
bli_obj_set_struc( BLIS_TRIANGULAR, &obj_a );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_a );
|
||||
bli_obj_set_conjtrans( BLIS_NO_TRANSPOSE, &obj_a );
|
||||
bli_obj_set_diag( BLIS_NONUNIT_DIAG, &obj_a );
|
||||
bli_trsm( BLIS_LEFT,
|
||||
&obj_alpha,
|
||||
&obj_a,
|
||||
&obj_b
|
||||
);
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_trsm( )
|
||||
{
|
||||
T *A, *B, *B_ref;
|
||||
T alpha;
|
||||
int m,n;
|
||||
int lda, ldb, ldb_ref;
|
||||
|
||||
alpha = ALPHA;
|
||||
m = M;
|
||||
n = N;
|
||||
|
||||
lda = m;
|
||||
ldb = m;
|
||||
ldb_ref = m;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , m , m);
|
||||
allocate_init_buffer(B , m , n);
|
||||
copy_buffer(B, B_ref , m ,n);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,m,m, (char *)"A");
|
||||
printmatrix(B, ldb ,m,n, (char *)"B");
|
||||
#endif
|
||||
|
||||
blis::trsm(
|
||||
CblasColMajor,
|
||||
CblasLeft,
|
||||
CblasLower,
|
||||
CblasNoTrans,
|
||||
CblasNonUnit,
|
||||
m,
|
||||
n,
|
||||
alpha,
|
||||
A,
|
||||
lda,
|
||||
B,
|
||||
ldb
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(B, ldb ,m,n, (char *)"B output");
|
||||
#endif
|
||||
ref_trsm(m, n, &alpha, A, B_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(B_ref, ldb_ref ,m,n, (char *)"B ref output");
|
||||
#endif
|
||||
if(computeErrorM(ldb, ldb_ref, m, n, B, B_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( B );
|
||||
delete[]( B_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_trsm<double>( );
|
||||
test_trsm<float>( );
|
||||
test_trsm<complex<float>>( );
|
||||
test_trsm<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
142
testcpp/test_trsv.cc
Normal file
142
testcpp/test_trsv.cc
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
|
||||
BLISPP
|
||||
C++ test driver for BLIS CPP gemm routine and reference blis gemm routine.
|
||||
|
||||
Copyright (C) 2019, Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
- Neither the name(s) of the copyright holder(s) nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
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 <complex>
|
||||
#include <iostream>
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
//#define PRINT
|
||||
//#define PRINT
|
||||
#define M 5
|
||||
#define N 6
|
||||
/*
|
||||
* Test application assumes matrices to be column major, non-transposed
|
||||
*/
|
||||
template< typename T >
|
||||
void ref_trsv(int64_t n,
|
||||
T *A,
|
||||
T *X
|
||||
)
|
||||
|
||||
{
|
||||
obj_t obj_a, obj_x;
|
||||
num_t dt;
|
||||
|
||||
if(is_same<T, float>::value)
|
||||
dt = BLIS_FLOAT;
|
||||
else if(is_same<T, double>::value)
|
||||
dt = BLIS_DOUBLE;
|
||||
else if(is_same<T, complex<float>>::value)
|
||||
dt = BLIS_SCOMPLEX;
|
||||
else if(is_same<T, complex<double>>::value)
|
||||
dt = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create_with_attached_buffer( dt, n, n, A, 1,n,&obj_a );
|
||||
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1,n,&obj_x );
|
||||
|
||||
bli_obj_set_struc( BLIS_TRIANGULAR, &obj_a );
|
||||
bli_obj_set_uplo( BLIS_LOWER, &obj_a );
|
||||
bli_obj_set_onlytrans( BLIS_NO_TRANSPOSE, &obj_a );
|
||||
bli_obj_set_diag( BLIS_NONUNIT_DIAG, &obj_a );
|
||||
bli_trsv( &BLIS_ONE,
|
||||
&obj_a,
|
||||
&obj_x
|
||||
);
|
||||
|
||||
}
|
||||
template< typename T >
|
||||
void test_trsv( )
|
||||
{
|
||||
T *A, *X, *X_ref;
|
||||
int n;
|
||||
int lda, incx, incx_ref;
|
||||
|
||||
n = N;
|
||||
|
||||
lda = n;
|
||||
incx = 1;
|
||||
incx_ref = 1;
|
||||
|
||||
srand (time(NULL));
|
||||
allocate_init_buffer(A , n , n);
|
||||
allocate_init_buffer(X , n , 1);
|
||||
copy_buffer(X, X_ref , n ,1);
|
||||
|
||||
#ifdef PRINT
|
||||
printmatrix(A, lda ,n,n,(char *) "A");
|
||||
printvector(X, n,(char *) "X");
|
||||
#endif
|
||||
blis::trsv(
|
||||
CblasColMajor,
|
||||
CblasLower,
|
||||
CblasNoTrans,
|
||||
CblasNonUnit,
|
||||
n,
|
||||
A,
|
||||
lda,
|
||||
X,
|
||||
incx
|
||||
);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X, n,(char *) "X output");
|
||||
#endif
|
||||
ref_trsv(n, A, X_ref);
|
||||
|
||||
#ifdef PRINT
|
||||
printvector(X_ref, n,(char *) "X ref output");
|
||||
#endif
|
||||
if(computeErrorV(incx, incx_ref, n, X, X_ref )==1)
|
||||
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
|
||||
else
|
||||
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
delete[]( A );
|
||||
delete[]( X );
|
||||
delete[]( X_ref );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
test_trsv<double>( );
|
||||
test_trsv<float>( );
|
||||
test_trsv<complex<float>>( );
|
||||
test_trsv<complex<double>>( );
|
||||
return 0;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user