Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pi
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
pi
Commits
d913aa21
Commit
d913aa21
authored
3 years ago
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
d6068c8f
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#16409
passed
3 years ago
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
CUDA/cudapi.cu
+3
-1
3 additions, 1 deletion
CUDA/cudapi.cu
with
3 additions
and
1 deletion
CUDA/cudapi.cu
+
3
−
1
View file @
d913aa21
...
@@ -35,7 +35,7 @@ void reduce(double *arr) {
...
@@ -35,7 +35,7 @@ void reduce(double *arr) {
uint64_t
len
=
npts
>>
1
;
uint64_t
len
=
npts
>>
1
;
while
(
1
)
{
while
(
1
)
{
reduce_sum
<<<
blocks
,
threads
>>>
(
arr
,
len
);
reduce_sum
<<<
blocks
,
threads
>>>
(
arr
,
len
);
cudaCheck
(
"reduce"
);
cudaCheck
(
"reduce
_sum
"
);
len
=
len
>>
1
;
len
=
len
>>
1
;
if
(
len
==
0
)
if
(
len
==
0
)
return
;
return
;
...
@@ -50,10 +50,12 @@ int main(void) {
...
@@ -50,10 +50,12 @@ int main(void) {
cudaCheck
(
"init"
);
cudaCheck
(
"init"
);
reduce
(
darr
);
reduce
(
darr
);
cudaDeviceSynchronize
();
cudaDeviceSynchronize
();
cudaCheck
(
"cudaDeviceSynchronize"
);
auto
tend
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
tend
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
dt
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
tend
-
tstart
).
count
();
auto
dt
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
tend
-
tstart
).
count
();
auto
mflops
=
npts
*
nloop
*
5.0
/
dt
;
auto
mflops
=
npts
*
nloop
*
5.0
/
dt
;
cudaMemcpy
(
harr
,
darr
,
8
,
cudaMemcpyDeviceToHost
);
cudaMemcpy
(
harr
,
darr
,
8
,
cudaMemcpyDeviceToHost
);
cudaCheck
(
"cudaMemcpy"
);
printf
(
"npts = %ld, nloop = %ld, pi = %lf
\n
"
,
npts
,
nloop
,
harr
[
0
]);
printf
(
"npts = %ld, nloop = %ld, pi = %lf
\n
"
,
npts
,
nloop
,
harr
[
0
]);
printf
(
"time = %f, estimated MFlops = %f
\n
"
,
1e-6
*
dt
,
mflops
);
printf
(
"time = %f, estimated MFlops = %f
\n
"
,
1e-6
*
dt
,
mflops
);
cudaFree
(
darr
);
cudaFree
(
darr
);
...
...
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