From 207ee11fae21abec94113cdc71fd406f7459c068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Sun, 11 Mar 2018 01:53:54 +0100 Subject: [PATCH] First try to integrate git info in pastis executable --- CMakeLists.txt | 13 +++++++++++++ main.cpp | 8 ++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c080f897..89279af51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,5 +31,18 @@ list(APPEND CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -O3) add_subdirectory(${CMAKE_SOURCE_DIR}/packages/kokkos) include_directories(${Kokkos_INCLUDE_DIRS_RET}) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules") +include(GetGitRevisionDescription) + +get_git_head_revision(GITREV GITHASH) +git_local_changes(GITHASLOCALCHANGES) +message("git rev ${GITREV} : ${GITHASH} (${GITHASLOCALCHANGES})") + +file(WRITE "${CMAKE_BINARY_DIR}/git_revision.hpp" "#define GITREV \"${GITREV}\"\n") +file(APPEND "${CMAKE_BINARY_DIR}/git_revision.hpp" "#define GITHASH \"${GITHASH}\"\n") +file(APPEND "${CMAKE_BINARY_DIR}/git_revision.hpp" "#define GITHASLOCALCHANGES \"${GITHASLOCALCHANGES}\"\n") + +include_directories(${CMAKE_BINARY_DIR}) + add_executable(pastis main.cpp) target_link_libraries(pastis kokkos) diff --git a/main.cpp b/main.cpp index 75a370db2..4675d52d5 100644 --- a/main.cpp +++ b/main.cpp @@ -1,10 +1,14 @@ #include <iostream> #include <Kokkos_Core.hpp> +#include <git_revision.hpp> int main(int argc, char *argv[]) { std::cout << "It's pastis time!\n"; - std::cout << "-----------------\n"; + std::cout << "--------------------- git info --------------------------\n"; + std::cout << "* branch: " << GITREV << '\n'; + std::cout << "* hash: " << GITHASH << '(' << GITHASLOCALCHANGES << ")\n"; + std::cout << "---------------------------------------------------------\n"; Kokkos::initialize(argc, argv); Kokkos::DefaultExecutionSpace::print_configuration(std::cout); @@ -21,7 +25,7 @@ int main(int argc, char *argv[]) Kokkos::Timer timer; timer.reset(); - // Compute the number of even integers from 0 to n-1, in parallel. + // Compute the number of even integers from 0 to n-1, in parallel. long count = 0; Kokkos::parallel_reduce(n, KOKKOS_LAMBDA (const long i, long& lcount) { lcount += (i % 2) == 0; -- GitLab