Skip to content
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

Open
wants to merge 12 commits into
base: v2c
Choose a base branch
from

Conversation

YasmineMoumou
Copy link
Collaborator

@YasmineMoumou YasmineMoumou commented Aug 26, 2021

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:
image

To reproduce these results, make sure to add -fopenmp after every "g++" in the Makefiles...

  • trRouting/connection_scan_algorithm/src/Makefile
  • trRouting/src/Makefile
  • trRouting/tests/connection_scan_algorithm/Makefile
  • trRouting/tests/Makefile

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 :
image

Duration without parallelization :
image

Duration with parallelization:
To set the number of threads to X type in the terminal 'export OMP_NUM_THREADS=X'

2 threads:
image
3 threads:
image

4 threads:
image

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):
image

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:

@kaligrafy
Copy link
Collaborator

Great work thanks!
Is it normal that the screenshot is not there?

@YasmineMoumou YasmineMoumou force-pushed the integrateOpenMPParallelization branch from adfe611 to 79aab2c Compare August 26, 2021 17:28
@YasmineMoumou
Copy link
Collaborator Author

Great work thanks!
Is it normal that the screenshot is not there?

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
@YasmineMoumou
Copy link
Collaborator Author

Great work thanks!
Is it normal that the screenshot is not there?

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants