advanced/CMakeLists.txt#
The file advanced/CMakeLists.txt
can be used to build the advanced examples
using CMake.
# This CMakeLists.txt file is included in the build using add_subdirectory().
# Note that the top-level CMakeLists.txt has called find_package() and has
# created the following library aliases: hpkfft_fp32, hpkfft_fp64
# This example uses both single and double precision.
add_executable(fft_12 fft_12.cpp)
target_link_libraries(fft_12 PRIVATE warnings hpkfft_fp32 hpkfft_fp64)
# The same example as above, but disabling dlsym() lookup.
add_executable(fft_12_ndlsym fft_12.cpp)
set_property(TARGET fft_12_ndlsym PROPERTY HPK_FFT_NDLSYM True)
target_link_libraries(fft_12_ndlsym PRIVATE warnings hpkfft_fp32 hpkfft_fp64)
# This 2D example uses only single precision. Note that we are *not* linking
# the AVX512 FFT library, but the code itself will try to dynamically load it.
# If that succeeds, AVX512 code will be used on AVX512 hardware.
add_executable(fft_3x6 fft_3x6.cpp)
target_link_libraries(fft_3x6 PRIVATE warnings hpkfft_fp32)
# The remainder of this file builds a binary that may actually be useful.
# Note that these utilities respect the process's CPU affinity. For example,
# taskset -c 0 ncore
# prints 1, as only a single core is available to the process.
# SEE ALSO: nproc(1), taskset(1), sched_getaffinity(2)
# First build ncpu, which prints the number of CPUs available to the current
# process. (This is similar to nproc in the GNU core utilities.)
add_executable(ncpu ncpu.cpp)
target_link_libraries(ncpu PRIVATE warnings hpk::core)
# When invoked as ncore, the binary prints the number of cores available to
# the current process. The code below makes ncore a symbolic link to ncpu.
# (In CMake version 3.19 or later, create_hardlink could have been used.)
add_custom_command(OUTPUT ncore
COMMAND ${CMAKE_COMMAND} -E create_symlink ncpu ncore
COMMENT "Creating ncore symlink."
DEPENDS ncpu
VERBATIM)
add_custom_target(create_ncore ALL DEPENDS ncore)
# When invoked as ndie, the binary prints the number of dies available to
# the current process. The code below makes ndie a symbolic link to ncpu.
add_custom_command(OUTPUT ndie
COMMAND ${CMAKE_COMMAND} -E create_symlink ncpu ndie
COMMENT "Creating ndie symlink."
DEPENDS ncpu
VERBATIM)
add_custom_target(create_ndie ALL DEPENDS ndie)
# When invoked as npkg, the binary prints the number of packages available to
# the current process. The code below makes npkg a symbolic link to ncpu.
add_custom_command(OUTPUT npkg
COMMAND ${CMAKE_COMMAND} -E create_symlink ncpu npkg
COMMENT "Creating npkg symlink."
DEPENDS ncpu
VERBATIM)
add_custom_target(create_npkg ALL DEPENDS npkg)