Added Function trace and Input logging for dotv and gemv

Change-Id: I992bd80b2322d6c387f609ecd70c1109c13f6254
AMD-Internal: [CPUPL-1274]
This commit is contained in:
managalv
2020-11-01 19:22:10 +05:30
parent c40bb45bdf
commit 68b4ff976b
6 changed files with 515 additions and 227 deletions

View File

@@ -12,6 +12,8 @@
#if AOCL_DTL_LOG_ENABLE
// Level-3
void AOCL_DTL_log_gemm_sizes(int8 loglevel,
obj_t* alpha,
obj_t* a,
@@ -34,7 +36,10 @@ void AOCL_DTL_log_gemm_sizes(int8 loglevel,
guint_t rsc = bli_obj_row_stride( c );
const num_t dt_exec = bli_obj_dt( c );
char transa, transb;
double alpha_r, alpha_i, beta_r, beta_i;
double alpha_r = 0.0;
double alpha_i = 0.0;
double beta_r = 0.0;
double beta_i = 0.0;;
/* The following convention is followed to print trans character
* BLIS_NO_TRANSPOSE = 'n';
@@ -444,19 +449,53 @@ void AOCL_DTL_log_gemv_sizes( int8 loglevel,
const f77_char transa,
const f77_int m,
const f77_int n,
const double alpha,
const void* alpha,
const f77_int lda,
const f77_int incx,
const double beta,
const void* beta,
const f77_int incy,
const char* filename,
const char* function_name,
int line)
{
char buffer[256];
double alpha_real = 0.0;
double alpha_imag = 0.0;
double beta_real = 0.0;
double beta_imag = 0.0;
if(dt_type == 's' || dt_type == 'S' )
{
alpha_real = *(float*)alpha;
alpha_imag = 0.0;
beta_real = *(float*)beta;
beta_imag = 0.0;
}
else if(dt_type == 'd' || dt_type == 'D' )
{
alpha_real = *(double*) alpha;
alpha_imag = 0.0;
beta_real = *(double*) beta;
beta_imag = 0.0;
}
else if(dt_type == 'c' || dt_type == 'C' )
{
alpha_real = (float)(((scomplex*)alpha)->real);
alpha_imag = (float)(((scomplex*)alpha)->imag);
beta_real = (float)(((scomplex*)beta)->real);
beta_imag = (float)(((scomplex*)beta)->imag);
}
else if(dt_type == 'z' || dt_type == 'Z' )
{
alpha_real = ((dcomplex*)alpha)->real;
alpha_imag = ((dcomplex*)alpha)->imag;
beta_real = ((dcomplex*)beta)->real;
beta_imag = ((dcomplex*)beta)->imag;
}
// {S, D,C, Z} { transa, m, n, alpha, lda, incx, beta, incy}
sprintf(buffer, " %c %c %ld %ld %lf %lu %lu %lf %lu",
dt_type, transa, (dim_t)m, (dim_t)n, alpha, (dim_t)lda, (dim_t)incx, beta, (dim_t)incy);
sprintf(buffer, " %c %c %ld %ld %lf %lf %lu %lu %lf %lf %lu",
dt_type, transa, (dim_t)m, (dim_t)n, alpha_real, alpha_imag,
(dim_t)lda, (dim_t)incx, beta_real, beta_imag, (dim_t)incy);
DTL_Trace(loglevel, TRACE_TYPE_LOG, function_name, function_name, line, buffer);
@@ -506,6 +545,26 @@ void AOCL_DTL_log_ger_sizes( int8 loglevel,
}
void AOCL_DTL_log_dotv_sizes( int8 loglevel,
char dt_type,
char transa,
const f77_int n,
const f77_int incx,
const f77_int incy,
const char* filename,
const char* function_name,
int line)
{
char buffer[256];
// { n, incx, incy}
sprintf(buffer, " %c %c %ld %lu %lu", dt_type, transa, (dim_t)n, (dim_t)incx, (dim_t)incy);
DTL_Trace(loglevel, TRACE_TYPE_LOG, function_name, function_name, line, buffer);
}
void AOCL_DTL_log_hemv_sizes ( int8 loglevel,
char dt_type,
const f77_char uploa,
@@ -559,7 +618,6 @@ void AOCL_DTL_log_hemv_sizes ( int8 loglevel,
DTL_Trace(loglevel, TRACE_TYPE_LOG, function_name, function_name, line, buffer);
}
void AOCL_DTL_log_her2_sizes ( int8 loglevel,
char dt_type,
const f77_char uploa,

View File

@@ -66,10 +66,10 @@ void AOCL_DTL_log_gemv_sizes( int8 loglevel,
const f77_char transa,
const f77_int m,
const f77_int n,
const double alpha,
const void* alpha,
const f77_int lda,
const f77_int incx,
const double beta,
const void* beta,
const f77_int incy,
const char* filename,
const char* function_name,
@@ -161,6 +161,18 @@ void AOCL_DTL_log_axpy_sizes ( int8 loglevel,
const char* function_name,
int line);
void AOCL_DTL_log_dotv_sizes( int8 loglevel,
char dt_type,
char transa,
const f77_int n,
const f77_int incx,
const f77_int incy,
const char* filename,
const char* function_name,
int line
);
// Level-3 Macros
#define AOCL_DTL_LOG_GEMM_INPUTS(loglevel, alpha, a, b, beta, c) \
AOCL_DTL_log_gemm_sizes(loglevel, alpha, a, b, beta, c, __FILE__, __FUNCTION__, __LINE__);
@@ -214,6 +226,10 @@ void AOCL_DTL_log_axpy_sizes ( int8 loglevel,
#define AOCL_DTL_LOG_AXPY_INPUTS(loglevel, dt_type, n, alpha, incx, incy) \
AOCL_DTL_log_axpy_sizes(loglevel, dt_type, n, alpha, incx, incy, __FILE__,\
__FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_DOTV_INPUTS(loglevel, dt_type, transa, n, incx, incy) \
AOCL_DTL_log_dotv_sizes(loglevel, dt_type, transa, n, incx, incy, __FILE__, __FUNCTION__, __LINE__); \
#else
#define AOCL_DTL_LOG_GEMM_INPUTS(loglevel, alpha, a, b, beta, c)
@@ -246,6 +262,8 @@ void AOCL_DTL_log_axpy_sizes ( int8 loglevel,
#define AOCL_DTL_LOG_AXPY_INPUTS(loglevel, dt_type, n, alpha, incx, incy)
#define AOCL_DTL_LOG_DOTV_INPUTS(loglevel, dt_type, transa, n, incx, incy)
#endif

View File

@@ -49,6 +49,8 @@ ftype PASTEF772(ch,blasname,chc) \
const ftype* y, const f77_int* incy \
) \
{ \
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1); \
AOCL_DTL_LOG_DOTV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, *MKSTR(ch),'N', *n, *incx, *incy); \
dim_t n0; \
ftype* x0; \
ftype* y0; \
@@ -80,6 +82,7 @@ ftype PASTEF772(ch,blasname,chc) \
NULL \
); \
\
AOCL_DTL_TRACE_EXIT(AOCL_DTL_LEVEL_TRACE_1); \
/* Finalize BLIS. */ \
bli_finalize_auto(); \
\
@@ -96,7 +99,8 @@ dcomplex zdotc_
const dcomplex* y, const f77_int* incy
)
{
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_LOG_DOTV_INPUTS(AOCL_DTL_LEVEL_TRACE_1,'Z', 'C', *n, *incx, *incy);
dim_t n0;
dcomplex* x0;
dcomplex* y0;
@@ -142,7 +146,8 @@ dcomplex zdotc_
const dcomplex* y, const f77_int* incy
)
{
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_LOG_DOTV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, 'Z', 'C', *n, *incx, *incy);
dim_t n0;
dcomplex* x0;
dcomplex* y0;
@@ -227,7 +232,8 @@ float sdot_
const float* y, const f77_int* incy
)
{
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_LOG_DOTV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, 'S', 'N', *n, *incx, *incy);
dim_t n0;
float* x0;
float* y0;
@@ -307,7 +313,8 @@ double ddot_
const double* y, const f77_int* incy
)
{
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_LOG_DOTV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, 'D', 'N', *n, *incx, *incy);
dim_t n0;
double* x0;
double* y0;
@@ -387,7 +394,8 @@ scomplex cdotu_
const scomplex* y, const f77_int* incy
)
{
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_LOG_DOTV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, 'C', 'N', *n, *incx, *incy);
dim_t n0;
scomplex* x0;
scomplex* y0;
@@ -475,6 +483,7 @@ dcomplex zdotu_
dcomplex rho;
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_LOG_DOTV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, 'Z', 'N', *n, *incx, *incy);
/* Initialize BLIS. */
// bli_init_auto();
@@ -559,6 +568,7 @@ scomplex cdotc_
scomplex rho;
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_LOG_DOTV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, 'C', 'N', *n, *incx, *incy);
/* Initialize BLIS. */
// bli_init_auto();
@@ -675,6 +685,7 @@ double PASTEF77(d,sdot)
dim_t i;
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_LOG_DOTV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, 'D', 'N', *n, *incx, *incy);
/* Initialization of BLIS is not required. */
/* Convert/typecast negative values of n to zero. */

