Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
reger-men committed Jul 1, 2021
1 parent 7d34582 commit b2932f8
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 45 deletions.
2 changes: 1 addition & 1 deletion include/backend/hpl_backendCPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern "C" {
#include "hpl_panel.h"
}

#define HPL_PRINT_INFO
//#define HPL_PRINT_INFO
#ifdef HPL_PRINT_INFO
#define CPUInfo(msg, ...) \
{ \
Expand Down
2 changes: 1 addition & 1 deletion include/backend/hpl_backendCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace HPL
{
template<typename Func, typename... Args>
constexpr auto dispatch(Func&& func, Args... args) {
func(args...);
return func(args...);
}
};

Expand Down
7 changes: 7 additions & 0 deletions include/backend/hpl_backendHIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,18 @@ extern "C" {
exit(EXIT_FAILURE); \
}


#define GPUError(...) GPUInfo(__VA_ARGS__)

//#define HPL_PRINT_INFO
#ifdef HPL_PRINT_INFO
#define GPUInfo(msg, ...) \
{ \
printf("INFO\t %-15s\t" msg "\n", ##__VA_ARGS__); \
}
#else
#define GPUInfo(msg, ...)
#endif



Expand Down
2 changes: 1 addition & 1 deletion include/backend/hpl_backendWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern "C" {
#include "hpl_blas.h"
#include "hpl_panel.h"

enum HPL_TARGET {T_DEFAULT, T_CPU, T_HIP};
enum HPL_TARGET {T_DEFAULT, T_CPU, T_HIP, T_TEMPO};

void HPL_BE_init(size_t, enum HPL_TARGET);

Expand Down
6 changes: 3 additions & 3 deletions src/panel/HPL_pdpanel_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void HPL_pdpanel_init
{ nu = nq - JB; lwork += JB * Mmax( 0, nu ); }

//Adil
HPL_BE_malloc((void**)&PANEL->WORK, (size_t)(lwork) * sizeof( double ), T_DEFAULT);
HPL_BE_malloc((void**)&PANEL->WORK, (size_t)(lwork) * sizeof( double ), T_TEMPO);
//if( !( PANEL->WORK = (void *)malloc( (size_t)(lwork) * sizeof( double ) ) ) )
if(!( PANEL->WORK ))
{
Expand Down Expand Up @@ -244,7 +244,7 @@ void HPL_pdpanel_init
}

//Adil
HPL_BE_malloc((void**)&PANEL->WORK, (size_t)(lwork) * sizeof( double ), T_DEFAULT);
HPL_BE_malloc((void**)&PANEL->WORK, (size_t)(lwork) * sizeof( double ), T_TEMPO);
//if( !( PANEL->WORK = (void *)malloc( (size_t)(lwork) * sizeof( double ) ) ) )
if(!(PANEL->WORK))
{
Expand Down Expand Up @@ -341,7 +341,7 @@ void HPL_pdpanel_init
}

//Adil
HPL_BE_malloc((void**)&PANEL->IWORK, (size_t)(lwork) * sizeof( int ), T_DEFAULT);
HPL_BE_malloc((void**)&PANEL->IWORK, (size_t)(lwork) * sizeof( int ), T_TEMPO);
//PANEL->IWORK = (int *)malloc( (size_t)(lwork) * sizeof( int ) );

if( PANEL->IWORK == NULL )
Expand Down
2 changes: 1 addition & 1 deletion src/panel/HPL_pdpanel_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void HPL_pdpanel_new
* Allocate the panel structure - Check for enough memory
*/
//Adil
HPL_BE_malloc((void**)&p, sizeof( HPL_T_panel ), T_DEFAULT);
HPL_BE_malloc((void**)&p, sizeof( HPL_T_panel ), T_TEMPO);
/*if( !( p = (HPL_T_panel *)malloc( sizeof( HPL_T_panel ) ) ) )*/
if( !( p ))
{
Expand Down
10 changes: 6 additions & 4 deletions src/pauxil/HPL_pdlange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ double HPL_pdlange
if( mp > 0 )
{
//Adil
HPL_BE_malloc((void**)&work, (size_t)(mp) * sizeof( double ), T_DEFAULT);
HPL_BE_malloc((void**)&work, (size_t)(mp) * sizeof( double ), T_TEMPO);
/*work = (double*)malloc( (size_t)(mp) * sizeof( double ) );*/
if( work == NULL )
{ HPL_pabort( __LINE__, "HPL_pdlange", "Memory allocation failed" ); }
Expand All @@ -225,9 +225,11 @@ double HPL_pdlange
/*
* Find maximum sum of rows for inf-norm
*/
if( mycol == 0 )
{ v0 = work[HPL_idamax( mp, work, 1 )]; v0 = Mabs( v0 ); }
if( work ) HPL_BE_free((void**)&work, T_DEFAULT);
if( mycol == 0 ){
v0 = work[HPL_BE_idamax( mp, work, 1, T_TEMPO)];
v0 = Mabs( v0 );
}
if( work ) HPL_BE_free((void**)&work, T_TEMPO);
/*if( work ) free( work );*/
}
/*
Expand Down
4 changes: 2 additions & 2 deletions src/pfact/HPL_pdfact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void HPL_pdfact
align = PANEL->algo->align;

//Adil
HPL_BE_malloc((void**)&vptr, ( (size_t)(align) + (size_t)(((4+((unsigned int)(jb) << 1)) << 1) )) * sizeof(double), T_DEFAULT);
HPL_BE_malloc((void**)&vptr, ( (size_t)(align) + (size_t)(((4+((unsigned int)(jb) << 1)) << 1) )) * sizeof(double), T_TEMPO);
/*vptr = (void *)malloc( ( (size_t)(align) + (size_t)(((4+((unsigned int)(jb) << 1)) << 1) )) * sizeof(double) );*/
if( vptr == NULL )
{ HPL_pabort( __LINE__, "HPL_pdfact", "Memory allocation failed" ); }
Expand All @@ -131,7 +131,7 @@ void HPL_pdfact
((size_t)(align) * sizeof(double) ) ) );

//Adil
if( vptr ) HPL_BE_free((void**)&vptr, T_DEFAULT);
if( vptr ) HPL_BE_free((void**)&vptr, T_TEMPO);
//if( vptr ) free( vptr );

PANEL->A = Mptr( PANEL->A, 0, jb, PANEL->lda );
Expand Down
4 changes: 2 additions & 2 deletions src/pfact/HPL_pdmxswp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ void HPL_pdmxswp
lda = PANEL->lda;
//Adil
HPL_BE_dcopy( n0, Mptr( PANEL->A, II+(int)(WORK[1]), 0, lda ), lda,
Wmx, 1, T_DEFAULT);
Wmx, 1, T_TEMPO);
/*HPL_dcopy( n0, Mptr( PANEL->A, II+(int)(WORK[1]), 0, lda ), lda,
Wmx, 1 );*/
if( myrow == icurrow )
{
//Adil
HPL_BE_dcopy( n0, Mptr( PANEL->A, II, 0, lda ), lda, A0, 1, T_DEFAULT);
HPL_BE_dcopy( n0, Mptr( PANEL->A, II, 0, lda ), lda, A0, 1, T_TEMPO);
/*HPL_dcopy( n0, Mptr( PANEL->A, II, 0, lda ), lda, A0, 1 ); */
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/pfact/HPL_pdpanrlT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ void HPL_pdpanrlT
*/
if( WORK[0] != HPL_rzero )
//Adil
HPL_BE_dscal( Mm1, HPL_rone / WORK[0], Acur, 1 , T_DEFAULT);
HPL_BE_dscal( Mm1, HPL_rone / WORK[0], Acur, 1 , T_TEMPO);
/*HPL_dscal( Mm1, HPL_rone / WORK[0], Acur, 1 );*/

//Adil
HPL_BE_daxpy( Mm1, -(*(Mptr( L1, jj+1, jj, n0 ))), Acur, 1, Anxt, 1, T_DEFAULT);
HPL_BE_daxpy( Mm1, -(*(Mptr( L1, jj+1, jj, n0 ))), Acur, 1, Anxt, 1, T_TEMPO);
/*HPL_daxpy( Mm1, -(*(Mptr( L1, jj+1, jj, n0 ))), Acur, 1, Anxt, 1 );*/
HPL_dlocmax( PANEL, Mm1, iip1, jj+1, WORK );

Expand Down Expand Up @@ -214,7 +214,7 @@ void HPL_pdpanrlT
//Adil
HPL_BE_dger( HplColumnMajor, Mm1, Nm1-1, -HPL_rone, Acur, 1,
Mptr( L1, jj+2, jj, n0 ), 1, Mptr( Anxt, 0, 1, lda ),
lda, T_DEFAULT);
lda, T_TEMPO);
/*HPL_dger( HplColumnMajor, Mm1, Nm1-1, -HPL_rone, Acur, 1,
Mptr( L1, jj+2, jj, n0 ), 1, Mptr( Anxt, 0, 1, lda ),
lda );*/
Expand All @@ -232,7 +232,7 @@ void HPL_pdpanrlT
HPL_dlocswpT( PANEL, ii, jj, WORK );
if( WORK[0] != HPL_rzero )
//Adil
HPL_BE_dscal( Mm1, HPL_rone / WORK[0], Mptr( A, iip1, jj, lda ), 1, T_DEFAULT);
HPL_BE_dscal( Mm1, HPL_rone / WORK[0], Mptr( A, iip1, jj, lda ), 1, T_TEMPO);
/*HPL_dscal( Mm1, HPL_rone / WORK[0], Mptr( A, iip1, jj, lda ), 1 );*/
#ifdef HPL_CALL_VSIPL
/*
Expand Down
8 changes: 4 additions & 4 deletions src/pgesv/HPL_pdgesv0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void HPL_pdgesv0
* Allocate a panel list of length 1 - Allocate panel[0] resources
*/
//Adil
HPL_BE_malloc((void**)&panel, sizeof( HPL_T_panel * ), T_DEFAULT);
HPL_BE_malloc((void**)&panel, sizeof( HPL_T_panel * ), T_TEMPO);
/*panel = (HPL_T_panel **)malloc( sizeof( HPL_T_panel * ) );*/
if( panel == NULL )
{ HPL_pabort( __LINE__, "HPL_pdgesv0", "Memory allocation failed" ); }
Expand All @@ -141,7 +141,7 @@ void HPL_pdgesv0
* Release panel resources - re-initialize panel data structure
*/
//Adil
(void) HPL_BE_panel_free( panel[0], T_DEFAULT);
(void) HPL_BE_panel_free( panel[0], T_TEMPO);
//(void) HPL_pdpanel_free( panel[0] );
HPL_pdpanel_init( GRID, ALGO, n, n+1, jb, A, j, j, tag, panel[0] );
/*
Expand All @@ -163,11 +163,11 @@ void HPL_pdgesv0
* Release panel resources and panel list
*/
//Adil
(void) HPL_BE_panel_disp((void**)&panel[0], T_DEFAULT);
(void) HPL_BE_panel_disp((void**)&panel[0], T_TEMPO);
/*(void) HPL_pdpanel_disp( &panel[0] );*/

//Adil
if( panel ) HPL_BE_free((void**)&panel, T_DEFAULT);
//if( panel ) HPL_BE_free((void**)&panel, T_TEMPO);
//if( panel ) free( panel);
/*
* End of HPL_pdgesv0
Expand Down
8 changes: 4 additions & 4 deletions src/pgesv/HPL_pdtrsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void HPL_pdtrsv
if( Anp > 0 )
{
//Adil
HPL_BE_malloc((void**)&W, (size_t)(Mmin( n1, Anp )) * sizeof( double ), T_DEFAULT);
HPL_BE_malloc((void**)&W, (size_t)(Mmin( n1, Anp )) * sizeof( double ), T_TEMPO);
/*W = (double*)malloc( (size_t)(Mmin( n1, Anp )) * sizeof( double ) );*/
if( W == NULL )
{ HPL_pabort( __LINE__, "HPL_pdtrsv", "Memory allocation failed" ); }
Expand All @@ -179,12 +179,12 @@ void HPL_pdtrsv
{
//Adil
HPL_BE_dtrsv(HplColumnMajor, HplUpper, HplNoTrans, HplNonUnit,
kb, Aptr+Anp, lda, XC+Anp, 1, T_DEFAULT);
kb, Aptr+Anp, lda, XC+Anp, 1, T_TEMPO);
/*HPL_dtrsv( HplColumnMajor, HplUpper, HplNoTrans, HplNonUnit,
kb, Aptr+Anp, lda, XC+Anp, 1 );*/

//Adil
HPL_BE_dcopy(kb, XC+Anp, 1, Xd, 1, T_DEFAULT);
HPL_BE_dcopy(kb, XC+Anp, 1, Xd, 1, T_TEMPO);
/*HPL_dcopy( kb, XC+Anp, 1, Xd, 1 );*/
}
}
Expand Down Expand Up @@ -310,7 +310,7 @@ void HPL_pdtrsv
Ccomm );

