Skip to content

Commit 92a1e49

Browse files
committed
Addeng profile from bash file
1 parent 468ecb7 commit 92a1e49

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

scripts/profiling_memory_and_time.py

100644100755
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
from time import time
2020
from mpi4py import MPI
2121

22+
from line_profiler import LineProfiler
23+
profile = LineProfiler()
24+
profile.add_function(parallel_tridiag_eigen)
25+
2226

2327
seed = 1000
2428
np.random.seed(seed)
@@ -99,11 +103,14 @@
99103
proc = psutil.Process()
100104
mem_before = proc.memory_info().rss / 1024 / 1024 # MB
101105
time_before_parallel = time()
102-
106+
profile.enable()
103107
eigvals, eigvecs = parallel_tridiag_eigen(
104108
diag, off_diag, comm=comm, min_size=1, tol_factor=1e-10
105109
)
106-
110+
profile.disable()
111+
profile_filename = f"Profiling_files/profile_rank{comm.Get_rank()}.lprof"
112+
with open(profile_filename, "w") as f:
113+
profile.print_stats(stream=f)
107114
time_after_parallel = time()
108115
gc.collect()
109116
mem_after = proc.memory_info().rss / 1024 / 1024

shell/time_profile.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4+
python_script="$SCRIPT_DIR/../scripts/profiling_memory_and_time.py"
5+
profiling_files="$SCRIPT_DIR/../Profiling_files/"*
6+
7+
echo "Cleaning the Profiling_files folder"
8+
rm -f $profiling_files
9+
10+
echo "Running with $1 process(es)"
11+
mpirun -np "$1" python "$python_script"

src/pyclassify/parallel_tridiag_eigen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def find_interval_extreme(total_dimension, n_processor):
4949
return counts, displs
5050

5151

52-
@profile
52+
#@profile
5353
def parallel_tridiag_eigen(
5454
diag,
5555
off,

0 commit comments

Comments
 (0)