Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Multicore GPU programming
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ylva Selling
Multicore GPU programming
Commits
3f84511c
Commit
3f84511c
authored
4 years ago
by
dansa828
Browse files
Options
Downloads
Patches
Plain Diff
update
parent
2e6d1189
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Lab5/filter.cu
+7
-7
7 additions, 7 deletions
Lab5/filter.cu
Lab5/filteroptimized.cu
+2
-2
2 additions, 2 deletions
Lab5/filteroptimized.cu
with
9 additions
and
9 deletions
Lab5/filter.cu
+
7
−
7
View file @
3f84511c
...
...
@@ -35,7 +35,7 @@
__global__
void
filter
(
unsigned
char
*
image
,
unsigned
char
*
out
,
const
unsigned
int
imagesizex
,
const
unsigned
int
imagesizey
,
const
int
kernelsizex
,
const
int
kernelsizey
)
{
{
// map from blockIdx to pixel position
int
x
=
blockIdx
.
x
*
blockDim
.
x
+
threadIdx
.
x
;
int
y
=
blockIdx
.
y
*
blockDim
.
y
+
threadIdx
.
y
;
...
...
@@ -44,18 +44,18 @@ __global__ void filter(unsigned char *image, unsigned char *out, const unsigned
unsigned
int
sumx
,
sumy
,
sumz
;
int
divby
=
(
2
*
kernelsizex
+
1
)
*
(
2
*
kernelsizey
+
1
);
// Works for box filters only!
if
(
x
<
imagesizex
&&
y
<
imagesizey
)
// If inside image
{
// Filter kernel (simple box filter)
sumx
=
0
;
sumy
=
0
;
sumz
=
0
;
for
(
dy
=-
kernelsizey
;
dy
<=
kernelsizey
;
dy
++
)
for
(
dx
=-
kernelsizex
;
dx
<=
kernelsizex
;
dx
++
)
for
(
dx
=-
kernelsizex
;
dx
<=
kernelsizex
;
dx
++
)
{
// Use max and min to avoid branching!
int
yy
=
min
(
max
(
y
+
dy
,
0
),
imagesizey
-
1
);
int
xx
=
min
(
max
(
x
+
dx
,
0
),
imagesizex
-
1
);
sumx
+=
image
[((
yy
)
*
imagesizex
+
(
xx
))
*
3
+
0
];
sumy
+=
image
[((
yy
)
*
imagesizex
+
(
xx
))
*
3
+
1
];
sumz
+=
image
[((
yy
)
*
imagesizex
+
(
xx
))
*
3
+
2
];
...
...
@@ -101,7 +101,7 @@ void computeImages(int kernelsizex, int kernelsizey)
// Display images
void
Draw
()
{
// Dump the whole picture onto the screen.
// Dump the whole picture onto the screen.
glClearColor
(
0.0
,
0.0
,
0.0
,
1.0
);
glClear
(
GL_COLOR_BUFFER_BIT
);
...
...
@@ -123,7 +123,7 @@ void Draw()
}
// Main program, inits
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
glutInit
(
&
argc
,
argv
);
glutInitDisplayMode
(
GLUT_SINGLE
|
GLUT_RGBA
);
...
...
@@ -143,7 +143,7 @@ int main( int argc, char** argv)
ResetMilli
();
computeImages
(
2
,
2
);
printf
(
"%s%f
\n
"
,
"Measured time (ms): "
,
(
float
)
GetMicroseconds
()
*
0.001
);
// You can save the result to a file like this:
// writeppm("out.ppm", imagesizey, imagesizex, pixels);
...
...
This diff is collapsed.
Click to expand it.
Lab5/filteroptimized.cu
+
2
−
2
View file @
3f84511c
...
...
@@ -172,8 +172,8 @@ int main( int argc, char** argv)
ResetMilli
();
computeImages
(
2
,
2
);
computeImages
(
3
,
3
);
printf
(
"%s%f
\n
"
,
"Measured time (ms): "
,
(
float
)
GetMicroseconds
()
*
0.001
);
// You can save the result to a file like this:
// writeppm("out.ppm", imagesizey, imagesizex, pixels);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment