From 2023b8e0def53f4bf6110c2ece668480846ec58f Mon Sep 17 00:00:00 2001 From: Ben Cumming <bcumming@cscs.ch> Date: Fri, 15 May 2020 10:52:08 +0200 Subject: [PATCH] Enrichen configuration information available via version.hpp (#1038) * Add VECTORIZE configuration feature macro to config, record in python lib. * Add ARB_ARCH configuration string as preprocessor define and character string in config and version info respectively. --- arbor/include/CMakeLists.txt | 5 ++++- arbor/include/git-source-id | 5 ++++- arbor/version.cpp | 1 + python/CMakeLists.txt | 4 ++-- python/config.cpp | 7 +++++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/arbor/include/CMakeLists.txt b/arbor/include/CMakeLists.txt index a5b2c3b0..ebc48ee4 100644 --- a/arbor/include/CMakeLists.txt +++ b/arbor/include/CMakeLists.txt @@ -42,11 +42,14 @@ if(ARB_WITH_PROFILING) # define ARB_PROFILE_ENABLED in version.hpp list(APPEND arb_features PROFILE) endif() +if(ARB_VECTORIZE) + list(APPEND arb_features VECTORIZE) +endif() add_custom_command( OUTPUT version.hpp-test DEPENDS _always_rebuild - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/git-source-id ${FULL_VERSION_STRING} ${arb_features} > version.hpp-test + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/git-source-id ${FULL_VERSION_STRING} ${ARB_ARCH} ${arb_features} > version.hpp-test ) set(version_hpp_path arbor/version.hpp) diff --git a/arbor/include/git-source-id b/arbor/include/git-source-id index dcfe9b71..7946b823 100755 --- a/arbor/include/git-source-id +++ b/arbor/include/git-source-id @@ -3,7 +3,8 @@ # arguments: version-string [feature...] version="$1" -shift +arch="$2" +shift 2 if gitlog=$(git log -1 --pretty=format:'%ci %H' 2>/dev/null); then git diff --quiet HEAD 2>/dev/null || gitlog="${gitlog} modified" @@ -16,10 +17,12 @@ cat << __end__ #define ARB_VERSION "${version}" #define ARB_SOURCE_ID "${gitlog}" +#define ARB_ARCH "${arch}" namespace arb { extern const char version[]; extern const char source_id[]; +extern const char arch[]; } __end__ diff --git a/arbor/version.cpp b/arbor/version.cpp index de8ba183..e3b689cf 100644 --- a/arbor/version.cpp +++ b/arbor/version.cpp @@ -3,4 +3,5 @@ namespace arb { const char version[] = ARB_VERSION; const char source_id[] = ARB_SOURCE_ID; +const char arch[] = ARB_ARCH; } diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 12e7c388..0b90b6d0 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -60,8 +60,8 @@ target_link_libraries(pyarb PRIVATE arbor pybind11::module) if (ARB_WITH_MPI) find_python_module(mpi4py) if (HAVE_MPI4PY) - target_include_directories(pyarb PRIVATE "${PY_MPI4PY}/include") - target_compile_definitions(pyarb PRIVATE -DARB_WITH_MPI4PY) + target_include_directories(pyarb_obj PRIVATE "${PY_MPI4PY}/include") + target_compile_definitions(pyarb_obj PRIVATE -DARB_WITH_MPI4PY) endif() endif() diff --git a/python/config.cpp b/python/config.cpp index 78d0a7ba..69188a7a 100644 --- a/python/config.cpp +++ b/python/config.cpp @@ -28,8 +28,15 @@ pybind11::dict config() { dict[pybind11::str("gpu")] = pybind11::bool_(true); #else dict[pybind11::str("gpu")] = pybind11::bool_(false); +#endif +#ifdef ARB_VECTORIZE_ENABLED + dict[pybind11::str("vectorize")] = pybind11::bool_(true); +#else + dict[pybind11::str("vectorize")] = pybind11::bool_(false); #endif dict[pybind11::str("version")] = pybind11::str(ARB_VERSION); + dict[pybind11::str("source")] = pybind11::str(ARB_SOURCE_ID); + dict[pybind11::str("arch")] = pybind11::str(ARB_ARCH); return dict; } -- GitLab