Skip to content

Commit

Permalink
Merge: Output information after CMake configuration.
Browse files Browse the repository at this point in the history
This PR outputs information from the CMake step onto the screen and also onto log files.

+ CI jobs now automatically output detailed configuration to the screen.

Related PR: #610
  • Loading branch information
pratikvn authored Aug 8, 2020
2 parents 8563fd1 + cb156bc commit 544f7ef
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ stages:
BUILD_OMP: "OFF"
BUILD_CUDA: "OFF"
BUILD_HIP: "OFF"
CONFIG_LOG: "ON"
CXX_FLAGS: ""
EXTRA_CMAKE_FLAGS: ""

Expand Down Expand Up @@ -59,6 +60,7 @@ stages:
-DGINKGO_BUILD_OMP=${BUILD_OMP} -DGINKGO_BUILD_CUDA=${BUILD_CUDA}
-DGINKGO_BUILD_HIP=${BUILD_HIP}
-DGINKGO_BUILD_TESTS=ON -DGINKGO_BUILD_EXAMPLES=ON
-DGINKGO_CONFIG_LOG_DETAILED=${CONFIG_LOG}
- ninja -j${NUM_CORES} -l${CI_LOAD_LIMIT}
dependencies: []
except:
Expand All @@ -84,6 +86,7 @@ stages:
-DGINKGO_BUILD_OMP=${BUILD_OMP} -DGINKGO_BUILD_CUDA=${BUILD_CUDA}
-DGINKGO_BUILD_HIP=${BUILD_HIP}
-DGINKGO_BUILD_TESTS=ON -DGINKGO_BUILD_EXAMPLES=ON
-DGINKGO_CONFIG_LOG_DETAILED=${CONFIG_LOG}
- ninja -j${NUM_CORES} -l${CI_LOAD_LIMIT} install
- |
(( $(ctest -N | tail -1 | sed 's/Total Tests: //') != 0 )) || exit 1
Expand Down
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ option(GINKGO_WITH_IWYU "Make Ginkgo call `iwyu` (Include What You Use) to find
option(GINKGO_CHECK_CIRCULAR_DEPS
"Enable compile-time checks detecting circular dependencies between libraries and non-self-sufficient headers."
OFF)
option(GINKGO_CONFIG_LOG_DETAILED
"Enable printing of detailed configuration log to screen in addition to the writing of files," OFF)
set(GINKGO_VERBOSE_LEVEL "1" CACHE STRING
"Verbosity level. Put 0 to turn off. 1 activates a few important messages.")
if(MSVC)
Expand Down Expand Up @@ -254,6 +256,8 @@ include(cmake/information_helpers.cmake)
ginkgo_interface_information()
ginkgo_git_information()

include(cmake/get_info.cmake)

if(GINKGO_BUILD_DOC)
add_subdirectory(doc)
endif()
Expand Down Expand Up @@ -297,3 +301,12 @@ set(CPACK_RESOURCE_FILE_LICENSE "${Ginkgo_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_ICON "${Ginkgo_SOURCE_DIR}/assets/logo.png")
set(CPACK_PACKAGE_CONTACT "[email protected]")
include(CPack)

# And finally, print the configuration to screen:
#
if(GINKGO_CONFIG_LOG_DETAILED)
FILE(READ ${CMAKE_BINARY_DIR}/detailed.log GINKGO_LOG_SUMMARY)
else()
FILE(READ ${CMAKE_BINARY_DIR}/minimal.log GINKGO_LOG_SUMMARY)
endif()
MESSAGE("${GINKGO_LOG_SUMMARY}")
179 changes: 179 additions & 0 deletions cmake/get_info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
SET(detailed_log "${CMAKE_BINARY_DIR}/detailed.log")
SET(minimal_log "${CMAKE_BINARY_DIR}/minimal.log")
FILE(REMOVE ${detailed_log} ${minimal_log})

MACRO(_both)
# Write to both log files:
FILE(APPEND ${detailed_log} "${ARGN}")
FILE(APPEND ${minimal_log} "${ARGN}")
ENDMACRO()

MACRO(_detailed)
# Only write to detailed.log:
FILE(APPEND ${detailed_log} "${ARGN}")
ENDMACRO()

MACRO(_minimal)
# Only write to minimal.log:
FILE(APPEND ${minimal_log} "${ARGN}")
ENDMACRO()

function(ginkgo_print_generic_header log_type optional_string)
set(upd_string
"
---------------------------------------------------------------------------------------------------------
--
-- ${optional_string}"
)
FILE(APPEND ${log_type} "${upd_string}")
endfunction()

function(ginkgo_print_module_header log_type module_name)
set(upd_string
"The ${module_name} module is being compiled.
--
-- CMake related ${module_name} module variables:"
)
ginkgo_print_generic_header(${log_type} "${upd_string}")
endfunction()

function(ginkgo_print_module_footer log_type optional_string)
set(upd_string
"
-- ${optional_string}"
)
FILE(APPEND ${log_type} "${upd_string}")
endfunction()

FUNCTION(ginkgo_print_flags log_type var_name)
string(TOUPPER "${CMAKE_BUILD_TYPE}" suff)
set(var_string "${var_name}_${suff}")
if(${var_string} STREQUAL "")
set(str_value "<empty>")
else()
set(str_value "${${var_string}}")
endif()
string(SUBSTRING "
-- ${var_string}: " 0 55 upd_string)
string(APPEND upd_string "${str_value}")
FILE(APPEND ${log_type} ${upd_string})
ENDFUNCTION()

function(ginkgo_print_variable log_type var_name)
string(SUBSTRING
"
-- ${var_name}: " 0 55 upd_string)
if(${var_name} STREQUAL "")
set(str_value "<empty>")
else()
set(str_value "${${var_name}}")
endif()
string(APPEND upd_string "${str_value}")
FILE(APPEND ${log_type} "${upd_string}")
endfunction()

IF("${GINKGO_GIT_SHORTREV}" STREQUAL "")
set(to_print "Summary of Configuration for Ginkgo (version ${Ginkgo_VERSION} with tag ${Ginkgo_VERSION_TAG})
--"
)
ginkgo_print_generic_header(${detailed_log} "${to_print}")
ginkgo_print_generic_header(${minimal_log} "${to_print}")
ELSE()
set(to_print "Summary of Configuration for (Ginkgo version ${Ginkgo_VERSION} with tag ${Ginkgo_VERSION_TAG}, shortrev ${GINKGO_GIT_SHORTREV})"
)
ginkgo_print_generic_header(${detailed_log} "${to_print}")
ginkgo_print_generic_header(${minimal_log} "${to_print}")
ENDIF()

set(log_types "detailed_log;minimal_log")
foreach(log_type ${log_types})
ginkgo_print_module_footer(${${log_type}} "Ginkgo configuration:")
set(print_var
"CMAKE_BUILD_TYPE;BUILD_SHARED_LIBS;CMAKE_INSTALL_PREFIX;CMAKE_SOURCE_DIR;CMAKE_BINARY_DIR"
)
foreach(var ${print_var})
ginkgo_print_variable(${${log_type}} ${var} )
endforeach()
string(SUBSTRING
"
-- CMAKE_CXX_COMPILER: " 0 55 print_string)
set(str2 "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} on platform ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR}")
string(APPEND print_string "${str2}")
FILE(APPEND ${${log_type}} "${print_string}")
string(SUBSTRING
"
-- " 0 55 print_string)
set(str2 "${CMAKE_CXX_COMPILER}")
string(APPEND print_string "${str2}")
FILE(APPEND ${${log_type}} "${print_string}")
ginkgo_print_module_footer(${${log_type}} "User configuration:")
ginkgo_print_module_footer(${${log_type}} " Enabled modules:")
set(print_var
"GINKGO_BUILD_OMP;GINKGO_BUILD_REFERENCE;GINKGO_BUILD_CUDA;GINKGO_BUILD_HIP"
)
foreach(var ${print_var})
ginkgo_print_variable(${${log_type}} ${var} )
endforeach()
ginkgo_print_module_footer(${${log_type}} " Tests, benchmarks and examples:")
set(print_var
"GINKGO_BUILD_TESTS;GINKGO_BUILD_EXAMPLES;GINKGO_EXTLIB_EXAMPLE;GINKGO_BUILD_BENCHMARKS")
foreach(var ${print_var})
ginkgo_print_variable(${${log_type}} ${var} )
endforeach()
ginkgo_print_module_footer(${${log_type}} " Documentation:")
set(print_var
"GINKGO_BUILD_DOC;GINKGO_VERBOSE_LEVEL")
foreach(var ${print_var})
ginkgo_print_variable(${${log_type}} ${var} )
endforeach()
ginkgo_print_module_footer(${${log_type}} " Developer helpers:")
set(print_var
"GINKGO_DEVEL_TOOLS;GINKGO_WITH_CLANG_TIDY;GINKGO_WITH_IWYU"
"GINKGO_CHECK_CIRCULAR_DEPS;GINKGO_CHECK_PATH")
foreach(var ${print_var})
ginkgo_print_variable(${${log_type}} ${var} )
endforeach()
ginkgo_print_module_footer(${${log_type}} "")
endforeach()

set(to_print
"Compiled Modules
--"
)
ginkgo_print_generic_header(${detailed_log} "${to_print}")

include(core/get_info.cmake)

IF(GINKGO_BUILD_REFERENCE)
include(reference/get_info.cmake)
ENDIF()

IF(GINKGO_BUILD_OMP)
include(omp/get_info.cmake)
ENDIF()

IF(GINKGO_BUILD_CUDA)
include(cuda/get_info.cmake)
ENDIF()

IF(GINKGO_BUILD_HIP)
include(hip/get_info.cmake)
ENDIF()

ginkgo_print_generic_header(${detailed_log} "Optional Components:")
ginkgo_print_variable(${detailed_log} "GKO_HAVE_PAPI_SDE")
if(PAPI_sde_FOUND)
ginkgo_print_variable(${detailed_log} "PAPI_VERSION")
ginkgo_print_variable(${detailed_log} "PAPI_INCLUDE_DIR")
ginkgo_print_flags(${detailed_log} "PAPI_LIBRARY")
endif()

_minimal(
"\n
--\n-- Detailed information (More compiler flags, module configuration) can be found in detailed.log
")
_both(
"\n--\n-- Now, run cmake --build . to compile Ginkgo!\n"
)
_both("--
---------------------------------------------------------------------------------------------------------\n")
8 changes: 8 additions & 0 deletions core/get_info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ginkgo_print_module_header(${detailed_log} "Core")
ginkgo_print_variable(${detailed_log} "BUILD_SHARED_LIBS")
ginkgo_print_variable(${detailed_log} "CMAKE_C_COMPILER")
ginkgo_print_flags(${detailed_log} "CMAKE_C_FLAGS")
ginkgo_print_variable(${detailed_log} "CMAKE_CXX_COMPILER")
ginkgo_print_flags(${detailed_log} "CMAKE_CXX_FLAGS")
ginkgo_print_variable(${detailed_log} "CMAKE_GENERATOR")
ginkgo_print_module_footer(${detailed_log} "")
2 changes: 1 addition & 1 deletion cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ include(CudaArchitectureSelector)

set(CUDA_INCLUDE_DIRS ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})

# This is required by some examples such as cmake_matrix_format
# This is required by some examples such as custom_matrix_format
# which need the correct CMAKE_CUDA_FLAGS to be set
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS}" PARENT_SCOPE)
set(CMAKE_CUDA_COMPILER_VERSION ${CMAKE_CUDA_COMPILER_VERSION} PARENT_SCOPE)
Expand Down
15 changes: 15 additions & 0 deletions cuda/get_info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ginkgo_print_module_header(${detailed_log} "CUDA")
ginkgo_print_variable(${detailed_log} "GINKGO_CUDA_ARCHITECTURES")
ginkgo_print_variable(${detailed_log} "GINKGO_CUDA_COMPILER_FLAGS")
ginkgo_print_variable(${detailed_log} "GINKGO_CUDA_DEFAULT_HOST_COMPILER")
ginkgo_print_module_footer(${detailed_log} "CUDA variables:")
ginkgo_print_variable(${detailed_log} "CMAKE_CUDA_COMPILER")
ginkgo_print_variable(${detailed_log} "CMAKE_CUDA_COMPILER_VERSION")
ginkgo_print_flags(${detailed_log} "CMAKE_CUDA_FLAGS")
ginkgo_print_variable(${detailed_log} "CMAKE_CUDA_HOST_COMPILER")
ginkgo_print_variable(${detailed_log} "CUDA_INCLUDE_DIRS")
ginkgo_print_module_footer(${detailed_log} "CUDA Libraries:")
ginkgo_print_variable(${detailed_log} "CUBLAS")
ginkgo_print_variable(${detailed_log} "CUDA_RUNTIME_LIBS")
ginkgo_print_variable(${detailed_log} "CUSPARSE")
ginkgo_print_module_footer(${detailed_log} "")
21 changes: 21 additions & 0 deletions hip/get_info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set(log_types "detailed_log")
foreach(log_type ${log_types})
ginkgo_print_module_header(${${log_type}} "HIP")
set(print_var "GINKGO_HIPCONFIG_PATH;GINKGO_HIP_AMDGPU;GINKGO_HIP_HCC_COMPILER_FLAGS;GINKGO_HIP_NVCC_COMPILER_FLAGS;GINKGO_HIP_THRUST_PATH"
)
foreach(var ${print_var})
ginkgo_print_variable(${${log_type}} ${var} )
endforeach()
endforeach()
foreach(log_type ${log_types})
ginkgo_print_module_footer(${${log_type}} "HIP variables:")
set(print_var "HIP_VERSION;HIP_COMPILER;HIP_PATH;ROCM_PATH;HIP_PLATFORM;HIP_ROOT_DIR;HCC_PATH;HIP_RUNTIME;HIPBLAS_PATH;HIPSPARSE_PATH;HIP_CLANG_INCLUDE_PATH;HIP_CLANG_PATH;HIP_HIPCC_EXECUTABLE;HIP_HIPCONFIG_EXECUTABLE;HIP_HOST_COMPILATION_CPP"
)
foreach(var ${print_var})
ginkgo_print_variable(${${log_type}} ${var} )
endforeach()
ginkgo_print_flags(${detailed_log} "HIP_HCC_FLAGS")
ginkgo_print_flags(${detailed_log} "HIP_HIPCC_FLAGS")
ginkgo_print_flags(${detailed_log} "HIP_NVCC_FLAGS")
ginkgo_print_module_footer(${detailed_log} "")
endforeach()
7 changes: 7 additions & 0 deletions omp/get_info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ginkgo_print_module_header(${detailed_log} "OpenMP")
ginkgo_print_variable(${detailed_log} "OpenMP_CXX_FLAGS")
ginkgo_print_variable(${detailed_log} "OpenMP_CXX_LIB_NAMES")
ginkgo_print_variable(${detailed_log} "OpenMP_CXX_LIBRARIES")
ginkgo_print_module_footer(${detailed_log} "OMP variables:")
ginkgo_print_variable(${detailed_log} "GINKGO_COMPILER_FLAGS")
ginkgo_print_module_footer(${detailed_log} "")
4 changes: 4 additions & 0 deletions reference/get_info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ginkgo_print_module_header(${detailed_log} "Reference")
ginkgo_print_variable(${detailed_log} "GINKGO_BUILD_REFERENCE")
ginkgo_print_variable(${detailed_log} "GINKGO_COMPILER_FLAGS")
ginkgo_print_module_footer(${detailed_log} "")

0 comments on commit 544f7ef

Please sign in to comment.