-
Notifications
You must be signed in to change notification settings - Fork 5
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
Improve cmake #47
Improve cmake #47
Conversation
@cedricchevalier19 Hello, could you please review this PR? |
CMakeLists.txt
Outdated
KokkosFFT | ||
VERSION 0.0.0.0 | ||
LANGUAGES CXX | ||
) | ||
|
||
# Add cmake helpers for FFTW | ||
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake") |
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.
You can simply:
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
CMakeLists.txt
Outdated
if (NOT KokkosFFT_INTERNAL_Kokkos) | ||
# First check, Kokkos is added as subdirectory or not | ||
if(NOT TARGET Kokkos::kokkos) | ||
find_package(Kokkos REQUIRED) | ||
# Kokkos version check | ||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Kokkos_Version_Check.cmake) |
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.
Since you update CMAKE_CURRENT_SOURCE_DIR
, you don't need to specify the absolute path anymore and can simply do:
include(Kokkos_Version_Check)
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.
Do they work in both KokkosFFT as library and KokkosFFT as subdirectory cases?
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.
This file is not included in the installation of Kokkos FFT, or is it?
Moreover, if you need a specific version of Kokkos, you should pass it as REQUIRED
in find_package
(if this is possible, see @cedricchevalier19 comment).
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 build based on pre-installed Kokkos, this is included.
Moreover, if you need a specific version of Kokkos, you should pass it as REQUIRED in find_package (if this is possible, see @cedricchevalier19 comment).
As commented, I would like custom error messages.
CMakeLists.txt
Outdated
if (NOT KokkosFFT_INTERNAL_Kokkos) | ||
# First check, Kokkos is added as subdirectory or not | ||
if(NOT TARGET Kokkos::kokkos) | ||
find_package(Kokkos REQUIRED) | ||
# Kokkos version check |
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.
Maybe the Kokkos version check should be done unconditionally. I know it's unlikely that the embedded version comes outdated, but I think it doesn't hurt to have a straightforward approach.
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.
Is there a way to access internal CMake variables in Kokkos CMake?
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.
find_package
can check for version directly no ?
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.
If we rely on a pre-installed Kokkos yes. I am not sure how can I retrieve information from Kokkos added as a subdirectory. I added a specific function for finer error messages
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.
I tested it with the sub-directory way and could access Kokkos_VERSION
.
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.
So, it would work except for using Kokkos as subdirectory of this KokkosFFT
?
CMakeLists.txt
Outdated
@@ -44,6 +51,7 @@ endif() | |||
if(KokkosFFT_ENABLE_BENCHMARK) | |||
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." OFF) | |||
add_subdirectory(tpls/benchmark) | |||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/KokkosFFT_Git_Hash.cmake) |
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.
You can do:
include(KokkosFFT_Git_Hash)
CMakeLists.txt
Outdated
@@ -60,6 +68,11 @@ set( | |||
KokkosFFT_Version_Info.hpp | |||
) | |||
|
|||
# Set tpls | |||
set(KOKKOSFFT_TPL_LIST) | |||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/KokkosFFT_tpls.cmake) |
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.
You can do:
include(KokkosFFT_tpls)
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.
Just a quick review.
CMakeLists.txt
Outdated
math(EXPR KOKKOSFFT_VERSION_MAJOR "${KOKKOSFFT_VERSION} / 10000") | ||
math(EXPR KOKKOSFFT_VERSION_MINOR "${KOKKOSFFT_VERSION} / 100 % 100") | ||
math(EXPR KOKKOSFFT_VERSION_PATCH "${KOKKOSFFT_VERSION} % 100") |
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.
Please remove this, just alias to PROJECT_VERSION_*
if it is not already done by CMake.
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.
The question is that Kokkos versioning has numbers like "4.2.00" which seems to me PROJECT_VERSION_MAJOR. PROJECT_VERSION_MINOR.PROJECT_VERSION_PATCH.PROJECT_VERSION_TWEAK
.
At the same time, it is reduced into "4.2.0" for version comparison. If we simply control PROJECT_VERSION_MAJOR. PROJECT_VERSION_MINOR.PROJECT_VERSION_PATCH
, we can just alias version variables to these
CMakeLists.txt
Outdated
if (NOT KokkosFFT_INTERNAL_Kokkos) | ||
# First check, Kokkos is added as subdirectory or not | ||
if(NOT TARGET Kokkos::kokkos) | ||
find_package(Kokkos REQUIRED) | ||
# Kokkos version check |
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.
find_package
can check for version directly no ?
cmake/KokkosFFT_Git_Hash.cmake
Outdated
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.
Is this really useful? It is quite a lot of code for something that does not bring any feature.
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.
It gives the git version in benchmark which should be important.
CMakeLists.txt
Outdated
message("") | ||
message("-- KokkosFFT version: ${KOKKOSFFT_VERSION_MAJOR}.${KOKKOSFFT_VERSION_MINOR}.${KOKKOSFFT_VERSION_PATCH}") | ||
message("-- KokkosFFT TPLs") |
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.
The --
prefix is rendered by using the STATUS
mode (see message documentation):
message(STATUS "KokkosFFT version: ${KOKKOSFFT_VERSION_MAJOR}.${KOKKOSFFT_VERSION_MINOR}.${KOKKOSFFT_VERSION_PATCH}")
message(STATUS "KokkosFFT TPLs")
@@ -0,0 +1,27 @@ | |||
function(get_tpls_list tpls_list) |
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.
You should add a documentation in the header to describe what this function does.
@@ -0,0 +1,11 @@ | |||
function(check_minimum_required_kokkos kokkos_required_version) |
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.
You should add a documentation in the header to describe what this function does.
CMakeLists.txt
Outdated
math(EXPR KOKKOSFFT_VERSION "${PROJECT_VERSION_MAJOR} * 10000 + ${PROJECT_VERSION_MINOR} * 100 + ${PROJECT_VERSION_PATCH} * 10 + ${PROJECT_VERSION_TWEAK}") | ||
math(EXPR KOKKOSFFT_VERSION_MAJOR "${KOKKOSFFT_VERSION} / 10000") | ||
math(EXPR KOKKOSFFT_VERSION_MINOR "${KOKKOSFFT_VERSION} / 100 % 100") | ||
math(EXPR KOKKOSFFT_VERSION_PATCH "${KOKKOSFFT_VERSION} % 100") |
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.
Do you really need to do that? You can use advantage of the standard version variables:
set(KOKKOSFFT_VERSION "${PROJECT_VERSION}")
set(KOKKOSFFT_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(KOKKOSFFT_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(KOKKOSFFT_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
Also, you specified a semver with tweak version (as of 0.0.0.0), and don't use it here.
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.
I have never used tweak version, but Kokkos version seems to have that. #47 (comment)
The easiest solution is removing the tweak version.
CMakeLists.txt
Outdated
# CMake Summary | ||
# ================================================================== | ||
|
||
message("") |
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.
Empty lines in CMake output is not common, in my experience.
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.
This is to distinguish the summaries from Kokkos
and KokkosFFT
as shown.
-- Setting default Kokkos CXX standard to 17
-- Kokkos version: 4.2.0
-- The project name is: Kokkos
-- Using internal gtest for testing
-- Configured git information in /home/i18048/jh220031a/github/benchmark/github/kokkos-fft/build/generated/Kokkos_Version_Info.cpp
-- Using -std=gnu++17 for C++17 extensions as feature
-- Built-in Execution Spaces:
-- Device Parallel: NoTypeDefined
-- Host Parallel: Kokkos::OpenMP
-- Host Serial: NONE
--
-- Architectures:
-- SKX
-- Using internal desul_atomics copy
-- Kokkos Devices: OPENMP, Kokkos Backends: OPENMP
-- KokkosFFT version: 0.0.0
-- KokkosFFT TPLs
FFTW_OPENMP
CMakeLists.txt
Outdated
else() | ||
message(" (None)") | ||
endif() | ||
message("") |
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.
Empty lines in CMake output is not common, in my experience.
CMakeLists.txt
Outdated
if(KOKKOSFFT_TPL_LIST) | ||
foreach(TPL ${KOKKOSFFT_TPL_LIST}) | ||
# [TO DO] show more information about the library (like location) | ||
message(" ${TPL}") |
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.
message(STATUS " ${TPL}")
CMakeLists.txt
Outdated
message(" ${TPL}") | ||
endforeach() | ||
else() | ||
message(" (None)") |
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.
message(STATUS " (None)")
Thank you for the reviews. I have fixed based on your reviews. I will merge this PR if you are fine. |
Resolves #32
In this PR, we add the version check of Kokkos when building against a pre-installed Kokkos library.
Following functionalities are added.