Skip to content
Snippets Groups Projects
Commit e3439d09 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

wip

parent 47d6d87f
No related branches found
No related tags found
No related merge requests found
Pipeline #24741 passed
#
# 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))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment