-
Notifications
You must be signed in to change notification settings - Fork 641
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
openmp for near2far calculation #868
Conversation
double freq = freq_min + i * dfreq; | ||
#ifdef HAVE_OPENMP | ||
# pragma omp parallel for | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, I am unable to compile with OpenMP via --with-openmp
on my local machine using this #HAVE_OPENMP
macro (i.e., the build is successful but the examples/binary_grating_n2f.py
test uses just a single thread/process for the get_farfields
calculation regardless of the value for OMP_NUM_THREADS
). To fix this problem, I had to revert back to using just #pragma omp parallel for
(i.e., removing the #ifdef
and #endif
lines) and CXX="g++ -fopenmp"
. Perhaps this is related to the openmp
-related changes in configure.ac
in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoop, I forgot to add OPENMP_CXXFLAGS
to CXXFLAGS
… try it again.
This is working and giving linear speed up as demonstrated previously in #861 and again as shown below for both serial and MPI ( As part of this PR, it would be good to also provide documentation in two places: (1) the The related tutorial example Near to Far Field Spectra/Diffraction Spectrum of a Finite Binary Grating will be updated in a separate PR with these results. |
* try openmp for near2far loop * add --with-openmp configure flag * use --with and not --enable * whoops need to add OPENMP_CXXFLAGS to CXXFLAGS * docs * typo
This adds an experimental
--with-openmp
flag to theconfigure
script that turns on OpenMP compilation, and uses it for thenear2far
calculation for part 1 of #861 (only parallelizing if you are computing for multiple frequencies, however).To use it,
./configure --with-openmp
and set theOMP_NUM_THREADS
environment variable before running Meep (or Python).In the long run, it would be nice to use more comprehensive OpenMP parallelism (#228).
Although this parallelizes over the different frequencies because that was simplest, we could alternatively parallelize at over spatial points in the near or far field.