View File

@@ -54,6 +54,8 @@ void PASTEF77(ch,blasname) \
ftype* y, const f77_int* incy \
) \
{ \
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1); \
AOCL_DTL_LOG_GEMV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, *MKSTR(ch), *transa, *m, *n, (void*)alpha, *lda, *incx, (void*)beta, *incy); \
trans_t blis_transa; \
dim_t m0, n0; \
dim_t m_y, n_x; \
@@ -133,6 +135,7 @@ void PASTEF77(ch,blasname) \
NULL \
); \
\
AOCL_DTL_TRACE_EXIT(AOCL_DTL_LEVEL_TRACE_1); \
/* Finalize BLIS. */ \
bli_finalize_auto(); \
}
@@ -162,7 +165,7 @@ void dgemv_
inc_t rs_a, cs_a;
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_LOG_GEMV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, 'D', *transa, *m, *n, *alpha, *lda, *incx, *beta, *incy);
AOCL_DTL_LOG_GEMV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, 'D', *transa, *m, *n, (void*)alpha, *lda, *incx, (void*)beta, *incy);
/* Perform BLAS parameter checking. */
PASTEBLACHK(gemv)
@@ -328,7 +331,7 @@ void sgemv_
inc_t rs_a, cs_a;
AOCL_DTL_TRACE_ENTRY(AOCL_DTL_LEVEL_TRACE_1);
AOCL_DTL_LOG_GEMV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, 'S', *transa, *m, *n, *alpha, *lda, *incx, *beta, *incy);
AOCL_DTL_LOG_GEMV_INPUTS(AOCL_DTL_LEVEL_TRACE_1, 'S', *transa, *m, *n, (void*)alpha, *lda, *incx, (void*)beta, *incy);
/* Perform BLAS parameter checking. */
PASTEBLACHK(gemv)
(
@@ -449,7 +452,6 @@ void sgemv_
AOCL_DTL_TRACE_EXIT(AOCL_DTL_LEVEL_TRACE_1);
}
INSERT_GENTFUNC_BLAS_CZ( gemv, gemv )
#else
INSERT_GENTFUNC_BLAS( gemv, gemv )

