Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pub
pi
Commits
73d4808e
Commit
73d4808e
authored
Feb 29, 2020
by
Neil Gershenfeld
Browse files
wip
parent
7ecacb5c
Pipeline
#5078
passed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Python/numbapig.py
View file @
73d4808e
...
...
@@ -36,6 +36,7 @@ def CUDA_reduce(arr,NPTS):
len
=
NPTS
>>
1
while
(
1
):
CUDA_sum
[
grid_size
,
block_size
](
arr
,
len
)
cuda
.
synchronize
()
len
=
len
>>
1
if
(
len
==
0
):
return
...
...
@@ -64,6 +65,7 @@ CUDA_result(arr,result)
#
start_time
=
time
.
time
()
init
[
grid_size
,
block_size
](
arr
)
cuda
.
synchronize
()
end_time
=
time
.
time
()
mflops
=
NPTS
*
4.0
/
(
1.0e6
*
(
end_time
-
start_time
))
print
(
"CUDA kernel array calculation:"
)
...
...
@@ -83,6 +85,7 @@ print(" time = %f, estimated MFlops = %f"%(end_time-start_time,mflops))
#
start_time
=
time
.
time
()
init
[
grid_size
,
block_size
](
arr
)
cuda
.
synchronize
()
pi
=
Numba_reduce
(
arr
)
end_time
=
time
.
time
()
mflops
=
NPTS
*
5.0
/
(
1.0e6
*
(
end_time
-
start_time
))
...
...
@@ -104,8 +107,10 @@ print(" time = %f, estimated MFlops = %f"%(end_time-start_time,mflops))
#
start_time
=
time
.
time
()
init
[
grid_size
,
block_size
](
arr
)
cuda
.
synchronize
()
CUDA_reduce
(
arr
,
NPTS
)
CUDA_result
(
arr
,
result
)
cuda
.
synchronize
()
end_time
=
time
.
time
()
pi
=
result
.
copy_to_host
()
mflops
=
NPTS
*
5.0
/
(
1.0e6
*
(
end_time
-
start_time
))
...
...
Write
Preview
Supports
Markdown
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