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

major cmake overhaul: #1902, #1930, #2026, #2027, #2099 #2104

Merged
merged 61 commits into from Aug 27, 2019
Merged

Conversation

crtrott
Copy link
Member

@crtrott crtrott commented Apr 17, 2019

No description provided.

@crtrott
Copy link
Member Author

crtrott commented Apr 18, 2019

this shoudldn't be merged in yet we need to do some testing.

cmake/kokkos_tribits.cmake Outdated Show resolved Hide resolved
cmake/kokkos_tribits.cmake Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
cmake/kokkos_settings.cmake Outdated Show resolved Hide resolved
CONFIGURE_FILE(kokkos.pc.in kokkos.pc @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/kokkos.pc DESTINATION lib/pkgconfig)
#CONFIGURE_FILE(kokkos.pc.in kokkos.pc @ONLY)
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/kokkos.pc DESTINATION lib/pkgconfig)
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean to comment these?

Copy link

Choose a reason for hiding this comment

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

Sort of? I should delete it here. It's in the kokkos_install.cmake file now.
Issue #2161 opened to address this.

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to revert these changes for now


SET(SOURCES "")
SET(SOURCES G2L_Main.cpp)
Copy link
Member

Choose a reason for hiding this comment

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

I'd say don't even bother with the variable :)

ELSEIF(FOUND_HPX_ROOT)
SET(HPX_ROOT ${FOUND_HPX_ROOT})
ENDIF()
ENDIF()
Copy link
Member

Choose a reason for hiding this comment

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

I find this block quite confusing. I suppose it is meant to help the downstream package to locate the same HPX that was found when building Kokkos.

Only the _DIR variable makes sense to me because AFAIU CMake sets it to the directory containing the configuration file provided by the package that was found. Also this seems to be the only invariant in the search procedure over the last few versions of CMake.

Copy link
Member

Choose a reason for hiding this comment

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

Also why would we do that for HPX and not for other dependencies that might have been enabled at the time Kokkos was built? Specifically I am thinking about MEMKIND, HWLOC, or Threads.

Copy link

Choose a reason for hiding this comment

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

HPX is the only TPL right now loaded directly via find_package without a find module. CMake will attempt to load this downstream dependency automatically when a project does find_package(Kokkos) so we need to make sure CMake has the correct HPX_DIR

hwloc and memkind, as far as I can tell, are private dependencies. The headers/libraries should not be necessary to have downstream. If these were public, we would need to do some extra work to make sure the imported Kokkos::hwloc target can be found.

TARGET_COMPILE_OPTIONS(${TARGET} ${ARGN})
else()
TARGET_COMPILE_OPTIONS(${TARGET} ${ARGN})
endif()
Copy link
Member

Choose a reason for hiding this comment

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

Uhhh?

Copy link

Choose a reason for hiding this comment

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

These used to be different. And then I changed tribits. And now they are same. Totally logical!

@masterleinad
Copy link
Contributor

I also get

-- *****************************************************
-- 
CMake Error at cmake/kokkos_tribits.cmake:326 (TARGET_COMPILE_FEATURES):
  TARGET_COMPILE_FEATURES no known features for CXX compiler

  "GNU"

  version 7.3.0.
Call Stack (most recent call first):
  cmake/kokkos_tribits.cmake:250 (KOKKOS_INTERNAL_ADD_LIBRARY)
  CMakeLists.txt:125 (KOKKOS_MAKE_LIBKOKKOS)


-- Configuring incomplete, errors occurred!

with the current version using

cmake  
  -D KOKKOS_ARCH="Kepler35" \
  -D KOKKOS_ENABLE_SERIAL=ON \
  -D KOKKOS_ENABLE_OPENMP=ON \
  -D KOKKOS_ENABLE_CUDA=ON \
  -D KOKKOS_ENABLE_CUDA_LAMBDA=ON \
  -D CMAKE_CXX_COMPILER=${NVCC_WRAPPER} \
  -D CMAKE_BUILD_TYPE=Release \
  ..

@dalg24
Copy link
Member

dalg24 commented May 12, 2019

@masterleinad It is a known issue with nvcc_wrapper. See the 1st part of Brad's comment