View File

@@ -40,152 +40,213 @@
#endif
#include "blis.h"
// res n x incx y incy
//double res = ddotv_( int*, double*, int*, double*, int* );
#ifdef BLIS_ENABLE_CBLAS
//#define CBLAS
#endif
#ifdef CBLAS
#include "cblas.h"
#endif
//#define PRINT
int main( int argc, char** argv )
{
obj_t x, y;
obj_t res;
dim_t n;
dim_t p;
dim_t p_begin, p_end, p_inc;
int n_input;
num_t dt_x, dt_y, dt_res;
int r, n_repeats;
num_t dt;
obj_t x, y;
obj_t res;
dim_t n;
dim_t p;
dim_t p_begin, p_end, p_inc;
int n_input;
num_t dt_x, dt_y, dt_res;
int r, n_repeats;
num_t dt;
double dtime;
double dtime_save;
double gflops;
double dtime;
double dtime_save;
double gflops;
bli_init();
bli_init();
n_repeats = 10;
n_repeats = 3;
#ifndef PRINT
p_begin = 40;
p_end = 4000;
p_inc = 40;
p_begin = 40;
p_end = 4000;
p_inc = 40;
n_input = -1;
n_input = -1;
#else
p_begin = 16;
p_end = 16;
p_inc = 1;
p_begin = 16;
p_end = 16;
p_inc = 1;
n_input = 16;
n_input = 16;
#endif
#if 1
dt = BLIS_FLOAT;
//dt = BLIS_DOUBLE;
dt = BLIS_FLOAT;
//dt = BLIS_DOUBLE;
#else
//dt = BLIS_SCOMPLEX;
dt = BLIS_DCOMPLEX;
dt = BLIS_SCOMPLEX;
//dt = BLIS_DCOMPLEX;
#endif
dt_x = dt_y = dt_res = dt;
dt_x = dt_y = dt_res = dt;
// Begin with initializing the last entry to zero so that
// matlab allocates space for the entire array once up-front.
for ( p = p_begin; p + p_inc <= p_end; p += p_inc ) ;
// Begin with initializing the last entry to zero so that
// matlab allocates space for the entire array once up-front.
for ( p = p_begin; p + p_inc <= p_end; p += p_inc ) ;
#ifdef BLIS
printf( "data_dotv_blis" );
printf( "data_dotv_blis" );
#else
printf( "data_dotv_%s", BLAS );
printf( "data_dotv_%s", BLAS );
#endif
printf( "( %2lu, 1:2 ) = [ %4lu %7.2f ];\n",
( unsigned long )(p - p_begin)/p_inc + 1,
( unsigned long )0, 0.0 );
printf( "( %2lu, 1:2 ) = [ %4lu %7.2f ];\n",
( unsigned long )(p - p_begin)/p_inc + 1,
( unsigned long )0, 0.0 );
//for ( p = p_begin; p <= p_end; p += p_inc )
for ( p = p_end; p_begin <= p; p -= p_inc )
{
// for ( p = p_begin; p <= p_end; p += p_inc )
for ( p = p_end; p_begin <= p; p -= p_inc )
{
if ( n_input < 0 ) n = p * ( dim_t )abs(n_input);
else n = ( dim_t ) n_input;
if ( n_input < 0 ) n = p * ( dim_t )abs(n_input);
else n = ( dim_t ) n_input;
bli_obj_create( dt_x, n, 1, 0, 0, &x );
bli_obj_create( dt_y, n, 1, 0, 0, &y );
bli_obj_create( dt_res, 1, 1, 0, 0, &res );
bli_obj_create( dt_x, n, 1, 0, 0, &x );
bli_obj_create( dt_y, n, 1, 0, 0, &y );
bli_obj_create( dt_res, 1, 1, 0, 0, &res );
bli_randm( &x );
bli_randm( &y );
bli_randm( &x );
bli_randm( &y );
dtime_save = 1.0e9;
dtime_save = 1.0e9;
for ( r = 0; r < n_repeats; ++r )
{
for ( r = 0; r < n_repeats; ++r )
{
dtime = bli_clock();
dtime = bli_clock();
#ifdef PRINT
bli_printm( "x", &x, "%4.1f", "" );
bli_printm( "y", &y, "%4.1f", "" );
bli_printm( "x", &x, "%4.1f", "" );
bli_printm( "y", &y, "%4.1f", "" );
#endif
#ifdef BLIS
bli_dotv( &x,
&y,
&res);
bli_dotv( &x,
&y,
&res);
#else
if ( bli_is_float( dt ) )
{
f77_int nn = bli_obj_length( &x );
f77_int incx = bli_obj_vector_inc( &x );
f77_int incy = bli_obj_vector_inc( &y );
float* xp = bli_obj_buffer( &x );
float* yp = bli_obj_buffer( &y );
float* resp = bli_obj_buffer( &res );
*resp = sdot_( &nn,
xp, &incx,
yp, &incy );
if ( bli_is_float( dt ) )
{
f77_int nn = bli_obj_length( &x );
f77_int incx = bli_obj_vector_inc( &x );
f77_int incy = bli_obj_vector_inc( &y );
float* xp = bli_obj_buffer( &x );
float* yp = bli_obj_buffer( &y );
float* resp = bli_obj_buffer( &res );
#ifdef CBLAS
*resp = cblas_sdot( nn,
xp, incx,
yp, incy );
}
else if ( bli_is_double( dt ) )
{
#else
*resp = sdot_( &nn,
xp, &incx,
yp, &incy );
#endif
f77_int nn = bli_obj_length( &x );
f77_int incx = bli_obj_vector_inc( &x );
f77_int incy = bli_obj_vector_inc( &y );
double* xp = bli_obj_buffer( &x );
double* yp = bli_obj_buffer( &y );
double* resp = bli_obj_buffer( &res );
}
else if ( bli_is_double( dt ) )
{
f77_int nn = bli_obj_length( &x );
f77_int incx = bli_obj_vector_inc( &x );
f77_int incy = bli_obj_vector_inc( &y );
double* xp = bli_obj_buffer( &x );
double* yp = bli_obj_buffer( &y );
double* resp = bli_obj_buffer( &res );
#ifdef CBLAS
*resp = cblas_ddot( nn,
xp, incx,
yp, incy );
#else
*resp = ddot_( &nn,
xp, &incx,
yp, &incy );
#endif
}
else if ( bli_is_scomplex( dt ) )
{
f77_int nn = bli_obj_length( &x );
f77_int incx = bli_obj_vector_inc( &x );
f77_int incy = bli_obj_vector_inc( &y );
scomplex* xp = bli_obj_buffer( &x );
scomplex* yp = bli_obj_buffer( &y );
scomplex* resp = bli_obj_buffer( &res );
#ifdef CBLAS
cblas_cdotu_sub(nn,
xp, incx,
yp, incy, resp );
#else
*resp = cdotu_(&nn,
xp, &incx,
yp, &incy );
#endif
}
else if ( bli_is_dcomplex( dt ) )
{
f77_int nn = bli_obj_length( &x );
f77_int incx = bli_obj_vector_inc( &x );
f77_int incy = bli_obj_vector_inc( &y );
dcomplex* xp = bli_obj_buffer( &x );
dcomplex* yp = bli_obj_buffer( &y );
dcomplex* resp = bli_obj_buffer( &res );
#ifdef CBLAS
cblas_zdotu_sub( nn,
xp, incx,
yp, incy, resp );
#else
*resp = zdotu_( &nn,
xp, &incx,
yp, &incy );
#endif
}
*resp = ddot_( &nn,
xp, &incx,
yp, &incy );
}
#endif
#ifdef PRINT
bli_printm( "res after", &res, "%4.1f", "" );
exit(1);
bli_printm( "res after", &res, "%4.1f", "" );
exit(1);
#endif
dtime_save = bli_clock_min_diff( dtime_save, dtime );
}
dtime_save = bli_clock_min_diff( dtime_save, dtime );
}
gflops = ( 2.0 * n ) / ( dtime_save * 1.0e9 );
gflops = ( 2.0 * n ) / ( dtime_save * 1.0e9 );
if ( bli_is_complex( dt ) ) gflops *= 4.0;
#ifdef BLIS
printf( "data_dotv_blis" );
printf( "data_dotv_blis" );
#else
printf( "data_dotv_%s", BLAS );
printf( "data_dotv_%s", BLAS );
#endif
printf( "( %2lu, 1:2 ) = [ %4lu %7.2f ];\n",
( unsigned long )(p - p_begin)/p_inc + 1,
( unsigned long )n, gflops );
printf( "( %2lu, 1:2 ) = [ %4lu %7.2f ];\n",
( unsigned long )(p - p_begin)/p_inc + 1,
( unsigned long )n, gflops );
bli_obj_free( &x );
bli_obj_free( &y );
bli_obj_free( &res );
}
bli_obj_free( &x );
bli_obj_free( &y );
bli_obj_free( &res );
}
bli_finalize();
//bli_finalize();
return 0;
return 0;
}

