Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
cuda_lab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gaurav Kukreja
cuda_lab
Commits
4b389e4c
Commit
4b389e4c
authored
Mar 28, 2014
by
Gaurav Kukreja
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Completed UI
Signed-off-by:
Gaurav Kukreja
<
gmkukreja@gmail.com
>
parent
d7e32b4a
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
171 additions
and
55 deletions
+171
-55
glwidget.cpp
miklos/project_integration_gui/glwidget.cpp
+13
-1
glwidget.h
miklos/project_integration_gui/glwidget.h
+12
-0
hello-opengl.pro.user
miklos/project_integration_gui/hello-opengl.pro.user
+2
-2
kernel.cu
miklos/project_integration_gui/kernel.cu
+6
-14
kernel.h
miklos/project_integration_gui/kernel.h
+1
-1
mainwindow.cpp
miklos/project_integration_gui/mainwindow.cpp
+28
-0
mainwindow.h
miklos/project_integration_gui/mainwindow.h
+13
-0
mainwindow.ui
miklos/project_integration_gui/mainwindow.ui
+96
-37
No files found.
miklos/project_integration_gui/glwidget.cpp
View file @
4b389e4c
#include "glwidget.h"
#include "camera.h"
#include "kernel.h"
#include "timer.h"
#include <QGLFunctions>
#include <iostream>
...
...
@@ -14,6 +15,12 @@ static struct cudaGraphicsResource* pixelsVBO_CUDA;
GlWidget
::
GlWidget
(
QWidget
*
parent
)
:
QGLWidget
(
QGLFormat
(),
parent
),
gl
(
context
())
{
lambda
=
1.0
;
sigma
=
0.4
;
tau
=
0.4
;
N
=
160
;
c1
=
1.0
;
c2
=
0.00
;
}
GlWidget
::~
GlWidget
()
...
...
@@ -59,7 +66,7 @@ void GlWidget::paintGL()
}
// Execute kernel
executeKernel
(
d_in
,
d_out
,
camera
.
width
(),
camera
.
height
());
executeKernel
(
d_in
,
d_out
,
camera
.
width
(),
camera
.
height
()
,
lambda
,
sigma
,
tau
,
N
,
c1
,
c2
);
// Unmap buffer object
cudaGraphicsUnmapResources
(
1
,
&
pixelsVBO_CUDA
,
0
);
...
...
@@ -67,4 +74,9 @@ void GlWidget::paintGL()
// Render from buffer object
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glDrawPixels
(
camera
.
width
(),
camera
.
height
(),
GL_RGBA
,
GL_UNSIGNED_BYTE
,
0
);
timer
.
end
();
fps
=
1.
F
/
timer
.
get
();
std
::
cout
<<
"FPS = "
<<
fps
<<
std
::
endl
;
emit
fps_updated
(
fps
);
timer
.
start
();
}
miklos/project_integration_gui/glwidget.h
View file @
4b389e4c
...
...
@@ -3,6 +3,7 @@
#include <QGLWidget>
#include <QGLFunctions>
#include "timer.h"
class
GlWidget
:
public
QGLWidget
{
...
...
@@ -13,6 +14,14 @@ public:
~
GlWidget
();
QSize
sizeHint
()
const
;
float
*
d_in
;
float
lambda
;
float
sigma
;
float
tau
;
int
N
;
float
c1
;
float
c2
;
Timer
timer
;
float
fps
;
protected
:
void
initializeGL
();
...
...
@@ -20,6 +29,9 @@ protected:
private
:
QGLFunctions
gl
;
signals
:
void
fps_updated
(
float
fps
);
};
#endif // GLWIDGET_H
miklos/project_integration_gui/hello-opengl.pro.user
View file @
4b389e4c
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 2.7.1, 2014-03-28T1
6:17:01
. -->
<!-- Written by QtCreator 2.7.1, 2014-03-28T1
7:03:36
. -->
<qtcreator>
<data>
<variable>
ProjectExplorer.Project.ActiveTarget
</variable>
...
...
@@ -224,7 +224,7 @@
</valuelist>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
hello-opengl
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QByteArray"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.Qt4RunConfiguration:/home/gkukreja/workspace/cuda_lab/miklos/project_integration/hello-opengl.pro
</value>
<value
type=
"QByteArray"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.Qt4RunConfiguration:/home/gkukreja/workspace/cuda_lab/miklos/project_integration
_gui
/hello-opengl.pro
</value>
<value
type=
"int"
key=
"Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase"
>
2
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"
></value>
<value
type=
"QString"
key=
"Qt4ProjectManager.Qt4RunConfiguration.ProFile"
>
hello-opengl.pro
</value>
...
...
miklos/project_integration_gui/kernel.cu
View file @
4b389e4c
#include "kernel.h"
#include "timer.h"
//
#include "timer.h"
#include <algorithm>
#include <stdio.h>
...
...
@@ -133,27 +133,19 @@ void allocate_device_memory(float *d_in, size_t w, size_t h)
}
void executeKernel(float *d_U, void *d_out, size_t w, size_t h)
void executeKernel(float *d_U, void *d_out, size_t w, size_t h
, float lambda, float sigma, float tau, int N, float c1, float c2
)
{
// float *d_U = reinterpret_cast<float *>(d_in);
uchar4 *pixel = reinterpret_cast<uchar4 *>(d_out);
static Timer timer;
timer.end();
printf("time: %.2fms (%.2f FPS)\n", timer.get() * 1E3F, 1.F / timer.get());
timer.start();
//
static Timer timer;
//
timer.end();
//
printf("time: %.2fms (%.2f FPS)\n", timer.get() * 1E3F, 1.F / timer.get());
//
timer.start();
dim3 dimBlock(32, 16);
dim3 dimGrid = make_grid(dim3(w, h, 1), dimBlock);
// set parameters manually here
float lambda = 1.0;
float sigma = 0.4;
float tau = 0.4;
int N = 160;
float c1 = 1.0;
float c2 = 0.00;
size_t imageBytes = w*h*sizeof(float);
cudaMemcpy(d_T, d_U, imageBytes, cudaMemcpyDeviceToDevice);
cudaMemset(d_Xi, 0, imageBytes);
...
...
miklos/project_integration_gui/kernel.h
View file @
4b389e4c
...
...
@@ -4,6 +4,6 @@
#include <stdlib.h>
extern
"C"
void
allocate_device_memory
(
float
*
d_in
,
size_t
width
,
size_t
height
);
extern
"C"
void
executeKernel
(
float
*
d_
in
,
void
*
d_out
,
size_t
width
,
size_t
height
);
extern
"C"
void
executeKernel
(
float
*
d_
U
,
void
*
d_out
,
size_t
w
,
size_t
h
,
float
lambda
,
float
sigma
,
float
tau
,
int
N
,
float
c1
,
float
c2
);
#endif // KERNEL_H
miklos/project_integration_gui/mainwindow.cpp
View file @
4b389e4c
...
...
@@ -28,7 +28,35 @@ int MainWindow::init()
QObject
::
connect
(
&
camera
,
SIGNAL
(
newFrame
()),
ui
->
widget
,
SLOT
(
updateGL
()));
allocate_device_memory
(
ui
->
widget
->
d_in
,
camera
.
width
(),
camera
.
height
());
QObject
::
connect
(
ui
->
widget
,
SIGNAL
(
fps_updated
(
float
)),
this
,
SLOT
(
update_fps
(
float
)));
camera
.
start
();
return
0
;
}
void
MainWindow
::
on_spinBox_valueChanged
(
int
arg1
)
{
ui
->
widget
->
N
=
arg1
;
}
void
MainWindow
::
on_doubleSpinBox_3_valueChanged
(
double
arg1
)
{
ui
->
widget
->
lambda
=
arg1
;
}
void
MainWindow
::
on_doubleSpinBox_4_valueChanged
(
double
arg1
)
{
ui
->
widget
->
c2
=
arg1
;
}
void
MainWindow
::
on_doubleSpinBox_5_valueChanged
(
double
arg1
)
{
ui
->
widget
->
c1
=
arg1
;
}
void
MainWindow
::
update_fps
(
float
fps
)
{
ui
->
plainTextEdit
->
appendPlainText
(
QString
::
number
((
double
)
fps
));
}
miklos/project_integration_gui/mainwindow.h
View file @
4b389e4c
...
...
@@ -17,6 +17,19 @@ public:
int
init
();
public
slots
:
void
update_fps
(
float
fps
);
private
slots
:
void
on_spinBox_valueChanged
(
int
arg1
);
void
on_doubleSpinBox_3_valueChanged
(
double
arg1
);
void
on_doubleSpinBox_4_valueChanged
(
double
arg1
);
void
on_doubleSpinBox_5_valueChanged
(
double
arg1
);
private
:
Ui
::
MainWindow
*
ui
;
};
...
...
miklos/project_integration_gui/mainwindow.ui
View file @
4b389e4c
...
...
@@ -11,7 +11,7 @@
</rect>
</property>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"
Fixed"
vsizetype=
"Fix
ed"
>
<sizepolicy
hsizetype=
"
Preferred"
vsizetype=
"Preferr
ed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
...
...
@@ -54,16 +54,58 @@
</size>
</property>
</widget>
<widget
class=
"QWidget"
name=
"
layoutWidget
"
>
<widget
class=
"QWidget"
name=
""
>
<property
name=
"geometry"
>
<rect>
<x>
700
</x>
<y>
50
</y>
<width>
1
3
1
</width>
<height>
48
1
</height>
<y>
32
</y>
<width>
1
5
1
</width>
<height>
50
1
</height>
</rect>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QLabel"
name=
"label_4"
>
<property
name=
"maximumSize"
>
<size>
<width>
50
</width>
<height>
16777215
</height>
</size>
</property>
<property
name=
"text"
>
<string>
FPS
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignCenter
</set>
</property>
</widget>
</item>
<item>
<widget
class=
"QPlainTextEdit"
name=
"plainTextEdit"
>
<property
name=
"enabled"
>
<bool>
true
</bool>
</property>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"maximumSize"
>
<size>
<width>
100
</width>
<height>
29
</height>
</size>
</property>
<property
name=
"readOnly"
>
<bool>
true
</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer
name=
"verticalSpacer"
>
<property
name=
"orientation"
>
...
...
@@ -78,9 +120,9 @@
</spacer>
</item>
<item>
<widget
class=
"QLabel"
name=
"label_
4
"
>
<widget
class=
"QLabel"
name=
"label_
7
"
>
<property
name=
"text"
>
<string>
FPS
</string>
<string>
Itertions
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignCenter
</set>
...
...
@@ -88,12 +130,22 @@
</widget>
</item>
<item>
<widget
class=
"QLCDNumber"
name=
"lcdNumber"
/>
<widget
class=
"QSpinBox"
name=
"spinBox"
>
<property
name=
"maximum"
>
<number>
500
</number>
</property>
<property
name=
"singleStep"
>
<number>
5
</number>
</property>
<property
name=
"value"
>
<number>
160
</number>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"label_
3
"
>
<widget
class=
"QLabel"
name=
"label_
6
"
>
<property
name=
"text"
>
<string>
Alpha
</string>
<string>
c1
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignCenter
</set>
...
...
@@ -101,12 +153,22 @@
</widget>
</item>
<item>
<widget
class=
"QDoubleSpinBox"
name=
"doubleSpinBox_3"
/>
<widget
class=
"QDoubleSpinBox"
name=
"doubleSpinBox_5"
>
<property
name=
"maximum"
>
<double>
1.000000000000000
</double>
</property>
<property
name=
"singleStep"
>
<double>
0.100000000000000
</double>
</property>
<property
name=
"value"
>
<double>
1.000000000000000
</double>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"label_
2
"
>
<widget
class=
"QLabel"
name=
"label_
5
"
>
<property
name=
"text"
>
<string>
Beta
</string>
<string>
c2
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignCenter
</set>
...
...
@@ -114,12 +176,19 @@
</widget>
</item>
<item>
<widget
class=
"QDoubleSpinBox"
name=
"doubleSpinBox_2"
/>
<widget
class=
"QDoubleSpinBox"
name=
"doubleSpinBox_4"
>
<property
name=
"maximum"
>
<double>
1.000000000000000
</double>
</property>
<property
name=
"singleStep"
>
<double>
0.100000000000000
</double>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"label"
>
<widget
class=
"QLabel"
name=
"label
_3
"
>
<property
name=
"text"
>
<string>
Gam
a
</string>
<string>
lambd
a
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignCenter
</set>
...
...
@@ -127,12 +196,15 @@
</widget>
</item>
<item>
<widget
class=
"QDoubleSpinBox"
name=
"doubleSpinBox"
/>
</item>
<item>
<widget
class=
"QPushButton"
name=
"pushButton_2"
>
<property
name=
"text"
>
<string>
&
Refresh
</string>
<widget
class=
"QDoubleSpinBox"
name=
"doubleSpinBox_3"
>
<property
name=
"maximum"
>
<double>
1.000000000000000
</double>
</property>
<property
name=
"singleStep"
>
<double>
0.100000000000000
</double>
</property>
<property
name=
"value"
>
<double>
1.000000000000000
</double>
</property>
</widget>
</item>
...
...
@@ -146,16 +218,6 @@
</layout>
</widget>
</widget>
<widget
class=
"QMenuBar"
name=
"menubar"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
865
</width>
<height>
23
</height>
</rect>
</property>
</widget>
<widget
class=
"QStatusBar"
name=
"statusbar"
/>
</widget>
<customwidgets>
...
...
@@ -164,9 +226,6 @@
<extends>
QWidget
</extends>
<header>
glwidget.h
</header>
<container>
1
</container>
<slots>
<signal>
update_param()
</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
...
...
@@ -178,8 +237,8 @@
<slot>
close()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
74
2
</x>
<y>
5
43
</y>
<x>
74
3
</x>
<y>
5
29
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
713
</x>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment