Skip to content

Commit d1ca4dc

Browse files
committed
Update profiling.py
1 parent a71a213 commit d1ca4dc

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

scripts/profiling.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
import time
1010
import pandas as pd
1111
from mpi4py import MPI
12-
12+
from scipy.sparse.linalg import eigsh
13+
from numpy.linalg import eigh
1314

1415
# Seed for reproducibility
15-
seed = 8422
16-
random.seed(seed)
17-
np.random.seed(seed)
16+
#seed = 8422
17+
#random.seed(seed)
18+
#np.random.seed(seed)
1819

1920
# Some MPI info
2021
comm = MPI.COMM_WORLD
@@ -54,10 +55,10 @@
5455

5556
# Now we start profiling. Notice that the only function that requires MPI is the one that is not profiled within a 'if rank==0' statement.
5657

57-
# @mpi_profiled
58-
# def profiled_divide_et_impera(A):
59-
# from pyclassify import divide_et_impera # avoid circular import
60-
# return divide_et_impera(A)
58+
@mpi_profiled
59+
def profiled_divide_et_impera(A, comm):
60+
from pyclassify import compute_eigs_parallel # avoid circular import
61+
return compute_eigs_parallel(A, comm)
6162

6263
results = {}
6364

@@ -66,14 +67,13 @@
6667
_ = profile_serial(power_method_numba, A.toarray())
6768
results["power_method"] = profile_serial(power_method, A)
6869
results["power_method_numba"] = profile_serial(power_method_numba, A.toarray())
69-
# results["QR"] = profile_serial(QR, A)
70+
results["eigh"] = profile_serial(eigh, A.toarray())
71+
results["eigsh"] = profile_serial(eigsh, A)
7072

71-
# mpi_result_QR = profiled_QR(A)
72-
# mpi_result_divide = profiled_divide_et_impera(A)
73+
mpi_result_divide = profiled_divide_et_impera(A.toarray(), comm)
7374

74-
# if rank == 0:
75-
# results["QR"] = mpi_result_QR
76-
# results["divide_et_impera"] = mpi_result_divide
75+
if rank == 0:
76+
results["divide_et_impera"] = mpi_result_divide
7777

7878

7979
# Now we just save to CSV.

shell/profile.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
11
#!/bin/bash
2+
3+
# Ranges over which we iterate
4+
n_processes=(1 2) # 4 8 16)
5+
matrix_sizes=(10 50 100 500 1000)
6+
7+
CONFIG_FILE="experiments/config_profiling.yaml"
8+
9+
# Backup the original config
10+
cp $CONFIG_FILE ${CONFIG_FILE}.bak
11+
12+
for dim in "${matrix_sizes[@]}"; do
13+
sed -i "s/^dim: .*/dim: $dim/" $CONFIG_FILE
14+
15+
for np in "${n_processes[@]}"; do
16+
echo "Running with size=$dim and n_processes=$np"
17+
mpirun -np $np python scripts/profiling.py
18+
done
19+
done
20+
21+
# Restore the original config file
22+
mv ${CONFIG_FILE}.bak $CONFIG_FILE

0 commit comments

Comments
 (0)