-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: Integrate open mp parallelization #80
base: v2c
Are you sure you want to change the base?
Draft: Integrate open mp parallelization #80
Conversation
Great work thanks! |
adfe611
to
79aab2c
Compare
Yes! I am adding them, i had a meeting with Geneviève to try to fix the problem with the CI (in the addBenchmarkTest and intergrateOpenMPParallelization branches) |
1 similar comment
Yes! I am adding them, i had a meeting with Geneviève to try to fix the problem with the CI (in the addBenchmarkTest and intergrateOpenMPParallelization branches) |
This PR adds a pragma to the alternativeRouting function before the foor loop. This PR also assesses the duration of the algorithm with and without the pragma using the benchmark test. (Source: https://www.geeksforgeeks.org/openmp-hello-world-program/ and https://moodle.polymtl.ca/mod/folder/view.php?id=120285&fbclid=IwAR0y7hI2Sv7DfOnXAqDT5yRr2AnbXkax1gEkVVYimJuRf8ad7aPqVszXwcQ)
To test without or with parallelization simply comment or uncomment the pragma code in trRouting/connection_scan_algorithm/src/alternatives_routing.cpp:
To reproduce these results, make sure to add -fopenmp after every "g++" in the Makefiles...
Note: This is temporary, normally the -fopenmp will be added in the Makefile.am (and pushed on the repo) and the right Makefile will be generated without needing to be added by every user in their local Makefile.
It is necessary to add a symbolic link to the cache in the following folders :
to run benchmarks: trRouting/tests/connection_scan_algorithm/cache
to debug: trRouting/cache
To debug, a launch.json file has to be added to specify the debug configuration. Finally, these tests have been made for the montreal map, for a different location, the longitude and latitude coordinates of origin and destination need to be changed in the transition app form and the trRouting/tests/connection_scan_algorithm/benchmark_CSA_test.cpp (line 130 and 133).
Results by starting TrRouting in debug mode and using the Transition web app :
Duration without parallelization :
Duration with parallelization:
To set the number of threads to X type in the terminal 'export OMP_NUM_THREADS=X'
2 threads:
3 threads:
4 threads:
Results by executing the benchmark tests with the command 'make check'
(found in the trRouting/tests/connection_scan_algorithm/benchmarkResults.txt file):
Duration without parallelization (with all the pragma code commented):
Duration with parallelization:
To set the number of threads to X type in the terminal 'export OMP_NUM_THREADS=X'
-------- Problems of segmentation fault when using the benchmark test with parallelization ---------
Solution idea:
In the pragma, we need to specify which variables are private and which are shared --> it is encouraged to write
default(none) next to the pragma to force the developer to explicitly choose private or shared for each variable
more info: https://pages.tacc.utexas.edu/~eijkhout/pcse/html/omp-data.html
I believe choosing the right option for each variable will get rid of the race condition. To make the right choices, we need to find which variables cause the race condition by debugging using valgrind (https://www.valgrind.org/docs/manual/drd-manual.html#drd-manual.data-race-detection).
To setup valgrind:
sudo apt-get update -y
sudo apt-get install -y valgrind
To run valgrind when running benchmark test in debug mode:
microsoft/vscode-cpptools#4531 (in progress)
2 threads:
3 threads:
4 threads: