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
6a4ddb5e
Commit
6a4ddb5e
authored
Mar 27, 2014
by
Miklós Homolya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add precise Timer
parent
413830ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
2 deletions
+45
-2
kernel.cu
miklos/project_integration/kernel.cu
+8
-2
timer.h
miklos/project_integration/timer.h
+37
-0
No files found.
miklos/project_integration/kernel.cu
View file @
6a4ddb5e
#include "kernel.h"
#include "timer.h"
#include <algorithm>
#include <stdio.h>
template<typename T>
__device__ __host__ T min(T a, T b)
...
...
@@ -118,6 +121,11 @@ void executeKernel(void *d_in, void *d_out, size_t w, size_t h)
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();
dim3 dimBlock(32, 16);
dim3 dimGrid = make_grid(dim3(w, h, 1), dimBlock);
...
...
@@ -151,6 +159,4 @@ void executeKernel(void *d_in, void *d_out, size_t w, size_t h)
cudaFree(d_F);
cudaFree(d_Xi);
cudaFree(d_Xj);
// createVertices<<<dimGrid, dimBlock>>>(in, pixel, w, h);
}
miklos/project_integration/timer.h
0 → 100644
View file @
6a4ddb5e
#ifndef TIMER_H
#define TIMER_H
#include <time.h>
// measuring time
class
Timer
{
public
:
Timer
()
:
running
(
false
),
sec
(
0
)
{
}
void
start
()
{
clock_gettime
(
CLOCK_MONOTONIC
,
&
tStart
);
running
=
true
;
}
void
end
()
{
if
(
!
running
)
{
sec
=
0
;
return
;
}
struct
timespec
tEnd
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
tEnd
);
sec
=
(
tEnd
.
tv_sec
-
tStart
.
tv_sec
)
+
(
tEnd
.
tv_nsec
-
tStart
.
tv_nsec
)
*
1E-9
F
;
running
=
false
;
}
float
get
()
{
if
(
running
)
end
();
return
sec
;
}
private
:
struct
timespec
tStart
;
bool
running
;
float
sec
;
};
#endif // TIMER_H
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