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

Fix CMake: FFTW Threads #55

Closed
wants to merge 1 commit into from
Closed

Conversation

ax3l
Copy link
Contributor

@ax3l ax3l commented Aug 29, 2024

Fix a build issues on Linux in Conda-Forge in which pthreads showed unresolved library paths from FFTW threads variants: conda-forge/staged-recipes#26633

Similar logic as in #47, but for (p)threads.

@ax3l ax3l force-pushed the fix-fftw-threads branch 10 times, most recently from ed89d3e to 89ce120 Compare August 29, 2024 02:43
@ax3l ax3l mentioned this pull request Aug 29, 2024
10 tasks
@ax3l ax3l changed the title [Draft] Fix CMake: FFTW Threads Fix CMake: FFTW Threads Aug 29, 2024
if (FFTW_OMP_LIBRARIES)
list(APPEND FFTW_OMP_LIBRARIES "${FFTW_LIBRARIES}")
list(APPEND FFTW_LIBRARIES "${FFTW_OMP_LIBRARIES}")
Copy link
Contributor Author

@ax3l ax3l Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a bug for OMP: swapped the arguments and assigned to an unused variable.

@ax3l ax3l force-pushed the fix-fftw-threads branch from 89ce120 to 7a7c453 Compare August 29, 2024 03:47
Trying to fix build issues on Linux in Conda-Forge in which
pthreads are over-linked and ill-resolved from FFTW.
@ax3l ax3l force-pushed the fix-fftw-threads branch from 7a7c453 to 2243716 Compare August 29, 2024 05:57
@ax3l
Copy link
Contributor Author

ax3l commented Aug 29, 2024

@mkstoyanov this one is ready for review now :)

OPTIONAL "fftw3_threads" "fftw3f_threads")
heffte_find_fftw_libraries(
PREFIX ${FFTW_ROOT}
VAR FFTW_OMP_LIBRARIES
REQUIRED ""
OPTIONAL "fftw3_omp" "fftw3f_omp")

if (FFTW_THREADS_LIBRARIES)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current way of listing all libraries will favor searching for OpenMP over Threads. I think we should preserve this behavior, e.g., search for OpenMP first and then look for threads only if the OpenMP libraries were not found.

The main reason is that scientific code using OpenMP is far more common than Threads.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, will update tomorrow

if (FFTW_THREADS_LIBRARIES)
list(APPEND FFTW_LIBRARIES "${FFTW_THREADS_LIBRARIES}")
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
if(WIN32) # Windows has an internal pthreads lib we can use
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heFFTe doesn't support windows, I don't even know how one will start with MPI on Windows.

if (@Heffte_ENABLE_FFTW@)
if (NOT "@FFTW_THREADS_LIBRARIES@" STREQUAL "")
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
if(WIN32) # Windows has an internal pthreads lib we can use
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, no need to consider windows.

@mkstoyanov
Copy link
Collaborator

@ax3l I'm currently on vacation, so I'm responding with a delay.

I don't like changing the default behavior on system with both threads and openmp, which should be an easy fix.

I also don't like superfluous code for features that aren't supported anyway. But other than that, this looks OK.

@mkstoyanov
Copy link
Collaborator

Effectively done in #65

@mkstoyanov mkstoyanov closed this Oct 23, 2024
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