diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c080f8973a1b244344f26c52f792380805611a3..89279af519ab1f17d8a104fd7eb998fb2dde2014 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 75a370db29ee67b23bf84bf218e2f2bca9f2b607..4675d52d50de8e50d151c244c1efb9bb86d49b22 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;