//Adil
if( Wfr ) HPL_BE_free((void**)&W, T_DEFAULT);
if( Wfr ) HPL_BE_free((void**)&W, T_TEMPO);
/*if( Wfr ) free( W );*/
#ifdef HPL_DETAILED_TIMING
HPL_ptimer( HPL_TIMING_PTRSV );
Expand Down
4 changes: 2 additions & 2 deletions src/pgesv/HPL_pdupdateTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void HPL_pdupdateTT
#endif
//Adil
HPL_BE_dtrsm(HplColumnMajor, HplLeft, HplUpper, HplTrans,
HplUnit, jb, nn, HPL_rone, L1ptr, jb, Aptr, lda, T_DEFAULT);
HplUnit, jb, nn, HPL_rone, L1ptr, jb, Aptr, lda, T_TEMPO);

/*HPL_dtrsm( HplColumnMajor, HplLeft, HplUpper, HplTrans,
HplUnit, jb, nn, HPL_rone, L1ptr, jb, Aptr, lda );*/
Expand All @@ -248,7 +248,7 @@ void HPL_pdupdateTT
//Adil
HPL_BE_dgemm(HplColumnMajor, HplNoTrans, HplNoTrans, mp, nn,
jb, -HPL_rone, L2ptr, ldl2, Aptr, lda, HPL_rone,
Mptr( Aptr, jb, 0, lda ), lda, T_DEFAULT);
Mptr( Aptr, jb, 0, lda ), lda, T_TEMPO);
/*HPL_dgemm( HplColumnMajor, HplNoTrans, HplNoTrans, mp, nn,
jb, -HPL_rone, L2ptr, ldl2, Aptr, lda, HPL_rone,
Mptr( Aptr, jb, 0, lda ), lda );*/
Expand Down
15 changes: 14 additions & 1 deletion testing/backend/HPL_backendCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,31 @@ int CPU::panel_disp(HPL_T_panel **ptr)
return HPL_pdpanel_disp( ptr );
}

