Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pub
pi
Commits
d913aa21
Commit
d913aa21
authored
Oct 24, 2021
by
Neil Gershenfeld
Browse files
wip
parent
d6068c8f
Pipeline
#16409
passed with stage
in 1 second
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CUDA/cudapi.cu
View file @
d913aa21
...
...
@@ -35,7 +35,7 @@ void reduce(double *arr) {
uint64_t
len
=
npts
>>
1
;
while
(
1
)
{
reduce_sum
<<<
blocks
,
threads
>>>
(
arr
,
len
);
cudaCheck
(
"reduce"
);
cudaCheck
(
"reduce
_sum
"
);
len
=
len
>>
1
;
if
(
len
==
0
)
return
;
...
...
@@ -50,10 +50,12 @@ int main(void) {
cudaCheck
(
"init"
);
reduce
(
darr
);
cudaDeviceSynchronize
();
cudaCheck
(
"cudaDeviceSynchronize"
);
auto
tend
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
dt
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
tend
-
tstart
).
count
();
auto
mflops
=
npts
*
nloop
*
5.0
/
dt
;
cudaMemcpy
(
harr
,
darr
,
8
,
cudaMemcpyDeviceToHost
);
cudaCheck
(
"cudaMemcpy"
);
printf
(
"npts = %ld, nloop = %ld, pi = %lf
\n
"
,
npts
,
nloop
,
harr
[
0
]);
printf
(
"time = %f, estimated MFlops = %f
\n
"
,
1e-6
*
dt
,
mflops
);
cudaFree
(
darr
);
...
...
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