- C++ Compiler: GCC or Clang (C++14 or higher required).
- OpenMP:
# 1. Create and activate a virtual environment
python -m venv env
source env/bin/activate
# 2. Install dependencies for all workshop stages
pip install -r requirements.txtLaunch Jupyter from the root directory of this repository and install the env as a usable kernel:
source env/bin/activate
python -m ipykernel install --user --name=phi-4-env --display-name="Phi4"
jupyter notebookNavigate through the folders and open the notebooks in order:
- 01-Python/01_notebook.ipynb
- 02-Python-Pybind/02_notebook.ipynb
- 03-Python-Pybind-OMP/03_notebook.ipynb
C bindings can be compiled in each respective folder but also in the notebook directly
!makeCompare the performance of each respective implementation. (Already found in notebook)
import time
import matplotlib.pyplot as plt
import pandas as pd
# 1. Initialize
L_scaling = [2**i for i in range(6,14)]
sweep_time = []
for L in L_scaling:
sim = Lattice(L=L, kappa=0.4, lambda_=0.1)
N_updates = 100
# 2. Run and measure
start_time = time.perf_counter()
for i in range(N_updates):
sim.update()
end_time = time.perf_counter()
sweep_time.append((end_time - start_time)/N_updates)
df_results = pd.DataFrame({
"L": L_scaling,
"SweepTime_Seconds": sweep_time
})
df_results["Model"] = "OpenMP"
print(df_results.to_markdown(index=False))
df_results.to_csv("performance_openmp.csv", index=False)