@masterleinad
Copy link
Contributor

Using

cmake -DKOKKOS_ARCH=Volta70 \
      -DKOKKOS_ENABLE_CUDA=ON \
      -DKOKKOS_ENABLE_OPENMP=ON \
      -DKOKKOS_ENABLE_CUDA_LAMBDA=ON \
      -DCMAKE_CXX_COMPILER=/tmp/kokkos/bin/nvcc_wrapper \
      -DCMAKE_INSTALL_PREFIX=${PWD}/install \
      ${KOKKOS_PATH}

I currently get

/tmp/kokkos/bin/nvcc_wrapper   -I/tmp/kokkos/build_cmake/build/core/src -I/tmp/kokkos/core/src -I/tmp/kokkos/build_cmake/build  KOKKOS_CUDA_OPTIONS "-arch=sm_70>" "SHELL: -Xcompiler -fopenmp" -std=c++11 -std=gnu++11 -o CMakeFiles/kokkoscore.dir/impl/Kokkos_CPUDiscovery.cpp.o -c /tmp/kokkos/core/src/impl/Kokkos_CPUDiscovery.cpp
nvcc fatal   : Value 'sm_70>' is not defined for option 'gpu-architecture'

when building.

@jjwilke
Copy link

jjwilke commented Jun 3, 2019

yes, type-o. This used to be a generator expression. If you want to continue, just delete the > from

    TARGET_COMPILE_OPTIONS(
      ${LIBRARY_NAME}
      PUBLIC ${KOKKOS_CUDA_OPTIONS}>
    )

in kokkos_tribits.cmake. I will fix in the next commit.

MACRO(GLOBAL_APPEND VARNAME)
SET(TEMP ${VARNAME})
LIST(APPEND TEMP ${ARGN})
GLOBAL_SET(${VARNAME} ${TEMP})
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
GLOBAL_SET(${VARNAME} ${TEMP})
SET(VARNAME "${VARNAME};${TEMP}" CACHE INTERNAL "")

This didn't work for me. I ended up with KOKKOS_CUDA_OPTIONS (literally) showing up in the compile arguments.

)
SET(NODEDUP_CUDAFE_OPTIONS)
FOREACH(OPT ${NODEDEUP_CUDAFE_OPTIONS})
LIST(APPEND NODEDUP_CUDAFE_OPTIONS "SHELL: -Xcudafe ${OPT}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LIST(APPEND NODEDUP_CUDAFE_OPTIONS "SHELL: -Xcudafe ${OPT}")
LIST(APPEND NODEDUP_CUDAFE_OPTIONS -Xcudafe ${OPT})

Copy link

Choose a reason for hiding this comment

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

Is this breaking your build? If you don't have the SHELL part, then CMake will deduplicate all the -Xcudafe flags, which you don't want.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it is breaking my build. I get

/tmp/kokkos/bin/nvcc_wrapper   -I/tmp/kokkos/build_cmake/build/core/src -I/tmp/kokkos/core/src -I/tmp/kokkos/build_cmake/build  -mavx "SHELL: -Xcompiler -fopenmp" -std=c++11 -std=gnu++11 -o CMakeFiles/kokkoscore.dir/impl/Kokkos_CPUDiscovery.cpp.o -c /tmp/kokkos/core/src/impl/Kokkos_CPUDiscovery.cpp
g++: error: SHELL:: No such file or directory

Copy link

Choose a reason for hiding this comment

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

What version of cmake are you using? Looks like I had my versions wrong. This didn't get added until 3.12, but I set minimum to 3.10.

Copy link

@jjwilke jjwilke Jun 3, 2019

Choose a reason for hiding this comment

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

@crtrott: Do we have any scenarios where we pass more than one -Xcudafe flag to the compiler? The only one I see right now is --diag_suppress=esa_on_defaulted_function_ignored. If we need to support more than one -Xcudafe we will need to bump minimum to 3.12.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was using CMake 3.10.2.

IF(KOKKOS_XCOMPILER_OPTIONS)
SET(NODEDUP_XCOMPILER_OPTIONS)
FOREACH(OPT ${KOKKOS_XCOMPILER_OPTIONS})
LIST(APPEND NODEDUP_XCOMPILER_OPTIONS "SHELL: -Xcompiler ${OPT}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LIST(APPEND NODEDUP_XCOMPILER_OPTIONS "SHELL: -Xcompiler ${OPT}")
LIST(APPEND NODEDUP_XCOMPILER_OPTIONS -Xcompiler ${OPT})

@masterleinad
Copy link
Contributor

With these last changes, I can at least build Kokkos.

@dalg24
Copy link
Member

dalg24 commented Aug 26, 2019

@masterleinad @jjwilke I am in favor to support finding Kokkos in the build directory but let's tackle that in a separate PR.

@jjwilke
Copy link

jjwilke commented Aug 26, 2019

@masterleinad @jjwilke I am in favor to support finding Kokkos in the build directory but let's tackle that in a separate PR.

Using the cmake export(...) for build trees? Or some other mechanism?

@masterleinad
Copy link
Contributor

@masterleinad @jjwilke I am in favor to support finding Kokkos in the build directory but let's tackle that in a separate PR.

Sure, it's not crucial.

@crtrott
Copy link
Member Author

crtrott commented Aug 27, 2019

@masterleinad Daniel you got anything else problematic which needs to be resolved before we merge this finally?

@crtrott
Copy link
Member Author

crtrott commented Aug 27, 2019

@jjwilke do you got more stuff we need to get in before merging?

@jjwilke
Copy link

jjwilke commented Aug 27, 2019

I am done except for Trilinos testing. Features and documentation are complete. @dalg24?

The only sort of pending issue is #2161. pkgconfig has its idiosyncracies that don't map well to modern C++ (or projects mixing C/C++ for that matter). I don't know that we made a final decision on whether we want to install a .pc file. If not, I should probably remove all the pkgconfig stuff.

@masterleinad
Copy link
Contributor

Daniel you got anything else problematic which needs to be resolved before we merge this finally?

Looking at the output of testing this pull request using ArborX (https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/ArborX/detail/PR-73/46/pipeline/20) we seem to miss linking against libcudart.so when using clang:

[...]
/opt/llvm/bin/clang++  -g  -mavx CMakeFiles/ArborX_DetailsTreeTraversal.exe.dir/tstDetailsTreeTraversal.cpp.o CMakeFiles/ArborX_DetailsTreeTraversal.exe.dir/utf_main.cpp.o  -o ArborX_DetailsTreeTraversal.exe -Wl,-rpath,/opt/boost/lib:/opt/openmpi/lib /opt/boost/lib/libboost_unit_test_framework.so /opt/kokkos/lib/libkokkos.a /usr/lib/x86_64-linux-gnu/libcuda.so /usr/lib/x86_64-linux-gnu/libdl.so -Wl,-rpath -Wl,/opt/openmpi/lib -Wl,--enable-new-dtags -pthread /opt/openmpi/lib/libmpi.so 
CMakeFiles/ArborX_DetailsTreeTraversal.exe.dir/tstDetailsTreeTraversal.cpp.o: In function `__cuda_register_globals':
tstDetailsTreeTraversal.cpp:(.text+0x1b8f): undefined reference to `__cudaRegisterVar'
tstDetailsTreeTraversal.cpp:(.text+0x1bcf): undefined reference to `__cudaRegisterVar'
[...]

@masterleinad
Copy link
Contributor

Forcing the relevant libraries to be found via something like

diff --git a/cmake/kokkos_tribits.cmake b/cmake/kokkos_tribits.cmake
index a4a5c2d7..3353a007 100644
--- a/cmake/kokkos_tribits.cmake
+++ b/cmake/kokkos_tribits.cmake
@@ -257,12 +257,16 @@ FUNCTION(KOKKOS_LINK_TPLS LIBRARY_NAME)
     IF (KOKKOS_CXX_COMPILER_ID STREQUAL Clang)
        SET(LIB_cuda "-lcuda -lcudart")
        find_library( cuda_lib_ NAMES libcuda cuda HINTS ${KOKKOS_CUDA_DIR}/lib64 ENV LD_LIBRARY_PATH ENV PATH )
-       find_library( cudart_lib_ NAMES libcudart  cudart HINTS ${KOKKOS_CUDA_DIR}/lib64 ENV LD_LIBRARY_PATH ENV PATH )
+       find_library( cudart_lib_ NAMES libcudart cudart HINTS ${KOKKOS_CUDA_DIR}/lib64 ENV LD_LIBRARY_PATH ENV PATH )
        if (cuda_lib_)
           TARGET_LINK_LIBRARIES(${LIBRARY_NAME} PUBLIC ${cuda_lib_})
+       else()
+          MESSAGE(SEND_ERROR "libcuda is required but could not be found. Make sure to include it in your LD_LIBRARY_PATH.")
        endif()
        if (cudart_lib_)
           TARGET_LINK_LIBRARIES(${LIBRARY_NAME} PUBLIC ${cudart_lib_})
+       else()
+         MESSAGE(SEND_ERROR "libcudart is required but could not be found. Make sure to include it in your LD_LIBRARY_PATH.")
        endif()
     else()
        SET(LIB_cuda "-lcuda")

resolves that problem.

@jjwilke
Copy link

jjwilke commented Aug 27, 2019

Forcing the relevant libraries to be found via something like

Ah, I see the code. So the issue is that we don't error out if the library is not found rather than a transitive dependency issue?

@masterleinad
Copy link
Contributor

Ah, I see the code. So the issue is that we don't error out if the library is not found rather than a transitive dependency issue?

Yes, exactly.

@masterleinad
Copy link
Contributor

As far as I am concerned, the pull request looks OK now.

@crtrott
Copy link
Member Author

crtrott commented Aug 27, 2019

OK the error was a system issue when trying to run the clang-format test. This is fine. I gonna pull the trigger ..........

@crtrott crtrott merged commit d45e8ff into develop Aug 27, 2019
@ipdemes
Copy link

ipdemes commented Aug 27, 2019

@jjwilke : is it possible to have KokkosConfig to contain "Kokkos_COMPILE_FLAGS" ?
Also, it seems like "Kokkos_INCLUDE_DIRS" is empty

@jjwilke
Copy link

jjwilke commented Aug 28, 2019

@jjwilke : is it possible to have KokkosConfig to contain "Kokkos_COMPILE_FLAGS" ?
Also, it seems like "Kokkos_INCLUDE_DIRS" is empty

Kokkos_INCLUDE_DIRS needs to be deleted for the same reason we don't have a Kokkos_COMPILE_FLAGS. The necessary flags should be added transitively when you target_link_libraries(kokkos).

Do you have a special use case for needing Kokkos_COMPILE_FLAGS as a variable? It's always possible there's some use case that doesn't fit, but we just want to make sure it can't be done the "right way" with modern CMake.

@ipdemes
Copy link

ipdemes commented Aug 29, 2019

@jjwilke : addind kokkos to the list of libraries when we call target_link_libraries(${target} .. didn't help: we don't get flags Kokkkos was compiled with in our CMAKE_CXX_FLAGS (like "-x cuda")

@masterleinad
Copy link
Contributor

@ipdemes Do you see the correct flags in lib/CMake/Kokkos/KokkosTargets.cmake in INTERFACE_COMPILE_OPTIONS for kokkoscore and kokkoscontainers?
How exactly are you invoking target_link_libraries?

find_package(Kokkos REQUIRED)
target_link_libraries(ArborX INTERFACE Kokkos::kokkos)

works fine for us.

@jjwilke
Copy link

jjwilke commented Aug 29, 2019

@ipdemes I'ill bounce this over to the issue tracker

@ipdemes
Copy link

ipdemes commented Aug 30, 2019

@masterleinad : Yes I see correct flags in "INTERFACE_COMPILE_OPTIONS" for kokkoscore
@jjwilke :what is the issue #? It still doesn't work for me. I do exactly the same thing ....

@ipdemes
Copy link

ipdemes commented Aug 30, 2019

@masterleinad @jjwilke :I have found the issue in our cmake set-up and it seems like Kokkos works now

@jjwilke
Copy link

jjwilke commented Aug 30, 2019

@ipdemes #2264

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.

None yet

7 participants