View File

@@ -39,170 +39,308 @@
#endif
#include "blis.h"
// transa m n alpha a lda x incx beta y incy
//void dgemv_( char*, int*, int*, double*, double*, int*, double*, int*, double*, double*, int* );
#ifdef BLIS_ENABLE_CBLAS
//#define CBLAS
#endif
#ifdef CBLAS
#include "cblas.h"
#endif
//#define PRINT
int main( int argc, char** argv )
{
obj_t a, x, y;
obj_t y_save;
obj_t alpha, beta;
dim_t m, n;
dim_t p;
dim_t p_begin, p_end, p_inc;
int m_input, n_input;
num_t dt_a, dt_x, dt_y;
num_t dt_alpha, dt_beta;
int r, n_repeats;
obj_t a, x, y;
obj_t y_save;
obj_t alpha, beta;
dim_t m, n;
dim_t p;
dim_t p_begin, p_end, p_inc;
int m_input, n_input;
num_t dt_a, dt_x, dt_y;
num_t dt_alpha, dt_beta;
int r, n_repeats;
num_t dt;
double dtime;
double dtime_save;
double gflops;
double dtime;
double dtime_save;
double gflops;
//bli_init();
//bli_init();
n_repeats = 3;
n_repeats = 3;
#ifndef PRINT
p_begin = 40;
p_end = 2000;
p_inc = 40;
p_begin = 40;
p_end = 2000;
p_inc = 40;
m_input = -1;
n_input = -1;
m_input = -1;
n_input = -1;
#else
p_begin = 16;
p_end = 16;
p_inc = 1;
p_begin = 16;
p_end = 16;
p_inc = 1;
m_input = 15;
n_input = 15;
m_input = 15;
n_input = 15;
#endif
dt_a = dt_x = dt_y = dt_alpha = dt_beta = BLIS_DOUBLE;
#if 1
dt = BLIS_FLOAT;
//dt = BLIS_DOUBLE;
#else
dt = BLIS_SCOMPLEX;
//dt = BLIS_DCOMPLEX;
#endif
// Begin with initializing the last entry to zero so that
// matlab allocates space for the entire array once up-front.
for ( p = p_begin; p + p_inc <= p_end; p += p_inc ) ;
dt_a = dt_x = dt_y = dt_alpha = dt_beta = dt;
// Begin with initializing the last entry to zero so that
// matlab allocates space for the entire array once up-front.
for ( p = p_begin; p + p_inc <= p_end; p += p_inc ) ;
#ifdef BLIS
printf( "data_gemv_blis" );
printf( "data_gemv_blis" );
#else
printf( "data_gemv_%s", BLAS );
printf( "data_gemv_%s", BLAS );
#endif
printf( "( %2lu, 1:3 ) = [ %4lu %4lu %7.2f ];\n",
( unsigned long )(p - p_begin)/p_inc + 1,
( unsigned long )0,
( unsigned long )0, 0.0 );
printf( "( %2lu, 1:3 ) = [ %4lu %4lu %7.2f ];\n",
( unsigned long )(p - p_begin)/p_inc + 1,
( unsigned long )0,
( unsigned long )0, 0.0 );
//for ( p = p_begin; p <= p_end; p += p_inc )
for ( p = p_end; p_begin <= p; p -= p_inc )
{
//for ( p = p_begin; p <= p_end; p += p_inc )
for ( p = p_end; p_begin <= p; p -= p_inc )
{
if ( m_input < 0 ) m = p * ( dim_t )abs(m_input);
else m = ( dim_t ) m_input;
if ( n_input < 0 ) n = p * ( dim_t )abs(n_input);
else n = ( dim_t ) n_input;
if ( m_input < 0 ) m = p * ( dim_t )abs(m_input);
else m = ( dim_t ) m_input;
if ( n_input < 0 ) n = p * ( dim_t )abs(n_input);
else n = ( dim_t ) n_input;
bli_obj_create( dt_alpha, 1, 1, 0, 0, &alpha );
bli_obj_create( dt_beta, 1, 1, 0, 0, &beta );
bli_obj_create( dt_alpha, 1, 1, 0, 0, &alpha );
bli_obj_create( dt_beta, 1, 1, 0, 0, &beta );
bli_obj_create( dt_a, m, n, 0, 0, &a );
bli_obj_create( dt_x, n, 1, 0, 0, &x );
bli_obj_create( dt_y, m, 1, 0, 0, &y );
bli_obj_create( dt_y, m, 1, 0, 0, &y_save );
bli_obj_create( dt_a, m, n, 1, m, &a );
bli_obj_create( dt_x, n, 1, 0, 0, &x );
bli_obj_create( dt_y, m, 1, 0, 0, &y );
bli_obj_create( dt_y, m, 1, 0, 0, &y_save );
bli_randm( &a );
bli_randm( &x );
bli_randm( &y );
bli_randm( &a );
bli_randm( &x );
bli_randm( &y );
bli_setsc( (2.0/1.0), 0.0, &alpha );
bli_setsc( -(1.0/1.0), 0.0, &beta );
bli_copym( &y, &y_save );
dtime_save = DBL_MAX;
for ( r = 0; r < n_repeats; ++r )
{
bli_copym( &y_save, &y );
bli_setsc( (2.0/1.0), 0.0, &alpha );
bli_setsc( -(1.0/1.0), 0.0, &beta );
bli_copym( &y, &y_save );
dtime_save = DBL_MAX;
for ( r = 0; r < n_repeats; ++r )
{
bli_copym( &y_save, &y );
dtime = bli_clock();
dtime = bli_clock();
#ifdef PRINT
bli_printm( "a", &a, "%4.1f", "" );
bli_printm( "x", &x, "%4.1f", "" );
bli_printm( "y", &y, "%4.1f", "" );
bli_printm( "a", &a, "%4.1f", "" );
bli_printm( "x", &x, "%4.1f", "" );
bli_printm( "y", &y, "%4.1f", "" );
#endif
#ifdef BLIS
bli_gemv( &alpha,
&a,
&x,
&beta,
&y );
bli_gemv( &alpha,
&a,
&x,
&beta,
&y );
#else
f77_char transa = 'N';
f77_int mm = bli_obj_length( &a );
f77_int nn = bli_obj_width( &a );
f77_int lda = bli_obj_col_stride( &a );
f77_int incx = bli_obj_vector_inc( &x );
f77_int incy = bli_obj_vector_inc( &y );
double* alphap = bli_obj_buffer( &alpha );
double* ap = bli_obj_buffer( &a );
double* xp = bli_obj_buffer( &x );
double* betap = bli_obj_buffer( &beta );
double* yp = bli_obj_buffer( &y );
dgemv_( &transa,
&mm,
&nn,
alphap,
ap, &lda,
xp, &incx,
betap,
yp, &incy );
#ifdef CBLAS
enum CBLAS_ORDER cblas_order;
enum CBLAS_TRANSPOSE cblas_transa;
if ( bli_obj_row_stride( &a ) == 1 )
cblas_order = CblasColMajor;
else
cblas_order = CblasRowMajor;
cblas_transa = CblasNoTrans;
#else
f77_char transa = 'N';
#endif
if ( bli_is_float( dt ) ){
f77_int mm = bli_obj_length( &a );
f77_int nn = bli_obj_width( &a );
f77_int lda = bli_obj_col_stride( &a );
f77_int incx = bli_obj_vector_inc( &x );
f77_int incy = bli_obj_vector_inc( &y );
float* alphap = bli_obj_buffer( &alpha );
float* ap = bli_obj_buffer( &a );
float* xp = bli_obj_buffer( &x );
float* betap = bli_obj_buffer( &beta );
float* yp = bli_obj_buffer( &y );
#ifdef CBLAS
cblas_sgemv( cblas_order,
cblas_transa,
mm,
nn,
*alphap,
ap, lda,
xp, incx,
*betap,
yp, incy );
#else
sgemv_( &transa,
&mm,
&nn,
alphap,
ap, &lda,
xp, &incx,
betap,
yp, &incy );
#endif
}
else if ( bli_is_double( dt ) )
{
f77_int mm = bli_obj_length( &a );
f77_int nn = bli_obj_width( &a );
f77_int lda = bli_obj_col_stride( &a );
f77_int incx = bli_obj_vector_inc( &x );
f77_int incy = bli_obj_vector_inc( &y );
double* alphap = bli_obj_buffer( &alpha );
double* ap = bli_obj_buffer( &a );
double* xp = bli_obj_buffer( &x );
double* betap = bli_obj_buffer( &beta );
double* yp = bli_obj_buffer( &y );
#ifdef CBLAS
cblas_dgemv( cblas_order,
cblas_transa,
mm,
nn,
*alphap,
ap, lda,
xp, incx,
*betap,
yp, incy );
#else
dgemv_( &transa,
&mm,
&nn,
alphap,
ap, &lda,
xp, &incx,
betap,
yp, &incy );
#endif
}
else if ( bli_is_scomplex( dt ) )
{
f77_int mm = bli_obj_length( &a );
f77_int nn = bli_obj_width( &a );
f77_int lda = bli_obj_col_stride( &a );
f77_int incx = bli_obj_vector_inc( &x );
f77_int incy = bli_obj_vector_inc( &y );
scomplex* alphap = bli_obj_buffer( &alpha );
scomplex* ap = bli_obj_buffer( &a );
scomplex* xp = bli_obj_buffer( &x );
scomplex* betap = bli_obj_buffer( &beta );
scomplex* yp = bli_obj_buffer( &y );
#ifdef CBLAS
cblas_cgemv( cblas_order,
cblas_transa,
mm,
nn,
alphap,
ap, lda,
xp, incx,
betap,
yp, incy );
#else
cgemv_( &transa,
&mm,
&nn,
alphap,
ap, &lda,
xp, &incx,
betap,
yp, &incy );
#endif
}
else if ( bli_is_dcomplex( dt ) )
{
f77_int mm = bli_obj_length( &a );
f77_int nn = bli_obj_width( &a );
f77_int lda = bli_obj_col_stride( &a );
f77_int incx = bli_obj_vector_inc( &x );
f77_int incy = bli_obj_vector_inc( &y );
dcomplex* alphap = bli_obj_buffer( &alpha );
dcomplex* ap = bli_obj_buffer( &a );
dcomplex* xp = bli_obj_buffer( &x );
dcomplex* betap = bli_obj_buffer( &beta );
dcomplex* yp = bli_obj_buffer( &y );
#ifdef CBLAS
cblas_zgemv( cblas_order,
cblas_transa,
mm,
nn,
alphap,
ap, lda,
xp, incx,
betap,
yp, incy );
#else
zgemv_( &transa,
&mm,
&nn,
alphap,
ap, &lda,
xp, &incx,
betap,
yp, &incy );
#endif
}
#endif
#ifdef PRINT
bli_printm( "y after", &y, "%4.1f", "" );
exit(1);
bli_printm( "y after", &y, "%4.1f", "" );
exit(1);
#endif
dtime_save = bli_clock_min_diff( dtime_save, dtime );
}
dtime_save = bli_clock_min_diff( dtime_save, dtime );
}
gflops = ( 2.0 * m * n ) / ( dtime_save * 1.0e9 );
gflops = ( 2.0 * m * n ) / ( dtime_save * 1.0e9 );
if ( bli_is_complex( dt ) ) gflops *= 4.0;
#ifdef BLIS
printf( "data_gemv_blis" );
printf( "data_gemv_blis" );
#else
printf( "data_gemv_%s", BLAS );
printf( "data_gemv_%s", BLAS );
#endif
printf( "( %2lu, 1:3 ) = [ %4lu %4lu %7.2f ];\n",
( unsigned long )(p - p_begin)/p_inc + 1,
( unsigned long )m,
( unsigned long )n, gflops );
printf( "( %2lu, 1:3 ) = [ %4lu %4lu %7.2f ];\n",
( unsigned long )(p - p_begin)/p_inc + 1,
( unsigned long )m,
( unsigned long )n, gflops );
bli_obj_free( &alpha );
bli_obj_free( &beta );
bli_obj_free( &alpha );
bli_obj_free( &beta );
bli_obj_free( &a );
bli_obj_free( &x );
bli_obj_free( &y );
bli_obj_free( &y_save );
}
bli_obj_free( &a );
bli_obj_free( &x );
bli_obj_free( &y );
bli_obj_free( &y_save );
}
//bli_finalize();
//bli_finalize();
return 0;
return 0;
}