Skip to content
Snippets Groups Projects
Commit 2dee642f authored by Prakalp Srivastava's avatar Prakalp Srivastava
Browse files

local changes to sgemm visc_sh. Removed some comments etc.

parent 8870af63
No related branches found
No related tags found
No related merge requests found
......@@ -91,25 +91,17 @@ void packData(RootIn* args,
args->grid_y = grid_y;
}
// TODO: decide between dynamic vs static allocation. Merely a convension - will
// be translated.
void Allocation(int block_x, int block_y) {
// Memory shared between threadblocks
//int bl_x = TILE_N;
//int bl_y = TILE_TB_HEIGHT;
//void* shB = __visc__malloc(bl_x*bl_y*sizeof(float));
void* shB = __visc__malloc(block_x*block_y*sizeof(float));
//__visc__return(shB, bl_x*bl_y*sizeof(float));
__visc__return(shB, block_x*block_y*sizeof(float));
}
void SgemmLeaf( float* A, size_t bytesA, int lda, float* B, size_t bytesB, int ldb, float* C, size_t bytesC, int ldc, int k, float alpha, float beta, float* shB, size_t bytesshB )
{
void SgemmLeaf( float* A, size_t bytesA, int lda, float* B, size_t bytesB, int ldb, float* C, size_t bytesC, int ldc, int k, float alpha, float beta, float* shB, size_t bytesshB) {
__visc__hint(visc::DEVICE);
//__visc__hint(visc::SPIR_TARGET);
// TODO: shB is not an in or out attribute
//__visc__hint(visc::GPU_TARGET);
__visc__attributes(3, A, B, C, 1, C);
void* thisNode = __visc__getNode();
......@@ -153,7 +145,7 @@ void SgemmLeaf( float* A, size_t bytesA, int lda, float* B, size_t bytesB, int l
}
}
// Thread block node for sgemm - Creates allocation node and leaf (thread) node
// Work group node for sgemm - Creates allocation node and leaf (work item) node
void SgemmTB(float *A, size_t bytesA,
int lda,
float *B, size_t bytesB,
......@@ -192,10 +184,9 @@ void SgemmTB(float *A, size_t bytesA,
__visc__edge(AllocationNode, SgemmLeafNode, 1, 0, 12, 0); // Edge local_B
__visc__edge(AllocationNode, SgemmLeafNode, 1, 1, 13, 0); // Edge bytes_local_B
//TODO: bindOut : for now with out attribute
}
// Root node for sgemm - Creates thread block node
// Root node for sgemm - Creates work group node
void SgemmRoot(float *A, size_t bytesA,
int lda,
float *B, size_t bytesB,
......@@ -229,7 +220,6 @@ void SgemmRoot(float *A, size_t bytesA,
__visc__bindIn(SgemmTBNode, 12, 12, 0); // Bind block_x
__visc__bindIn(SgemmTBNode, 13, 13, 0); // Bind block_y
//TODO: bindOut : for now with out attribute
}
// Creates root node for sgemm
......@@ -254,14 +244,12 @@ __attribute__((noinline)) void basicSgemm(struct pb_TimerSet* timers, char trans
// unsigned db[2] = {TILE_N,TILE_TB_HEIGHT};
// unsigned dg[2] = {m*TILE_N/TILE_M,n*TILE_TB_HEIGHT/TILE_N};
// unsigned dg[2] = {m*db[0]/TILE_M,n*db[1]/TILE_N};
// unsigned sgemmDFG = __visc__node(mysgemmNT, 2, 2, db[0], db[1], dg[0]/db[0], dg[1]/db[1], 12, A, bytesA, lda, B, bytesB, ldb, C, bytesC, ldc, k, alpha, beta, 0);
int block_x = TILE_N;
int block_y = TILE_TB_HEIGHT;
int grid_x = m/TILE_M;
int grid_y = n/TILE_N;
// Pack data in struct
RootIn* args = (RootIn*) malloc(sizeof(RootIn));
packData(args,
......@@ -344,7 +332,8 @@ int main (int argc, char *argv[]) {
// Use standard sgemm interface
basicSgemm(&timers, 'N', 'T', matArow, matBcol, matAcol, 1.0f, \
&matA.front(), A_sz, matArow, &matBT.front(), B_sz, matBcol, 0.0f, &matC.front(), C_sz, matArow);
&matA.front(), A_sz, matArow, &matBT.front(), B_sz, matBcol,
0.0f, &matC.front(), C_sz, matArow);
pb_SwitchToTimer( &timers, pb_TimerID_COPY );
llvm_visc_request_mem(&matC.front(), C_sz);
......@@ -360,11 +349,9 @@ int main (int argc, char *argv[]) {
__visc__cleanup();
if (params->outFile) {
/* Write C to file */
//pb_SwitchToTimer(&timers, pb_TimerID_IO);
writeColMajorMatrixFile(params->outFile,
matArow, matBcol, matC);
/* Write C to file */
//pb_SwitchToTimer(&timers, pb_TimerID_IO);
writeColMajorMatrixFile(params->outFile, matArow, matBcol, matC);
}
double GPUtime = pb_GetElapsedTime(&(timers.timers[pb_TimerID_KERNEL]));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment