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

CMake: Adding support for building multiple precisions at once #276

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

emmenlau
Copy link
Contributor

@emmenlau emmenlau commented Mar 9, 2022

This PR allows to build multiple (or all) precisions in a single go in cmake. Please let me know what you think?

@emmenlau emmenlau force-pushed the bda_multi_prec_build branch from 75b64eb to a2a0a78 Compare March 10, 2022 20:40
@emmenlau
Copy link
Contributor Author

emmenlau commented Apr 2, 2022

The PR does not fully work out of the box, because it will not select the sources dynamically for the precision. I can provide an improved version if this is relevant at all?

Copy link

@LecrisUT LecrisUT left a comment

Choose a reason for hiding this comment

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

Most of the comments are regarding the cmake project in general. Maybe these can be spun up in a different PR. Also what do you mean selecting the sources dynamically for the precision? Also, mark this as Depends on #275?

@@ -192,9 +194,20 @@ if (ENABLE_AVX2)
endforeach ()
endif ()

if (ENABLE_NEON)
if (ENABLE_LONG_DOUBLE)
message (FATAL_ERROR "NEON only works in single or double precision, please disable long double support")

Choose a reason for hiding this comment

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

This seems contradictory to this PR. Shouldn't it be fine that NEON is only built for single and double, and we just give a warning that it doesn't work for the others?

set (BENCHFFT_LDOUBLE TRUE)
set (PREC_SUFFIX l)
endif ()
set (FFTW_VERSION 3.3.10)

Choose a reason for hiding this comment

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

This is rather archaic. We should move this into project(FFTW VERSION 3.3.10)

Copy link

Choose a reason for hiding this comment

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

Also in the project, only C language should be enabled

set (PREC_SUFFIX q)
endif ()
set (fftw3_lib fftw3${PREC_SUFFIX})
set (PRECISIONS SINGLE DOUBLE LDOUBLE QUAD)

Choose a reason for hiding this comment

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

How about passing this as a list via set(CACHE), then if any flags are added, simply add to the list.

configure_file (cmake.config.h.in "${PRECISION}/config.h" @ONLY)
target_include_directories (${fftw3_lib} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${PRECISION}")

target_include_directories (${fftw3_lib} INTERFACE $<INSTALL_INTERFACE:include>)

Choose a reason for hiding this comment

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

$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>

Copy link

@LecrisUT LecrisUT Jan 2, 2023

Choose a reason for hiding this comment

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

Oops, I understood this tutorial the other way around.

This is still recommended. Just don't use ${CMAKE_INSTALL_FULL_INCLUDEDIR}

target_include_directories (${fftw3_lib} INTERFACE $<INSTALL_INTERFACE:include>)

if (BUILD_SHARED_LIBS)
target_compile_definitions (${fftw3_lib} PRIVATE -DFFTW_DLL)

Choose a reason for hiding this comment

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

Is this specific to windows?

else ()
add_library (${fftw3_lib}_threads ${fftw_threads_SOURCE})
target_include_directories (${fftw3_lib}_threads PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${PRECISION}")
target_include_directories (${fftw3_lib}_threads INTERFACE $<INSTALL_INTERFACE:include>)

Choose a reason for hiding this comment

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

Seems these can be generalized in an interface target as well. Can combine with depends to link to appropriate config.h as well.

endif ()

foreach(subtarget ${subtargets})
set_target_properties (${subtarget} PROPERTIES SOVERSION 3.6.9 VERSION 3)

Choose a reason for hiding this comment

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

Why are SOVERSIONs not in sync with PROJECT_VERSION?

foreach(subtarget ${subtargets})
set_target_properties (${subtarget} PROPERTIES SOVERSION 3.6.9 VERSION 3)
install (TARGETS ${subtarget}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}

Choose a reason for hiding this comment

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

These should be exported as well


enable_testing ()

if (Threads_FOUND)

Choose a reason for hiding this comment

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

Either move this together with condition BUILD_TESTS, or enable the testing altogether. Also bench is not a good name for this purpose. Preferably move these to tests subfolder

${CMAKE_CURRENT_BINARY_DIR}/FFTW3${PREC_SUFFIX}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fftw3${PREC_SUFFIX}
COMPONENT Development)
${CMAKE_CURRENT_BINARY_DIR}/fftw3${PREC_SUFFIX}.pc

Choose a reason for hiding this comment

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

These should be in the loop

@emmenlau
Copy link
Contributor Author

emmenlau commented Jan 3, 2023

Hi @LecrisUT , thanks for your interest to push the cmake support forward, it's appreciated. However I should note that currently the commit CMakeLists.txt: Support multi-precision builds
is broken because it makes some wrong assumption about which code needs to be built. I don't even recall the details but there was a flaw that requires slightly larger re-design of the change.

@LecrisUT
Copy link

LecrisUT commented Jan 3, 2023

The only part that I can see is the lack of target_compile_definitions for FFTW_SINGLE etc. Check these lines:

fftw3/kernel/ifftw.h

Lines 63 to 78 in 9426cd5

#define CONCAT(prefix, name) prefix ## name
#if defined(FFTW_SINGLE)
typedef float R;
# define X(name) CONCAT(fftwf_, name)
#elif defined(FFTW_LDOUBLE)
typedef long double R;
# define X(name) CONCAT(fftwl_, name)
# define TRIGREAL_IS_LONG_DOUBLE
#elif defined(FFTW_QUAD)
typedef __float128 R;
# define X(name) CONCAT(fftwq_, name)
# define TRIGREAL_IS_QUAD
#else
typedef double R;
# define X(name) CONCAT(fftw_, name)
#endif

@emmenlau
Copy link
Contributor Author

Hi @LecrisUT , thanks for your interest to push the cmake support forward, it's appreciated. However I should note that currently the commit CMakeLists.txt: Support multi-precision builds is broken because it makes some wrong assumption about which code needs to be built. I don't even recall the details but there was a flaw that requires slightly larger re-design of the change.

Hey @LecrisUT , I've re-considered this PR and I'm not sure whether there is a problem with my changes or not. It may help if you could try the fftw built with these instructions here and see if it is any faster or slower than the "common" fftw. Is that something you can test?

@LecrisUT
Copy link

Honestly I have completely lost interest in contributing to modernizing this project after the comments in #307. I have no hope that any improvements we make will be considered. Cmake fully supports OCaml and the project can be made to be fully compiled with cmake, but until that is being considered I don't think I'll participate.

@JiahanBro
Copy link

JiahanBro commented Jun 26, 2023 via email

@LecrisUT
Copy link

@JiahanBro, did you meant to forward that message internally or make a comment?

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.

3 participants