|
9 | 9 | import time
|
10 | 10 | import pandas as pd
|
11 | 11 | from mpi4py import MPI
|
12 |
| - |
| 12 | +from scipy.sparse.linalg import eigsh |
| 13 | +from numpy.linalg import eigh |
13 | 14 |
|
14 | 15 | # 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) |
18 | 19 |
|
19 | 20 | # Some MPI info
|
20 | 21 | comm = MPI.COMM_WORLD
|
|
54 | 55 |
|
55 | 56 | # 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.
|
56 | 57 |
|
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) |
61 | 62 |
|
62 | 63 | results = {}
|
63 | 64 |
|
|
66 | 67 | _ = profile_serial(power_method_numba, A.toarray())
|
67 | 68 | results["power_method"] = profile_serial(power_method, A)
|
68 | 69 | 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) |
70 | 72 |
|
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) |
73 | 74 |
|
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 |
77 | 77 |
|
78 | 78 |
|
79 | 79 | # Now we just save to CSV.
|
|
0 commit comments