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

Fixed pipeline code. Allows multiple runs within the code. Fixed visc.mk to...

Fixed pipeline code. Allows multiple runs within the code. Fixed visc.mk to support SPIR and PTX both
parent 44844ada
No related branches found
No related tags found
No related merge requests found
......@@ -87,12 +87,13 @@ B : structural element for dilation - erosion ([0 1 0; 1 1 1; 0 1 0])
L : output (laplacian of the image)
Need 2D grid, a thread per pixel
*/
OutStruct laplacianEstimate(float *I, size_t bytesI,
void laplacianEstimate(float *I, size_t bytesI,
float *B, size_t bytesB,
float *L, size_t bytesL,
int m, int n) {
__visc__hint(visc::GPU_TARGET);
__visc__hint(visc::DEVICE);
//__visc__hint(visc::GPU_TARGET);
__visc__attributes(2, I, B, 1, L);
// 3x3 image area
float imageArea[SZB][SZB];
......@@ -163,16 +164,17 @@ OutStruct laplacianEstimate(float *I, size_t bytesI,
float laplacian = dilatedPixel + erodedPixel - 2 * imageArea[1][1];
L[gy*n+gx] = laplacian;
}
OutStruct output = {bytesB, bytesL};
//OutStruct output = {bytesB, bytesL};
//if(gx == m-1 && gy == n-1)
//std::cout << "Exit laplacian\n";
return output;
__visc__return(bytesB, bytesL);
}
OutStruct WrapperlaplacianEstimate(float *I, size_t bytesI,
float *B, size_t bytesB,
float *L, size_t bytesL,
int m, int n) {
__visc__hint(visc::CPU_TARGET);
__visc__attributes(2, I, B, 1, L);
void* LNode = __visc__createNode2D(laplacianEstimate, m, n);
__visc__bindIn(LNode, 0, 0, 0); // Bind I
......@@ -198,11 +200,12 @@ B : structural element for dilation - erosion ([0 1 0; 1 1 1; 0 1 0])
S : output (sign of the image)
Need 2D grid, a thread per pixel
*/
OutStruct computeZeroCrossings(float *L, size_t bytesL,
void computeZeroCrossings(float *L, size_t bytesL,
float *B, size_t bytesB,
float *S, size_t bytesS,
int m, int n) {
__visc__hint(visc::GPU_TARGET);
__visc__hint(visc::DEVICE);
//__visc__hint(visc::SPIR_TARGET);
__visc__attributes(2, L, B, 1, S);
// 3x3 image area
......@@ -273,16 +276,17 @@ OutStruct computeZeroCrossings(float *L, size_t bytesL,
float pixelSign = dilatedPixel - erodedPixel;
S[gy*n+gx] = pixelSign;
}
OutStruct output = {bytesB, bytesS};
//OutStruct output = {bytesB, bytesS};
//if(gx == n-1 && gy == n-1)
//std::cout << "Exit ZC\n";
return output;
__visc__return(bytesB, bytesS);
}
OutStruct WrapperComputeZeroCrossings(float *L, size_t bytesL,
float *B, size_t bytesB,
float *S, size_t bytesS,
int m, int n) {
__visc__hint(visc::CPU_TARGET);
__visc__attributes(2, L, B, 1, S);
void* ZCNode = __visc__createNode2D(computeZeroCrossings, m, n);
__visc__bindIn(ZCNode, 0, 0, 0); // Bind L
......@@ -340,6 +344,9 @@ OutStruct edgeDetection(float *I, size_t bytesI,
}
}
#define NUM_RUNS 5
#define NUM_FRAMES 20
int main (int argc, char *argv[]) {
struct pb_Parameters *params;
......@@ -397,8 +404,7 @@ int main (int argc, char *argv[]) {
matS[i] = 0.0f;
}
pb_SwitchToTimer( &timers, pb_TimerID_NONE );
pb_SwitchToTimer( &timers, visc_TimerID_COMPUTATION );
struct InStruct* args = (struct InStruct*)malloc (sizeof(InStruct));
packData(args, &matI.front(), I_sz,
......@@ -408,7 +414,9 @@ int main (int argc, char *argv[]) {
matIrow, matIcol);
assert(I_sz % BlockSize == 0);
void* DFG = __visc__launch(1, edgeDetection, (void*)args);
for(unsigned j=0; j<NUM_RUNS; j++) {
std::cout << "Run: " << j << "\n";
void* DFG = __visc__launch(1, edgeDetection, (void*)args);
llvm_visc_track_mem(&matI[0], I_sz);
llvm_visc_track_mem(&matL[0], L_sz);
......@@ -417,8 +425,10 @@ int main (int argc, char *argv[]) {
//packData(args, &matA[0], BlockSize, &matB[i], BlockSize, &matC[i], BlockSize, BlockElements);
__visc__push(DFG, args);
__visc__push(DFG, args);
__visc__push(DFG, args);
__visc__pop(DFG);
for(unsigned i=0; i<NUM_FRAMES-2; i++) {
__visc__push(DFG, args);
__visc__pop(DFG);
}
__visc__pop(DFG);
__visc__pop(DFG);
llvm_visc_request_mem(&matS[0], S_sz);
......@@ -440,8 +450,8 @@ int main (int argc, char *argv[]) {
//llvm_visc_untrack_mem(&matC[i]);
//}
__visc__wait(DFG);
__visc__wait(DFG);
}
pb_SwitchToTimer( &timers, pb_TimerID_COPY );
//llvm_visc_request_mem(&matC.front(), C_sz);
......
......@@ -103,18 +103,17 @@ TEST_OBJS = $(call INBUILDDIR,$(VISC_OBJS))
PARBOIL_OBJS = $(call INBUILDDIR,parboil.ll)
KERNEL = $(TEST_OBJS).kernels.ll
KERNEL_OPT = $(BUILDDIR)/$(APP).kernels.opt.ll
ifneq ($(TARGET),x86)
ifeq ($(TARGET),x86)
SPIR_ASSEMBLY = $(TEST_OBJS).kernels.bc
else ifeq ($(TARGET),seq)
else
KERNEL_LINKED = $(BUILDDIR)/$(APP).kernels.linked.ll
#KERNEL = $(TEST_OBJS).kernels.ll
PTX_ASSEMBLY = $(TEST_OBJS).nvptx.s
else
SPIR_ASSEMBLY = $(TEST_OBJS).kernels.bc
endif
HOST_LINKED = $(BUILDDIR)/$(APP).linked.ll
HOST = $(BUILDDIR)/$(APP).host.ll
APP_BINS = $(PTX_ASSEMBLY) $(BIN) $(KERNEL)
ifeq ($(DEBUGGER),)
DEBUGGER=gdb
endif
......
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