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

Added macros for placing the windows in the right places

parent 3261cf3b
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,16 @@ ifeq ($(PLATFORM),)
PLATFORM=default
endif
ifeq ($(POS),)
POS = left
endif
ifeq ($(POS),middle)
APP_CXXFLAGS+=-DMIDDLE
else ifeq ($(POS),right)
APP_CXXFLAGS+=-DRIGHT
endif
BIN = $(addsuffix -$(VERSION), $(APP))
SRCDIR = src/$(VERSION)
......@@ -37,7 +47,7 @@ OUTPUT = $(RUNDIR)/output.txt
#ARGS = -i $(VIDEO1) -o $(OUTPUT)
#ARGS = -i $(VIDEO)
#ARGS = -i $(VIDEO3)
ARGS = -i $(VIDEO4)
ARGS = -i $(VIDEO4)
#ARGS = -i $(MATRIX) -o $(OUTPUT)
#TOOL = tools/compare-output
TOOL=echo
......
......@@ -23,6 +23,39 @@
#include <parboil.h>
#include <visc.h>
#define NUM_RUNS 5
#define DEPTH 3
#define HEIGHT 640
#define WIDTH 480
std::string input_window = "GPU Pipeline - Input Video";
std::string output_window = "GPU Pipeline - Edge Mapping";
#ifdef MIDDLE
#define POSX_IN 640
#define POSY_IN 0
#define POSX_OUT 640
#define POSY_OUT 540
#elif RIGHT
#define POSX_IN 1280
#define POSY_IN 0
#define POSX_OUT 1280
#define POSY_OUT 540
#else // LEFT
#define POSX_IN 0
#define POSY_IN 0
#define POSX_OUT 0
#define POSY_OUT 540
#endif
//#define NUM_FRAMES 20
// Definitions of sizes for edge detection kernels
#define MIN_BR 0.0f
......@@ -205,7 +238,6 @@ void laplacianEstimate(float *Is, size_t bytesIs,
int m, int n) {
__visc__hint(visc::DEVICE);
//__visc__hint(visc::GPU_TARGET);
__visc__attributes(2, Is, B, 1, L);
// 3x3 image area
float imageArea[SZB][SZB];
......@@ -315,7 +347,7 @@ void computeZeroCrossings(float *L, size_t bytesL,
float *S, size_t bytesS,
int m, int n) {
__visc__hint(visc::DEVICE);
//__visc__hint(visc::SPIR_TARGET);
//__visc__hint(visc::CPU_TARGET);
__visc__attributes(2, L, B, 1, S);
// 3x3 image area
......@@ -525,6 +557,7 @@ void computeMaxGradientLeaf(float *G, size_t bytesG,
int m, int n) {
__visc__hint(visc::DEVICE);
//__visc__hint(visc::CPU_TARGET);
__visc__attributes(1, G, 1, maxG);
void* thisNode = __visc__getNode();
......@@ -600,6 +633,7 @@ void computeMaxGradientTB(float *G, size_t bytesG,
int m, int n,
int block_x) {
__visc__hint(visc::DEVICE);
//__visc__hint(visc::CPU_TARGET);
__visc__attributes(2, G, maxG, 1, maxG);
void* CMGLeafNode = __visc__createNode1D(computeMaxGradientLeaf, block_x);
__visc__bindIn(CMGLeafNode, 0, 0, 0); // Bind G
......@@ -646,6 +680,7 @@ void rejectZeroCrossings(float *S, size_t bytesS,
float *E, size_t bytesE,
int m, int n) {
__visc__hint(visc::DEVICE);
//__visc__hint(visc::CPU_TARGET);
__visc__attributes(3, S, G, maxG, 1, E);
void* thisNode = __visc__getNode();
......@@ -786,9 +821,7 @@ void edgeDetection(float *I, size_t bytesI, // 0
}
}
#define NUM_RUNS 1
#define DEPTH 3
//#define NUM_FRAMES 20
using namespace cv;
void getNextFrame(VideoCapture& VC, Mat& F) {
......@@ -801,6 +834,15 @@ void getNextFrame(VideoCapture& VC, Mat& F) {
}
//void showInOut(Mat& Input, Mat& Output) {
//Mat in, out;
//resize(Input, in, Size(512, 768));
//resize(Output, out, Size(512, 768));
//imshow(input_window, in);
//imshow(output_window, out);
//}
int main (int argc, char *argv[]) {
struct pb_Parameters *params;
......@@ -808,8 +850,6 @@ int main (int argc, char *argv[]) {
size_t I_sz;
int block_x, grid_x;
std::string input_window = "Input Frame";
std::string output_window = "Edge Map";
std::cout << "Using OpenCV" << CV_VERSION << "\n";
......@@ -835,6 +875,8 @@ int main (int argc, char *argv[]) {
std::cout << "Number of frames = " << NUM_FRAMES << "\n";
namedWindow(input_window, CV_WINDOW_AUTOSIZE);
namedWindow(output_window, CV_WINDOW_AUTOSIZE);
moveWindow(input_window, POSX_IN, POSY_IN);
moveWindow(output_window, POSX_OUT, POSY_OUT);
Mat src, Is, L, S, G, E;
......@@ -858,7 +900,7 @@ int main (int argc, char *argv[]) {
pb_InitializeTimerSet(&timers);
__visc__init();
pb_SwitchToTimer( &timers, pb_TimerID_COMPUTE );
//pb_SwitchToTimer( &timers, pb_TimerID_COMPUTE );
// copy A to device memory
I_sz = src.size[0]*src.size[1]*sizeof(float);
......@@ -895,14 +937,19 @@ int main (int argc, char *argv[]) {
grid_x = 1;
// Copy A and B^T into device memory
pb_SwitchToTimer( &timers, pb_TimerID_COMPUTE );
//pb_SwitchToTimer( &timers, pb_TimerID_COMPUTE );
//showInOut(src, E);
Mat in, out;
resize(src, in, Size(HEIGHT, WIDTH));
resize(E, out, Size(HEIGHT, WIDTH));
imshow(input_window, in);
imshow(output_window, out);
waitKey(0);
//NUM_FRAMES = 20;
pb_SwitchToTimer( &timers, visc_TimerID_COMPUTATION );
struct InStruct* args = (struct InStruct*)malloc (sizeof(InStruct));
imshow(input_window, src);
imshow(output_window, Is);
waitKey(0);
packData(args, (float*)src.data, I_sz,
(float*)Is.data, I_sz,
(float*)L.data, I_sz,
......@@ -920,16 +967,18 @@ int main (int argc, char *argv[]) {
// Check if the total elements is a multiple of block size
assert(src.size[0]*src.size[1] % block_x == 0);
imshow(input_window, src);
imshow(output_window, E);
waitKey(0);
//imshow(input_window, src);
//imshow(output_window, E);
//waitKey(0);
for(unsigned j=0; j<NUM_RUNS; j++) {
std::cout << "Run: " << j << "\n";
void* DFG = __visc__launch(1, edgeDetection, (void*)args);
cap = VideoCapture(params->inpFiles[0]);
getNextFrame(cap, src);
//packData(args, A.data, BlockSize, &matB[i], BlockSize, &matC[i], BlockSize, BlockElements);
if(NUM_FRAMES >=2) {
//__visc__push(DFG, args);
//__visc__push(DFG, args);
......@@ -938,6 +987,7 @@ int main (int argc, char *argv[]) {
args->I = (float*) src.data;
*maxG = 0.0;
llvm_visc_track_mem(src.data, I_sz);
llvm_visc_track_mem(Is.data, I_sz);
llvm_visc_track_mem(L.data, I_sz);
......@@ -949,7 +999,7 @@ int main (int argc, char *argv[]) {
llvm_visc_track_mem(B, bytesB);
llvm_visc_track_mem(Sx, bytesSx);
llvm_visc_track_mem(Sy, bytesSy);
__visc__push(DFG, args);
__visc__pop(DFG);
......@@ -964,12 +1014,38 @@ int main (int argc, char *argv[]) {
//llvm_visc_request_mem(G.data, I_sz);
llvm_visc_request_mem(maxG, bytesMaxG);
llvm_visc_request_mem(E.data, I_sz);
//std::cout << "src.data = " << (float*)src.data << "\n";
//std::cout << "Is.data = " << (float*)Is.data << "\n";
//std::cout << "L.data = " << (float*)L.data << "\n";
//std::cout << "S.data = " << (float*)S.data << "\n";
//std::cout << "G.data = " << (float*)G.data << "\n";
//std::cout << "E.data = " << (float*)E.data << "\n";
//std::cout << "Max G = " << *maxG << "\n";
imshow(output_window, E);
imshow(input_window, src);
Mat in, out;
resize(src, in, Size(HEIGHT, WIDTH));
//std::cout << "Show E\n";
resize(E, out, Size(HEIGHT, WIDTH));
imshow(output_window, out);
imshow(input_window, in);
waitKey(1);
getNextFrame(cap, src);
//waitKey(0);
//std::cout << "Show Is\n";
//resize(Is, out, Size(HEIGHT, WIDTH));
//imshow(output_window, out);
//waitKey(0);
//std::cout << "Show L\n";
//resize(L, out, Size(HEIGHT, WIDTH));
//imshow(output_window, out);
//waitKey(0);
//std::cout << "Show S\n";
//resize(S, out, Size(HEIGHT, WIDTH));
//imshow(output_window, out);
//waitKey(0);
//std::cout << "Show G\n";
//resize(G, out, Size(HEIGHT, WIDTH));
//imshow(output_window, out);
//waitKey(0);
llvm_visc_untrack_mem(src.data);
llvm_visc_untrack_mem(Is.data);
......@@ -983,7 +1059,7 @@ int main (int argc, char *argv[]) {
llvm_visc_untrack_mem(Sx);
llvm_visc_untrack_mem(Sy);
getNextFrame(cap, src);
}
//__visc__pop(DFG);
......@@ -993,7 +1069,8 @@ int main (int argc, char *argv[]) {
__visc__push(DFG, args);
__visc__pop(DFG);
}
__visc__wait(DFG);
}
......@@ -1011,26 +1088,26 @@ int main (int argc, char *argv[]) {
//src.size[0], src.size[1], matE);
//}
std::cout << "Show Is" << "\n";
Mat output(src.size[0], src.size[1], CV_32F);
imshow(output_window, Is);
waitKey(0);
std::cout << "Show G" << "\n";
imshow(output_window, L);
waitKey(0);
std::cout << "Show L" << "\n";
imshow(output_window, S);
waitKey(0);
//std::cout << "Show Is" << "\n";
//Mat output(src.size[0], src.size[1], CV_32F);
//imshow(output_window, Is);
//waitKey(0);
//std::cout << "Show G" << "\n";
//imshow(output_window, L);
//waitKey(0);
//std::cout << "Show L" << "\n";
//imshow(output_window, S);
//waitKey(0);
std::cout << "Show S" << "\n";
imshow(output_window, G);
waitKey(0);
//std::cout << "Show S" << "\n";
//imshow(output_window, G);
//waitKey(0);
std::cout << "Show E" << "\n";
imshow(output_window, E);
waitKey(0);
//std::cout << "Show E" << "\n";
//imshow(output_window, E);
//waitKey(0);
//double GPUtime = pb_GetElapsedTime(&(timers.timers[pb_TimerID_KERNEL]));
//std::cout<< "GFLOPs = " << 2.* src.size[0] * src.size[1] * src.size[1]/GPUtime/1e9 << std::endl;
......
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