Skip to content

Commit

Permalink
Allow more nproc tests in one run
Browse files Browse the repository at this point in the history
  • Loading branch information
liuhao-cn committed Sep 5, 2022
1 parent ffaeceb commit 4044798
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 33 deletions.
38 changes: 11 additions & 27 deletions scripts/nproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,11 @@
import sys as sys
import os

# default parameters
nside = 64
nsim = 2000
n_proc = 8
niter = 3
compare = True


# the command line input will overwrite the defaults
if len(sys.argv)>1:
nside = int(sys.argv[1])
if len(sys.argv)>2:
nsim = int(sys.argv[2])
if len(sys.argv)>3:
n_proc = int(sys.argv[3])
if len(sys.argv)>4:
niter = int(sys.argv[4])
nside = int(sys.argv[1])
nsim = int(sys.argv[2])
n_proc = int(sys.argv[3])
niter = int(sys.argv[4])


os.environ["OMP_NUM_THREADS"] = str(n_proc) # export OMP_NUM_THREADS=4
Expand Down Expand Up @@ -54,26 +42,17 @@
npix = 12 * nside ** 2

def test_t2alm(seed=23333):
# print('Testing t2alm...')

np.random.seed(seed)
# maps = np.asfortranarray(np.random.rand(npix, nsim))
maps = np.ones([npix, nsim], dtype=np.double, order='F')
alms = np.ones([nsim, lmax+1, lmax+1], dtype=np.double, order='F')

start = time.time()
sht = SHT.SHT(nside, lmax, nsim, niter)
end = time.time() - start
# print('Time cost for memory initialization is ' + str(end))

start = time.time()
sht.t2alm(maps, alms_in=alms)
end1 = time.time() - start
# print('Calculation time cost for fastSHT is ' + str(end / nrep))

#print(time.sleep(10))
if(compare==False):
return

start = time.time()
for i in range(nsim):
Expand All @@ -84,5 +63,10 @@ def test_t2alm(seed=23333):

end1, end2 = test_t2alm()

print("t2alm: Nside = %i, Nsim = %i, n_proc = %2i, fastSHT-CPU = %6.2f, healpy = %6.2f"
%(nside, nsim, n_proc, end1, end2))

filename = '%4.4i-%5.5i.txt' %(nside, nsim)
with open(filename, 'a') as f:
sys.stdout = f
print("t2alm: Nside = %i, Nsim = %i, n_proc = %2i, fastSHT-CPU = %6.2f, healpy = %6.2f"
%(nside, nsim, n_proc, end1, end2))

49 changes: 43 additions & 6 deletions scripts/run_nproc.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,44 @@
#!/bin/bash
#!/bin/bash
niter=3

# syntax:
# ./run_nproc.sh nside nsim nproc_start nproc_end nproc_step
for(( i=$3; i<=$4; i=i+$5 )); do
python nproc.py $1 $2 $i 3
done
# test 1
nside=64
nsim=40000
for(( i=8; i<=48; i=i+4 )); do
python nproc.py $nside $nsim $i $niter
done

# test 2
nside=128
nsim=20000
for(( i=8; i<=48; i=i+4 )); do
python nproc.py $nside $nsim $i $niter
done

# test 3
nside=256
nsim=8000
for(( i=8; i<=48; i=i+4 )); do
python nproc.py $nside $nsim $i $niter
done

# test 4
nside=256
nsim=16000
for(( i=8; i<=48; i=i+4 )); do
python nproc.py $nside $nsim $i $niter
done

# test 5
nside=512
nsim=4000
for(( i=8; i<=48; i=i+4 )); do
python nproc.py $nside $nsim $i $niter
done

# test 6
nside=1024
nsim=2000
for(( i=8; i<=48; i=i+4 )); do
python nproc.py $nside $nsim $i $niter
done

0 comments on commit 4044798

Please sign in to comment.