void printMat(const int M, const int N, const int LDA, const double *A)
{
// Last row is the vector b
for(int y=0;y<M+1; y++){
for(int x=0;x<N-1; x++){
int index = x+y*LDA;
printf("%-4d:%-8lf\t", index, A[index]);
}
printf("\n");
}
}

void CPU::matgen(const HPL_T_grid *GRID, const int M, const int N,
const int NB, double *A, const int LDA,
const int ISEED)
{
CPUInfo("%-25s %-8d%-8d \t%-5s", "[Generate matrix]", "With A of (R:C)", M, N, "CPU");
HPL_pdmatgen(GRID, M, N, NB, A, LDA, ISEED);
//printMat(M,N,LDA,A);
}

int CPU::idamax(const int N, const double *DX, const int INCX)
{
CPUInfo("%-25s %-17d \t%-5s", "[IDAMAX]", "With X of (R)", N, "CPU");
HPL_idamax( N, DX, INCX );
return HPL_idamax( N, DX, INCX );
}

void CPU::daxpy(const int N, const double DA, const double *DX, const int INCX, double *DY,
Expand Down
18 changes: 16 additions & 2 deletions testing/backend/HPL_backendHIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ int HIP::panel_disp(HPL_T_panel **ptr)
return( err );
}

void gPrintMat(const int M, const int N, const int LDA, const double *A)
{
// Last row is the vector b
for(int y=0;y<M+1; y++){
for(int x=0;x<N-1; x++){
int index = x+y*LDA;
printf("%-4d:%-8lf\t", index, A[index]);
}
printf("\n");
}
}

void HIP::matgen(const HPL_T_grid *GRID, const int M, const int N,
const int NB, double *A, const int LDA,
const int ISEED)
Expand All @@ -94,6 +106,7 @@ void HIP::matgen(const HPL_T_grid *GRID, const int M, const int N,
//TODO: generate numbers in this range (-0.5, 0.5]
ROCRAND_CHECK_STATUS(rocrand_generate_normal_double(generator, A, mp*nq, 0, 0.1));
ROCRAND_CHECK_STATUS(rocrand_destroy_generator(generator));
//gPrintMat(M,N,LDA,A);
}

int HIP::idamax(const int N, const double *DX, const int INCX)
Expand Down Expand Up @@ -189,7 +202,7 @@ __global__ void
_dlacpy(const int M, const int N, const double *A, const int LDA,
double *B, const int LDB)
{

}

/*
Expand Down Expand Up @@ -225,4 +238,5 @@ void HIP::atcpy(const int M, const int N, const double *A, const int LDA,
dim3 grid_size((M+TILE_DIM-1)/TILE_DIM, (N+TILE_DIM-1)/TILE_DIM);
dim3 block_size(TILE_DIM, BLOCK_ROWS);
_dlatcpy<<<grid_size, block_size, 0, 0>>>(M, N, A, LDA, B, LDB);
}
}

10 changes: 4 additions & 6 deletions testing/backend/HPL_backendWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
#include "backend/hpl_backendCommon.h"



extern "C" {

/*
* Initialize the Target device
*/
void HPL_BE_init(size_t num_devices, enum HPL_TARGET TR)
{
switch(TR) {
case T_CPU :
case T_CPU:
DO_NOTHING();
break;
case T_HIP:
Expand Down Expand Up @@ -124,13 +122,13 @@ extern "C" {
{
switch(TR) {
case T_CPU :
HPL::dispatch(CPU::idamax, N, DX, INCX);
return HPL::dispatch(CPU::idamax, N, DX, INCX);
break;
case T_HIP:
HPL::dispatch(HIP::idamax, N, DX, INCX);
return HPL::dispatch(HIP::idamax, N, DX, INCX);
break;
default:
HPL::dispatch(CPU::idamax, N, DX, INCX);
return HPL::dispatch(CPU::idamax, N, DX, INCX);
}
}

Expand Down
Loading

0 comments on commit b2932f8

Please sign in to comment.