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
e3439d09
Commit
e3439d09
authored
2 years ago
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
47d6d87f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#24741
passed
2 years ago
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Python/cupi.py
+28
-0
28 additions, 0 deletions
Python/cupi.py
with
28 additions
and
0 deletions
Python/cupi.py
0 → 100644
+
28
−
0
View file @
e3439d09
#
# cupi.py
# Neil Gershenfeld 1/23/17
# calculation of pi by a CuPy sum
# pi = 3.14159265358979323846
#
import
numpy
as
np
import
cupy
as
cp
import
time
NPTS
=
100000000
start_time
=
time
.
time
()
i
=
np
.
arange
(
1
,(
NPTS
+
1
),
dtype
=
np
.
float64
)
pi
=
np
.
sum
(
0.5
/
((
i
-
0.75
)
*
(
i
-
.
25
)))
end_time
=
time
.
time
()
mflops
=
NPTS
*
5.0
/
(
1.0e6
*
(
end_time
-
start_time
))
print
(
"
NPTS = %d, pi = %f
"
%
(
NPTS
,
pi
))
print
(
"
time = %f, estimated NumPy MFlops = %f
"
%
(
end_time
-
start_time
,
mflops
))
NPTS
=
100000000
start_time
=
time
.
time
()
i
=
cp
.
arange
(
1
,(
NPTS
+
1
),
dtype
=
cp
.
float64
)
pi
=
cp
.
sum
(
0.5
/
((
i
-
0.75
)
*
(
i
-
.
25
)))
end_time
=
time
.
time
()
mflops
=
NPTS
*
5.0
/
(
1.0e6
*
(
end_time
-
start_time
))
print
(
"
NPTS = %d, pi = %f
"
%
(
NPTS
,
pi
))
print
(
"
time = %f, estimated CuPy MFlops = %f
"
%
(
end_time
-
start_time
,
mflops
))
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