Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cuda-lab-exercises
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pdc-summer-school
cuda-lab-exercises
Commits
b50e2800
Commit
b50e2800
authored
5 years ago
by
Steven
Browse files
Options
Downloads
Patches
Plain Diff
fix timer
parent
7ad66cb2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lab_1/C/lab01_ex2.cu
+2
-2
2 additions, 2 deletions
lab_1/C/lab01_ex2.cu
lab_2/C/lab02_ex3_6.cu
+6
-6
6 additions, 6 deletions
lab_2/C/lab02_ex3_6.cu
lab_2/Fortran/lab02_ex3_6_c.cu
+5
-5
5 additions, 5 deletions
lab_2/Fortran/lab02_ex3_6_c.cu
with
13 additions
and
13 deletions
lab_1/C/lab01_ex2.cu
+
2
−
2
View file @
b50e2800
...
...
@@ -25,9 +25,9 @@ float generate_hash(int n, float *y)
/**
* Helper method that calculates the elapsed time between two time intervals (in milliseconds).
*/
long
get_elapsed
(
tval
t0
,
tval
t1
)
double
get_elapsed
(
tval
t0
,
tval
t1
)
{
return
(
t1
.
tv_sec
-
t0
.
tv_sec
)
*
1000
+
(
t1
.
tv_usec
-
t0
.
tv_usec
)
/
1000
;
return
(
double
)
(
t1
.
tv_sec
-
t0
.
tv_sec
)
*
1000
.0L
+
(
double
)
(
t1
.
tv_usec
-
t0
.
tv_usec
)
/
1000
.0L
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
lab_2/C/lab02_ex3_6.cu
+
6
−
6
View file @
b50e2800
...
...
@@ -120,15 +120,15 @@ void checkCUDAError()
/**
* Calculates the elapsed time between two time intervals (in milliseconds).
*/
long
get_elapsed
(
tval
t0
,
tval
t1
)
double
get_elapsed
(
tval
t0
,
tval
t1
)
{
return
(
t1
.
tv_sec
-
t0
.
tv_sec
)
*
1000
+
(
t1
.
tv_usec
-
t0
.
tv_usec
)
/
1000
;
return
(
double
)
(
t1
.
tv_sec
-
t0
.
tv_sec
)
*
1000
.0L
+
(
double
)
(
t1
.
tv_usec
-
t0
.
tv_usec
)
/
1000
.0L
;
}
/**
* Stores the result image and prints a message.
*/
void
store_result
(
int
index
,
long
elapsed_cpu
,
long
elapsed_gpu
,
void
store_result
(
int
index
,
double
elapsed_cpu
,
double
elapsed_gpu
,
int
width
,
int
height
,
float
*
image
)
{
char
path
[
255
];
...
...
@@ -137,7 +137,7 @@ void store_result(int index, long elapsed_cpu, long elapsed_gpu,
writeBMPGrayscale
(
width
,
height
,
image
,
path
);
printf
(
"Step #%d Completed - Result stored in
\"
%s
\"
.
\n
"
,
index
,
path
);
printf
(
"Elapsed CPU: %
ld
ms / "
,
elapsed_cpu
);
printf
(
"Elapsed CPU: %
f
ms / "
,
elapsed_cpu
);
if
(
elapsed_gpu
==
0
)
{
...
...
@@ -145,7 +145,7 @@ void store_result(int index, long elapsed_cpu, long elapsed_gpu,
}
else
{
printf
(
"Elapsed GPU: %
ld
ms
\n
"
,
elapsed_gpu
);
printf
(
"Elapsed GPU: %
f
ms
\n
"
,
elapsed_gpu
);
}
}
...
...
@@ -310,7 +310,7 @@ int main(int argc, char **argv)
float
*
d_image_out
[
2
]
=
{
0
};
int
image_size
=
0
;
tval
t
[
2
]
=
{
0
};
long
elapsed
[
2
]
=
{
0
};
double
elapsed
[
2
]
=
{
0
};
dim3
grid
(
1
);
// The grid will be defined later
dim3
block
(
BLOCK_SIZE
,
BLOCK_SIZE
);
// The block size will not change
...
...
This diff is collapsed.
Click to expand it.
lab_2/Fortran/lab02_ex3_6_c.cu
+
5
−
5
View file @
b50e2800
...
...
@@ -120,15 +120,15 @@ void checkCUDAError()
/**
* Calculates the elapsed time between two time intervals (in milliseconds).
*/
long
get_elapsed
(
tval
t0
,
tval
t1
)
double
get_elapsed
(
tval
t0
,
tval
t1
)
{
return
(
t1
.
tv_sec
-
t0
.
tv_sec
)
*
1000
+
(
t1
.
tv_usec
-
t0
.
tv_usec
)
/
1000
;
return
(
double
)
(
t1
.
tv_sec
-
t0
.
tv_sec
)
*
1000
.0L
+
(
double
)
(
t1
.
tv_usec
-
t0
.
tv_usec
)
/
1000
.0L
;
}
/**
* Stores the result image and prints a message.
*/
void
store_result
(
int
index
,
long
elapsed_cpu
,
long
elapsed_gpu
,
void
store_result
(
int
index
,
double
elapsed_cpu
,
double
elapsed_gpu
,
int
width
,
int
height
,
float
*
image
)
{
char
path
[
255
];
...
...
@@ -137,7 +137,7 @@ void store_result(int index, long elapsed_cpu, long elapsed_gpu,
writeBMPGrayscale
(
width
,
height
,
image
,
path
);
printf
(
"Step #%d Completed - Result stored in
\"
%s
\"
.
\n
"
,
index
,
path
);
printf
(
"Elapsed CPU: %
ld
ms / "
,
elapsed_cpu
);
printf
(
"Elapsed CPU: %
f
ms / "
,
elapsed_cpu
);
if
(
elapsed_gpu
==
0
)
{
...
...
@@ -145,7 +145,7 @@ void store_result(int index, long elapsed_cpu, long elapsed_gpu,
}
else
{
printf
(
"Elapsed GPU: %
ld
ms
\n
"
,
elapsed_gpu
);
printf
(
"Elapsed GPU: %
f
ms
\n
"
,
elapsed_gpu
);
}
}
...
...
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