-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Faster almxfl? #273
Comments
What shape arrays is this for? Do you have a test case? |
Sorry I did not see this, I will make a test case |
from optweight import alm_c_utils
from pixell import curvedsky
import numpy as np
import time
lmax = 10800
ainfo = curvedsky.alm_info(lmax=lmax)
# double prec, matmul
ps = np.eye(6)[..., None]
ps = np.tile(ps, (1, 1, lmax+1))
pixell_times = []
optweight_times = []
lfilter = np.random.randn(*(6, 6, lmax+1)).astype(np.float64)
alm = curvedsky.rand_alm(ps, lmax=lmax).astype(np.complex128)
out = np.empty_like(alm)
for i in range(10):
t0 = time.time()
ainfo.lmul(alm, lfilter, out=out)
pixell_times.append(time.time() - t0)
t0 = time.time()
alm_c_utils.lmul(alm, lfilter, ainfo, alm_out=out)
optweight_times.append(time.time() - t0)
print('double prec, matmul')
print(f'pixell time = {np.mean(pixell_times):0.4f} +/- {np.std(pixell_times):0.4f}')
print(f'optweight time = {np.mean(optweight_times):0.4f} +/- {np.std(optweight_times):0.4f}')
# single prec, matmul
pixell_times = []
optweight_times = []
lfilter = np.random.randn(*(6, 6, lmax+1)).astype(np.float32)
alm = curvedsky.rand_alm(ps, lmax=lmax).astype(np.complex64)
out = np.empty_like(alm)
for i in range(10):
t0 = time.time()
ainfo.lmul(alm, lfilter, out=out)
pixell_times.append(time.time() - t0)
t0 = time.time()
alm_c_utils.lmul(alm, lfilter, ainfo, alm_out=out)
optweight_times.append(time.time() - t0)
print('single prec, matmul')
print(f'pixell time = {np.mean(pixell_times):0.4f} +/- {np.std(pixell_times):0.4f}')
print(f'optweight time = {np.mean(optweight_times):0.4f} +/- {np.std(optweight_times):0.4f}')
lmax = 21600
ainfo = curvedsky.alm_info(lmax=lmax)
# double prec, scalar
ps = np.ones(lmax+1)
pixell_times = []
optweight_times = []
lfilter = np.random.randn(lmax+1).astype(np.float64)
alm = curvedsky.rand_alm(ps, lmax=lmax).astype(np.complex128)
out = np.empty_like(alm)
for i in range(10):
t0 = time.time()
ainfo.lmul(alm, lfilter, out=out)
pixell_times.append(time.time() - t0)
t0 = time.time()
alm_c_utils.lmul(alm[None], lfilter[None], ainfo, alm_out=out[None]) # optweight needs mat
optweight_times.append(time.time() - t0)
print('double prec, scalar')
print(f'pixell time = {np.mean(pixell_times):0.4f} +/- {np.std(pixell_times):0.4f}')
print(f'optweight time = {np.mean(optweight_times):0.4f} +/- {np.std(optweight_times):0.4f}')
# single prec, scalar
pixell_times = []
optweight_times = []
lfilter = np.random.randn(lmax+1).astype(np.float32)
alm = curvedsky.rand_alm(ps, lmax=lmax).astype(np.complex64)
out = np.empty_like(alm)
for i in range(10):
t0 = time.time()
ainfo.lmul(alm, lfilter, out=out)
pixell_times.append(time.time() - t0)
t0 = time.time()
alm_c_utils.lmul(alm[None], lfilter[None], ainfo, alm_out=out[None]) # optweight needs mat
optweight_times.append(time.time() - t0)
print('single prec, scalar')
print(f'pixell time = {np.mean(pixell_times):0.4f} +/- {np.std(pixell_times):0.4f}')
print(f'optweight time = {np.mean(optweight_times):0.4f} +/- {np.std(optweight_times):0.4f}') gives
Obviously the compilation of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
optweight.alm_c_utils.lmul
is allegedly 80% faster thanpixell.curvedsky.almxfl
https://github.com/AdriJD/optweight/blob/0b286eba73d712b4b3a54ebcdd0371de495432d0/cython/alm_c_utils.pyx#L157
@amaurea @AdriJD keeping this open until we understand this / incorporate Adri's version into pixell
The text was updated successfully, but these errors were encountered: