11/***************************************************************************
2- Copyright (c) 2014, The OpenBLAS Project
2+ Copyright (c) 2014, 2025 The OpenBLAS Project
33All rights reserved.
44Redistribution and use in source and binary forms, with or without
55modification, are permitted provided that the following conditions are
@@ -34,6 +34,12 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3434
3535#ifdef DOUBLE
3636#define GEMV BLASFUNC(dgemv)
37+ #elif defined(BFLOAT16 ) && defined(BGEMM )
38+ #define GEMV BLASFUNC(bgemv)
39+ #elif defined(BFLOAT16 )
40+ #define GEMV BLASFUNC(sbgemv)
41+ #undef IFLOAT
42+ #define IFLOAT bfloat16
3743#else
3844#define GEMV BLASFUNC(sgemv)
3945#endif
@@ -49,9 +55,20 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4955#endif
5056int main (int argc , char * argv []){
5157
52- FLOAT * a , * x , * y ;
53- FLOAT alpha [] = {1.0 , 1.0 };
54- FLOAT beta [] = {1.0 , 0.0 };
58+ IFLOAT * a , * x ;
59+ FLOAT * y ;
60+ #ifdef BGEMM
61+ blasint one = 1 ;
62+ blasint two = 2 ;
63+ float alpha_in [] = {1.0 , 0.0 };
64+ float beta_in [] = {0.0 , 0.0 };
65+ FLOAT alpha [2 ], beta [2 ];
66+ sbstobf16_ (& two , alpha_in , & one , alpha , & one );
67+ sbstobf16_ (& two , beta_in , & one , beta , & one );
68+ #else
69+ FLOAT alpha [] = {1.0 , 0.0 };
70+ FLOAT beta [] = {0.0 , 0.0 };
71+ #endif
5572 char trans = 'N' ;
5673 blasint m , i , j ;
5774 blasint inc_x = 1 ,inc_y = 1 ;
@@ -97,11 +114,11 @@ int main(int argc, char *argv[]){
97114
98115 fprintf (stderr , "From : %3d To : %3d Step = %3d Trans = '%c' Inc_x = %d Inc_y = %d Loops = %d\n" , from , to , step ,trans ,inc_x ,inc_y ,loops );
99116
100- if (( a = (FLOAT * )malloc (sizeof (FLOAT ) * tomax * tomax * COMPSIZE )) == NULL ){
117+ if (( a = (IFLOAT * )malloc (sizeof (IFLOAT ) * tomax * tomax * COMPSIZE )) == NULL ){
101118 fprintf (stderr ,"Out of Memory!!\n" );exit (1 );
102119 }
103120
104- if (( x = (FLOAT * )malloc (sizeof (FLOAT ) * tomax * abs (inc_x ) * COMPSIZE )) == NULL ){
121+ if (( x = (IFLOAT * )malloc (sizeof (IFLOAT ) * tomax * abs (inc_x ) * COMPSIZE )) == NULL ){
105122 fprintf (stderr ,"Out of Memory!!\n" );exit (1 );
106123 }
107124
@@ -125,15 +142,15 @@ int main(int argc, char *argv[]){
125142 fprintf (stderr , " %6dx%d : " , (int )m ,(int )n );
126143 for (j = 0 ; j < m ; j ++ ){
127144 for (i = 0 ; i < n * COMPSIZE ; i ++ ){
128- a [(long )i + (long )j * (long )m * COMPSIZE ] = ((FLOAT ) rand () / (FLOAT ) RAND_MAX ) - 0.5 ;
145+ a [(long )i + (long )j * (long )m * COMPSIZE ] = ((IFLOAT ) rand () / (FLOAT ) RAND_MAX ) - 0.5 ;
129146 }
130147 }
131148
132149 for (l = 0 ; l < loops ; l ++ )
133150 {
134151
135152 for (i = 0 ; i < n * COMPSIZE * abs (inc_x ); i ++ ){
136- x [i ] = ((FLOAT ) rand () / (FLOAT ) RAND_MAX ) - 0.5 ;
153+ x [i ] = ((IFLOAT ) rand () / (FLOAT ) RAND_MAX ) - 0.5 ;
137154 }
138155
139156 for (i = 0 ; i < m * COMPSIZE * abs (inc_y ); i ++ ){
0 commit comments