// HOW TO COMPILE ON MACOS // export CPPFLAGS="-I/opt/homebrew/opt/libomp/include" // export LDFLAGS="-L/opt/homebrew/opt/libomp/lib" // clang++ -std=c++17 -O3 -Xpreprocessor -fopenmp $CPPFLAGS main.cpp bench_funcs.cpp $LDFLAGS -lomp -o Ex5 // ./Ex5 #include #include #include #include #include "bench_funcs.h" using namespace std; using namespace std::chrono; int main() { size_t n = 200000; // FEM system size size_t maxit = 5000; double omega = 1.0; double tol = 1e-8; // show threads #pragma omp parallel { #pragma omp single cout << "Using " << omp_get_num_threads() << " OpenMP threads\n"; } CSR K; vector f, u; cout << "\nBuilding FEM system (parallel)\n"; auto t0 = high_resolution_clock::now(); build_fem_system(n, K, f); auto t1 = high_resolution_clock::now(); cout << "Assembly time = " << duration(t1 - t0).count() << " s\n"; cout << "\nRunning Jacobi solver (parallel)\n"; t0 = high_resolution_clock::now(); jacobi_csr_parallel(K, f, u, maxit, omega, tol); t1 = high_resolution_clock::now(); cout << "Jacobi time = " << duration(t1 - t0).count() << " s\n"; cout << "Done\n"; }