From 5a94848e1a3c4b268efabccf024ee82d71325a58 Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Wed, 30 Jun 2021 01:10:00 -0500 Subject: [PATCH 1/6] pytimem fix (#211) - fix missing import of component_bundle and component_tuple - updated pytimem - added additional python tests --- pyctest-runner.py | 44 ++++++++++++++++ .../python/libpytimemory-component-list.cpp | 52 ++++++++++--------- source/python/libpytimemory-components.hpp | 12 ++--- source/python/tools/timem.py | 37 +++++++++++-- timemory/libs/__init__.py | 4 ++ 5 files changed, 114 insertions(+), 35 deletions(-) diff --git a/pyctest-runner.py b/pyctest-runner.py index c9b71a897..1a1906dc0 100755 --- a/pyctest-runner.py +++ b/pyctest-runner.py @@ -1158,6 +1158,50 @@ def add_timem_test(name, cmd): }, ) + pyct.test( + "timemory-python-sample", + [ + sys.executable, + "ex_python_sample", + ], + { + "WORKING_DIRECTORY": pyct.BINARY_DIRECTORY, + "LABELS": pyct.PROJECT_NAME, + "TIMEOUT": "120", + "ENVIRONMENT": base_env, + }, + ) + + pyct.test( + "timemory-python-general", + [ + sys.executable, + "ex_python_general", + ], + { + "WORKING_DIRECTORY": pyct.BINARY_DIRECTORY, + "LABELS": pyct.PROJECT_NAME, + "TIMEOUT": "120", + "ENVIRONMENT": base_env, + }, + ) + + if len(args.tools) > 0: + pyct.test( + "timemory-python-timem", + [ + "./pytimem", + "sleep", + "2", + ], + { + "WORKING_DIRECTORY": pyct.BINARY_DIRECTORY, + "LABELS": pyct.PROJECT_NAME, + "TIMEOUT": "15", + "ENVIRONMENT": base_env, + }, + ) + pyunittests = [ "flat", "general", diff --git a/source/python/libpytimemory-component-list.cpp b/source/python/libpytimemory-component-list.cpp index 0a80e3f01..e744b9cfd 100644 --- a/source/python/libpytimemory-component-list.cpp +++ b/source/python/libpytimemory-component-list.cpp @@ -71,7 +71,9 @@ components_enum_to_vec(py::list enum_list) component_list_t* create_component_list(std::string obj_tag, const component_enum_vec& components) { - auto obj = new component_list_t(obj_tag, true); + using quirk_config_t = + tim::quirk::config; + auto obj = new component_list_t{ obj_tag, quirk_config_t{} }; tim::initialize(*obj, components); return obj; } @@ -85,13 +87,19 @@ class component_list_decorator : m_ptr(_ptr) { if(m_ptr) + { + m_ptr->push(); m_ptr->start(); + } } ~component_list_decorator() { if(m_ptr) + { m_ptr->stop(); + m_ptr->pop(); + } delete m_ptr; } @@ -100,11 +108,15 @@ class component_list_decorator if(m_ptr) { m_ptr->stop(); + m_ptr->pop(); delete m_ptr; } m_ptr = _ptr; if(m_ptr) + { + m_ptr->push(); m_ptr->start(); + } return *this; } @@ -146,7 +158,7 @@ component_list(py::object farg, py::object sarg) component_list_decorator* component_decorator(py::list components, const std::string& key) { - component_list_decorator* _ptr = new component_list_decorator(); + component_list_decorator* _ptr = new component_list_decorator{}; if(!tim::settings::enabled()) return _ptr; @@ -175,49 +187,41 @@ generate(py::module& _pymod) py::arg("components") = py::list{}, py::arg("key") = std::string{}, py::return_value_policy::automatic); //----------------------------------------------------------------------------------// - comp_list.def("start", - [](py::object self) { self.cast()->start(); }, + comp_list.def("push", [](component_list_t* self) { self->push(); }, + "Push components into storage"); + //----------------------------------------------------------------------------------// + comp_list.def("pop", [](component_list_t* self) { self->pop(); }, + "Finalize the component in storage"); + //----------------------------------------------------------------------------------// + comp_list.def("start", [](component_list_t* self) { self->start(); }, "Start component tuple"); //----------------------------------------------------------------------------------// - comp_list.def("stop", [](py::object self) { self.cast()->stop(); }, + comp_list.def("stop", [](component_list_t* self) { self->stop(); }, "Stop component tuple"); //----------------------------------------------------------------------------------// comp_list.def("report", - [](py::object self) { - std::cout << *(self.cast()) << std::endl; - }, + [](component_list_t* self) { std::cout << *(self) << std::endl; }, "Report component tuple"); //----------------------------------------------------------------------------------// comp_list.def("__str__", - [](py::object self) { + [](component_list_t* self) { std::stringstream ss; - ss << *(self.cast()); + ss << *(self); return ss.str(); }, "Stringify component tuple"); //----------------------------------------------------------------------------------// - comp_list.def("reset", - [](py::object self) { self.cast()->reset(); }, + comp_list.def("reset", [](component_list_t* self) { self->reset(); }, "Reset the component tuple"); //----------------------------------------------------------------------------------// - comp_list.def("__str__", - [](py::object self) { - std::stringstream _ss; - component_list_t* _self = self.cast(); - _ss << *_self; - return _ss.str(); - }, - "Print the component tuple"); - //----------------------------------------------------------------------------------// - comp_list.def("get_raw", - [](py::object self) { return (*self.cast()).get(); }, + comp_list.def("get_raw", [](component_list_t* self) { return self->get(); }, "Get the component list data"); //----------------------------------------------------------------------------------// comp_list.def("get", [](component_list_t* self) { return pytim::dict::construct(self->get_labeled()); }, - "Get the component list data"); + "Get the component list data (labeled)"); //----------------------------------------------------------------------------------// comp_decorator.def(py::init(&init::component_decorator), "Initialization", py::return_value_policy::automatic); diff --git a/source/python/libpytimemory-components.hpp b/source/python/libpytimemory-components.hpp index 3e7279f48..f4f65f802 100644 --- a/source/python/libpytimemory-components.hpp +++ b/source/python/libpytimemory-components.hpp @@ -99,17 +99,17 @@ get_enum(py::object _obj) { try { - auto _sitr = _obj.cast(); - // return native components end so that message isn't delivered - if(_sitr.length() == 0) - return TIMEMORY_NATIVE_COMPONENTS_END; - return tim::runtime::enumerate(_sitr); + return _obj.cast(); } catch(py::cast_error&) {} try { - return _obj.cast(); + auto _sitr = _obj.cast(); + // return native components end so that message isn't delivered + if(_sitr.length() == 0) + return TIMEMORY_NATIVE_COMPONENTS_END; + return tim::runtime::enumerate(_sitr); } catch(py::cast_error& e) { std::cerr << e.what() << std::endl; diff --git a/source/python/tools/timem.py b/source/python/tools/timem.py index e91888a0b..d4c99634d 100755 --- a/source/python/tools/timem.py +++ b/source/python/tools/timem.py @@ -144,11 +144,38 @@ def set_environ(field, default_val): ) report = report.replace(": ", "", 1) suffix_report = report.split(",") - - strings = ["\n> {} total execution time :".format(exe_name)] - for comp in suffix_report: - if "laps" not in comp: - strings.append(" {}".format(comp)) + _sorted = [] + + def _insert(key): + for itr in suffix_report: + if key in itr: + _sorted.append(itr) + suffix_report.remove(itr) + return + + _insert(" wall") + _insert(" sys") + _insert(" user") + _insert(" cpu") + _insert(" cpu_util") + _insert(" peak") + _insert(" prio_") + _insert(" vol_") + _insert(" major_") + _insert(" minor_") + for itr in suffix_report: + _sorted.append(itr) + suffix_report = _sorted + + strings = [f"\n{exe_name}> Measurement totals:"] + for itr in suffix_report: + if "laps" not in itr: + data = itr.strip().split() + if len(data) > 1: + entry = "{:>16} {:<16}".format(data[0], " ".join(data[1:])) + else: + entry = "{:>16}".format(" ".join(data)) + strings.append(" {}".format(entry)) for s in strings: print("{}".format(s)) diff --git a/timemory/libs/__init__.py b/timemory/libs/__init__.py index 21c999cdc..b1b018249 100644 --- a/timemory/libs/__init__.py +++ b/timemory/libs/__init__.py @@ -99,6 +99,8 @@ options, timer_decorator, component_decorator, + component_bundle, + component_tuple, timer, rss_usage, ) @@ -161,6 +163,8 @@ "options", "timer_decorator", "component_decorator", + "component_bundle", + "component_tuple", "timer", "rss_usage", "profile", From 3f14f5d89ef758ea097d793deb9dc607b71a3b1a Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Tue, 6 Jul 2021 13:54:37 -0500 Subject: [PATCH 2/6] Modifications for conda-forge distribution (#212) - Ability to build with static libraries: python bindings, mpip library, mallocp library, ompt library, ncclp library, KokkosP libraries - Setting TIMEMORY_BUILD_PYTHON to OFF now results in searching for external pybind11 install - Moved ArchConfig.cmake to ConfigCpuArch.cmake - Moved CUDAConfig.cmake to ConfigCUDA.cmake - Moved CaliperDepends.cmake to ConfigCaliper.cmake - Moved PythonConfig.cmake to ConfigPython.cmake - Updated caliper and gotcha submodules to support {CALIPER,GOTCHA}_INSTALL_{CONFIG,HEADER} options - Disabled C flag checks when TIMEMORY_BUILD_C is OFF - Added TIMEMORY_INSTALL_PYTHON option (default: auto) - global: force install to ${Python3_SITEARCH} - lib: force install to ${CMAKE_INSTALL_PREFIX}/lib/python/site-packages - prefix: force install to ${CMAKE_INSTALL_PREFIX} - auto: use global if writable, otherwise lib - Fixed BUILD_STATIC_LIBS=ON + CMAKE_POSITION_INDEPENDENT_CODE=ON - Fixed TIMEMORY_USE_CUDA=ON + TIMEMORY_REQUIRE_PACKAGES=ON to fail - If TIMEMORY_REQUIRED_PACKAGES=OFF, search for packages first before adding submodule - Extended setup.py to support more options and support non-development install (no headers or cmake config) - Removed TIMEMORY_EMBED_PYTHON option - Disable timemory-jump when no shared libraries are built since dlopen isn't possible --- .circleci/config.yml | 2 +- .requirements/build.txt | 1 - CMakeLists.txt | 24 +- VERSION | 2 +- cmake/Modules/BuildSettings.cmake | 2 +- cmake/Modules/Compilers.cmake | 30 +- .../{CUDAConfig.cmake => ConfigCUDA.cmake} | 0 ...liperDepends.cmake => ConfigCaliper.cmake} | 8 +- .../{ArchConfig.cmake => ConfigCpuArch.cmake} | 12 +- ...{PythonConfig.cmake => ConfigPython.cmake} | 67 +++- cmake/Modules/MacroUtilities.cmake | 7 +- cmake/Modules/Options.cmake | 78 +++-- cmake/Modules/PackageConfigure.cmake | 3 +- cmake/Modules/Packages.cmake | 62 ++-- cmake/Modules/ProjectSetup.cmake | 5 +- docs/api/python.md | 16 +- examples/ex-python/libex_bindings.cpp | 1 - external/CMakeLists.txt | 12 +- external/caliper | 2 +- external/gotcha | 2 +- external/line-profiler | 2 +- pyproject.toml | 3 + recipe/conda_build_config.yaml | 9 - recipe/meta.yaml | 67 ---- setup.cfg | 10 +- setup.py | 315 +++++++++++++----- source/CMakeLists.txt | 2 +- source/python/CMakeLists.txt | 15 +- source/timemory/plotting/CMakeLists.txt | 10 +- source/timemory/plotting/definition.hpp | 27 -- source/timemory/plotting/plotting.cpp | 3 - source/timemory/plotting/types.hpp | 11 - source/tools/kokkos-connector/CMakeLists.txt | 4 +- source/tools/timemory-jump/CMakeLists.txt | 5 + 34 files changed, 469 insertions(+), 350 deletions(-) rename cmake/Modules/{CUDAConfig.cmake => ConfigCUDA.cmake} (100%) rename cmake/Modules/{CaliperDepends.cmake => ConfigCaliper.cmake} (79%) rename cmake/Modules/{ArchConfig.cmake => ConfigCpuArch.cmake} (85%) rename cmake/Modules/{PythonConfig.cmake => ConfigPython.cmake} (82%) delete mode 100644 recipe/conda_build_config.yaml delete mode 100644 recipe/meta.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml index 423a325a7..6c2a4b535 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -241,7 +241,7 @@ jobs: python ./pyctest-runner.py -SF --pyctest-site=CircleCI --pyctest-model=Continuous --pyctest-build-type=Release -j 1 --build-libs shared --python --tools avail timem --cxx-standard=17 --compile-time-perf ${HOME}/ctp -- -V --output-on-failure - -- -DTIMEMORY_BUILD_{CALIPER,COMPILER_INSTRUMENTATION}=OFF -DPYTHON_EXECUTABLE=$(which python) -DTIMEMORY_BUILD_PYTHON_{HATCHET,TIMEMORY_BUILD_PYTHON_LINE_PROFILER}=OFF -DCMAKE_INSTALL_PREFIX=${HOME}/timemory-install + -- -DTIMEMORY_BUILD_{CALIPER,COMPILER_INSTRUMENTATION}=OFF -DPYTHON_EXECUTABLE=$(which python) -DTIMEMORY_BUILD_PYTHON_{HATCHET,LINE_PROFILER}=OFF -DCMAKE_INSTALL_PREFIX=${HOME}/timemory-install - run: name: install command: > diff --git a/.requirements/build.txt b/.requirements/build.txt index 1a23eeae7..7cf50660d 100644 --- a/.requirements/build.txt +++ b/.requirements/build.txt @@ -1,4 +1,3 @@ Cython scikit-build cmake -ninja diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b3e1e0f3..ca0d5990e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,11 +14,11 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND message(AUTHOR_WARNING "In-source build") endif() -if(APPLE AND NOT "$ENV{CONDA_PYTHON_EXE}" STREQUAL "") - # disable by default bc conda will set these and cause problem with python bindings - set(CMAKE_C_FLAGS "" CACHE STRING "") - set(CMAKE_CXX_FLAGS "" CACHE STRING "") -endif() +# if(APPLE AND NOT "$ENV{CONDA_PYTHON_EXE}" STREQUAL "") +# # disable by default bc conda will set these and cause problem with python bindings +# set(CMAKE_C_FLAGS "" CACHE STRING "") +# set(CMAKE_CXX_FLAGS "" CACHE STRING "") +# endif() #----------------------------------------------------------------------------------------# # project @@ -183,14 +183,12 @@ option(TIMEMORY_QUIET_CONFIG "Make timemory configuration quieter" OFF) mark_as_advanced(TIMEMORY_QUIET_CONFIG) if(SKBUILD) - set(_BUILD_SHARED_CXX ON) + if(BUILD_STATIC_LIBS AND TIMEMORY_USE_PYTHON) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + endif() else() - if((TIMEMORY_BUILD_PYTHON OR TIMEMORY_USE_PYTHON) AND NOT BUILD_SHARED_LIBS) - if(NOT TIMEMORY_BUILD_QUIET) - message(AUTHOR_WARNING "BUILD_SHARED_LIBS=OFF --> disabling TIMEMORY_BUILD_PYTHON...") - endif() - set(TIMEMORY_BUILD_PYTHON OFF) - set(TIMEMORY_USE_PYTHON OFF) + if(BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS AND TIMEMORY_USE_PYTHON AND NOT CMAKE_POSITION_INDEPENDENT_CODE) + message(FATAL_ERROR "Error! Python compilation with static libraries requires CMAKE_POSITION_INDEPENDENT_CODE to be ON") endif() endif() @@ -202,7 +200,7 @@ endif() set(_TLS_DESCRIPT "Thread-local static model: 'global-dynamic', 'local-dynamic', 'initial-exec', 'local-exec'") set(_TLS_OPTIONS "global-dynamic" "local-dynamic" "initial-exec" "local-exec") -if(SKBUILD OR TIMEMORY_BUILD_PYTHON OR TIMEMORY_USE_PYTHON OR TIMEMORY_USE_DYNINST) +if(SKBUILD OR TIMEMORY_USE_PYTHON OR TIMEMORY_USE_DYNINST) set(TIMEMORY_TLS_MODEL "global-dynamic" CACHE STRING "${_TLS_DESCRIPT}") # ensure local override set(TIMEMORY_TLS_MODEL "global-dynamic") diff --git a/VERSION b/VERSION index 944880fa1..5c7feaa80 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.0 +3.2.1.rc12 diff --git a/cmake/Modules/BuildSettings.cmake b/cmake/Modules/BuildSettings.cmake index 8a248e2cd..3b532206d 100644 --- a/cmake/Modules/BuildSettings.cmake +++ b/cmake/Modules/BuildSettings.cmake @@ -333,7 +333,7 @@ set(VECTOR_DEFINITION TIMEMORY_VEC) set(VECTOR_INTERFACE_TARGET timemory-vector) set(ARCH_INTERFACE_TARGET timemory-arch) -include(ArchConfig) +include(ConfigCpuArch) add_cmake_defines(TIMEMORY_VEC VALUE) diff --git a/cmake/Modules/Compilers.cmake b/cmake/Modules/Compilers.cmake index 1b23ccc13..db0521233 100644 --- a/cmake/Modules/Compilers.cmake +++ b/cmake/Modules/Compilers.cmake @@ -174,21 +174,25 @@ macro(ADD_C_FLAG_IF_AVAIL FLAG) string(REPLACE "-" "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE " " "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE "=" "_" FLAG_NAME "${FLAG_NAME}") - timemory_begin_flag_check() - check_c_compiler_flag("-Werror" c_werror) - if(c_werror) - check_c_compiler_flag("${FLAG} -Werror" ${FLAG_NAME}) + if(NOT TIMEMORY_BUILD_C) + set(${FLAG_NAME} ON) else() - check_c_compiler_flag("${FLAG}" ${FLAG_NAME}) - endif() - timemory_end_flag_check() - if(${FLAG_NAME}) - if("${_LTARG}" STREQUAL "") - list(APPEND ${PROJECT_NAME}_C_FLAGS "${FLAG}") - list(APPEND ${PROJECT_NAME}_C_COMPILE_OPTIONS "${FLAG}") - add_target_c_flag(${LIBNAME}-compile-options ${FLAG}) + timemory_begin_flag_check() + check_c_compiler_flag("-Werror" c_werror) + if(c_werror) + check_c_compiler_flag("${FLAG} -Werror" ${FLAG_NAME}) else() - add_target_c_flag(${_TARG} ${FLAG}) + check_c_compiler_flag("${FLAG}" ${FLAG_NAME}) + endif() + timemory_end_flag_check() + if(${FLAG_NAME}) + if("${_LTARG}" STREQUAL "") + list(APPEND ${PROJECT_NAME}_C_FLAGS "${FLAG}") + list(APPEND ${PROJECT_NAME}_C_COMPILE_OPTIONS "${FLAG}") + add_target_c_flag(${LIBNAME}-compile-options ${FLAG}) + else() + add_target_c_flag(${_TARG} ${FLAG}) + endif() endif() endif() endif() diff --git a/cmake/Modules/CUDAConfig.cmake b/cmake/Modules/ConfigCUDA.cmake similarity index 100% rename from cmake/Modules/CUDAConfig.cmake rename to cmake/Modules/ConfigCUDA.cmake diff --git a/cmake/Modules/CaliperDepends.cmake b/cmake/Modules/ConfigCaliper.cmake similarity index 79% rename from cmake/Modules/CaliperDepends.cmake rename to cmake/Modules/ConfigCaliper.cmake index 56f29df4b..45126f5b7 100644 --- a/cmake/Modules/CaliperDepends.cmake +++ b/cmake/Modules/ConfigCaliper.cmake @@ -1,7 +1,7 @@ # Try to find the libraries and headers for Caliper optional dependencies # Usage of this module is as follows # -# include(CaliperDepends) +# include(ConfigCaliper) # set(CALIPER_OPTION_PREFIX ON CACHE INTERNAL "Prefix caliper options with CALIPER_") @@ -11,9 +11,9 @@ set(CALIPER_WITH_PAPI OFF CACHE BOOL "Enable PAPI in Caliper") set(CALIPER_WITH_MPI OFF CACHE BOOL "Enable MPI in Caliper") set(CALIPER_WITH_CUPTI OFF CACHE BOOL "Enable CUPTI in Caliper") -if(TIMEMORY_USE_CUPTI) - set(CALIPER_WITH_CUPTI OFF CACHE BOOL "Enable cupti in Caliper") -endif() +# always sync with timemory settings +set(CALIPER_INSTALL_CONFIG ${TIMEMORY_INSTALL_CONFIG} CACHE BOOL "Install cmake and pkg-config files" FORCE) +set(CALIPER_INSTALL_HEADERS ${TIMEMORY_INSTALL_HEADERS} CACHE BOOL "Install caliper headers" FORCE) find_path(LIBUNWIND_INCLUDE_DIR NAMES unwind.h libunwind.h diff --git a/cmake/Modules/ArchConfig.cmake b/cmake/Modules/ConfigCpuArch.cmake similarity index 85% rename from cmake/Modules/ArchConfig.cmake rename to cmake/Modules/ConfigCpuArch.cmake index 976059458..a52aee625 100644 --- a/cmake/Modules/ArchConfig.cmake +++ b/cmake/Modules/ConfigCpuArch.cmake @@ -2,7 +2,17 @@ # Configures architecture options # -find_package(CpuArch) +set(_CpuArch_COMPONENTS) +if(TIMEMORY_BUILD_PORTABLE) + set(CpuArch_FIND_DEFAULT ON) + if(MSVC) + set(_CpuArch_COMPONENTS OPTIONAL_COMPONENTS sse sse2 avx avx2) + else() + set(_CpuArch_COMPONENTS OPTIONAL_COMPONENTS sse sse2 sse3 ssse3 sse4 sse4_1 sse4_2 fma avx avx2 altivec) + endif() +endif() + +find_package(CpuArch ${_CpuArch_COMPONENTS}) if(CpuArch_FOUND) diff --git a/cmake/Modules/PythonConfig.cmake b/cmake/Modules/ConfigPython.cmake similarity index 82% rename from cmake/Modules/PythonConfig.cmake rename to cmake/Modules/ConfigPython.cmake index 258063e0a..c1bdd3530 100644 --- a/cmake/Modules/PythonConfig.cmake +++ b/cmake/Modules/ConfigPython.cmake @@ -66,7 +66,7 @@ if(PYTHON_EXECUTABLE AND NOT Python3_EXECUTABLE) endif() # default python types to search for -set(Python_ADDITIONAL_VERSIONS "3.9;3.8;3.7;3.6" CACHE STRING +set(Python_ADDITIONAL_VERSIONS "3.9;3.8;3.7;3.6" CACHE STRING "Python versions supported by timemory") # override types to search for @@ -157,6 +157,7 @@ endif() if(NOT Python3_FOUND) set(TIMEMORY_USE_PYTHON OFF) set(TIMEMORY_BUILD_PYTHON OFF) + inform_empty_interface(timemory-python "Python embedded interpreter") inform_empty_interface(timemory-plotting "Python plotting from C++") else() set(TIMEMORY_PYTHON_VERSION "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}" @@ -220,10 +221,10 @@ execute_process(COMMAND ${PYTHON_EXECUTABLE} string(REPLACE " " " " TIMEMORY_INSTALL_DATE "${TIMEMORY_INSTALL_DATE}") -if(SKBUILD) +if(SKBUILD OR "${TIMEMORY_INSTALL_PYTHON}" STREQUAL "prefix") set(CMAKE_INSTALL_PYTHONDIR ${CMAKE_INSTALL_PREFIX} CACHE PATH "Installation directory for python") -elseif(SPACK_BUILD) +elseif(SPACK_BUILD OR "${TIMEMORY_INSTALL_PYTHON}" STREQUAL "lib") set(CMAKE_INSTALL_PYTHONDIR lib/python${PYBIND11_PYTHON_VERSION}/site-packages CACHE PATH "Installation directory for python") @@ -255,6 +256,9 @@ else() endif() # check the error code of the touch command if(ERR_CODE) + if("${TIMEMORY_INSTALL_PYTHON}" STREQUAL "global") + message(FATAL_ERROR "timemory could not install python files to ${Python3_SITEARCH} (not writable):\n${ERR_MSG}") + endif() # get the python directory name, e.g. 'python3.6' from # '/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6' get_filename_component(PYDIR "${Python3_STDLIB}" NAME) @@ -265,12 +269,23 @@ else() endif() if(TIMEMORY_BUILD_PYTHON OR pybind11_FOUND) + set(_PYBIND11_INCLUDE_DIRS) + foreach(_TARG pybind11 pybind11::pybind11 pybind11::module) + if(TARGET ${_TARG}) + get_target_property(_INCLUDE_DIR ${_TARG} INTERFACE_INCLUDE_DIRECTORIES) + list(APPEND _PYBIND11_INCLUDE_DIRS ${_INCLUDE_DIR}) + endif() + endforeach() + if(_PYBIND11_INCLUDE_DIRS) + list(REMOVE_DUPLICATES _PYBIND11_INCLUDE_DIRS) + endif() timemory_target_compile_definitions(timemory-python INTERFACE TIMEMORY_USE_PYTHON) target_link_libraries(timemory-python INTERFACE ${PYTHON_LIBRARIES}) target_include_directories(timemory-python SYSTEM INTERFACE ${PYTHON_INCLUDE_DIRS} ${PYBIND11_INCLUDE_DIRS} - $) + $ + $) endif() if(APPLE) @@ -309,5 +324,47 @@ find_package(PythonLibs ${TIMEMORY_PYTHON_VERSION} EXACT REQUIRED) # find_package(PythonExtensions REQUIRED) if("${PYTHON_MODULE_EXTENSION}" STREQUAL "") - message(WARNING "Python module extension is empty!") + execute_process( + COMMAND + "${Python3_EXECUTABLE}" "-c" " +from distutils import sysconfig as s;import sys;import struct; +print('.'.join(str(v) for v in sys.version_info)); +print(sys.prefix); +print(s.get_python_inc(plat_specific=True)); +print(s.get_python_lib(plat_specific=True)); +print(s.get_config_var('EXT_SUFFIX') or s.get_config_var('SO')); +print(hasattr(sys, 'gettotalrefcount')+0); +print(struct.calcsize('@P')); +print(s.get_config_var('LDVERSION') or s.get_config_var('VERSION')); +print(s.get_config_var('LIBDIR') or ''); +print(s.get_config_var('MULTIARCH') or ''); +" + RESULT_VARIABLE _PYTHON_SUCCESS + OUTPUT_VARIABLE _PYTHON_VALUES + ERROR_VARIABLE _PYTHON_ERROR_VALUE) + + if(_PYTHON_SUCCESS MATCHES 0) + # Convert the process output into a list + if(WIN32) + string(REGEX REPLACE "\\\\" "/" _PYTHON_VALUES ${_PYTHON_VALUES}) + endif() + string(REGEX REPLACE ";" "\\\\;" _PYTHON_VALUES ${_PYTHON_VALUES}) + string(REGEX REPLACE "\n" ";" _PYTHON_VALUES ${_PYTHON_VALUES}) + list(GET _PYTHON_VALUES 0 _PYTHON_VERSION_LIST) + list(GET _PYTHON_VALUES 1 PYTHON_PREFIX) + list(GET _PYTHON_VALUES 2 PYTHON_INCLUDE_DIR) + list(GET _PYTHON_VALUES 3 PYTHON_SITE_PACKAGES) + list(GET _PYTHON_VALUES 4 PYTHON_MODULE_EXTENSION) + list(GET _PYTHON_VALUES 5 PYTHON_IS_DEBUG) + list(GET _PYTHON_VALUES 6 PYTHON_SIZEOF_VOID_P) + list(GET _PYTHON_VALUES 7 PYTHON_LIBRARY_SUFFIX) + list(GET _PYTHON_VALUES 8 PYTHON_LIBDIR) + list(GET _PYTHON_VALUES 9 PYTHON_MULTIARCH) + else() + message(WARNING "${_PYTHON_ERROR_VALUE}") + endif() + + if("${PYTHON_MODULE_EXTENSION}" STREQUAL "") + message(WARNING "Python module extension is empty!") + endif() endif() diff --git a/cmake/Modules/MacroUtilities.cmake b/cmake/Modules/MacroUtilities.cmake index b1938192f..8fbf950b0 100644 --- a/cmake/Modules/MacroUtilities.cmake +++ b/cmake/Modules/MacroUtilities.cmake @@ -635,6 +635,11 @@ FUNCTION(BUILD_LIBRARY) set(_EXCLUDE EXCLUDE_FROM_ALL) endif() + # handle PIC not specified but global PIC specified + if(NOT LIBRARY_PIC AND CMAKE_POSITION_INDEPENDENT_CODE) + set(LIBRARY_PIC ON) + endif() + if(NOT "${LIBRARY_TYPE}" STREQUAL "OBJECT") if(NOT WIN32 AND NOT XCODE) list(APPEND LIBRARY_EXTRA_PROPERTIES @@ -1092,7 +1097,7 @@ FUNCTION(BUILD_INTERMEDIATE_LIBRARY) if(_BUILD_STATIC_CXX OR COMP_FORCE_STATIC) list(APPEND _LIB_TYPES static) - set(static_OPTIONS PIC TYPE STATIC) + set(static_OPTIONS TYPE STATIC) set(_LIB_DEFAULT_TYPE static) endif() diff --git a/cmake/Modules/Options.cmake b/cmake/Modules/Options.cmake index 334d7e37f..ca726c0ad 100644 --- a/cmake/Modules/Options.cmake +++ b/cmake/Modules/Options.cmake @@ -105,10 +105,11 @@ timemory_test_find_package(libunwind _USE_LIBUNWIND) set(_REQUIRE_LIBUNWIND OFF) set(_HATCHET ${_UNIX_OS}) -# once hatchet is available in a release with timemory support -# if(SKBUILD OR SPACK_BUILD) -# set(_HATCHET OFF) -# endif() + +# skip check_language if suppose to fail +if(DEFINED TIMEMORY_USE_CUDA AND TIMEMORY_USE_CUDA AND TIMEMORY_REQUIRE_PACKAGES) + enable_language(CUDA) +endif() # Check if CUDA can be enabled if CUDA is enabled or in auto-detect mode if(TIMEMORY_USE_CUDA OR (NOT DEFINED TIMEMORY_USE_CUDA AND NOT TIMEMORY_REQUIRE_PACKAGES)) @@ -199,11 +200,12 @@ if(NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) set(TIMEMORY_BUILD_PYTHON OFF) set(TIMEMORY_BUILD_FORTRAN OFF) set(TIMEMORY_USE_PYTHON OFF) - set(TIMEMORY_USE_DYNINST OFF) + set(TIMEMORY_USE_NCCL OFF) set(TIMEMORY_BUILD_KOKKOS_TOOLS OFF) set(TIMEMORY_BUILD_DYNINST_TOOLS OFF) set(TIMEMORY_BUILD_MPIP_LIBRARY OFF) set(TIMEMORY_BUILD_OMPT_LIBRARY OFF) + set(TIMEMORY_BUILD_NCCLP_LIBRARY OFF) endif() if(${PROJECT_NAME}_MAIN_PROJECT OR TIMEMORY_LANGUAGE_STANDARDS) @@ -217,7 +219,7 @@ if(${PROJECT_NAME}_MAIN_PROJECT OR TIMEMORY_LANGUAGE_STANDARDS) endif() if(${PROJECT_NAME}_MAIN_PROJECT OR TIMEMORY_LANGUAGE_STANDARDS) - # standard + # standard set(CMAKE_C_STANDARD 11 CACHE STRING "C language standard") set(CMAKE_CXX_STANDARD 14 CACHE STRING "CXX language standard") if(CMAKE_VERSION VERSION_LESS 3.18.0) @@ -257,12 +259,31 @@ endif() add_option(CMAKE_INSTALL_RPATH_USE_LINK_PATH "Embed RPATH using link path" ON) +set(_INSTALL_PYTHON auto) +if(SKBUILD) + set(_INSTALL_PYTHON prefix) +elseif(SPACK_BUILD) + set(_INSTALL_PYTHON lib) +endif() # Install settings add_option(TIMEMORY_INSTALL_HEADERS "Install the header files" ON) -add_option(TIMEMORY_INSTALL_CONFIG "Install the cmake package config files, i.e. timemory-config.cmake, etc." ON) -add_option(TIMEMORY_INSTALL_ALL - "install target depends on all target. Set to OFF to only install artifacts which were explicitly built" ON) +add_option(TIMEMORY_INSTALL_CONFIG "Install the cmake package config files, i.e. timemory-config.cmake, etc." ON) +add_option(TIMEMORY_INSTALL_ALL "'install' target depends on 'all' target. Set to OFF to only install artifacts which were explicitly built" ON) +set(TIMEMORY_INSTALL_PYTHON "${_INSTALL_PYTHON}" CACHE STRING "Installation mode for Python") +set(TIMEMORY_INSTALL_PYTHON_OPTIONS auto global lib prefix) +set_property(CACHE TIMEMORY_INSTALL_PYTHON PROPERTY STRINGS "${TIMEMORY_INSTALL_PYTHON_OPTIONS}") +if(NOT "${TIMEMORY_INSTALL_PYTHON}" IN_LIST TIMEMORY_INSTALL_PYTHON_OPTIONS) + message("") + message(STATUS "TIMEMORY_INSTALL_PYTHON options:") + message(" global = Python3_SITEARCH") + message(" lib = ${CMAKE_INSTALL_PREFIX}/lib/python/site-packages") + message(" prefix = ${CMAKE_INSTALL_PREFIX} (generally only used by scikit-build)") + message(" auto = global (if writable) otherwise lib") + message("") + message(FATAL_ERROR "TIMEMORY_INSTALL_PYTHON set to invalid option. See guide above") +endif() +add_feature(TIMEMORY_INSTALL_PYTHON "Installation mode for python (${TIMEMORY_INSTALL_PYTHON_OPTIONS})") if(NOT TIMEMORY_INSTALL_ALL) set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY ON) @@ -283,8 +304,10 @@ add_option(TIMEMORY_BUILD_C "Build the C compatible library" ON) add_option(TIMEMORY_BUILD_FORTRAN "Build the Fortran compatible library" ${_BUILD_FORTRAN}) +add_option(TIMEMORY_BUILD_PORTABLE + "Disable arch flags which may cause portability issues (e.g. AVX-512)" OFF) add_option(TIMEMORY_BUILD_PYTHON - "Build Python binding" OFF) + "Build Python bindings with internal pybind11" ON) add_option(TIMEMORY_BUILD_PYTHON_LINE_PROFILER "Build customized Python line-profiler" ON) add_option(TIMEMORY_BUILD_PYTHON_HATCHET @@ -366,7 +389,7 @@ define_default_option(_GPERFTOOLS ON) define_default_option(_VTUNE ON) define_default_option(_CUDA ${_USE_CUDA}) define_default_option(_CALIPER ${_BUILD_CALIPER}) -define_default_option(_PYTHON ${TIMEMORY_BUILD_PYTHON}) +define_default_option(_PYTHON OFF) define_default_option(_DYNINST ON) define_default_option(_ALLINEA_MAP ON) define_default_option(_CRAYPAT ON) @@ -471,22 +494,19 @@ if(TIMEMORY_BUILD_TOOLS AND TIMEMORY_USE_DYNINST) endif() set(_MPIP ${TIMEMORY_USE_MPI}) -if(_MPIP AND (NOT BUILD_SHARED_LIBS OR NOT TIMEMORY_USE_GOTCHA)) +if(_MPIP AND NOT TIMEMORY_USE_GOTCHA) set(_MPIP OFF) endif() set(_OMPT ${TIMEMORY_USE_OMPT}) -if(_OMPT AND NOT BUILD_SHARED_LIBS) - set(_OMPT OFF) -endif() set(_NCCLP ${TIMEMORY_USE_NCCL}) -if(_NCCLP AND (NOT BUILD_SHARED_LIBS OR NOT TIMEMORY_USE_GOTCHA)) +if(_NCCLP AND NOT TIMEMORY_USE_GOTCHA) set(_NCCLP OFF) endif() set(_MALLOCP ${TIMEMORY_USE_GOTCHA}) -if(_MALLOCP AND (NOT BUILD_SHARED_LIBS OR NOT TIMEMORY_USE_GOTCHA)) +if(_MALLOCP AND NOT TIMEMORY_USE_GOTCHA) set(_MALLOCP OFF) endif() @@ -512,35 +532,33 @@ unset(_NCCLP) unset(_MALLOCP) unset(_DYNINST) -if(TIMEMORY_BUILD_MPIP_LIBRARY AND (NOT BUILD_SHARED_LIBS OR - NOT TIMEMORY_USE_MPI OR NOT TIMEMORY_USE_GOTCHA)) +if(TIMEMORY_BUILD_MPIP_LIBRARY AND (NOT TIMEMORY_USE_MPI OR NOT TIMEMORY_USE_GOTCHA)) timemory_message(AUTHOR_WARNING - "TIMEMORY_BUILD_MPIP_LIBRARY requires BUILD_SHARED_LIBS=ON, TIMEMORY_USE_MPI=ON, and TIMEMORY_USE_GOTCHA=ON...") + "TIMEMORY_BUILD_MPIP_LIBRARY requires TIMEMORY_USE_MPI=ON and TIMEMORY_USE_GOTCHA=ON...") set(TIMEMORY_BUILD_MPIP_LIBRARY OFF CACHE BOOL "Build the mpiP library" FORCE) endif() if(TIMEMORY_BUILD_OMPT_LIBRARY AND NOT TIMEMORY_USE_OMPT) timemory_message(AUTHOR_WARNING - "TIMEMORY_BUILD_OMPT_LIBRARY requires BUILD_SHARED_LIBS=ON and TIMEMORY_USE_OMPT=ON...") + "TIMEMORY_BUILD_OMPT_LIBRARY requires TIMEMORY_USE_OMPT=ON...") set(TIMEMORY_BUILD_OMPT_LIBRARY OFF CACHE BOOL "Build the OMPT library" FORCE) endif() -if(TIMEMORY_BUILD_NCCLP_LIBRARY AND (NOT BUILD_SHARED_LIBS OR - NOT TIMEMORY_USE_NCCL OR NOT TIMEMORY_USE_GOTCHA)) +if(TIMEMORY_BUILD_NCCLP_LIBRARY AND (NOT TIMEMORY_USE_NCCL OR NOT TIMEMORY_USE_GOTCHA)) timemory_message(AUTHOR_WARNING - "TIMEMORY_BUILD_NCCLP_LIBRARY requires BUILD_SHARED_LIBS=ON, TIMEMORY_USE_NCCL=ON, and TIMEMORY_USE_GOTCHA=ON...") + "TIMEMORY_BUILD_NCCLP_LIBRARY requires TIMEMORY_USE_NCCL=ON, and TIMEMORY_USE_GOTCHA=ON...") set(TIMEMORY_BUILD_NCCLP_LIBRARY OFF CACHE BOOL "Build the ncclP library" FORCE) endif() -if(TIMEMORY_BUILD_MALLOCP_LIBRARY AND (NOT BUILD_SHARED_LIBS OR NOT TIMEMORY_USE_GOTCHA)) +if(TIMEMORY_BUILD_MALLOCP_LIBRARY AND NOT TIMEMORY_USE_GOTCHA) timemory_message(AUTHOR_WARNING - "TIMEMORY_BUILD_MALLOCP_LIBRARY requires BUILD_SHARED_LIBS=ON and TIMEMORY_USE_GOTCHA=ON...") + "TIMEMORY_BUILD_MALLOCP_LIBRARY requires TIMEMORY_USE_GOTCHA=ON...") set(TIMEMORY_BUILD_MALLOCP_LIBRARY OFF CACHE BOOL "Build the ncclP library" FORCE) endif() -if(NOT BUILD_SHARED_LIBS AND TIMEMORY_BUILD_KOKKOS_TOOLS) +if(NOT BUILD_SHARED_LIBS AND TIMEMORY_BUILD_KOKKOS_TOOLS AND NOT CMAKE_POSITION_INDEPENDENT_CODE) timemory_message(AUTHOR_WARNING - "TIMEMORY_BUILD_KOKKOS_TOOLS requires BUILD_SHARED_LIBS=ON...") + "TIMEMORY_BUILD_KOKKOS_TOOLS requires CMAKE_POSITION_INDEPENDENT_CODE=ON if shared libraries are not enabled...") set(TIMEMORY_BUILD_KOKKOS_TOOLS OFF CACHE BOOL "Build the kokkos-tools libraries" FORCE) endif() @@ -592,10 +610,6 @@ if(NOT TIMEMORY_USE_CUDA) unset(CMAKE_CUDA_COMPILER CACHE) endif() -if(TIMEMORY_USE_PYTHON) - set(TIMEMORY_BUILD_PYTHON ON) -endif() - if(WIN32) option(TIMEMORY_USE_WINSOCK "Include winsock.h with the windows build" OFF) endif() diff --git a/cmake/Modules/PackageConfigure.cmake b/cmake/Modules/PackageConfigure.cmake index 79249a35f..6486b1e39 100644 --- a/cmake/Modules/PackageConfigure.cmake +++ b/cmake/Modules/PackageConfigure.cmake @@ -20,7 +20,7 @@ foreach(_LANG C CXX CUDA) endforeach() set(_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) -if(TIMEMORY_BUILD_PYTHON OR TIMEMORY_USE_PYTHON) +if(TIMEMORY_USE_PYTHON) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; print('{}'.format(sys.prefix))" OUTPUT_VARIABLE _INSTALL_PREFIX @@ -104,4 +104,3 @@ if(TIMEMORY_USE_GPERFTOOLS) endif() export(PACKAGE ${PROJECT_NAME}) - diff --git a/cmake/Modules/Packages.cmake b/cmake/Modules/Packages.cmake index 6e9a54545..20da4cec9 100644 --- a/cmake/Modules/Packages.cmake +++ b/cmake/Modules/Packages.cmake @@ -670,37 +670,31 @@ endif() # PyBind11 # #----------------------------------------------------------------------------------------# -# if using is enable but not internal pybind11 distribution -if(TIMEMORY_USE_PYTHON AND NOT TIMEMORY_BUILD_PYTHON) - find_package(pybind11 ${TIMEMORY_FIND_REQUIREMENT}) +if(TIMEMORY_USE_PYTHON AND (NOT TIMEMORY_BUILD_PYTHON OR NOT TIMEMORY_REQUIRE_PACKAGES)) - if(NOT pybind11_FOUND) - set(TIMEMORY_USE_PYTHON OFF) + find_package(pybind11 ${TIMEMORY_FIND_QUIETLY} ${TIMEMORY_FIND_REQUIREMENT}) + + if(pybind11_FOUND) set(TIMEMORY_BUILD_PYTHON OFF) else() - set(TIMEMORY_PYTHON_VERSION "${PYBIND11_PYTHON_VERSION}" CACHE STRING - "Python version for timemory") + set(TIMEMORY_BUILD_PYTHON ON) endif() - if(NOT "${TIMEMORY_PYTHON_VERSION}" MATCHES "${PYBIND11_PYTHON_VERSION}*") - message(STATUS "TIMEMORY_PYTHON_VERSION is set to ${TIMEMORY_PYTHON_VERSION}") - message(STATUS "PYBIND11_PYTHON_VERSION is set to ${PYBIND11_PYTHON_VERSION}") - message(FATAL_ERROR - "Mismatched 'TIMEMORY_PYTHON_VERSION' and 'PYBIND11_PYTHON_VERSION'") +else() + if(PYBIND11_INSTALL) + # just above warning about variable endif() - endif() if(TIMEMORY_USE_PYTHON) - include(PythonConfig) + include(ConfigPython) else() set(TIMEMORY_BUILD_PYTHON OFF) inform_empty_interface(timemory-python "Python embedded interpreter") inform_empty_interface(timemory-plotting "Python plotting from C++") endif() - #----------------------------------------------------------------------------------------# # # Google Test @@ -763,7 +757,7 @@ endif() #----------------------------------------------------------------------------------------# if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - find_library(GCOV_LIBRARY gcov ${TIMEMORY_FIND_QUIETLY}) + find_library(GCOV_LIBRARY gcov) add_target_flag_if_avail(timemory-coverage "-fprofile-abs-path" "--coverage") add_target_flag(timemory-coverage "-fprofile-arcs" "-ftest-coverage" "-O0" "-g") @@ -795,7 +789,7 @@ if(TIMEMORY_USE_CUDA) set(PROJECT_CUDA_USE_HALF_OPTION TIMEMORY_USE_CUDA_HALF) set(PROJECT_CUDA_USE_HALF_DEFINITION TIMEMORY_USE_CUDA_HALF) - include(CUDAConfig) + include(ConfigCUDA) find_package(NVTX ${TIMEMORY_FIND_QUIETLY}) if(NVTX_FOUND) @@ -816,6 +810,7 @@ else() set(TIMEMORY_USE_NVTX OFF) set(TIMEMORY_USE_CUPTI OFF) inform_empty_interface(timemory-cuda "CUDA") + inform_empty_interface(timemory-cuda-compiler "CUDA compiler options") inform_empty_interface(timemory-cudart "CUDA Runtime (shared)") inform_empty_interface(timemory-cudart-device "CUDA Runtime (device)") inform_empty_interface(timemory-cudart-static "CUDA Runtime (static)") @@ -842,7 +837,6 @@ if(CUPTI_FOUND) target_link_libraries(timemory-cupti INTERFACE ${CUPTI_LIBRARIES} timemory-cuda - # timemory-cudart timemory-cudart-device) target_link_directories(timemory-cupti INTERFACE @@ -888,7 +882,7 @@ if(TIMEMORY_USE_NCCL) find_package(NCCL ${TIMEMORY_FIND_QUIETLY} ${TIMEMORY_FIND_REQUIREMENT}) endif() -if(NCCL_FOUND AND TIMEMORY_USE_CUDA) +if(NCCL_FOUND) add_rpath(${NCCL_LIBRARIES}) target_link_libraries(timemory-nccl INTERFACE ${NCCL_LIBRARIES}) target_include_directories(timemory-nccl SYSTEM INTERFACE ${NCCL_INCLUDE_DIRS}) @@ -957,11 +951,6 @@ if(NOT TIMEMORY_FORCE_GPERFTOOLS_PYTHON) set(_GPERF_COMPONENTS ) set(TIMEMORY_gperftools_COMPONENTS ) endif() - - if(TIMEMORY_BUILD_PYTHON) - set(_GPERF_COMPONENTS ) - set(TIMEMORY_gperftools_COMPONENTS ) - endif() endif() if(TIMEMORY_USE_GPERFTOOLS) @@ -998,7 +987,7 @@ if(TIMEMORY_USE_GPERFTOOLS) # changes malloc/free after Python has used libc malloc, which commonly # corrupts the deletion of the Python interpreter at the end of the application # - if(TIMEMORY_BUILD_PYTHON) + if(TIMEMORY_USE_PYTHON) set(gperftools_PREFER_STATIC OFF) endif() @@ -1028,6 +1017,9 @@ if(TIMEMORY_USE_GPERFTOOLS) add_rpath(${gperftools_LIBRARIES} ${gperftools_ROOT_DIR}/lib ${gperftools_ROOT_DIR}/lib64) +else() + set(TIMEMORY_USE_GPERFTOOLS OFF) + inform_empty_interface(timemory-gperftools "gperftools") endif() @@ -1041,6 +1033,13 @@ if(NOT TIMEMORY_USE_CALIPER) set(TIMEMORY_BUILD_CALIPER OFF) endif() +if(TIMEMORY_USE_CALIPER AND NOT TIMEMORY_REQUIRE_PACKAGES) + find_package(caliper ${TIMEMORY_FIND_QUIETLY} ${TIMEMORY_FIND_REQUIREMENT}) + if(caliper_FOUND) + set(TIMEMORY_BUILD_CALIPER OFF) + endif() +endif() + if(TIMEMORY_BUILD_CALIPER) set(caliper_FOUND ON) checkout_git_submodule(RECURSIVE @@ -1048,7 +1047,7 @@ if(TIMEMORY_BUILD_CALIPER) WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} REPO_URL https://github.com/jrmadsen/Caliper.git REPO_BRANCH master) - include(CaliperDepends) + include(ConfigCaliper) set(_ORIG_CEXT ${CMAKE_C_EXTENSIONS}) set(_ORIG_TESTING ${BUILD_TESTING}) set(CMAKE_C_EXTENSIONS ON) @@ -1107,8 +1106,17 @@ endif() # #----------------------------------------------------------------------------------------# if(UNIX AND NOT APPLE) - set(GOTCHA_BUILD_EXAMPLES OFF CACHE BOOL "Build GOTCHA examples") + if(TIMEMORY_USE_GOTCHA AND NOT TIMEMORY_REQUIRE_PACKAGES) + find_package(gotcha ${TIMEMORY_FIND_QUIETLY} ${TIMEMORY_FIND_REQUIREMENT}) + if(gotcha_FOUND) + set(TIMEMORY_BUILD_GOTCHA OFF) + endif() + endif() + if(TIMEMORY_BUILD_GOTCHA AND TIMEMORY_USE_GOTCHA) + set(GOTCHA_BUILD_EXAMPLES OFF CACHE BOOL "Build GOTCHA examples") + set(GOTCHA_INSTALL_CONFIG ${TIMEMORY_INSTALL_CONFIG} CACHE BOOL "Install gotcha cmake config" FORCE) + set(GOTCHA_INSTALL_HEADERS ${TIMEMORY_INSTALL_HEADERS} CACHE BOOL "Install gotcha headers" FORCE) set(gotcha_FOUND ON) checkout_git_submodule(RECURSIVE RELATIVE_PATH external/gotcha diff --git a/cmake/Modules/ProjectSetup.cmake b/cmake/Modules/ProjectSetup.cmake index 28cb7c647..3d0f12e8d 100644 --- a/cmake/Modules/ProjectSetup.cmake +++ b/cmake/Modules/ProjectSetup.cmake @@ -80,9 +80,6 @@ math(EXPR TIMEMORY_VERSION_CODE # setup.py #----------------------------------------------------------------------------------------# -if(SKBUILD) +if(SKBUILD AND TIMEMORY_USE_PYTHON) set(CMAKE_INSTALL_LIBDIR lib) - set(TIMEMORY_USE_PYTHON ON CACHE BOOL "" FORCE) - set(TIMEMORY_BUILD_PYTHON ON CACHE BOOL "" FORCE) - set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) endif() diff --git a/docs/api/python.md b/docs/api/python.md index e1dc08b35..86ed5eeb1 100644 --- a/docs/api/python.md +++ b/docs/api/python.md @@ -24,7 +24,7 @@ PACKAGE CONTENTS component (package) ert (package) hardware_counters (package) - libpytimemory + libs (package) line_profiler (package) mpi (package) mpi_support (package) @@ -46,12 +46,12 @@ SUBMODULES CLASSES pybind11_builtins.pybind11_object(builtins.object) - timemory.libpytimemory.auto_timer - timemory.libpytimemory.component_bundle - timemory.libpytimemory.manager - timemory.libpytimemory.rss_usage - timemory.libpytimemory.settings - timemory.libpytimemory.timer + timemory.libs.auto_timer + timemory.libs.component_bundle + timemory.libs.manager + timemory.libs.rss_usage + timemory.libs.settings + timemory.libs.timer class auto_timer(...) class component_bundle(...) @@ -151,7 +151,7 @@ FUNCTIONS Enable/disable timemory DATA - __all__ = ['version_info', 'build_info', 'version', 'libpytimemory', '... + __all__ = ['version_info', 'build_info', 'version', 'libs', '... __copyright__ = 'Copyright 2020, The Regents of the University of Cali... __email__ = 'jrmadsen@lbl.gov' __license__ = 'MIT' diff --git a/examples/ex-python/libex_bindings.cpp b/examples/ex-python/libex_bindings.cpp index abad8bf81..525115812 100644 --- a/examples/ex-python/libex_bindings.cpp +++ b/examples/ex-python/libex_bindings.cpp @@ -24,7 +24,6 @@ #include "pybind11/cast.h" #include "pybind11/chrono.h" -#include "pybind11/embed.h" #include "pybind11/eval.h" #include "pybind11/functional.h" #include "pybind11/iostream.h" diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 66fff50c1..fff7f00a5 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -1,5 +1,5 @@ -if(TIMEMORY_BUILD_PYTHON AND TIMEMORY_BUILD_PYTHON_LINE_PROFILER) +if(TIMEMORY_USE_PYTHON AND TIMEMORY_BUILD_PYTHON_LINE_PROFILER) checkout_git_submodule(RECURSIVE RELATIVE_PATH external/line-profiler WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} @@ -14,7 +14,7 @@ if(TIMEMORY_BUILD_PYTHON AND TIMEMORY_BUILD_PYTHON_LINE_PROFILER) endif() endif() -if(TIMEMORY_BUILD_PYTHON AND TIMEMORY_BUILD_PYTHON_HATCHET) +if(TIMEMORY_USE_PYTHON AND TIMEMORY_BUILD_PYTHON_HATCHET) checkout_git_submodule(RECURSIVE RELATIVE_PATH external/hatchet WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} @@ -73,3 +73,11 @@ if(TIMEMORY_BUILD_PYTHON AND TIMEMORY_BUILD_PYTHON_HATCHET) endif() endif() endif() + +if(NOT TARGET _line_profiler) + set(TIMEMORY_BUILD_PYTHON_LINE_PROFILER OFF PARENT_SCOPE) +endif() + +if(NOT TARGET hatchet) + set(TIMEMORY_BUILD_PYTHON_HATCHET OFF PARENT_SCOPE) +endif() diff --git a/external/caliper b/external/caliper index 56f7f1bf9..5c9b4a5b0 160000 --- a/external/caliper +++ b/external/caliper @@ -1 +1 @@ -Subproject commit 56f7f1bf9bb4a8c325f2cbff916395b7f1fcf4f9 +Subproject commit 5c9b4a5b07a558290134dc4bda30f841a09fcf72 diff --git a/external/gotcha b/external/gotcha index 26f35f530..2e4578116 160000 --- a/external/gotcha +++ b/external/gotcha @@ -1 +1 @@ -Subproject commit 26f35f530b102a9c27218774ca48fa74e3240d70 +Subproject commit 2e4578116c65899792d1a3d06f15b69a008174ff diff --git a/external/line-profiler b/external/line-profiler index 2e77e7c19..214e87dd7 160000 --- a/external/line-profiler +++ b/external/line-profiler @@ -1 +1 @@ -Subproject commit 2e77e7c198c9e541aa2881cd2628e6614f243ac7 +Subproject commit 214e87dd7fbcee7487959ee779037c4c0a76c3de diff --git a/pyproject.toml b/pyproject.toml index 0e6f7d578..c794a42ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,9 @@ exclude = ''' | \.misc | _build | __pycache__ + | _skbuild | build + | build-timemory | dist | external | scripts @@ -24,6 +26,7 @@ exclude = ''' | docker | docs | hatchet + | .pytest_cache )/ | cmake/Templates/console-script.py.in ) diff --git a/recipe/conda_build_config.yaml b/recipe/conda_build_config.yaml deleted file mode 100644 index 07d761517..000000000 --- a/recipe/conda_build_config.yaml +++ /dev/null @@ -1,9 +0,0 @@ -python: - - 3.6 - - 3.7 -mpi: - - openmpi - - mpich -cuda: - - cudatoolkit - - cudatoolkit-dev diff --git a/recipe/meta.yaml b/recipe/meta.yaml deleted file mode 100644 index 880ddff1d..000000000 --- a/recipe/meta.yaml +++ /dev/null @@ -1,67 +0,0 @@ -{% set name = "timemory" %} -{% set version = "3.0.1" %} -{% set file_ext = "tar.gz" %} -{% set hash_type = "sha256" %} -{% set hash_value = "a4ee67e20fb8536d2c08d643514229a34fe4e748029dc54cf916a3eca5c09417" %} - -package: - name: '{{ name|lower }}' - version: '{{ version }}' - -source: - url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.{{ file_ext }} - '{{ hash_type }}': '{{ hash_value }}' - -build: - number: 0 - script: "{{ PYTHON }} -m pip install . --no-deps --ignore-installed -vvv" - -requirements: - host: - - '{{ compiler('c') }}' - - '{{ compiler('cxx') }}' - - python {{ python }} - - scikit-build - - '{{ mpi }}' - - '{{ cuda }}' - - cmake - - git - - gperftools - run: - - python {{ python }} - - pillow - - matplotlib - - numpy - - '{{ mpi }}' - - '{{ cuda }}' - - gperftools - -test: - imports: - - timemory - - timemory.libpytimemory - - timemory.mpi_support - - timemory.plotting - - timemory.tests - - timemory.ert - - timemory.options - - timemory.roofline - - timemory.signals - - timemory.units - - timemory.util - -about: - home: https://github.com/NERSC/timemory.git - license: MIT - license_family: MIT - license_file: "" - description: | - Lightweight, cross-language utility for recording timing, memory, resource usage, and hardware counters on the CPU and GPU. - Timemory provides 40+ metrics for C, C++, CUDA, and/or Python codes that can arbitrarily composed into distinct toolsets - which can inter-weaved and without nesting restrictions. - doc_url: "https://timemory.readthedocs.io/" - dev_url: "https://github.com/NERSC/timemory.git" - -extra: - recipe-maintainers: - - jrmadsen diff --git a/setup.cfg b/setup.cfg index 404ff6091..4af5a2df8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -59,11 +59,6 @@ classifiers = packages = timemory zip_safe = false include_package_data = false -setup_requires = - scikit-build - cmake>=3.15 - Cython - ninja [flake8] ignore = @@ -71,6 +66,11 @@ ignore = F405, W503, E203, + N801, + N802, + N804, + N806, + N812, exclude = .git, __pycache__, diff --git a/setup.py b/setup.py index cdb052a66..b8cfafe2e 100644 --- a/setup.py +++ b/setup.py @@ -16,10 +16,8 @@ cmake_args = [ "-DPYTHON_EXECUTABLE:FILEPATH={}".format(sys.executable), "-DPython3_EXECUTABLE:FILEPATH={}".format(sys.executable), - "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON", - "-DTIMEMORY_USE_PYTHON:BOOL=ON", - "-DTIMEMORY_BUILD_PYTHON:BOOL=ON", ] +cmake_options = [] # array of functors parser = argparse.ArgumentParser(add_help=False) parser.add_argument("-h", "--help", help="Print help", action="store_true") @@ -28,6 +26,18 @@ gotcha_opt = True +def get_bool_option(_args, _name, default=False): + _name = _name.replace("-", "_") + _enable = getattr(_args, f"enable_{_name}") + _disable = getattr(_args, f"disable_{_name}") + _ret = default + if _enable: + _ret = True + if _disable: + _ret = False + return _ret + + def set_cmake_bool_option(opt, enable_opt, disable_opt): global cmake_args try: @@ -39,45 +49,161 @@ def set_cmake_bool_option(opt, enable_opt, disable_opt): print("Exception: {}".format(e)) -def add_arg_bool_option(lc_name, disp_name, default=None): +def add_arg_bool_option( + lc_name, disp_name, default=None, doc="", disp_aliases=[] +): global parser + global cmake_options + # enable option parser.add_argument( "--enable-{}".format(lc_name), action="store_true", - default=default, - help="Explicitly enable {} build".format(disp_name), + default=(None if default is False else default), + help="Explicitly enable {} build. {}".format(disp_name, doc), ) # disable option parser.add_argument( "--disable-{}".format(lc_name), action="store_true", - help="Explicitly disable {} build".format(disp_name), + default=None, + help="Explicitly disable {} build. {}".format(disp_name, doc), ) + def _add_cmake_bool_option(_args): + _name = lc_name.replace("-", "_") + _enable = getattr(_args, f"enable_{_name}") + _disable = getattr(_args, f"disable_{_name}") + # if default=False is passed in, set _disable to false + # only when neither --enable_{} and --disable_{} were not specified + if default is False and _enable is None and _disable is None: + _disable = True + for itr in [disp_name] + disp_aliases: + set_cmake_bool_option(itr, _enable, _disable) + + cmake_options.append(_add_cmake_bool_option) + -# add options +# build variants +add_arg_bool_option( + "require-packages", + "TIMEMORY_REQUIRE_PACKAGES", + doc=( + "Enables auto-detection of third-party packages" + + " and suppresses configuration failure" + + " when packages are not found" + ), +) +add_arg_bool_option("shared-libs", "BUILD_SHARED_LIBS") +add_arg_bool_option("static-libs", "BUILD_STATIC_LIBS") +add_arg_bool_option( + "install-rpath-use-link-path", + "CMAKE_INSTALL_RPATH_USE_LINK_PATH", + default=True, +) add_arg_bool_option("c", "TIMEMORY_BUILD_C") -add_arg_bool_option("tools", "TIMEMORY_BUILD_TOOLS", default=True) +add_arg_bool_option( + "python", "TIMEMORY_USE_PYTHON", default=True, doc="Build python bindings" +) +add_arg_bool_option("fortran", "TIMEMORY_BUILD_FORTRAN") +add_arg_bool_option( + "arch", "TIMEMORY_USE_ARCH", doc="Compile everything for CPU arch" +) +add_arg_bool_option( + "portable", + "TIMEMORY_BUILD_PORTABLE", + doc="Disable CPU arch flags likely to cause portability issue", +) +add_arg_bool_option("ert", "TIMEMORY_BUILD_ERT") +add_arg_bool_option( + "skip-build", "TIMEMORY_SKIP_BUILD", doc="Disable building any libraries" +) +add_arg_bool_option( + "unity-build", + "TIMEMORY_UNITY_BUILD", + doc="timemory-localized CMAKE_UNITY_BUILD", +) +add_arg_bool_option( + "install-headers", + "TIMEMORY_INSTALL_HEADERS", + doc="Install timemory headers", +) +add_arg_bool_option( + "install-config", + "TIMEMORY_INSTALL_CONFIG", + doc="Install cmake configuration", +) +add_arg_bool_option( + "install-all", + "TIMEMORY_INSTALL_ALL", + doc="install target depends on all target", +) +# distributed memory parallelism add_arg_bool_option("mpi", "TIMEMORY_USE_MPI") add_arg_bool_option("nccl", "TIMEMORY_USE_NCCL") add_arg_bool_option("upcxx", "TIMEMORY_USE_UPCXX") +# components add_arg_bool_option("cuda", "TIMEMORY_USE_CUDA") add_arg_bool_option("cupti", "TIMEMORY_USE_CUPTI") add_arg_bool_option("papi", "TIMEMORY_USE_PAPI") -add_arg_bool_option("arch", "TIMEMORY_USE_ARCH") add_arg_bool_option("ompt", "TIMEMORY_USE_OMPT") add_arg_bool_option("gotcha", "TIMEMORY_USE_GOTCHA", default=gotcha_opt) -add_arg_bool_option("kokkos", "TIMEMORY_BUILD_KOKKOS_TOOLS", default=False) -add_arg_bool_option("dyninst", "TIMEMORY_BUILD_DYNINST_TOOLS") add_arg_bool_option("tau", "TIMEMORY_USE_TAU") add_arg_bool_option("caliper", "TIMEMORY_USE_CALIPER") add_arg_bool_option("likwid", "TIMEMORY_USE_LIKWID") add_arg_bool_option("gperftools", "TIMEMORY_USE_GPERFTOOLS") add_arg_bool_option("vtune", "TIMEMORY_USE_VTUNE") +# submodules add_arg_bool_option("build-caliper", "TIMEMORY_BUILD_CALIPER") add_arg_bool_option("build-gotcha", "TIMEMORY_BUILD_GOTCHA") -add_arg_bool_option("pybind-install", "PYBIND11_INSTALL") +add_arg_bool_option( + "build-ompt", + "TIMEMORY_BUILD_OMPT", + doc="Build/install OpenMP with OMPT support", +) +add_arg_bool_option( + "build-python", + "TIMEMORY_BUILD_PYTHON", + doc="Build bindings with internal pybind11", +) +# tools +add_arg_bool_option("tools", "TIMEMORY_BUILD_TOOLS", default=True) +add_arg_bool_option("timem", "TIMEMORY_BUILD_TIMEM", doc="Build timem tool") +add_arg_bool_option("jump", "TIMEMORY_BUILD_JUMP", default=False) +add_arg_bool_option("stubs", "TIMEMORY_BUILD_STUBS", default=False) +add_arg_bool_option( + "avail", "TIMEMORY_BUILD_AVAIL", doc="Build timemory-avail tool" +) +add_arg_bool_option( + "dyninst", + "TIMEMORY_USE_DYNINST", + disp_aliases=["TIMEMORY_BUILD_DYNINST_TOOLS", "TIMEMORY_BUILD_RUN"], +) +add_arg_bool_option( + "compiler-instrumentation", "TIMEMORY_BUILD_COMPILER_INSTRUMENTATION" +) +add_arg_bool_option( + "kokkos", + "TIMEMORY_BUILD_KOKKOS_TOOLS", + doc="Build separate KokkosP libraries", +) +add_arg_bool_option( + "kokkos-config", + "TIMEMORY_BUILD_KOKKOS_CONFIG", + doc="Build array of dedicated KokkosP libraries", +) +add_arg_bool_option("mpip-library", "TIMEMORY_BUILD_MPIP_LIBRARY") +add_arg_bool_option("ompt-library", "TIMEMORY_BUILD_OMPT_LIBRARY") +add_arg_bool_option("ncclp-library", "TIMEMORY_BUILD_NCCLP_LIBRARY") +add_arg_bool_option("mallocp-library", "TIMEMORY_BUILD_MALLOCP_LIBRARY") +add_arg_bool_option("python-hatchet", "TIMEMORY_BUILD_PYTHON_HATCHET") +add_arg_bool_option( + "python-line-profiler", + "TIMEMORY_BUILD_PYTHON_LINE_PROFILER", + doc="Build line_profiler with timemory backend", +) +# miscellaneous +add_arg_bool_option("pybind-install", "PYBIND11_INSTALL", default=False) add_arg_bool_option("build-testing", "TIMEMORY_BUILD_TESTING") parser.add_argument( "--cxx-standard", @@ -96,6 +222,32 @@ def add_arg_bool_option(lc_name, disp_name, default=None): '--install-option=--cmake-args="-DTIMEMORY_BUILD_LTO=ON -DCMAKE_UNITY_BUILD=OFF"', ), ) +parser.add_argument( + "--c-flags", + default=None, + type=str, + nargs="*", + help="Explicitly set CMAKE_C_FLAGS", +) +parser.add_argument( + "--cxx-flags", + default=None, + type=str, + nargs="*", + help="Explicitly set CMAKE_CXX_FLAGS", +) +parser.add_argument( + "--enable-develop", + action="store_true", + default=None, + help="Enable a development install (timemory headers, cmake config, etc.)", +) +parser.add_argument( + "--disable-develop", + action="store_true", + default=None, + help="Disable a development install (timemory headers, cmake config, etc.)", +) args, left = parser.parse_known_args() # if help was requested, print these options and then add '--help' back @@ -105,97 +257,49 @@ def add_arg_bool_option(lc_name, disp_name, default=None): left.append("--help") sys.argv = sys.argv[:1] + left +if args.c_flags is not None: + cmake_args.append("-DCMAKE_C_FLAGS={}".format(" ".join(args.c_flags))) + +if args.cxx_flags is not None: + cmake_args.append("-DCMAKE_CXX_FLAGS='{}'".format(" ".join(args.cxx_flags))) + +if args.enable_develop: + for itr in ["install_headers", "install_config"]: + setattr(args, f"enable_{itr}", True) + +if args.disable_develop: + for itr in ["install_headers", "install_config"]: + setattr(args, f"disable_{itr}", True) + +# loop over the functors +for itr in cmake_options: + itr(args) + runtime_req_file = ( ".requirements/mpi_runtime.txt" if args.enable_mpi and not args.disable_mpi else ".requirements/runtime.txt" ) -set_cmake_bool_option("TIMEMORY_BUILD_C", args.enable_c, args.disable_c) -set_cmake_bool_option( - "TIMEMORY_BUILD_TOOLS", args.enable_tools, args.disable_tools -) -set_cmake_bool_option("TIMEMORY_USE_MPI", args.enable_mpi, args.disable_mpi) -set_cmake_bool_option("TIMEMORY_USE_NCCL", args.enable_nccl, args.disable_nccl) -set_cmake_bool_option( - "TIMEMORY_USE_UPCXX", args.enable_upcxx, args.disable_upcxx -) -set_cmake_bool_option( - "TIMEMORY_USE_GOTCHA", args.enable_gotcha, args.disable_gotcha -) -set_cmake_bool_option("TIMEMORY_USE_CUDA", args.enable_cuda, args.disable_cuda) -set_cmake_bool_option( - "TIMEMORY_USE_CUPTI", args.enable_cupti, args.disable_cupti -) -set_cmake_bool_option("TIMEMORY_USE_PAPI", args.enable_papi, args.disable_papi) -set_cmake_bool_option("TIMEMORY_USE_ARCH", args.enable_arch, args.disable_arch) -set_cmake_bool_option("TIMEMORY_USE_OMPT", args.enable_ompt, args.disable_ompt) -set_cmake_bool_option( - "TIMEMORY_USE_DYNINST", args.enable_dyninst, args.disable_dyninst -) -set_cmake_bool_option( - "TIMEMORY_BUILD_OMPT_LIBRARY", - args.enable_ompt and args.enable_tools, - args.disable_ompt or args.disable_tools, -) -set_cmake_bool_option( - "TIMEMORY_BUILD_MPIP_LIBRARY", - args.enable_gotcha and args.enable_mpi and args.enable_tools, - args.disable_gotcha or args.disable_mpi or args.disable_tools, -) -set_cmake_bool_option( - "TIMEMORY_BUILD_NCCLP_LIBRARY", - args.enable_gotcha and args.enable_nccl and args.enable_tools, - args.disable_gotcha or args.disable_nccl or args.disable_tools, -) -set_cmake_bool_option( - "TIMEMORY_BUILD_DYNINST_TOOLS", args.enable_dyninst, args.disable_dyninst -) -set_cmake_bool_option( - "TIMEMORY_BUILD_KOKKOS_TOOLS", args.enable_kokkos, args.disable_kokkos -) -set_cmake_bool_option("TIMEMORY_USE_TAU", args.enable_tau, args.disable_tau) -set_cmake_bool_option( - "TIMEMORY_USE_CALIPER", args.enable_caliper, args.disable_caliper -) -set_cmake_bool_option( - "TIMEMORY_USE_LIKWID", args.enable_likwid, args.disable_likwid -) -set_cmake_bool_option( - "TIMEMORY_USE_VTUNE", args.enable_vtune, args.disable_vtune -) -set_cmake_bool_option( - "TIMEMORY_USE_GPERFTOOLS", args.enable_gperftools, args.disable_gperftools -) -set_cmake_bool_option( - "TIMEMORY_BUILD_CALIPER", - args.enable_build_caliper, - args.disable_build_caliper, -) -set_cmake_bool_option( - "TIMEMORY_BUILD_GOTCHA", args.enable_build_gotcha, args.disable_build_gotcha -) -set_cmake_bool_option( - "PYBIND11_INSTALL", args.enable_pybind_install, args.disable_pybind_install -) -set_cmake_bool_option( - "TIMEMORY_BUILD_TESTING", - args.enable_build_testing, - args.disable_build_testing, -) cmake_args.append("-DCMAKE_CXX_STANDARD={}".format(args.cxx_standard)) for itr in args.cmake_args: cmake_args += itr.split() -gotcha_opt = False if platform.system() == "Darwin": # scikit-build will set this to 10.6 and C++ compiler check will fail version = platform.mac_ver()[0].split(".") version = ".".join([version[0], version[1]]) cmake_args += ["-DCMAKE_OSX_DEPLOYMENT_TARGET={}".format(version)] -elif platform.system() == "Linux": - gotcha_opt = True + +# DO THIS LAST! +# support PYKOKKOS_BASE_SETUP_ARGS environment variables because +# --install-option for pip is a pain to use +# TIMEMORY_SETUP_ARGS should be space-delimited set of cmake arguments, e.g.: +# export TIMEMORY_SETUP_ARGS="-DTIMEMORY_USE_MPI=ON -DTIMEMORY_USE_OMPT=OFF" +env_cmake_args = os.environ.get("TIMEMORY_SETUP_ARGS", None) +if env_cmake_args is not None: + cmake_args += env_cmake_args.split(" ") # --------------------------------------------------------------------------- # @@ -232,7 +336,7 @@ def __init__(self, *args, **kwargs): skinstall.__init__(self, *args, **kwargs) def run(self): - print("\n\n\tRunning install...") + print("\n\n\t[timemory] Running install...") print("\t\t {:10} : {}".format("base", self.install_base)) print("\t\t {:10} : {}".format("purelib", self.install_purelib)) print("\t\t {:10} : {}".format("platlib", self.install_platlib)) @@ -245,7 +349,7 @@ def run(self): print("\n\n") skinstall.run(self) for itr in self.get_outputs(): - print('installed file : "{}"'.format(itr)) + print('[timemory] installed file : "{}"'.format(itr)) # --------------------------------------------------------------------------- # @@ -270,6 +374,36 @@ def parse_requirements(fname="requirements.txt"): return requirements +# --------------------------------------------------------------------------- # +# +def exclude_install_hook(cmake_manifest): + cmake_manifest = list( + filter(lambda name: "pytest.ini" not in name, cmake_manifest) + ) + if not get_bool_option(args, "develop"): + cmake_manifest = list( + filter(lambda name: not (name.endswith(".a")), cmake_manifest) + ) + if not get_bool_option(args, "install-config"): + cmake_manifest = list( + filter( + lambda name: (os.path.join("share", "cmake") not in name), + cmake_manifest, + ) + ) + cmake_manifest = list( + filter( + lambda name: (os.path.join("lib", "cmake") not in name), + cmake_manifest, + ) + ) + if not get_bool_option(args, "install-headers"): + cmake_manifest = list( + filter(lambda name: "include" not in name, cmake_manifest) + ) + return cmake_manifest + + # suppress: # "setuptools_scm/git.py:68: UserWarning: "/.../" # is shallow and may cause errors" @@ -293,6 +427,7 @@ def parse_requirements(fname="requirements.txt"): }, python_requires=">=3.6", cmdclass=dict(install=custom_install), + cmake_process_manifest_hook=exclude_install_hook, entry_points={ "console_scripts": [ "timemory-plotter=timemory.plotting.__main__:try_plot", diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 517e7c601..0e7eac3b6 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -503,7 +503,7 @@ add_subdirectory(python) # named 'timemory-plotter' as C++ JSON outputs can use this # to generate plots # -if((TIMEMORY_BUILD_PYTHON OR TIMEMORY_USE_PYTHON) AND NOT SKBUILD) +if(TIMEMORY_USE_PYTHON AND NOT SKBUILD) configure_file(${PROJECT_SOURCE_DIR}/timemory/plotting/__main__.py ${PROJECT_BINARY_DIR}/timemory-plotter @ONLY) diff --git a/source/python/CMakeLists.txt b/source/python/CMakeLists.txt index 9f87f9762..c7cf3c08f 100644 --- a/source/python/CMakeLists.txt +++ b/source/python/CMakeLists.txt @@ -81,7 +81,7 @@ endfunction() ########################################################################################## -if(TIMEMORY_BUILD_PYTHON) +if(TIMEMORY_USE_PYTHON) add_library(timemory-python-compile-options INTERFACE) add_library(timemory::timemory-python-compile-options ALIAS @@ -121,20 +121,23 @@ if(TIMEMORY_BUILD_PYTHON) endif() set(pybind_libs pybind11::module) - if((TIMEMORY_BUILD_LTO OR APPLE) AND TARGET pybind11::thin_lto) - list(APPEND pybind_libs pybind11::thin_lto) - elseif(APPLE) + if(TIMEMORY_BUILD_LTO) list(APPEND pybind_libs timemory::timemory-lto) endif() + set(_LINK shared) + if((APPLE AND BUILD_STATIC_LIBS) OR (BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS)) + set(_LINK static) + endif() + add_library(libpytimemory-interface INTERFACE) target_link_libraries(libpytimemory-interface INTERFACE ${pybind_libs} timemory::timemory-python timemory::timemory-headers - timemory::timemory-cxx-shared + timemory::timemory-cxx-${_LINK} timemory::timemory-compile-options - timemory::timemory-external-shared + timemory::timemory-external-${_LINK} timemory::timemory-mpip-library timemory::timemory-ompt-library timemory::timemory-ncclp-library diff --git a/source/timemory/plotting/CMakeLists.txt b/source/timemory/plotting/CMakeLists.txt index 2dafcd55d..ccc8c783e 100644 --- a/source/timemory/plotting/CMakeLists.txt +++ b/source/timemory/plotting/CMakeLists.txt @@ -2,13 +2,6 @@ file(GLOB_RECURSE header_files ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) file(GLOB_RECURSE source_files ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) -option(TIMEMORY_EMBED_PYTHON "Embed the interpreter" OFF) -mark_as_advanced(TIMEMORY_EMBED_PYTHON) - -if(TIMEMORY_EMBED_PYTHON) - set(_PYTHON timemory::timemory-python) -endif() - build_intermediate_library( USE_INTERFACE NAME plotting @@ -17,5 +10,4 @@ build_intermediate_library( FOLDER components HEADERS ${header_files} SOURCES ${source_files} - PROPERTY_DEPENDS GLOBAL - PRIVATE_LINK ${_PYTHON}) + PROPERTY_DEPENDS GLOBAL) diff --git a/source/timemory/plotting/definition.hpp b/source/timemory/plotting/definition.hpp index 8ab658316..1bdbda1ae 100644 --- a/source/timemory/plotting/definition.hpp +++ b/source/timemory/plotting/definition.hpp @@ -30,10 +30,6 @@ #include "timemory/settings/declaration.hpp" #include "timemory/utility/popen.hpp" -#if defined(TIMEMORY_USE_PYTHON) -# include "pybind11/embed.h" -#endif - namespace tim { // @@ -98,27 +94,6 @@ plot(const string_t& _label, const string_t& _prefix, const string_t& _dir, set_env("TIMEMORY_LIBRARY_CTOR", "OFF", 1); set_env("TIMEMORY_BANNER", "OFF", 1); set_env("TIMEMORY_CXX_PLOT_MODE", "1", 1); -# if defined(TIMEMORY_USE_PYTHON) - auto cmd = operation::join(" ", "-f", _file, "-t", - TIMEMORY_JOIN("\"", "", _prefix, ""), "-o", _dir); - - if(_echo_dart) - cmd += " -e"; - - tim::set_env("TIMEMORY_EMBEDDED_PLOT_ARGS", cmd.c_str(), 1); - { - py::scoped_interpreter guard{}; - py::exec(R"( - import os - from timemory.plotting import embedded_plot - _args = os.environ.get("TIMEMORY_EMBEDDED_PLOT_ARGS") - if _args is not None: - embedded_plot(_args.split(" ")) - )", - py::globals()); - } - tim::set_env("TIMEMORY_EMBEDDED_PLOT_ARGS", ""); -# else auto cmd = operation::join(" ", settings::python_exe(), "-m", "timemory.plotting", "-f", _file, "-t", TIMEMORY_JOIN("\"", "", _prefix, ""), "-o", _dir); @@ -140,8 +115,6 @@ plot(const string_t& _label, const string_t& _prefix, const string_t& _dir, std::cerr << _log.str() << '\n'; } -# endif - // revert the environment set_env("TIMEMORY_CXX_PLOT_MODE", _plot, 1); set_env("TIMEMORY_BANNER", _bann, 1); diff --git a/source/timemory/plotting/plotting.cpp b/source/timemory/plotting/plotting.cpp index 294f7e281..8974fb22d 100644 --- a/source/timemory/plotting/plotting.cpp +++ b/source/timemory/plotting/plotting.cpp @@ -24,6 +24,3 @@ #include "timemory/plotting/definition.hpp" #include "timemory/plotting/extern.hpp" - -#if defined(TIMEMORY_USE_PYTHON) -#endif diff --git a/source/timemory/plotting/types.hpp b/source/timemory/plotting/types.hpp index d9bc5186f..97f5f3f96 100644 --- a/source/timemory/plotting/types.hpp +++ b/source/timemory/plotting/types.hpp @@ -29,20 +29,9 @@ #include #include -#if defined(TIMEMORY_USE_PYTHON) -# include "pybind11/embed.h" -#endif - namespace tim { // -#if defined(TIMEMORY_USE_PYTHON) -namespace py = pybind11; -#else -namespace py -{} -#endif -// //--------------------------------------------------------------------------------------// // // plotting diff --git a/source/tools/kokkos-connector/CMakeLists.txt b/source/tools/kokkos-connector/CMakeLists.txt index 7a5ef4355..7e6fa83d2 100644 --- a/source/tools/kokkos-connector/CMakeLists.txt +++ b/source/tools/kokkos-connector/CMakeLists.txt @@ -63,7 +63,7 @@ message(STATUS "") # Configure common target # set(timemory_INTERFACE_LIBRARY) -foreach(_COMP headers vector dmp cxx-shared mpip-library ompt-library ncclp-library +foreach(_COMP headers vector dmp cxx mpip-library ompt-library ncclp-library ${TIMEMORY_KOKKOS_COMPONENTS}) if(TARGET timemory::timemory-${_COMP}) list(APPEND timemory_INTERFACE_LIBRARY timemory::timemory-${_COMP}) @@ -180,7 +180,7 @@ if(TIMEMORY_BUILD_KOKKOS_SAMPLE) set_target_properties(kokkos-connector-sample PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # kokkos_compilation(TARGET kokkos-connector-sample) - add_kokkos_sample_test(libtimemory timemory::timemory-cxx-shared) + add_kokkos_sample_test(libtimemory timemory::timemory-cxx) add_kokkos_sample_test(kp-timemory kp_timemory) add_kokkos_sample_test(kp-timemory-filter kp_timemory_filter) endif() diff --git a/source/tools/timemory-jump/CMakeLists.txt b/source/tools/timemory-jump/CMakeLists.txt index fd83a0d8c..ca6920235 100644 --- a/source/tools/timemory-jump/CMakeLists.txt +++ b/source/tools/timemory-jump/CMakeLists.txt @@ -7,6 +7,11 @@ if(DEFINED TIMEMORY_BUILD_JUMP AND NOT TIMEMORY_BUILD_JUMP) return() endif() +if(NOT BUILD_SHARED_LIBS) + # if shared libraries are not build, dlopen will not be possible + return() +endif() + if(NOT timemory_MAIN_PROJECT OR TIMEMORY_BUILD_EXCLUDE_FROM_ALL) set(_EXCLUDE EXCLUDE_FROM_ALL) endif() From 41f6de00d4a53a5b41100573b7ef8e81c7a69530 Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Wed, 7 Jul 2021 10:01:42 -0500 Subject: [PATCH 3/6] Allocator traits (#213) - replaced allocator member functions construct, destroy, allocate, deallocate with calls to static functions of allocator traits - these member functions were deprecated in C++17 - only enable coverage flags when build type is Debug and TIMEMORY_CI=ON - added support for CMAKE_ARGS env variable in setup.py - tweaked some testing tolerances in component bundle and hybrid tests to cut down on false-positive failures - excluded timem-md5sum target from all in cmake - support CMAKE_ARGS in setup.py --- VERSION | 2 +- cmake/Modules/ClangFormat.cmake | 6 +- cmake/Modules/Options.cmake | 12 ++- cmake/Modules/ProjectSetup.cmake | 6 +- pyctest-runner.py | 4 +- setup.py | 12 ++- source/tests/cache_tests.cpp | 3 + source/tests/component_bundle_tests.cpp | 4 +- source/tests/hybrid_tests.cpp | 16 ++-- source/timemory/storage/graph.hpp | 105 ++++++++++----------- source/tools/timemory-timem/CMakeLists.txt | 6 +- 11 files changed, 100 insertions(+), 76 deletions(-) diff --git a/VERSION b/VERSION index 5c7feaa80..580ab568f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.1.rc12 +3.2.1.rc14 diff --git a/cmake/Modules/ClangFormat.cmake b/cmake/Modules/ClangFormat.cmake index ef9d6a385..633dcb492 100644 --- a/cmake/Modules/ClangFormat.cmake +++ b/cmake/Modules/ClangFormat.cmake @@ -113,14 +113,18 @@ if(CLANG_FORMATTER) COMMAND ${CLANG_FORMATTER} -i ${examples}) endif() + set(_MSG "'${CLANG_FORMATTER}'") if(BLACK_FORMATTER) set(_COMMAND ${_COMMAND} COMMAND ${BLACK_FORMATTER} -q ${PROJECT_SOURCE_DIR}) + set(_MSG "${_MSG} and '${BLACK_FORMATTER}'") endif() add_custom_target(${FORMAT_NAME} ${_COMMAND} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMENT "[${PROJECT_NAME}] Running '${CLANG_FORMATTER}'..." + COMMENT "[${PROJECT_NAME}] Running ${_MSG}..." SOURCES ${headers} ${sources} ${examples}) + + unset(_MSG) endif() diff --git a/cmake/Modules/Options.cmake b/cmake/Modules/Options.cmake index ca726c0ad..7151786b9 100644 --- a/cmake/Modules/Options.cmake +++ b/cmake/Modules/Options.cmake @@ -87,8 +87,16 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") set(_BUILD_OPT ON) endif() -if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND - (TIMEMORY_BUILD_TESTING OR TIMEMORY_BUILD_MINIMAL_TESTING OR TIMEMORY_CI)) +if(TIMEMORY_BUILD_TESTING) + set(TIMEMORY_BUILD_EXAMPLES ON) +endif() + +if(TIMEMORY_BUILD_MINIMAL_TESTING) + set(TIMEMORY_BUILD_TESTING ON) + set(TIMEMORY_BUILD_EXAMPLES OFF) +endif() + +if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND TIMEMORY_CI) set(_USE_COVERAGE ON) endif() diff --git a/cmake/Modules/ProjectSetup.cmake b/cmake/Modules/ProjectSetup.cmake index 3d0f12e8d..10ed67e32 100644 --- a/cmake/Modules/ProjectSetup.cmake +++ b/cmake/Modules/ProjectSetup.cmake @@ -35,12 +35,8 @@ endif() # override any cache settings if(TIMEMORY_BUILD_TESTING) set(TIMEMORY_BUILD_GOOGLE_TEST ON) - if(NOT TIMEMORY_BUILD_MINIMAL_TESTING) - set(TIMEMORY_BUILD_EXAMPLES ON) - endif() -else() + set(TIMEMORY_BUILD_EXAMPLES ON) if(TIMEMORY_BUILD_MINIMAL_TESTING) - set(TIMEMORY_BUILD_GOOGLE_TEST ON) set(TIMEMORY_BUILD_EXAMPLES OFF) endif() endif() diff --git a/pyctest-runner.py b/pyctest-runner.py index 1a1906dc0..7855637f4 100755 --- a/pyctest-runner.py +++ b/pyctest-runner.py @@ -1186,7 +1186,9 @@ def add_timem_test(name, cmd): }, ) - if len(args.tools) > 0: + if len(args.tools) > 0 and not ( + len(args.tools) == 1 and args.tools[0] == "avail" + ): pyct.test( "timemory-python-timem", [ diff --git a/setup.py b/setup.py index b8cfafe2e..65f3db1a7 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,14 @@ parser = argparse.ArgumentParser(add_help=False) parser.add_argument("-h", "--help", help="Print help", action="store_true") +# support CMAKE_ARGS environment variables because +# --install-option for pip is a pain to use +env_cmake_args = os.environ.get("CMAKE_ARGS", None) +if env_cmake_args is not None: + for _arg in env_cmake_args.split(" "): + if "CMAKE_INSTALL_PREFIX" not in _arg: + cmake_args += [_arg] + gotcha_opt = False if platform.system() == "Linux": gotcha_opt = True @@ -293,9 +301,9 @@ def _add_cmake_bool_option(_args): cmake_args += ["-DCMAKE_OSX_DEPLOYMENT_TARGET={}".format(version)] # DO THIS LAST! -# support PYKOKKOS_BASE_SETUP_ARGS environment variables because +# support TIMEMORY_SETUP_ARGS environment variables because # --install-option for pip is a pain to use -# TIMEMORY_SETUP_ARGS should be space-delimited set of cmake arguments, e.g.: +# Env variables should be space-delimited set of cmake arguments, e.g.: # export TIMEMORY_SETUP_ARGS="-DTIMEMORY_USE_MPI=ON -DTIMEMORY_USE_OMPT=OFF" env_cmake_args = os.environ.get("TIMEMORY_SETUP_ARGS", None) if env_cmake_args is not None: diff --git a/source/tests/cache_tests.cpp b/source/tests/cache_tests.cpp index b84ca3678..51cfcf8c2 100644 --- a/source/tests/cache_tests.cpp +++ b/source/tests/cache_tests.cpp @@ -217,6 +217,9 @@ class cache_tests : public ::testing::Test trait::runtime_enabled::set(false); trait::runtime_enabled::set(false); trait::runtime_enabled::set(false); + trait::runtime_enabled::set(false); + trait::runtime_enabled::set(false); + trait::runtime_enabled::set(false); trait::runtime_enabled::set(false); } diff --git a/source/tests/component_bundle_tests.cpp b/source/tests/component_bundle_tests.cpp index bc2d2cda3..30a468373 100644 --- a/source/tests/component_bundle_tests.cpp +++ b/source/tests/component_bundle_tests.cpp @@ -267,8 +267,8 @@ TEST_F(component_bundle_tests, get) EXPECT_NEAR(std::get<0>(cb), 2.0, 0.1); EXPECT_NEAR(std::get<0>(ab), 2.0, 0.1); - EXPECT_NEAR(std::get<1>(cb) + std::get<2>(cb), 1.0, 0.1); - EXPECT_NEAR(std::get<1>(ab), 1.0, 0.1); + EXPECT_NEAR(std::get<1>(cb) + std::get<2>(cb), 1.0, 0.15); + EXPECT_NEAR(std::get<1>(ab), 1.0, 0.15); } //--------------------------------------------------------------------------------------// diff --git a/source/tests/hybrid_tests.cpp b/source/tests/hybrid_tests.cpp index c6011a144..e11b21359 100644 --- a/source/tests/hybrid_tests.cpp +++ b/source/tests/hybrid_tests.cpp @@ -64,7 +64,7 @@ static const auto memory_unit = std::pair(tim::units::KiB, // acceptable absolute error static const double util_tolerance = 5.0; -static const double timer_tolerance = 0.075; +static const double timer_tolerance = 0.1; // acceptable relative error // static const double util_epsilon = 0.5; @@ -100,7 +100,7 @@ get_test_name() } // this function consumes approximately "n" milliseconds of real time -inline void +TIMEMORY_FLATTEN void do_sleep(long n) { std::this_thread::sleep_for(std::chrono::milliseconds(n)); @@ -114,7 +114,7 @@ fibonacci(long n) } // this function consumes approximately "t" milliseconds of cpu time -inline void +TIMEMORY_FLATTEN void consume(long n) { // a mutex held by one lock @@ -252,8 +252,8 @@ TEST_F(hybrid_tests, hybrid) ASSERT_TRUE(t_util != nullptr) << obj; EXPECT_NEAR(2.0, t_rc->get(), timer_tolerance) << obj; - EXPECT_NEAR(2.5, t_cpu->get(), timer_tolerance) << obj; - EXPECT_NEAR(125.0, t_util->get(), util_tolerance) << obj; + EXPECT_NEAR(2.5, t_cpu->get(), 2.0 * timer_tolerance) << obj; + EXPECT_NEAR(125.0, t_util->get(), 2.0 * util_tolerance) << obj; auto* l_rc = obj.get(); auto* l_cpu = obj.get(); @@ -301,8 +301,8 @@ TEST_F(hybrid_tests, auto_timer) details::print_info(_util, 125.0, "%", cpu_util_convert); ASSERT_NEAR(1.0, _rc.get(), timer_tolerance); - ASSERT_NEAR(1.25, _cpu.get(), timer_tolerance); - ASSERT_NEAR(125.0, _util.get(), util_tolerance); + ASSERT_NEAR(1.25, _cpu.get(), 2.0 * timer_tolerance); + ASSERT_NEAR(125.0, _util.get(), 2.0 * util_tolerance); cpu_clock _cpu_obj = *obj.get(); double _cpu_val = obj.get()->get(); @@ -335,7 +335,7 @@ TEST_F(hybrid_tests, compose) details::print_info(_cpu_obj, 0.75, "sec"); - ASSERT_NEAR(0.75, _cpu_val, timer_tolerance); + ASSERT_NEAR(0.75, _cpu_val, 2.0 * timer_tolerance); ASSERT_NEAR(_cpu_obj.get(), _cpu_val, compose_tolerance); ASSERT_NEAR(_cpu_val, std::get<0>(_cpu_ret) + std::get<1>(_cpu_ret), compose_tolerance); diff --git a/source/timemory/storage/graph.hpp b/source/timemory/storage/graph.hpp index 8df24ee21..ddb083a79 100644 --- a/source/timemory/storage/graph.hpp +++ b/source/timemory/storage/graph.hpp @@ -759,9 +759,12 @@ class graph } private: - AllocatorT m_alloc; inline void m_head_initialize(); inline void m_copy(const graph& other); + +private: + using allocator_traits = std::allocator_traits; + AllocatorT m_alloc{}; }; //======================================================================================// @@ -816,10 +819,10 @@ template graph::~graph() { clear(); - m_alloc.destroy(head); - m_alloc.destroy(feet); - m_alloc.deallocate(head, 1); - m_alloc.deallocate(feet, 1); + allocator_traits::destroy(m_alloc, head); + allocator_traits::destroy(m_alloc, feet); + allocator_traits::deallocate(m_alloc, head, 1); + allocator_traits::deallocate(m_alloc, feet, 1); } //--------------------------------------------------------------------------------------// @@ -828,10 +831,11 @@ template void graph::m_head_initialize() { - head = m_alloc.allocate(1, nullptr); // MSVC does not have default second argument - feet = m_alloc.allocate(1, nullptr); - m_alloc.construct(head, std::move(tgraph_node{})); - m_alloc.construct(feet, std::move(tgraph_node{})); + head = allocator_traits::allocate( + m_alloc, 1, nullptr); // MSVC does not have default second argument + feet = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, head, std::move(tgraph_node{})); + allocator_traits::construct(m_alloc, feet, std::move(tgraph_node{})); head->parent = nullptr; head->first_child = nullptr; @@ -880,7 +884,7 @@ graph::operator=(graph&& x) noexcept template graph::graph(const graph& other) { - // m_alloc.reserve(2 + other.size()); + // allocator_traits::reserve(2 + other.size()); m_head_initialize(); m_copy(other); } @@ -980,8 +984,8 @@ graph::erase(IterT it) cur->next_sibling->prev_sibling = cur->prev_sibling; } - m_alloc.destroy(cur); - m_alloc.deallocate(cur, 1); + allocator_traits::destroy(m_alloc, cur); + allocator_traits::deallocate(m_alloc, cur, 1); it.node = nullptr; return ret; } @@ -1077,8 +1081,8 @@ graph::append_child(IterT position) assert(position.node != feet); assert(position.node); - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, std::move(tgraph_node{})); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, std::move(tgraph_node{})); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1108,8 +1112,8 @@ graph::prepend_child(IterT position) assert(position.node != feet); assert(position.node); - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, std::move(tgraph_node{})); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, std::move(tgraph_node{})); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1143,8 +1147,8 @@ graph::append_child(IterT position, const T& x) assert(position.node != feet); assert(position.node); - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, x); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1174,10 +1178,8 @@ graph::append_child(IterT position, T&& x) assert(position.node != feet); assert(position.node); - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, std::forward(x)); - // m_alloc.construct(tmp); // Here is where the move semantics kick in - // std::swap(tmp->data, x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, std::forward(x)); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1208,8 +1210,8 @@ graph::prepend_child(IterT position, const T& x) assert(position.node != feet); assert(position.node); - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, x); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1239,11 +1241,8 @@ graph::prepend_child(IterT position, T&& x) assert(position.node != feet); assert(position.node); - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, std::forward(x)); - // std::swap(tmp->data, std::forward(x)); - // auto _x = std::move(x); - // std::swap(tmp->data, _x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, std::forward(x)); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1274,7 +1273,7 @@ graph::append_child(IterT position, IterT other) assert(position.node != feet); assert(position.node); - IterT aargh = append_child(position, value_type()); + IterT aargh = append_child(position, value_type{}); return move_ontop(aargh, other); } @@ -1289,7 +1288,7 @@ graph::prepend_child(IterT position, IterT other) assert(position.node != feet); assert(position.node); - IterT aargh = prepend_child(position, value_type()); + IterT aargh = prepend_child(position, value_type{}); return move_ontop(aargh, other); } @@ -1374,8 +1373,8 @@ graph::insert(IterT position, const T& x) } assert(position.node != head); // Cannot insert before head. - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, x); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1406,9 +1405,9 @@ graph::insert(IterT position, T&& x) position.node = feet; // Backward compatibility: when calling insert on // a null node, insert before the feet. } - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, std::forward(x)); - // std::swap(tmp->data, x); // Move semantics + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, std::forward(x)); + tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1433,8 +1432,8 @@ template typename graph::sibling_iterator graph::insert(sibling_iterator position, const T& x) { - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, x); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1469,8 +1468,8 @@ template IterT graph::insert_after(IterT position, const T& x) { - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, x); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1498,9 +1497,9 @@ template IterT graph::insert_after(IterT position, T&& x) { - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, std::forward(x)); - // std::swap(tmp->data, x); // move semantics + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, std::forward(x)); + tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1529,7 +1528,7 @@ IterT graph::insert_subgraph(IterT position, const iterator_base& _subgraph) { // insert dummy - IterT it = insert(position, value_type()); + IterT it = insert(position, value_type{}); // replace dummy with subgraph return replace(it, _subgraph); } @@ -1556,7 +1555,7 @@ graph::insert_subgraph_after(IterT position, // position, IterT subgraph) // { // // insert dummy -// IterT it(insert(position, value_type())); +// IterT it(insert(position, value_type{})); // // replace dummy with subgraph // return replace(it, subgraph); // } @@ -1568,8 +1567,8 @@ template IterT graph::replace(IterT position, const T& x) { - m_alloc.destroy(position.node); - m_alloc.construct(position.node, x); + allocator_traits::destroy(m_alloc, position.node); + allocator_traits::construct(m_alloc, position.node, x); return position; } @@ -1580,8 +1579,8 @@ template IterT graph::replace(IterT position, T&& x) { - m_alloc.destroy(position.node); - m_alloc.construct(position.node, std::forward(x)); + allocator_traits::destroy(m_alloc, position.node); + allocator_traits::construct(m_alloc, position.node, std::forward(x)); return position; } @@ -1601,8 +1600,8 @@ graph::replace(IterT position, const iterator_base& from) // std::cout << "warning!" << position.node << std::endl; erase_children(position); // std::cout << "no warning!" << std::endl; - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, (*from)); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, (*from)); tmp->first_child = nullptr; tmp->last_child = nullptr; if(current_to->prev_sibling == nullptr) @@ -1626,8 +1625,8 @@ graph::replace(IterT position, const iterator_base& from) } tmp->next_sibling = current_to->next_sibling; tmp->parent = current_to->parent; - m_alloc.destroy(current_to); - m_alloc.deallocate(current_to, 1); + allocator_traits::destroy(m_alloc, current_to); + allocator_traits::deallocate(m_alloc, current_to, 1); current_to = tmp; // only at this stage can we fix 'last' diff --git a/source/tools/timemory-timem/CMakeLists.txt b/source/tools/timemory-timem/CMakeLists.txt index b8ef82024..745547011 100644 --- a/source/tools/timemory-timem/CMakeLists.txt +++ b/source/tools/timemory-timem/CMakeLists.txt @@ -70,7 +70,7 @@ if(NOT DEFINED TIMEM_PAPI_TARGET OR NOT TIMEM_PAPI_TARGET) endif() endif() -add_library(timem-md5sum OBJECT md5.cpp md5.hpp) +add_library(timem-md5sum EXCLUDE_FROM_ALL OBJECT md5.cpp md5.hpp) target_link_libraries(timem-md5sum PRIVATE timemory::timemory-compile-options @@ -80,6 +80,8 @@ target_link_libraries(timem-md5sum PRIVATE add_executable(timem ${_EXCLUDE} timem.cpp timem.hpp $) +add_dependencies(timem timem-md5sum) + target_link_libraries(timem PRIVATE timemory::timemory-compile-options timemory::timemory-develop-options @@ -107,6 +109,8 @@ endif() add_executable(timem-mpi ${_EXCLUDE} timem.cpp timem.hpp $) +add_dependencies(timem-mpi timem-md5sum) + target_link_libraries(timem-mpi PRIVATE timemory::timemory-compile-options timemory::timemory-develop-options From 0ce6be2444d1d0d76ba19619aeeff13f16367e27 Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Fri, 9 Jul 2021 02:13:22 -0500 Subject: [PATCH 4/6] Build system fixes (#214) - remove absolute rpath when SKBUILD/SPACK_BUILD - add hatchet/tests/timemory_tests.py to cmake_proces_manifest - tweaks to {dl,rt,pthread}_LIBRARY - warn about PYBIND11_INSTALL - timemory-{c,cxx,fortran} alias libraries in build tree - fixes to building timemory-{mpip,ncclp,mallocp}-shared when static cxx --- CMakeLists.txt | 5 +- VERSION | 2 +- cmake/Modules/BuildSettings.cmake | 56 ++++++++++++++----- cmake/Modules/ConfigCUDA.cmake | 42 ++++++++------ cmake/Modules/Options.cmake | 3 + cmake/Modules/Packages.cmake | 7 ++- external/CMakeLists.txt | 7 +++ setup.py | 36 ++++++------ source/CMakeLists.txt | 18 ++++++ source/tools/timemory-mallocp/CMakeLists.txt | 12 +++- .../timemory-mallocp/timemory-mallocp.cpp | 6 +- source/tools/timemory-mpip/CMakeLists.txt | 12 +++- source/tools/timemory-mpip/timemory-mpip.cpp | 10 ++-- source/tools/timemory-ncclp/CMakeLists.txt | 12 +++- .../tools/timemory-ncclp/timemory-ncclp.cpp | 6 +- source/tools/timemory-ompt/CMakeLists.txt | 13 ++--- 16 files changed, 169 insertions(+), 78 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca0d5990e..48d1926ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,10 @@ set(CMAKE_INSTALL_CONFIGDIR ${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}) if(UNIX AND NOT APPLE) set(CMAKE_INSTALL_RPATH - "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/timemory:\$ORIGIN:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/timemory") + "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/timemory:\$ORIGIN") + if(NOT SKBUILD AND NOT SPACK_BUILD) + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/timemory") + endif() endif() # create the full path version and generic path versions diff --git a/VERSION b/VERSION index 580ab568f..163bfcd5a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.1.rc14 +3.2.1.rc15 diff --git a/cmake/Modules/BuildSettings.cmake b/cmake/Modules/BuildSettings.cmake index 3b532206d..1b1c634aa 100644 --- a/cmake/Modules/BuildSettings.cmake +++ b/cmake/Modules/BuildSettings.cmake @@ -10,19 +10,54 @@ include_guard(DIRECTORY) include(GNUInstallDirs) include(Compilers) +include(FindPackageHandleStandardArgs) target_compile_definitions(timemory-compile-options INTERFACE $<$:DEBUG>) -if(CMAKE_DL_LIBS) - set(dl_LIBRARY ${CMAKE_DL_LIBS}) - target_link_libraries(timemory-compile-options INTERFACE ${CMAKE_DL_LIBS}) -else() - find_library(dl_LIBRARY NAMES dl) +#----------------------------------------------------------------------------------------# +# dynamic linking and runtime libraries +# +if(CMAKE_DL_LIBS AND NOT "${CMAKE_DL_LIBS}" STREQUAL "dl") + # if cmake provides dl library, use that + set(dl_LIBRARY ${CMAKE_DL_LIBS} CACHE FILEPATH "dynamic linking system library") +endif() + +foreach(_TYPE dl rt dw) + if(NOT ${_TYPE}_LIBRARY) + find_library(${_TYPE}_LIBRARY NAMES ${_TYPE}) + endif() +endforeach() + +find_package_handle_standard_args(dl-library REQUIRED_VARS dl_LIBRARY) +find_package_handle_standard_args(rt-library REQUIRED_VARS rt_LIBRARY) +# find_package_handle_standard_args(dw-library REQUIRED_VARS dw_LIBRARY) + +if(TIMEMORY_BUILD_PORTABLE) if(dl_LIBRARY) - target_link_libraries(timemory-compile-options INTERFACE ${dl_LIBRARY}) + set(dl_LIBRARY dl) + else() + set(dl_LIBRARY) + endif() +elseif(dl_LIBRARY) + add_rpath(${dl_LIBRARY}) +endif() + +if(dl_LIBRARY) + target_link_libraries(timemory-compile-options INTERFACE ${dl_LIBRARY}) +endif() + +if(TIMEMORY_BUILD_PORTABLE) + if(rt_LIBRARY) + set(rt_LIBRARY rt) + else() + set(rt_LIBRARY) endif() +elseif(rt_LIBRARY) + add_rpath(${rt_LIBRARY}) endif() +#----------------------------------------------------------------------------------------# + if(WIN32) set(OS_FLAG "/bigobj") else() @@ -72,15 +107,6 @@ endif() add_interface_library(timemory-compile-debuginfo "Attempts to set best flags for more expressive profiling information in debug or optimized binaries") -# if cmake provides dl library, use that -if(CMAKE_DL_LIBS) - set(dl_LIBRARY "${CMAKE_DL_LIBS}" CACHE STRING "dynamic linking libraries") -endif() - -find_library(rt_LIBRARY NAMES rt) -find_library(dl_LIBRARY NAMES dl) -find_library(dw_LIBRARY NAMES dw) - add_target_flag_if_avail(timemory-compile-debuginfo "-g" "-fno-omit-frame-pointer" diff --git a/cmake/Modules/ConfigCUDA.cmake b/cmake/Modules/ConfigCUDA.cmake index 0c55c0a47..6f998731a 100644 --- a/cmake/Modules/ConfigCUDA.cmake +++ b/cmake/Modules/ConfigCUDA.cmake @@ -157,28 +157,38 @@ if("CUDA" IN_LIST LANGUAGES) ${CUDA_INCLUDE_DIRS} ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) - find_library(CUDA_dl_LIBRARY - NAMES dl) + if(NOT CUDA_dl_LIBRARY) + if(dl_LIBRARY) + set(CUDA_dl_LIBRARY ${dl_LIBRARY}) + else() + find_library(CUDA_dl_LIBRARY NAMES dl) + endif() + endif() - target_link_libraries(${PROJECT_CUDA_INTERFACE_PREFIX}-cudart INTERFACE - ${CUDA_CUDART_LIBRARY} ${CUDA_rt_LIBRARY}) + if(NOT CUDA_rt_LIBRARY) + if(rt_LIBRARY) + set(CUDA_rt_LIBRARY ${rt_LIBRARY}) + else() + find_library(CUDA_rt_LIBRARY NAMES rt) + endif() + endif() - target_link_libraries(${PROJECT_CUDA_INTERFACE_PREFIX}-cudart-device INTERFACE - ${CUDA_cudadevrt_LIBRARY} ${CUDA_rt_LIBRARY}) + if(NOT CUDA_dl_LIBRARY) + set(CUDA_dl_LIBRARY) + endif() - target_link_libraries(${PROJECT_CUDA_INTERFACE_PREFIX}-cudart-static INTERFACE - ${CUDA_cudart_static_LIBRARY} ${CUDA_rt_LIBRARY}) + if(NOT CUDA_rt_LIBRARY) + set(CUDA_rt_LIBRARY) + endif() - if(CUDA_dl_LIBRARY) - target_link_libraries(${PROJECT_CUDA_INTERFACE_PREFIX}-cudart INTERFACE - ${CUDA_dl_LIBRARY}) + target_link_libraries(${PROJECT_CUDA_INTERFACE_PREFIX}-cudart INTERFACE + ${CUDA_CUDART_LIBRARY} ${CUDA_rt_LIBRARY} ${CUDA_dl_LIBRARY}) - target_link_libraries(${PROJECT_CUDA_INTERFACE_PREFIX}-cudart-device INTERFACE - ${CUDA_dl_LIBRARY}) + target_link_libraries(${PROJECT_CUDA_INTERFACE_PREFIX}-cudart-device INTERFACE + ${CUDA_cudadevrt_LIBRARY} ${CUDA_rt_LIBRARY} ${CUDA_dl_LIBRARY}) - target_link_libraries(${PROJECT_CUDA_INTERFACE_PREFIX}-cudart-static INTERFACE - ${CUDA_dl_LIBRARY}) - endif() + target_link_libraries(${PROJECT_CUDA_INTERFACE_PREFIX}-cudart-static INTERFACE + ${CUDA_cudart_static_LIBRARY} ${CUDA_rt_LIBRARY} ${CUDA_dl_LIBRARY}) else() message(FATAL_ERROR diff --git a/cmake/Modules/Options.cmake b/cmake/Modules/Options.cmake index 7151786b9..89b6f37e1 100644 --- a/cmake/Modules/Options.cmake +++ b/cmake/Modules/Options.cmake @@ -582,6 +582,9 @@ if(TIMEMORY_BUILD_DOCS) endif() set(PYBIND11_INSTALL OFF CACHE BOOL "Install Pybind11") +if(PYBIND11_INSTALL AND (SKBUILD OR SPACK_BUILD)) + timemory_message(WARNING "Pybind11 will be installed. This may overwrite an existing pip/conda/spack PyBind11 installation...") +endif() # clang-tidy macro(_TIMEMORY_ACTIVATE_CLANG_TIDY) diff --git a/cmake/Modules/Packages.cmake b/cmake/Modules/Packages.cmake index 20da4cec9..c2bde0e40 100644 --- a/cmake/Modules/Packages.cmake +++ b/cmake/Modules/Packages.cmake @@ -526,15 +526,16 @@ if(NOT WIN32) set(THREADS_PREFER_PTHREAD_FLAG OFF) endif() -find_library(PTHREADS_LIBRARY pthread) +find_library(pthread_LIBRARY NAMES pthread pthreads) +find_package_handle_standard_args(pthread-library REQUIRED_VARS pthread_LIBRARY) find_package(Threads ${TIMEMORY_FIND_QUIETLY} ${TIMEMORY_FIND_REQUIREMENT}) if(Threads_FOUND) target_link_libraries(timemory-threading INTERFACE ${CMAKE_THREAD_LIBS_INIT}) endif() -if(PTHREADS_LIBRARY AND NOT WIN32) - target_link_libraries(timemory-threading INTERFACE ${PTHREADS_LIBRARY}) +if(NOT TIMEMORY_BUILD_PORTABLE AND pthread_LIBRARY AND NOT WIN32) + target_link_libraries(timemory-threading INTERFACE ${pthread_LIBRARY}) endif() diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index fff7f00a5..17d028ded 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -38,12 +38,19 @@ if(TIMEMORY_USE_PYTHON AND TIMEMORY_BUILD_PYTHON_HATCHET) add_dependencies(libpytimemory hatchet) if(CMAKE_INSTALL_PYTHONDIR) set(HATCHET_PYDIR "${CMAKE_CURRENT_LIST_DIR}/hatchet/hatchet") + file(GLOB_RECURSE hatchet_files "${HATCHET_PYDIR}/*.py" "${HATCHET_PYDIR}/*.js") + file(GLOB_RECURSE hatchet_test_files "${HATCHET_PYDIR}/tests/*") + if("${HATCHET_PYDIR}/tests/timemory_test.py" IN_LIST hatchet_test_files) + list(REMOVE_ITEM hatchet_test_files + "${HATCHET_PYDIR}/tests/timemory_test.py") + endif() + set(HATCHET_CYTHONDIR "${HATCHET_PYDIR}/cython_modules/libs") diff --git a/setup.py b/setup.py index 65f3db1a7..da604b169 100644 --- a/setup.py +++ b/setup.py @@ -385,30 +385,34 @@ def parse_requirements(fname="requirements.txt"): # --------------------------------------------------------------------------- # # def exclude_install_hook(cmake_manifest): - cmake_manifest = list( - filter(lambda name: "pytest.ini" not in name, cmake_manifest) + def _filter_manifest(_manifest, *args): + for itr in args: + _manifest = list( + filter( + lambda name: itr not in name, + cmake_manifest, + ) + ) + return _manifest + + cmake_manifest = _filter_manifest( + cmake_manifest, + "pytest.ini", + os.path.join("hatchet", "tests", "timemory_test.py"), ) if not get_bool_option(args, "develop"): cmake_manifest = list( filter(lambda name: not (name.endswith(".a")), cmake_manifest) ) if not get_bool_option(args, "install-config"): - cmake_manifest = list( - filter( - lambda name: (os.path.join("share", "cmake") not in name), - cmake_manifest, - ) - ) - cmake_manifest = list( - filter( - lambda name: (os.path.join("lib", "cmake") not in name), - cmake_manifest, - ) + cmake_manifest = _filter_manifest( + cmake_manifest, + os.path.join("share", "cmake"), + os.path.join("lib", "cmake"), ) if not get_bool_option(args, "install-headers"): - cmake_manifest = list( - filter(lambda name: "include" not in name, cmake_manifest) - ) + cmake_manifest = _filter_manifest(cmake_manifest, "include") + return cmake_manifest diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 0e7eac3b6..65f3f3e71 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -363,6 +363,20 @@ if(TIMEMORY_BUILD_FORTRAN) endif() endif() +#----------------------------------------------------------------------------------------# +# +# Language aliases libraries +# +#----------------------------------------------------------------------------------------# + +foreach(_LANG c cxx fortran) + if(TARGET timemory-${_LANG}-shared) + add_library(timemory::timemory-${_LANG} ALIAS timemory-${_LANG}-shared) + elseif(TARGET timemory-${_LANG}-static) + add_library(timemory::timemory-${_LANG} ALIAS timemory-${_LANG}-static) + endif() +endforeach() + #----------------------------------------------------------------------------------------# # # TOOL executables and libraries @@ -392,6 +406,7 @@ if(TARGET timemory-mpip-shared) list(APPEND TIMEMORY_TOOL_LIBRARIES timemory-mpip-shared) else() inform_empty_interface(timemory-mpip-library "MPIP standalone instrumentation library") + set(TIMEMORY_BUILD_MPIP_LIBRARY OFF PARENT_SCOPE) endif() if(_OMPT_LIB) @@ -400,6 +415,7 @@ if(_OMPT_LIB) target_link_libraries(timemory-ompt-library INTERFACE timemory-ompt ${_OMPT_LIB}) else() inform_empty_interface(timemory-ompt-library "OpenMP stand-alone instrumentation library") + set(TIMEMORY_BUILD_OMPT_LIBRARY OFF PARENT_SCOPE) endif() if(TARGET timemory-ncclp-shared) @@ -409,6 +425,7 @@ if(TARGET timemory-ncclp-shared) list(APPEND TIMEMORY_TOOL_LIBRARIES timemory-ncclp-shared) else() inform_empty_interface(timemory-ncclp-library "NCCLP standalone instrumentation library") + set(TIMEMORY_BUILD_NCCLP_LIBRARY OFF PARENT_SCOPE) endif() if(TARGET timemory-mallocp-shared) @@ -418,6 +435,7 @@ if(TARGET timemory-mallocp-shared) list(APPEND TIMEMORY_TOOL_LIBRARIES timemory-mallocp-shared) else() inform_empty_interface(timemory-mallocp-library "MALLOCP standalone instrumentation library") + set(TIMEMORY_BUILD_MALLOCP_LIBRARY OFF PARENT_SCOPE) endif() if(TARGET timemory-compiler-instrument-base) diff --git a/source/tools/timemory-mallocp/CMakeLists.txt b/source/tools/timemory-mallocp/CMakeLists.txt index f03e77bbc..9c5d02212 100644 --- a/source/tools/timemory-mallocp/CMakeLists.txt +++ b/source/tools/timemory-mallocp/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) -if(NOT TIMEMORY_USE_GOTCHA OR NOT TARGET timemory::timemory-cxx-shared) +if(NOT TIMEMORY_USE_GOTCHA OR + (BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS AND NOT CMAKE_POSITION_INDEPENDENT_CODE)) return() endif() @@ -8,6 +9,13 @@ if(NOT TIMEMORY_BUILD_MALLOCP_LIBRARY OR TIMEMORY_SKIP_BUILD OR TIMEMORY_BUILD_E set(_EXCLUDE EXCLUDE_FROM_ALL) endif() +if(NOT TARGET timemory::timemory-cxx) + if(TIMEMORY_BUILD_MALLOCP_LIBRARY) + message(WARNING "timemory-mallocp-library cannot be built due to missing timemory::timemory-cxx target") + endif() + return() +endif() + project(timemory-mallocp-tool) add_library(timemory-mallocp-shared SHARED ${_EXCLUDE} ${PROJECT_SOURCE_DIR}/timemory-mallocp.cpp) @@ -16,7 +24,7 @@ add_library(timemory::timemory-mallocp-shared ALIAS timemory-mallocp-shared) # public link targets target_link_libraries(timemory-mallocp-shared PUBLIC timemory::timemory-headers - timemory::timemory-cxx-shared + timemory::timemory-cxx timemory::timemory-gotcha) # private link targets diff --git a/source/tools/timemory-mallocp/timemory-mallocp.cpp b/source/tools/timemory-mallocp/timemory-mallocp.cpp index b1d6ac1db..037e489e3 100644 --- a/source/tools/timemory-mallocp/timemory-mallocp.cpp +++ b/source/tools/timemory-mallocp/timemory-mallocp.cpp @@ -32,9 +32,9 @@ using namespace tim::component; -using malloc_toolset_t = tim::component_tuple; -uint64_t global_cnt = 0; -uint64_t global_id = std::numeric_limits::max(); +using malloc_toolset_t = tim::component_tuple; +static uint64_t global_cnt = 0; +static uint64_t global_id = std::numeric_limits::max(); // //--------------------------------------------------------------------------------------// // diff --git a/source/tools/timemory-mpip/CMakeLists.txt b/source/tools/timemory-mpip/CMakeLists.txt index 040c0b609..8646b1cfb 100644 --- a/source/tools/timemory-mpip/CMakeLists.txt +++ b/source/tools/timemory-mpip/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) -if(NOT TIMEMORY_USE_GOTCHA OR NOT TIMEMORY_USE_MPI OR NOT TARGET timemory::timemory-cxx-shared) +if(NOT TIMEMORY_USE_GOTCHA OR NOT TIMEMORY_USE_MPI OR + (BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS AND NOT CMAKE_POSITION_INDEPENDENT_CODE)) return() endif() @@ -8,6 +9,13 @@ if(NOT TIMEMORY_BUILD_MPIP_LIBRARY OR TIMEMORY_SKIP_BUILD OR TIMEMORY_BUILD_EXCL set(_EXCLUDE EXCLUDE_FROM_ALL) endif() +if(NOT TARGET timemory::timemory-cxx) + if(TIMEMORY_BUILD_MPIP_LIBRARY) + message(WARNING "timemory-mpip-library cannot be built due to missing timemory::timemory-cxx target") + endif() + return() +endif() + project(timemory-mpip-tool) add_library(timemory-mpip-shared SHARED ${_EXCLUDE} ${PROJECT_SOURCE_DIR}/timemory-mpip.cpp) @@ -16,7 +24,7 @@ add_library(timemory::timemory-mpip-shared ALIAS timemory-mpip-shared) # public link targets target_link_libraries(timemory-mpip-shared PUBLIC timemory::timemory-headers - timemory::timemory-cxx-shared + timemory::timemory-cxx timemory::timemory-mpi timemory::timemory-gotcha) diff --git a/source/tools/timemory-mpip/timemory-mpip.cpp b/source/tools/timemory-mpip/timemory-mpip.cpp index c50dfe519..e60ae3794 100644 --- a/source/tools/timemory-mpip/timemory-mpip.cpp +++ b/source/tools/timemory-mpip/timemory-mpip.cpp @@ -51,11 +51,11 @@ TIMEMORY_DEFINE_CONCRETE_TRAIT(is_memory_category, mpi_data_tracker_t, true_type // //--------------------------------------------------------------------------------------// // -using api_t = TIMEMORY_API; -using mpi_toolset_t = tim::component_tuple; -using mpip_handle_t = mpip_handle; -uint64_t global_id = 0; -void* libmpi_handle = nullptr; +using api_t = TIMEMORY_API; +using mpi_toolset_t = tim::component_tuple; +using mpip_handle_t = mpip_handle; +static uint64_t global_id = 0; +static void* libmpi_handle = nullptr; // //--------------------------------------------------------------------------------------// // diff --git a/source/tools/timemory-ncclp/CMakeLists.txt b/source/tools/timemory-ncclp/CMakeLists.txt index f8e2b241a..ac786ee05 100644 --- a/source/tools/timemory-ncclp/CMakeLists.txt +++ b/source/tools/timemory-ncclp/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) -if(NOT TIMEMORY_USE_GOTCHA OR NOT TIMEMORY_USE_NCCL OR NOT TARGET timemory::timemory-cxx-shared) +if(NOT TIMEMORY_USE_GOTCHA OR NOT TIMEMORY_USE_NCCL OR + (BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS AND NOT CMAKE_POSITION_INDEPENDENT_CODE)) return() endif() @@ -8,6 +9,13 @@ if(NOT TIMEMORY_BUILD_NCCLP_LIBRARY OR TIMEMORY_SKIP_BUILD OR TIMEMORY_BUILD_EXC set(_EXCLUDE EXCLUDE_FROM_ALL) endif() +if(NOT TARGET timemory::timemory-cxx) + if(TIMEMORY_BUILD_NCCLP_LIBRARY) + message(WARNING "timemory-ncclp-library cannot be built due to missing timemory::timemory-cxx target") + endif() + return() +endif() + project(timemory-ncclp-tool) add_library(timemory-ncclp-shared SHARED ${_EXCLUDE} ${PROJECT_SOURCE_DIR}/timemory-ncclp.cpp) @@ -16,7 +24,7 @@ add_library(timemory::timemory-ncclp-shared ALIAS timemory-ncclp-shared) # public link targets target_link_libraries(timemory-ncclp-shared PUBLIC timemory::timemory-headers - timemory::timemory-cxx-shared + timemory::timemory-cxx timemory::timemory-nccl timemory::timemory-gotcha) diff --git a/source/tools/timemory-ncclp/timemory-ncclp.cpp b/source/tools/timemory-ncclp/timemory-ncclp.cpp index 0399177d7..ed91610c2 100644 --- a/source/tools/timemory-ncclp/timemory-ncclp.cpp +++ b/source/tools/timemory-ncclp/timemory-ncclp.cpp @@ -57,9 +57,9 @@ TIMEMORY_DEFINE_CONCRETE_TRAIT(is_memory_category, nccl_data_tracker_t, true_typ using api_t = ncclp_tag; using nccl_toolset_t = tim::component_tuple; -using ncclp_handle_t = ncclp_handle; -uint64_t global_id = 0; -void* libnccl_handle = nullptr; +using ncclp_handle_t = ncclp_handle; +static uint64_t global_id = 0; +static void* libnccl_handle = nullptr; // //--------------------------------------------------------------------------------------// // diff --git a/source/tools/timemory-ompt/CMakeLists.txt b/source/tools/timemory-ompt/CMakeLists.txt index 74cd0e400..a7eee1399 100644 --- a/source/tools/timemory-ompt/CMakeLists.txt +++ b/source/tools/timemory-ompt/CMakeLists.txt @@ -11,16 +11,11 @@ endif() project(timemory-ompt-tool) -set(LIB_TYPES) -if(BUILD_SHARED_LIBS AND NOT TIMEMORY_SKIP_BUILD) - list(APPEND LIB_TYPES SHARED) -endif() - -if(BUILD_STATIC_LIBS AND NOT TIMEMORY_SKIP_BUILD) - list(APPEND LIB_TYPES STATIC) -endif() +foreach(_TYPE SHARED STATIC) -foreach(_TYPE ${LIB_TYPES}) + if(NOT BUILD_${_TYPE}_LIBS) + continue() + endif() string(TOLOWER "${_TYPE}" _LC_TYPE) if(NOT TARGET timemory-cxx-${_LC_TYPE}) From 653af4401a891d851a1380b6db20467a1e3a6e2c Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Fri, 9 Jul 2021 16:54:33 -0500 Subject: [PATCH 5/6] Scripts updates (#215) * removed old scripts + gitinfo for release * MANIFEST.in tweak * toggled python function profiler to not include line number by default since this can cause misleading results when generator are used --- CMakeLists.txt | 19 -- MANIFEST.in | 4 + cmake/Modules/ProjectSetup.cmake | 43 ++++ docs/.gitignore | 1 + scripts/bundle-sdist.sh | 16 +- scripts/clean-setup-files.sh | 14 -- scripts/component-generator/generate.cmake | 47 ---- scripts/component-generator/generate.sh | 12 - .../template/CMakeLists.txt.in | 18 -- .../template/backends.hpp.in | 45 ---- .../template/components.hpp.in | 61 ----- .../template/declaration.hpp.in | 63 ----- .../template/definition.hpp.in | 63 ----- .../template/extern.cpp.in | 25 -- .../template/extern.hpp.in | 75 ------ .../component-generator/template/types.hpp.in | 66 ------ scripts/extern-generator/generate.cmake | 55 ----- scripts/extern-generator/generate.sh | 12 - .../template/CMakeLists.txt.in | 14 -- .../template/declaration.hpp.in | 44 ---- .../template/definition.hpp.in | 48 ---- .../extern-generator/template/extern.cpp.in | 25 -- .../extern-generator/template/extern.hpp.in | 44 ---- .../extern-generator/template/macros.hpp.in | 53 ----- .../template/templates.hpp.in | 45 ---- .../extern-generator/template/types.hpp.in | 43 ---- .../template/types/type.cpp.in | 29 --- .../template/types/type.hpp.in | 42 ---- scripts/generate-gitinfo.sh | 16 ++ scripts/type-generator/generate-enum.py | 37 --- scripts/type-generator/generate-if.py | 132 ----------- scripts/type-generator/generate-init.py | 35 --- scripts/type-generator/generate-latex.py | 31 --- .../type-generator/generate-native-extern.py | 44 ---- scripts/type-generator/generate-properties.py | 51 ---- scripts/type-generator/generate-pyenum.py | 34 --- scripts/type-generator/generate-switch.py | 121 ---------- scripts/type-generator/generate-traits.py | 38 --- scripts/type-generator/generate-types.py | 147 ------------ scripts/type-generator/timemory_types.py | 219 ------------------ scripts/update-conda-yaml.py | 57 ----- scripts/update-docs.sh | 63 ----- source/python/libpytimemory-profile.cpp | 2 +- 43 files changed, 76 insertions(+), 1977 deletions(-) delete mode 100755 scripts/clean-setup-files.sh delete mode 100644 scripts/component-generator/generate.cmake delete mode 100755 scripts/component-generator/generate.sh delete mode 100644 scripts/component-generator/template/CMakeLists.txt.in delete mode 100644 scripts/component-generator/template/backends.hpp.in delete mode 100644 scripts/component-generator/template/components.hpp.in delete mode 100644 scripts/component-generator/template/declaration.hpp.in delete mode 100644 scripts/component-generator/template/definition.hpp.in delete mode 100644 scripts/component-generator/template/extern.cpp.in delete mode 100644 scripts/component-generator/template/extern.hpp.in delete mode 100644 scripts/component-generator/template/types.hpp.in delete mode 100644 scripts/extern-generator/generate.cmake delete mode 100755 scripts/extern-generator/generate.sh delete mode 100644 scripts/extern-generator/template/CMakeLists.txt.in delete mode 100644 scripts/extern-generator/template/declaration.hpp.in delete mode 100644 scripts/extern-generator/template/definition.hpp.in delete mode 100644 scripts/extern-generator/template/extern.cpp.in delete mode 100644 scripts/extern-generator/template/extern.hpp.in delete mode 100644 scripts/extern-generator/template/macros.hpp.in delete mode 100644 scripts/extern-generator/template/templates.hpp.in delete mode 100644 scripts/extern-generator/template/types.hpp.in delete mode 100644 scripts/extern-generator/template/types/type.cpp.in delete mode 100644 scripts/extern-generator/template/types/type.hpp.in create mode 100755 scripts/generate-gitinfo.sh delete mode 100755 scripts/type-generator/generate-enum.py delete mode 100755 scripts/type-generator/generate-if.py delete mode 100755 scripts/type-generator/generate-init.py delete mode 100755 scripts/type-generator/generate-latex.py delete mode 100755 scripts/type-generator/generate-native-extern.py delete mode 100755 scripts/type-generator/generate-properties.py delete mode 100755 scripts/type-generator/generate-pyenum.py delete mode 100755 scripts/type-generator/generate-switch.py delete mode 100755 scripts/type-generator/generate-traits.py delete mode 100755 scripts/type-generator/generate-types.py delete mode 100644 scripts/type-generator/timemory_types.py delete mode 100755 scripts/update-conda-yaml.py delete mode 100755 scripts/update-docs.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 48d1926ee..552992b3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,25 +70,6 @@ else() # set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() -set(TIMEMORY_GIT_DESCRIBE "unknown") -set(TIMEMORY_GIT_REVISION "unknown") - -find_package(Git QUIET) -if(Git_FOUND) - execute_process( - COMMAND ${GIT_EXECUTABLE} describe --tags - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE TIMEMORY_GIT_DESCRIBE - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process( - COMMAND ${GIT_EXECUTABLE} rev-parse HEAD - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE TIMEMORY_GIT_REVISION - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) -endif() - # install directories include(GNUInstallDirs) # cmake installation folder -- change CMAKE_INSTALL_DATAROOTDIR to tweak this diff --git a/MANIFEST.in b/MANIFEST.in index e56c08669..b06e4ab95 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -46,3 +46,7 @@ recursive-exclude _skbuild * recursive-exclude build * recursive-exclude dist * recursive-exclude external/hatchet/build * + +# bypass global exclude of git files + +include docs/.gitinfo diff --git a/cmake/Modules/ProjectSetup.cmake b/cmake/Modules/ProjectSetup.cmake index 10ed67e32..8b8704759 100644 --- a/cmake/Modules/ProjectSetup.cmake +++ b/cmake/Modules/ProjectSetup.cmake @@ -79,3 +79,46 @@ math(EXPR TIMEMORY_VERSION_CODE if(SKBUILD AND TIMEMORY_USE_PYTHON) set(CMAKE_INSTALL_LIBDIR lib) endif() + +#----------------------------------------------------------------------------------------# +# Git info +#----------------------------------------------------------------------------------------# + +set(TIMEMORY_GIT_DESCRIBE "unknown") +set(TIMEMORY_GIT_REVISION "unknown") + +# the docs/.gitinfo only exists in releases +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/docs/.gitinfo") + file(READ "${CMAKE_CURRENT_SOURCE_DIR}/docs/.gitinfo" _GIT_INFO) + string(REGEX REPLACE "[\n\r\t ]" ";" _GIT_INFO "${_GIT_INFO}") + string(REGEX REPLACE ";$" "" _GIT_INFO "${_GIT_INFO}") + list(LENGTH _GIT_INFO _GIT_INFO_LEN) + if(_GIT_INFO_LEN GREATER 1) + list(GET _GIT_INFO 0 TIMEMORY_GIT_REVISION) + list(GET _GIT_INFO 1 TIMEMORY_GIT_DESCRIBE) + endif() +endif() + +find_package(Git QUIET) +if(Git_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --tags + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE TIMEMORY_GIT_DESCRIBE + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE TIMEMORY_GIT_REVISION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +if(NOT "${TIMEMORY_GIT_REVISION}" STREQUAL "unknown") + message(STATUS "[timemory] git revision: ${TIMEMORY_GIT_REVISION}") +endif() + +if(NOT "${TIMEMORY_GIT_DESCRIBE}" STREQUAL "unknown") + message(STATUS "[timemory] git describe: ${TIMEMORY_GIT_DESCRIBE}") +endif() diff --git a/docs/.gitignore b/docs/.gitignore index 0ad8df340..13af53396 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -6,3 +6,4 @@ /Doxyfile.timemory /installation.md /CONTRIBUTING.md +/.gitinfo diff --git a/scripts/bundle-sdist.sh b/scripts/bundle-sdist.sh index e67ffe316..1585903d7 100755 --- a/scripts/bundle-sdist.sh +++ b/scripts/bundle-sdist.sh @@ -4,14 +4,20 @@ set -o errexit : ${PYTHON_EXE:=python3} -if [ ${PWD} = ${BASH_SOURCE[0]} ]; then - cd ../../ -fi +_SCRIPT_DIR=$(bash -c "cd $(dirname ${BASH_SOURCE[0]}) && pwd") +_SOURCE_DIR=$(dirname ${_SCRIPT_DIR}) -rm -rf TiMemory.* .eggs build dist +cd ${_SOURCE_DIR} + +rm -f docs/.gitinfo +./scripts/generate-gitinfo.sh +echo "############### git info ###############" +cat ./docs/.gitinfo +echo "########################################" + +rm -rf dist ${PYTHON_EXE} setup.py sdist cd dist sha256sum * gpg --detach-sign -a * # twine upload * - diff --git a/scripts/clean-setup-files.sh b/scripts/clean-setup-files.sh deleted file mode 100755 index c49ad5470..000000000 --- a/scripts/clean-setup-files.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -set -o errexit - -if [ ${PWD} = ${BASH_SOURCE[0]} ]; then - cd ../.. -fi - - -for i in TiMemory.egg-info build dist .eggs -do - echo -e "### Removing ${PWD}/${i}..." - rm -rf ${i} -done diff --git a/scripts/component-generator/generate.cmake b/scripts/component-generator/generate.cmake deleted file mode 100644 index 6703ee975..000000000 --- a/scripts/component-generator/generate.cmake +++ /dev/null @@ -1,47 +0,0 @@ - -cmake_minimum_required(VERSION 3.11 FATAL_ERROR) - -macro(CHECK_REQUIRED VAR) - if(NOT DEFINED ${VAR}) - message(FATAL_ERROR "Error! Variable '${VAR}' must be defined") - endif() -endmacro() - -macro(SET_DEFAULT VAR) - if(NOT DEFINED ${VAR}) - set(${VAR} ${ARGN}) - endif() -endmacro() - -CHECK_REQUIRED(COMPONENT_FOLDER) - -STRING(TOUPPER "${COMPONENT_FOLDER}" COMPONENT_FOLDER_UPPER) - -SET_DEFAULT(INPUT_DIR ${CMAKE_CURRENT_LIST_DIR}/template) -SET_DEFAULT(OUTPUT_DIR ${CMAKE_CURRENT_LIST_DIR}/${COMPONENT_FOLDER}) - -# default values -SET_DEFAULT(CXX_STRUCT example) -SET_DEFAULT(CXX_ENUM EXAMPLE) -SET_DEFAULT(SOME_TRAIT is_available) -SET_DEFAULT(STRING_ALIASES timemory_example) -SET_DEFAULT(CXX_STRUCT_DATA_TYPE int64_t) -SET_DEFAULT(CXX_STRUCT_STAT_TYPE double) -SET_DEFAULT(COMPONENT_CHECK ${COMPONENT_FOLDER_UPPER}) - -if("${INPUT_DIR}" STREQUAL "${OUTPUT_DIR}") - message(FATAL_ERROR "Input directory == Output directory (${INPUT_DIR} == ${OUTPUT_DIR})") -endif() - -if(EXISTS "${OUTPUT_DIR}") - message(FATAL_ERROR "Output directory (${OUTPUT_DIR}) exists!") -endif() - -file(GLOB_RECURSE INPUT_FILES ${INPUT_DIR}/*.in) - -foreach(INP ${INPUT_FILES}) - string(REPLACE "${CMAKE_CURRENT_LIST_DIR}/template/" "${OUTPUT_DIR}/" OUT "${INP}") - string(REPLACE ".in" "" OUT "${OUT}") - message(STATUS "${INP} --> ${OUT}") - configure_file(${INP} ${OUT} @ONLY) -endforeach() diff --git a/scripts/component-generator/generate.sh b/scripts/component-generator/generate.sh deleted file mode 100755 index e7b5f5ab0..000000000 --- a/scripts/component-generator/generate.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -e - -if [ $# -lt 1 ]; then - echo "Error! Provide at least one component folder name" - exit 1 -fi - -for i in $@ -do - echo -e "\n### ${i} ###\n" - cmake -DCOMPONENT_FOLDER=${i} -P generate.cmake -done diff --git a/scripts/component-generator/template/CMakeLists.txt.in b/scripts/component-generator/template/CMakeLists.txt.in deleted file mode 100644 index d8a427eaf..000000000 --- a/scripts/component-generator/template/CMakeLists.txt.in +++ /dev/null @@ -1,18 +0,0 @@ - -if(TIMEMORY_USE_@COMPONENT_CHECK@) - set(NAME @COMPONENT_FOLDER@) - set(DEPS timemory-@COMPONENT_FOLDER@) - - file(GLOB_RECURSE header_files ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) - file(GLOB_RECURSE source_files ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - - build_intermediate_library( - NAME ${NAME} - TARGET ${NAME}-component - CATEGORY COMPONENT - FOLDER components - HEADERS ${header_files} - SOURCES ${source_files} - DEPENDS ${DEPS} - PROPERTY_DEPENDS GLOBAL) -endif() diff --git a/scripts/component-generator/template/backends.hpp.in b/scripts/component-generator/template/backends.hpp.in deleted file mode 100644 index baee34c2c..000000000 --- a/scripts/component-generator/template/backends.hpp.in +++ /dev/null @@ -1,45 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// - -/** - * \file timemory/components/@COMPONENT_FOLDER@/backends.hpp - * \brief Implementation of the @COMPONENT_FOLDER@ functions/utilities - */ - -#pragma once - -//======================================================================================// -// -namespace tim -{ -namespace backend -{ -// -// -// -} // namespace backend -} // namespace tim -// -//======================================================================================// diff --git a/scripts/component-generator/template/components.hpp.in b/scripts/component-generator/template/components.hpp.in deleted file mode 100644 index 606224fb8..000000000 --- a/scripts/component-generator/template/components.hpp.in +++ /dev/null @@ -1,61 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/components/@COMPONENT_FOLDER@/components.hpp - * \brief Implementation of the @COMPONENT_FOLDER@ component(s) - */ - -#pragma once - -#include "timemory/components/base.hpp" -// -#include "timemory/components/@COMPONENT_FOLDER@/backends.hpp" -#include "timemory/components/@COMPONENT_FOLDER@/types.hpp" - -//======================================================================================// -// -namespace tim -{ -namespace component -{ -// -// struct @CXX_STRUCT@ : base<@CXX_STRUCT@, @CXX_STRUCT_DATA_TYPE@> -// { -// static std::string label() { return "example"; } -// static std::string description() { return "Example component"; } -// -// static @CXX_STRUCT_DATA_TYPE@ record() { } -// -// @CXX_STRUCT_STAT_TYPE@ get() const { } -// @CXX_STRUCT_STAT_TYPE@ get_display() const { return get(); } -// -// void start() { } -// void stop() { } -// }; -// -} // namespace component -} // namespace tim -// -//======================================================================================// diff --git a/scripts/component-generator/template/declaration.hpp.in b/scripts/component-generator/template/declaration.hpp.in deleted file mode 100644 index d43d7ba0e..000000000 --- a/scripts/component-generator/template/declaration.hpp.in +++ /dev/null @@ -1,63 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/components/@COMPONENT_FOLDER@/components.hpp - * \brief Implementation of the @COMPONENT_FOLDER@ component(s) - */ - -#pragma once - -#include "timemory/components/base/declaration.hpp" -#include "timemory/mpl/types.hpp" -#include "timemory/units.hpp" - -#include "timemory/components/@COMPONENT_FOLDER@/backends.hpp" -#include "timemory/components/@COMPONENT_FOLDER@/types.hpp" - -//======================================================================================// -// -namespace tim -{ -namespace component -{ -// -// struct @CXX_STRUCT@ : base<@CXX_STRUCT@, @CXX_STRUCT_DATA_TYPE@> -// { -// static std::string label() { return "example"; } -// static std::string description() { return "Example component"; } -// -// static @CXX_STRUCT_DATA_TYPE@ record() { } -// -// @CXX_STRUCT_STAT_TYPE@ get() const { } -// @CXX_STRUCT_STAT_TYPE@ get_display() const { return get(); } -// -// void start() { } -// void stop() { } -// }; -// -} // namespace component -} // namespace tim -// -//======================================================================================// diff --git a/scripts/component-generator/template/definition.hpp.in b/scripts/component-generator/template/definition.hpp.in deleted file mode 100644 index dfc12fcfa..000000000 --- a/scripts/component-generator/template/definition.hpp.in +++ /dev/null @@ -1,63 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/components/@COMPONENT_FOLDER@/components.hpp - * \brief Implementation of the @COMPONENT_FOLDER@ component(s) - */ - -#pragma once - -#include "timemory/components/base/definition.hpp" -#include "timemory/mpl/types.hpp" -#include "timemory/units.hpp" - -#include "timemory/components/@COMPONENT_FOLDER@/backends.hpp" -#include "timemory/components/@COMPONENT_FOLDER@/types.hpp" - -//======================================================================================// -// -namespace tim -{ -namespace component -{ -// -// struct @CXX_STRUCT@ : base<@CXX_STRUCT@, @CXX_STRUCT_DATA_TYPE@> -// { -// static std::string label() { return "example"; } -// static std::string description() { return "Example component"; } -// -// static @CXX_STRUCT_DATA_TYPE@ record() { } -// -// @CXX_STRUCT_STAT_TYPE@ get() const { } -// @CXX_STRUCT_STAT_TYPE@ get_display() const { return get(); } -// -// void start() { } -// void stop() { } -// }; -// -} // namespace component -} // namespace tim -// -//======================================================================================// diff --git a/scripts/component-generator/template/extern.cpp.in b/scripts/component-generator/template/extern.cpp.in deleted file mode 100644 index 576a71628..000000000 --- a/scripts/component-generator/template/extern.cpp.in +++ /dev/null @@ -1,25 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#include "timemory/components/@COMPONENT_FOLDER@/extern.hpp" diff --git a/scripts/component-generator/template/extern.hpp.in b/scripts/component-generator/template/extern.hpp.in deleted file mode 100644 index 9784718d3..000000000 --- a/scripts/component-generator/template/extern.hpp.in +++ /dev/null @@ -1,75 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/components/@COMPONENT_FOLDER@/extern.hpp - * \brief Include the extern declarations for @COMPONENT_FOLDER@ components - */ - -#pragma once - -//======================================================================================// -// -#include "timemory/components/base.hpp" -#include "timemory/components/macros.hpp" -// -#include "timemory/components/@COMPONENT_FOLDER@/components.hpp" -#include "timemory/components/@COMPONENT_FOLDER@/types.hpp" -// -#if defined(TIMEMORY_COMPONENT_SOURCE) || \ - (!defined(TIMEMORY_USE_EXTERN) && !defined(TIMEMORY_USE_COMPONENT_EXTERN)) -// source/header-only requirements -# include "timemory/environment/declaration.hpp" -# include "timemory/operations/definition.hpp" -# include "timemory/plotting/definition.hpp" -# include "timemory/settings/declaration.hpp" -# include "timemory/storage/definition.hpp" -#else -// extern requirements -# include "timemory/environment/declaration.hpp" -# include "timemory/operations/definition.hpp" -# include "timemory/plotting/declaration.hpp" -# include "timemory/settings/declaration.hpp" -# include "timemory/storage/declaration.hpp" -#endif -// -//======================================================================================// -// -namespace tim -{ -namespace component -{ -// -// TIMEMORY_EXTERN_TEMPLATE(struct base<@CXX_STRUCT@, @CXX_STRUCT_DATA_TYPE@>) -// -} // namespace component -} // namespace tim -// -//======================================================================================// -// -// TIMEMORY_EXTERN_OPERATIONS(component::@CXX_STRUCT@, true) -// -// TIMEMORY_EXTERN_STORAGE(component::@CXX_STRUCT@, @CXX_STRUCT@) -// -//======================================================================================// diff --git a/scripts/component-generator/template/types.hpp.in b/scripts/component-generator/template/types.hpp.in deleted file mode 100644 index 2f69e7804..000000000 --- a/scripts/component-generator/template/types.hpp.in +++ /dev/null @@ -1,66 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/components/@COMPONENT_FOLDER@/types.hpp - * \brief Declare the @COMPONENT_FOLDER@ component types - */ - -#pragma once - -#include "timemory/components/macros.hpp" -#include "timemory/enum.h" -#include "timemory/mpl/type_traits.hpp" -#include "timemory/mpl/types.hpp" - -//======================================================================================// -// -// TIMEMORY_DECLARE_COMPONENT(@CXX_STRUCT@) -// -//--------------------------------------------------------------------------------------// -// -// STATISTICS -// -//--------------------------------------------------------------------------------------// -// -// TIMEMORY_STATISTICS_TYPE(component::@CXX_STRUCT@, @CXX_STRUCT_STAT_TYPE@) -// -//--------------------------------------------------------------------------------------// -// -// IS AVAILABLE -// -//--------------------------------------------------------------------------------------// -// -// TIMEMORY_DEFINE_CONCRETE_TRAIT(@SOME_TRAIT@, component::@CXX_STRUCT@, true_type) -// TIMEMORY_DEFINE_CONCRETE_TRAIT(@SOME_TRAIT@, component::@CXX_STRUCT@, false_type) -// -//--------------------------------------------------------------------------------------// -// -// PROPERTIES -// -//--------------------------------------------------------------------------------------// -// -// TIMEMORY_PROPERTY_SPECIALIZATION(@CXX_STRUCT@, @CXX_ENUM@, "@STRING_ALIASES@", ...) -// -//======================================================================================// diff --git a/scripts/extern-generator/generate.cmake b/scripts/extern-generator/generate.cmake deleted file mode 100644 index d4a37cec3..000000000 --- a/scripts/extern-generator/generate.cmake +++ /dev/null @@ -1,55 +0,0 @@ - -cmake_minimum_required(VERSION 3.11 FATAL_ERROR) - -macro(CHECK_REQUIRED VAR) - if(NOT DEFINED ${VAR}) - message(FATAL_ERROR "Error! Variable '${VAR}' must be defined") - endif() -endmacro() - -macro(SET_DEFAULT VAR) - if(NOT DEFINED ${VAR}) - set(${VAR} ${ARGN}) - endif() -endmacro() - -CHECK_REQUIRED(FOLDER) - -STRING(TOUPPER "${FOLDER}" FOLDER_UPPER) - -SET_DEFAULT(INPUT_DIR ${CMAKE_CURRENT_LIST_DIR}/template) -SET_DEFAULT(OUTPUT_DIR ${CMAKE_CURRENT_LIST_DIR}/${FOLDER}) - -# default values -SET_DEFAULT(CHECK ${FOLDER_UPPER}) - -if("${INPUT_DIR}" STREQUAL "${OUTPUT_DIR}") - message(FATAL_ERROR "Input directory == Output directory (${INPUT_DIR} == ${OUTPUT_DIR})") -endif() - -if(EXISTS "${OUTPUT_DIR}") - message(FATAL_ERROR "Output directory (${OUTPUT_DIR}) exists!") -endif() - -file(GLOB INPUT_FILES ${INPUT_DIR}/*.in) - -foreach(INP ${INPUT_FILES}) - string(REPLACE "${INPUT_DIR}/" "${OUTPUT_DIR}/" OUT "${INP}") - string(REPLACE ".in" "" OUT "${OUT}") - message(STATUS "${INP} --> ${OUT}") - configure_file(${INP} ${OUT} @ONLY) -endforeach() - -file(GLOB TYPES_FILES ${INPUT_DIR}/types/*.in) - -foreach(TYPE ${TYPES}) - foreach(INP ${TYPES_FILES}) - string(REPLACE "${INPUT_DIR}/" "${OUTPUT_DIR}/" OUT "${INP}") - get_filename_component(OUT_NAME "${OUT}" NAME_WE) - message(STATUS "OUT_NAME: ${OUT_NAME}") - string(REPLACE "${OUT_NAME}." "${TYPE}." OUT "${OUT}") - string(REPLACE ".in" "" OUT "${OUT}") - message(STATUS "${INP} --> ${OUT}") - configure_file(${INP} ${OUT} @ONLY) - endforeach() -endforeach() diff --git a/scripts/extern-generator/generate.sh b/scripts/extern-generator/generate.sh deleted file mode 100755 index ac02f4155..000000000 --- a/scripts/extern-generator/generate.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -e - -if [ $# -lt 1 ]; then - echo "Error! Provide at least one folder name" - exit 1 -fi - -for i in $@ -do - echo -e "\n### ${i} ###\n" - cmake -DFOLDER=${i} -P generate.cmake -done diff --git a/scripts/extern-generator/template/CMakeLists.txt.in b/scripts/extern-generator/template/CMakeLists.txt.in deleted file mode 100644 index a52c0a021..000000000 --- a/scripts/extern-generator/template/CMakeLists.txt.in +++ /dev/null @@ -1,14 +0,0 @@ - -file(GLOB_RECURSE header_files ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) -file(GLOB_RECURSE source_files ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - -build_intermediate_library( - USE_INTERFACE - NAME @COMPONENT_FOLDER@ - TARGET @COMPONENT_FOLDER@ - CATEGORY EXTERN - FOLDER extern - HEADERS ${header_files} - SOURCES ${source_files} - DEPENDS timemory-headers - PROPERTY_DEPENDS GLOBAL COMPONENT USER_BUNDLE FACTORY) diff --git a/scripts/extern-generator/template/declaration.hpp.in b/scripts/extern-generator/template/declaration.hpp.in deleted file mode 100644 index b89269373..000000000 --- a/scripts/extern-generator/template/declaration.hpp.in +++ /dev/null @@ -1,44 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/@FOLDER@/declaration.hpp - * \brief The declaration for the types for @FOLDER@ without definitions - */ - -#pragma once - -#include "timemory/@FOLDER@/macros.hpp" -#include "timemory/@FOLDER@/types.hpp" - -namespace tim -{ -// -//--------------------------------------------------------------------------------------// -// -// @FOLDER@ -// -//--------------------------------------------------------------------------------------// -// -} // namespace tim diff --git a/scripts/extern-generator/template/definition.hpp.in b/scripts/extern-generator/template/definition.hpp.in deleted file mode 100644 index fb1e51143..000000000 --- a/scripts/extern-generator/template/definition.hpp.in +++ /dev/null @@ -1,48 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/@FOLDER@/definition.hpp - * \brief The definitions for the types in @FOLDER@ - */ - -#pragma once - -#include "timemory/@FOLDER@/declaration.hpp" -#include "timemory/@FOLDER@/macros.hpp" -#include "timemory/@FOLDER@/types.hpp" - -namespace tim -{ -// -//--------------------------------------------------------------------------------------// -// -// @FOLDER@ -// -//--------------------------------------------------------------------------------------// -// -#if defined(TIMEMORY_@CHECK@_SOURCE) || \ - (!defined(TIMEMORY_USE_EXTERN) && !defined(TIMEMORY_USE_@CHECK@_EXTERN)) -#endif -} // namespace tim diff --git a/scripts/extern-generator/template/extern.cpp.in b/scripts/extern-generator/template/extern.cpp.in deleted file mode 100644 index 1ae7023ac..000000000 --- a/scripts/extern-generator/template/extern.cpp.in +++ /dev/null @@ -1,25 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#include "timemory/@FOLDER@/extern.hpp" diff --git a/scripts/extern-generator/template/extern.hpp.in b/scripts/extern-generator/template/extern.hpp.in deleted file mode 100644 index c236061ac..000000000 --- a/scripts/extern-generator/template/extern.hpp.in +++ /dev/null @@ -1,44 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/@FOLDER@/extern.hpp - * \brief Include the extern declarations for @FOLDER@ - */ - -#pragma once - -//======================================================================================// -// -#include "timemory/@FOLDER@/macros.hpp" -// -#include "timemory/@FOLDER@/types.hpp" -// -#include "timemory/@FOLDER@/declaration.hpp" -// -#if defined(TIMEMORY_@CHECK@_SOURCE) -# include "timemory/@FOLDER@/definition.hpp" -#endif -// -//======================================================================================// diff --git a/scripts/extern-generator/template/macros.hpp.in b/scripts/extern-generator/template/macros.hpp.in deleted file mode 100644 index a676361ed..000000000 --- a/scripts/extern-generator/template/macros.hpp.in +++ /dev/null @@ -1,53 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/@FOLDER@/macros.hpp - * \brief Include the macros for @FOLDER@ - */ - -#pragma once - -//======================================================================================// -// -// Define macros for @FOLDER@ -// -//======================================================================================// -// -#if defined(TIMEMORY_@CHECK@_SOURCE) -// -# define TIMEMORY_@CHECK@_LINKAGE(...) __VA_ARGS__ -// -#elif defined(TIMEMORY_USE_EXTERN) || defined(TIMEMORY_USE_@CHECK@_EXTERN) -// -# define TIMEMORY_@CHECK@_LINKAGE(...) extern __VA_ARGS__ -// -#else -// -# define TIMEMORY_@CHECK@_LINKAGE(...) __VA_ARGS__ -// -#endif -// -//--------------------------------------------------------------------------------------// -// diff --git a/scripts/extern-generator/template/templates.hpp.in b/scripts/extern-generator/template/templates.hpp.in deleted file mode 100644 index 569a911ec..000000000 --- a/scripts/extern-generator/template/templates.hpp.in +++ /dev/null @@ -1,45 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/@FOLDER@/templates.hpp - * \brief The template definitions for the types in @FOLDER@ - */ - -#pragma once - -#include "timemory/@FOLDER@/declaration.hpp" -#include "timemory/@FOLDER@/macros.hpp" -#include "timemory/@FOLDER@/types.hpp" - -namespace tim -{ -// -//--------------------------------------------------------------------------------------// -// -// @FOLDER@ -// -//--------------------------------------------------------------------------------------// -// -} // namespace tim diff --git a/scripts/extern-generator/template/types.hpp.in b/scripts/extern-generator/template/types.hpp.in deleted file mode 100644 index f5f624fbc..000000000 --- a/scripts/extern-generator/template/types.hpp.in +++ /dev/null @@ -1,43 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/@FOLDER@/types.hpp - * \brief Declare the @FOLDER@ types - */ - -#pragma once - -#include "timemory/@FOLDER@/macros.hpp" - -namespace tim -{ -// -//--------------------------------------------------------------------------------------// -// -// @FOLDER@ -// -//--------------------------------------------------------------------------------------// -// -} // namespace tim diff --git a/scripts/extern-generator/template/types/type.cpp.in b/scripts/extern-generator/template/types/type.cpp.in deleted file mode 100644 index 29a750c13..000000000 --- a/scripts/extern-generator/template/types/type.cpp.in +++ /dev/null @@ -1,29 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -//======================================================================================// -// -#include "timemory/@FOLDER@/types/@TYPE@.hpp" -// -//======================================================================================// diff --git a/scripts/extern-generator/template/types/type.hpp.in b/scripts/extern-generator/template/types/type.hpp.in deleted file mode 100644 index 8832a437d..000000000 --- a/scripts/extern-generator/template/types/type.hpp.in +++ /dev/null @@ -1,42 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/@FOLDER@/types/@TYPE@.hpp - * \brief Include the extern declarations for @TYPE@ in @FOLDER@ - */ - -#pragma once - -//======================================================================================// -// -#include "timemory/@FOLDER@/macros.hpp" -// -#include "timemory/@FOLDER@/types.hpp" -// -#include "timemory/@FOLDER@/declaration.hpp" -// -#include "timemory/@FOLDER@/extern.hpp" -// -//======================================================================================// diff --git a/scripts/generate-gitinfo.sh b/scripts/generate-gitinfo.sh new file mode 100755 index 000000000..01ec633f0 --- /dev/null +++ b/scripts/generate-gitinfo.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -o errexit + +_SCRIPT_DIR=$(bash -c "cd $(dirname ${BASH_SOURCE[0]}) && pwd") +_SOURCE_DIR=$(dirname ${_SCRIPT_DIR}) + +cd ${_SOURCE_DIR} + +: ${GIT_EXECUTABLE:=git} +: ${OUTPUT:=${_SOURCE_DIR}/docs/.gitinfo} + +if [ -n "$1" ]; then OUTPUT=${1}; shift; fi + +${GIT_EXECUTABLE} rev-parse HEAD > ${OUTPUT} +${GIT_EXECUTABLE} describe --tags >> ${OUTPUT} diff --git a/scripts/type-generator/generate-enum.py b/scripts/type-generator/generate-enum.py deleted file mode 100755 index ab9b51d6e..000000000 --- a/scripts/type-generator/generate-enum.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python - -import sys -import argparse -# read in components and mangled enums -from timemory_types import components, mangled_enums - - -def generate_enum(component, ncount, indent): - """ - This function generates a type trait label for C++ - """ - enumeration = mangled_enums.get(component, component) - return "{}{:30} = {},".format(" " * indent, enumeration.upper(), ncount) - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("-V", "--verbose", help="Enable verbosity", default=0, type=int) - parser.add_argument("-i", "--indent", help="Indentation", default=4, type=int) - args = parser.parse_args() - - if args.verbose > 0: - print("timemory components: [{}]\n".format(", ".join(components))) - - components.sort() - outdata = "enum TIMEMORY_NATIVE_COMPONENT\n{\n" - for i in range(0, len(components)): - outdata += "{}\n".format(generate_enum(components[i], i, args.indent)) - - outdata += "{}{} {} = \n{} ({} + {})\n".format(" " * args.indent, - "TIMEMORY_USER_COMPONENT_ENUM", - "TIMEMORY_COMPONENTS_END", " " * args.indent, - "TIMEMORY_COMPONENT_ENUM_SIZE", - "TIMEMORY_USER_COMPONENT_ENUM_SIZE") - outdata += "};" - print("{}".format(outdata)) diff --git a/scripts/type-generator/generate-if.py b/scripts/type-generator/generate-if.py deleted file mode 100755 index 5ba0ca512..000000000 --- a/scripts/type-generator/generate-if.py +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/env python - -import sys -import argparse -# read in components and mangled enums -from timemory_types import components, mangled_enums, mangled_strings - - -def generate_if_statement(component, idx, indent_tabs=2, spaces=4, var="_hashmap"): - """ - This function generates a case label for C++ - """ - enumeration = mangled_enums.get(component, component) - component_options = mangled_strings.get(component, [component]) - if component not in component_options: - component_options += [component] - component_options.sort() - - tab = " " * spaces * indent_tabs - statement = "" - for comp in component_options: - statement += '{}{}"{}", {}{},\n'.format( - tab, '{', comp, enumeration.upper(), '}') - return statement - - -if __name__ == "__main__": - - rbegin = "// GENERATE_SWITCH_REPLACE_BEGIN" - rend = "// GENERATE_SWITCH_REPLACE_END" - - parser = argparse.ArgumentParser() - parser.add_argument("-a", "--additional", - help="Additional components to produce case labels for", nargs='*') - parser.add_argument("-i", "--input", help="input file for replacing", - type=str, default=None) - parser.add_argument("-o", "--output", help="output components from file", - type=str, default=None) - parser.add_argument("-e", "--exclude", - help="exclude components", action='store_true') - parser.add_argument("-s", "--spaces-per-tab", - help="Number of spaces in a tab", type=int, default=4) - parser.add_argument("-t", "--tabs-per-indent", - help="Number of tabs to indent", type=int, default=2) - parser.add_argument("-r", "--replace", action='store_true', - help="Replace area between '{}' and '{}' in the output file".format(rbegin, rend)) - parser.add_argument("-c", "--config", help="alternative to -i/--input when replacing", - type=str, default=None) - parser.add_argument("-v", "--var", help="Name of the map variable", - type=str, default="_instance") - parser.add_argument("-I", "--iter-var", help="Name of the iteration variable", - type=str, default="itr") - parser.add_argument("-V", "--verbose", - help="Enable verbosity", default=0, type=int) - - args = parser.parse_args() - - if args.replace and args.input is None and args.output is None: - raise Exception( - "-r/--replace requires specifying -o/--output or -i/--input") - - # substitution string for replacing - subdata = None - - if args.input is not None: - with open(args.input, 'r') as f: - subdata = f.read() - - if args.config is not None: - with open(args.config, 'r') as f: - components = f.read().strip().split() - - if args.additional: - components += args.additional - - if subdata is None and args.replace: - if args.input is None: - print("reading '{}' for replacement...".format(args.output)) - with open(args.output, 'r') as f: - subdata = f.read() - - components.sort() - if args.verbose > 0: - print("timemory components: [{}]\n".format(", ".join(components))) - - component_options = [] - for component in components: - component_options += mangled_strings.get(component, [component]) - if component not in component_options: - component_options.append(component) - component_options.sort() - - tab = " " * args.spaces_per_tab * args.tabs_per_indent - btab = " " * args.spaces_per_tab * (args.tabs_per_indent - 1) - outdata = "{}static component_hash_map_t _hashmap = {}\n".format( - btab, '{') - idx = 0 - for component in components: - outdata += "{}".format(generate_if_statement(component, idx, - args.tabs_per_indent, args.spaces_per_tab, - args.var)) - idx += 1 - outdata = outdata.strip(",\n") - outdata += '\n{}{};\n'.format(btab, '}') - # outdata += "{}return _instance;\n{}{}\n".format(tab, btab, '};') - - message = '{}static auto errmsg = [](const std::string& {}) {} fprintf(stderr, "Unknown component label: %s{}", {}.c_str()); {};'.format( - btab, args.iter_var, "{", ". Valid choices are: {}\\n".format(component_options), args.iter_var, "}") - - outdata += "\n{}".format(message) - - if subdata is not None: - try: - sbegin = subdata.find(rbegin) + len(rbegin) + 1 - send = subdata.find(rend) - substr = subdata[sbegin:send] - outdata += " " * args.spaces_per_tab * (args.tabs_per_indent + 1) - if args.verbose > 1: - print("sbegin = {}\nsend = {}\nsubstring:\n{}\n\noutdata:\n{}\n".format( - sbegin, send, substr, outdata)) - outdata = subdata.replace(substr, outdata) - if args.verbose > 1: - print("converted:\n{}\n".format(subdata)) - except Exception as e: - print(e) - raise - - if args.output is not None: - with open(args.output, 'w') as f: - f.write(outdata) - else: - print("{}".format(outdata)) diff --git a/scripts/type-generator/generate-init.py b/scripts/type-generator/generate-init.py deleted file mode 100755 index dc84876b7..000000000 --- a/scripts/type-generator/generate-init.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python - -import sys -import argparse -# read in components and mangled enums -from timemory_types import components, mangled_enums - - -def generate_storage(component, key): - """ - This function generates a type trait label for C++ - """ - return "TIMEMORY_{}_EXTERN_INIT({})".format(key.upper(), component) - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("-V", "--verbose", - help="Enable verbosity", default=0, type=int) - parser.add_argument( - "-i", "--indent", help="Indentation", default=4, type=int) - args = parser.parse_args() - - if args.verbose > 0: - print("timemory components: [{}]\n".format(", ".join(components))) - - components.sort() - outdata = "\n" - for component in components: - outdata += "{}\n".format(generate_storage(component, "declare")) - outdata += "\n" - for component in components: - outdata += "{}\n".format(generate_storage(component, "instantiate")) - - print("{}".format(outdata)) diff --git a/scripts/type-generator/generate-latex.py b/scripts/type-generator/generate-latex.py deleted file mode 100755 index c4bca4bde..000000000 --- a/scripts/type-generator/generate-latex.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python - -import sys -import argparse -# read in components and mangled enums -from timemory_types import components - - -def generate_latex(component, indent): - """ - This function generates a type trait label for C++ - """ - return "{}\item \lstinlinec{}{}{}".format(" " * indent, "{", component, "}") - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("-V", "--verbose", help="Enable verbosity", default=0, type=int) - parser.add_argument("-i", "--indent", help="Indentation", default=4, type=int) - args = parser.parse_args() - - if args.verbose > 0: - print("timemory components: [{}]\n".format(", ".join(components))) - - components.sort() - outdata = "\\begin{itemize}\n" - for component in components: - outdata += "{}\n".format(generate_latex(component, args.indent)) - - outdata += "\\end{itemize}" - print("{}".format(outdata)) diff --git a/scripts/type-generator/generate-native-extern.py b/scripts/type-generator/generate-native-extern.py deleted file mode 100755 index 35bd00dff..000000000 --- a/scripts/type-generator/generate-native-extern.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python - -import sys -import argparse -# read in components and mangled enums -from timemory_types import native_components - - -def generate_extern(component, key, alias, suffix, specify_comp=True): - """ - This function generates a type trait label for C++ - """ - if specify_comp: - return "TIMEMORY_{}_EXTERN_{}({}, {})".format( - key.upper(), suffix.upper(), alias, "::tim::component::{}".format(component)) - else: - return "TIMEMORY_{}_EXTERN_{}({})".format( - key.upper(), suffix.upper(), alias) - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("-V", "--verbose", - help="Enable verbosity", default=0, type=int) - parser.add_argument( - "-i", "--indent", help="Indentation", default=4, type=int) - args = parser.parse_args() - - if args.verbose > 0: - print("timemory components: [{}]\n".format( - ", ".join(native_components))) - - native_components.sort() - outdata = "\n" - for key in ["declare", "instantiate"]: - for suffix in ["tuple", "list", "hybrid"]: - specify_comp = False if suffix == "hybrid" else True - for component in native_components: - outdata += "{}\n".format(generate_extern( - component, key, "_".join([component, "t"]), - suffix, specify_comp)) - outdata += "\n" - - print("{}".format(outdata)) diff --git a/scripts/type-generator/generate-properties.py b/scripts/type-generator/generate-properties.py deleted file mode 100755 index dbbaea54e..000000000 --- a/scripts/type-generator/generate-properties.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python - -import sys -import argparse -# read in components and mangled enums -from timemory_types import components, mangled_enums, mangled_strings - - -def generate_get_enum(component): - """ - This function generates a case label for C++ - """ - enumeration = mangled_enums.get(component, component).upper() - strings = ["{}".format(component)] + mangled_strings.get(component, []) - if len(strings) == 1: - strings += [''] - - quoted = ('"{}"'.format(x) for x in strings) - - return "TIMEMORY_PROPERTY_SPECIALIZATION({}, {}, {})".format( - component, enumeration, ", ".join(quoted)) - - -if __name__ == "__main__": - - parser = argparse.ArgumentParser() - parser.add_argument("-a", "--additional", nargs='*', - help="Additional components to produce case labels for") - parser.add_argument("-e", "--exclude", - help="exclude components", action='store_true') - parser.add_argument("-s", "--spaces-per-tab", - help="Number of spaces in a tab", type=int, default=4) - parser.add_argument("-t", "--tabs-per-indent", - help="Number of tabs to indent", type=int, default=1) - parser.add_argument("-V", "--verbose", - help="Enable verbosity", default=0, type=int) - - args = parser.parse_args() - - if args.additional: - components += args.additional - - components.sort() - if args.verbose > 0: - print("timemory components: [{}]\n".format(", ".join(components))) - outdata = "" - for component in components: - outdata += "{}\n".format(generate_get_enum(component)) - outdata += "\n//{}//\n\n".format("-" * 86) - outdata = outdata.strip("\n") - print("{}".format(outdata)) diff --git a/scripts/type-generator/generate-pyenum.py b/scripts/type-generator/generate-pyenum.py deleted file mode 100755 index 2516a3e21..000000000 --- a/scripts/type-generator/generate-pyenum.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python - -import sys -import argparse -# read in components and mangled enums -from timemory_types import components, mangled_enums - - -def generate_enum(component, indent): - """ - This function generates a type trait label for C++ - """ - enumeration = mangled_enums.get(component, component) - return "{}.value({}{}{}, {})".format(" " * indent, '"', enumeration, '"', - enumeration.upper()) - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("-V", "--verbose", help="Enable verbosity", default=0, type=int) - parser.add_argument("-i", "--indent", help="Indentation", default=8, type=int) - args = parser.parse_args() - - if args.verbose > 0: - print("timemory components: [{}]\n".format(", ".join(components))) - - components.sort() - outdata = "components_enum\n" - for component in components: - outdata += "{}\n".format(generate_enum(component, args.indent)) - - outdata = outdata.strip("\n") - outdata += ";" - print("{}".format(outdata)) diff --git a/scripts/type-generator/generate-switch.py b/scripts/type-generator/generate-switch.py deleted file mode 100755 index 21b8cfd1b..000000000 --- a/scripts/type-generator/generate-switch.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env python - -import sys -import argparse -# read in components and mangled enums -from timemory_types import components, mangled_enums - - -def generate_case_label(component, func, indent_tabs=3, spaces=4, reference=True, template=True): - """ - This function generates a case label for C++ - """ - enumeration = mangled_enums.get(component, component) - - spacer = " "*spaces # a spacer of spaces length - atab = "{}".format(spacer) # the generic tab - ftab = atab*indent_tabs # the first tab level - - init_str = "." if reference else "->" - if template: - init_str += "template " - return "{2}case {1}: obj{3}{4}<{0}>(); break;\n".format( - component, enumeration.upper(), ftab, init_str, func) - - -if __name__ == "__main__": - - rbegin = "// GENERATE_SWITCH_REPLACE_BEGIN" - rend = "// GENERATE_SWITCH_REPLACE_END" - - parser = argparse.ArgumentParser() - parser.add_argument( - "-a", "--additional", help="Additional components to produce case labels for", nargs='*') - parser.add_argument( - "-i", "--input", help="input file for replacing", type=str, default=None) - parser.add_argument( - "-o", "--output", help="output components from file", type=str, default=None) - parser.add_argument("-e", "--exclude", - help="exclude components", action='store_true') - parser.add_argument("-s", "--spaces-per-tab", - help="Number of spaces in a tab", type=int, default=4) - parser.add_argument("-t", "--tabs-per-indent", - help="Number of tabs to indent", type=int, default=3) - parser.add_argument("-r", "--replace", action='store_true', - help="Replace area between '{}' and '{}' in the output file".format(rbegin, rend)) - parser.add_argument( - "-c", "--config", help="alternative to -i/--input when replacing", type=str, default=None) - parser.add_argument("-P", "--pointer", help="Object operating on is pointer ('->') instead of reference ('.')", - action='store_true') - parser.add_argument("-S", "--specialized", help="Initialization is specialized (not a template)", - action='store_true') - parser.add_argument("-V", "--verbose", - help="Enable verbosity", default=0, type=int) - parser.add_argument("-f", "--function", - help="Function name", default="init", type=str) - - args = parser.parse_args() - - if args.replace and args.input is None and args.output is None: - raise Exception( - "-r/--replace requires specifying -o/--output or -i/--input") - - # substitution string for replacing - subdata = None - - if args.input is not None: - with open(args.input, 'r') as f: - subdata = f.read() - - if args.config is not None: - with open(args.config, 'r') as f: - components = f.read().strip().split() - print("timemory components: [{}]\n".format( - ", ".join(components))) - - if args.additional: - components += args.additional - - if subdata is None and args.replace: - if args.input is None: - print("reading '{}' for replacement...".format(args.output)) - with open(args.output, 'r') as f: - subdata = f.read() - - components.sort() - if args.verbose > 0: - print("timemory components: [{}]\n".format(", ".join(components))) - outdata = "" - for component in components: - outdata += "{}".format(generate_case_label(component, args.function, - args.tabs_per_indent, args.spaces_per_tab, - not args.pointer, not args.specialized)) - outdata = outdata.strip("\n") - spacer = " "*args.spaces_per_tab # a spacer of spaces length - atab = "{}".format(spacer) # the generic tab - ftab = atab*args.tabs_per_indent # the first tab level - - outdata += "\n{}case TIMEMORY_COMPONENTS_END:\n{}default: break;".format( - ftab, ftab) - - if subdata is not None: - try: - sbegin = subdata.find(rbegin) + len(rbegin) + 1 - send = subdata.find(rend) - substr = subdata[sbegin:send] - outdata += " " * args.spaces_per_tab * (args.tabs_per_indent + 1) - if args.verbose > 1: - print("sbegin = {}\nsend = {}\nsubstring:\n{}\n\noutdata:\n{}\n".format( - sbegin, send, substr, outdata)) - outdata = subdata.replace(substr, outdata) - if args.verbose > 1: - print("converted:\n{}\n".format(subdata)) - except Exception as e: - print(e) - raise - - if args.output is not None: - with open(args.output, 'w') as f: - f.write(outdata) - else: - print("{}".format(outdata)) diff --git a/scripts/type-generator/generate-traits.py b/scripts/type-generator/generate-traits.py deleted file mode 100755 index 873d50894..000000000 --- a/scripts/type-generator/generate-traits.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python - -import sys -import argparse -# read in components and mangled enums -from timemory_types import traits - - -def generate_trait(trait, component, inherit): - """ - This function generates a type trait label for C++ - """ - return "template <>\nstruct {} : {} {};\n".format( - trait, component, inherit, "{}") - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("-V", "--verbose", - help="Enable verbosity", default=0, type=int) - parser.add_argument("-w", "--page-width", - help="Page width", default=90, type=int) - args = parser.parse_args() - - dashes = "-" * (args.page_width - 4) - outdata = "" - for trait, spec in traits.items(): - inherit = spec[0] - components = spec[1] - outdata += "//{0}//\n//\n//\t\t\t{1}\n//\n//{0}//\n\n".format( - dashes, trait.replace("_", " ").upper()) - if args.verbose > 0: - print("timemory components: [{}]\n".format(", ".join(components))) - for component in components: - outdata += "{}\n".format(generate_trait(trait, component, inherit)) - - outdata = outdata.strip("\n") - print("{}".format(outdata)) diff --git a/scripts/type-generator/generate-types.py b/scripts/type-generator/generate-types.py deleted file mode 100755 index edfa46c31..000000000 --- a/scripts/type-generator/generate-types.py +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env python - -import sys -import argparse -# read in components and mangled enums -from timemory_types import components, mangled_enums, recommended_types - - -def generate_list(component, indent_tabs=3, spaces=4, reference=True, template=True): - """ - This function generates a case label for C++ - """ - enumeration = mangled_enums.get(component, component) - - spacer = " "*spaces # a spacer of spaces length - atab = "{}".format(spacer) # the generic tab - ftab = atab*indent_tabs # the first tab level - stab = atab*(indent_tabs+1) # the second tab level - - init_str = "." if reference else "->" - if template: - init_str += "template " - return "{2}case {1}: obj{3}init<{0}>(); break;\n".format( - component, enumeration.upper(), ftab, init_str) - - -if __name__ == "__main__": - - rbegin = "// GENERATE_SWITCH_REPLACE_BEGIN" - rend = "// GENERATE_SWITCH_REPLACE_END" - - parser = argparse.ArgumentParser() - parser.add_argument( - "-a", "--additional", help="Additional components to produce case labels for", nargs='*') - parser.add_argument( - "-i", "--input", help="input file for replacing", type=str, default=None) - parser.add_argument( - "-o", "--output", help="output components from file", type=str, default=None) - parser.add_argument("-e", "--exclude", - help="exclude components", action='store_true') - parser.add_argument("-s", "--spaces-per-tab", - help="Number of spaces in a tab", type=int, default=4) - parser.add_argument("-t", "--tabs-per-indent", - help="Number of tabs to indent", type=int, default=3) - parser.add_argument("-r", "--replace", action='store_true', - help="Replace area between '{}' and '{}' in the output file".format(rbegin, rend)) - parser.add_argument( - "-c", "--config", help="alternative to -i/--input when replacing", type=str, default=None) - parser.add_argument("-P", "--pointer", help="Object operating on is pointer ('->') instead of reference ('.')", - action='store_true') - parser.add_argument("-S", "--specialized", help="Initialization is specialized (not a template)", - action='store_true') - parser.add_argument("-V", "--verbose", - help="Enable verbosity", default=0, type=int) - - args = parser.parse_args() - - if args.replace and args.input is None and args.output is None: - raise Exception( - "-r/--replace requires specifying -o/--output or -i/--input") - - # substitution string for replacing - subdata = None - - if args.input is not None: - with open(args.input, 'r') as f: - subdata = f.read() - - if args.config is not None: - with open(args.config, 'r') as f: - components = f.read().strip().split() - print("timemory components: [{}]\n".format( - ", ".join(components))) - - if args.additional: - components += args.additional - - if subdata is None and args.replace: - if args.input is None: - print("reading '{}' for replacement...".format(args.output)) - with open(args.output, 'r') as f: - subdata = f.read() - - components.sort() - if args.verbose > 0: - print("timemory components: [{}]\n".format(", ".join(components))) - - # - outdata = "using complete_tuple_t = std::tuple<\n" - for component in components: - outdata += "\tcomponent::{},\n".format(component) - outdata = outdata.strip("\n") - outdata = outdata.strip(",") - outdata += ">;\n\n" - - outdata += "using complete_auto_list_t = auto_list<\n" - for component in components: - outdata += "\tcomponent::{},\n".format(component) - outdata = outdata.strip("\n") - outdata = outdata.strip(",") - outdata += ">;\n\n" - outdata += "using complete_list_t = complete_auto_list_t::component_type;\n\n" - - a_hybdata = "using recommended_auto_hybrid_t = auto_hybrid<\n" - c_hybdata = "using recommended_hybrid_t = component_hybrid<\n" - for key, items in recommended_types.items(): - outdata += "using recommended_auto_{0}_t = auto_{0}<\n".format(key) - for item in items: - outdata += "\tcomponent::{},\n".format(item) - outdata = outdata.strip("\n") - outdata = outdata.strip(",") - outdata += ">;\n\n" - outdata += "using recommended_{0}_t = recommended_auto_{0}_t::component_type;\n\n".format( - key) - a_hybdata += "\trecommended_{0}_t,\n".format(key) - c_hybdata += "\trecommended_{0}_t,\n".format(key) - a_hybdata = a_hybdata.strip("\n") - a_hybdata = a_hybdata.strip(",") - a_hybdata += ">;\n\n" - c_hybdata = c_hybdata.strip("\n") - c_hybdata = c_hybdata.strip(",") - c_hybdata += ">;\n\n" - - outdata += a_hybdata - outdata += c_hybdata - - if subdata is not None: - try: - sbegin = subdata.find(rbegin) + len(rbegin) + 1 - send = subdata.find(rend) - substr = subdata[sbegin:send] - outdata += " " * args.spaces_per_tab * (args.tabs_per_indent + 1) - if args.verbose > 1: - print("sbegin = {}\nsend = {}\nsubstring:\n{}\n\noutdata:\n{}\n".format( - sbegin, send, substr, outdata)) - outdata = subdata.replace(substr, outdata) - if args.verbose > 1: - print("converted:\n{}\n".format(subdata)) - except Exception as e: - print(e) - raise - - if args.output is not None: - with open(args.output, 'w') as f: - f.write(outdata) - else: - print("{}".format(outdata)) diff --git a/scripts/type-generator/timemory_types.py b/scripts/type-generator/timemory_types.py deleted file mode 100644 index fb99699fe..000000000 --- a/scripts/type-generator/timemory_types.py +++ /dev/null @@ -1,219 +0,0 @@ -#!/usr/bin/env python - -# -# the list of components in timemory -# see -# -components = [ - "wall_clock", - "system_clock", - "user_clock", - "cpu_clock", - "monotonic_clock", - "monotonic_raw_clock", - "thread_cpu_clock", - "process_cpu_clock", - "cpu_util", - "process_cpu_util", - "thread_cpu_util", - "peak_rss", - "page_rss", - "stack_rss", - "data_rss", - "num_swap", - "num_io_in", - "num_io_out", - "num_minor_page_faults", - "num_major_page_faults", - "num_msg_sent", - "num_msg_recv", - "num_signals", - "voluntary_context_switch", - "priority_context_switch", - "cuda_event", - "cuda_profiler", - "papi_array_t", - "papi_vector", - "caliper", - "trip_count", - "read_bytes", - "written_bytes", - "cupti_counters", - "cupti_activity", - "nvtx_marker", - "cpu_roofline_sp_flops", - "cpu_roofline_dp_flops", - "cpu_roofline_flops", - "gpu_roofline_hp_flops", - "gpu_roofline_sp_flops", - "gpu_roofline_dp_flops", - "gpu_roofline_flops", - "gperftools_cpu_profiler", - "gperftools_heap_profiler", - "virtual_memory", - "likwid_marker", - "likwid_nvmarker", - "vtune_frame", - "vtune_event", - "vtune_profiler", - "user_tuple_bundle", - "user_list_bundle", - "user_global_bundle", - "tau_marker", - "user_mode_time", - "kernel_mode_time", - "current_peak_rss", - "malloc_gotcha", - "user_mpip_bundle", - "user_ompt_bundle", - "ompt_handle", - "allinea_map", - "craypat_record", - "craypat_region", - "craypat_counters", - "craypat_flush_buffer", - "craypat_heap_stats" -] - -# -# dictionary of components that have a different component -# name than the enumeration -# e.g. "component_name" : "enumeration_name" -# -mangled_enums = { - "system_clock": "sys_clock", - "papi_array_t": "papi_array", -} - -# -# dictionary of components that have a different string -# identifier than than enumeration -# e.g. "component_name" : "string_identifier" -# -mangled_strings = { - "wall_clock": ["real_clock", "virtual_clock"], - "system_clock": ["sys_clock"], - "papi_array_t": ["papi_array"], - "papi_vector": ["papi"], - "cpu_roofline_flops": ["cpu_roofline"], - "gpu_roofline_flops": ["gpu_roofline"], - "cpu_roofline_sp_flops": ["cpu_roofline_sp", "cpu_roofline_single"], - "cpu_roofline_dp_flops": ["cpu_roofline_dp", "cpu_roofline_double"], - "gpu_roofline_sp_flops": ["gpu_roofline_sp", "gpu_roofline_single"], - "gpu_roofline_dp_flops": ["gpu_roofline_dp", "gpu_roofline_double"], - "gpu_roofline_hp_flops": ["gpu_roofline_hp", "gpu_roofline_half"], - "caliper": ["cali"], - "written_bytes": ["write_bytes"], - "nvtx_marker": ["nvtx"], - "tau_marker": ["tau"], - "gperf_cpu_profiler": ["gperf_cpu", "gperftools-cpu"], - "gperf_heap_profiler": ["gperf_heap", "gperftools-heap"], - "ompt_handle": ["ompt", "omp_tools", "openmp", "openmp_tools"], - "mpip": ["mpi_tools", "mpi"], - "user_global_bundle": ["global_bundle"], - "user_list_bundle": ["list_bundle"], - "user_tuple_bundle": ["tuple_bundle"], -} - -recommended_types = { - "tuple": ["wall_clock", "system_clock", "user_clock", "cpu_util", - "page_rss", "peak_rss", "read_bytes", "written_bytes", - "num_minor_page_faults", "num_major_page_faults", - "voluntary_context_switch", "priority_context_switch"], - "list": ["caliper", "papi_vector", - "cuda_event", "nvtx_marker", - "cupti_counters", "cupti_activity", - "cpu_roofline_flops", "gpu_roofline_flops", - "gperf_cpu_profiler", "gperf_heap_profiler"], -} - -traits = { - "is_timing_category": ("std::true_type", - [ - "wall_clock", - "system_clock", - "user_clock", - "cpu_clock", - "monotonic_clock", - "monotonic_raw_clock", - "thread_cpu_clock", - "process_cpu_clock", - "cuda_event", - "cupti_activity", - ]), - "is_memory_category": ("std::true_type", - [ - "peak_rss", - "page_rss", - "stack_rss", - "data_rss", - "num_swap", - "num_io_in", - "num_io_out", - "num_minor_page_faults", - "num_major_page_faults", - "num_msg_sent", - "num_msg_recv", - "num_signals", - "voluntary_context_switch", - "priority_context_switch", - "read_bytes", - "written_bytes", - "virtual_memory", - ]), - "uses_timing_units": ("std::true_type", - [ - "wall_clock", - "system_clock", - "user_clock", - "cpu_clock", - "monotonic_clock", - "monotonic_raw_clock", - "thread_cpu_clock", - "process_cpu_clock", - "cuda_event", - "cupti_activity", - ]), - "uses_memory_units": ("std::true_type", - [ - "peak_rss", - "page_rss", - "stack_rss", - "data_rss", - "read_bytes", - "written_bytes", - "virtual_memory", - ]), -} - -native_components = [ - "wall_clock", - "system_clock", - "user_clock", - "cpu_clock", - "monotonic_clock", - "monotonic_raw_clock", - "thread_cpu_clock", - "process_cpu_clock", - "cpu_util", - "process_cpu_util", - "thread_cpu_util", - "peak_rss", - "page_rss", - "stack_rss", - "data_rss", - "num_swap", - "num_io_in", - "num_io_out", - "num_minor_page_faults", - "num_major_page_faults", - "num_msg_sent", - "num_msg_recv", - "num_signals", - "voluntary_context_switch", - "priority_context_switch", - "trip_count", - "read_bytes", - "written_bytes", - "virtual_memory", -] diff --git a/scripts/update-conda-yaml.py b/scripts/update-conda-yaml.py deleted file mode 100755 index b43806a97..000000000 --- a/scripts/update-conda-yaml.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python - -import os -import sys -import traceback -import subprocess as sp - -def read_file(fname): - content = [] - with open(fname) as f: - for line in f: - content.append(line) - # you may also want to remove whitespace characters like `\n` at the end of each line - content = [x.strip("\n") for x in content] - return content - -def main(new_git_rev): - content = read_file("recipe/meta.yaml") - - fm = open("recipe/meta.yaml", "w") - old_git_rev = "" - for l in content: - lstrip = l.strip().strip("-").strip("\t") - entries = lstrip.split() - if len(entries) > 1: - if entries[0] == "git_rev:": - old_git_rev = entries[1] - l = l.replace(old_git_rev, new_git_rev) - fm.write("{}\n".format(l)) - print("{}".format(l)) - - fm.close() - print("\nOld git revision: {}".format(old_git_rev)) - print("\nNew git revision: {}\n".format(new_git_rev)) - - -if __name__ == "__main__": - try: - - git_rev = "" - if len(sys.argv) < 2: - process = sp.Popen(['git', 'rev-parse', 'HEAD'], stdout=sp.PIPE) - out, err = process.communicate() - git_rev = "{}".format(out.decode("utf-8").strip()) - #git_rev = sp.check_output(['git', 'rev-parse', 'HEAD']).strip() - else: - git_rev = sys.argv[1] - - main(git_rev) - - except Exception as e: - print ('Error running pyctest - {}'.format(e)) - exc_type, exc_value, exc_trback = sys.exc_info() - traceback.print_exception(exc_type, exc_value, exc_trback, limit=10) - sys.exit(1) - - sys.exit(0) diff --git a/scripts/update-docs.sh b/scripts/update-docs.sh deleted file mode 100755 index f9fe1536b..000000000 --- a/scripts/update-docs.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash - -set -o errexit - -if [ -z "${3}" ]; then - echo -e "\nPlease provide:" - echo -e " (1) build directory" - echo -e " (2) source directory" - echo -e " (3) html directory\n" - exit 0 -fi - -_BINARY=$(realpath ${1}) -_SOURCE=$(realpath ${2}) -_DOCDIR=$(realpath ${3}) - -directory-exists() -{ - for i in $@ - do - if [ ! -d "${i}" ]; then - echo -e "Directory ${i} does not exist!" - exit 1 - fi - done -} - -directory-exists "${1}" "${2}" "${3}" "${_BINARY}/doc/html" "${_DOCDIR}/doxy" - -DIR=${PWD} - -#------------------------------------------------------------------------------# -# remove old docs in build directory -for i in ${_BINARY}/doc/html/* -do - rm -rf ${i} -done - -#------------------------------------------------------------------------------# -# remove old docs in documentation directory -for i in ${_DOCDIR}/doxy/* -do - rm -rf ${i} -done - -#------------------------------------------------------------------------------# -# switch to build directory -cd ${_BINARY} -# ensure configuration -cmake -DTIMEMORY_DOXYGEN_DOCS=ON -DENABLE_DOXYGEN_HTML_DOCS=ON ${_SOURCE} -# build the docs -cmake --build . --target doc -# copy new docs over -for i in ${_BINARY}/doc/html/* -do - cp -r ${i} ${_DOCDIR}/doxy/ -done - -#------------------------------------------------------------------------------# -# go to documentation directory -cd ${_DOCDIR} -# build the documentation -bundle exec jekyll build diff --git a/source/python/libpytimemory-profile.cpp b/source/python/libpytimemory-profile.cpp index 8b7a3010f..b812ae0e8 100644 --- a/source/python/libpytimemory-profile.cpp +++ b/source/python/libpytimemory-profile.cpp @@ -49,7 +49,7 @@ struct config bool trace_c = true; bool include_internal = false; bool include_args = false; - bool include_line = true; + bool include_line = false; bool include_filename = true; bool full_filepath = false; int32_t max_stack_depth = std::numeric_limits::max(); From 1357647d7c16ec9ade3ad00faf45e4dd024d3bff Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Fri, 9 Jul 2021 16:55:33 -0500 Subject: [PATCH 6/6] Release-3.2.1 - Updated CHANGELOG.md --- CHANGELOG.md | 25 +++++++++++++++++++++++++ VERSION | 2 +- cmake/Modules/ProjectSetup.cmake | 10 ++++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 817562b92..9e042b95c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # timemory +## Version 3.2.1 + +> Date: Fri Jul 9 16:55:33 2021 -0500 + +- pytimem fix + - fix missing import of component_bundle and component_tuple +- added additional python tests +- Ability to build with static libraries: python bindings, mpip library, mallocp library, ompt library, ncclp library, KokkosP libraries +- Setting TIMEMORY_BUILD_PYTHON to OFF now results in searching for external pybind11 install +- Renamed some CMake files in cmake/Modules +- Updated caliper and gotcha submodules to support {CALIPER,GOTCHA}_INSTALL_{CONFIG,HEADER} options +- Added TIMEMORY_INSTALL_PYTHON option +- Fixed BUILD_STATIC_LIBS=ON + CMAKE_POSITION_INDEPENDENT_CODE=ON +- Fixed TIMEMORY_USE_CUDA=ON + TIMEMORY_REQUIRE_PACKAGES=ON to fail +- If TIMEMORY_REQUIRED_PACKAGES=OFF, search for packages first before adding submodule +- Extended setup.py to support more options and support non-development install (no headers or cmake config) +- Removed TIMEMORY_EMBED_PYTHON option +- Disable timemory-jump when no shared libraries are built since dlopen isn't possible +- Replaced allocator member functions construct, destroy, allocate, deallocate with calls to static functions of allocator traits +- added support for CMAKE_ARGS env variable in setup.py +- remove absolute rpath when SKBUILD/SPACK_BUILD (since these have staging directories) +- timemory-{c,cxx,fortran} alias libraries in build tree +- toggled python function profiler to not include line number by default + - This can cause strange results when generators are used + ## Version 3.2.0 > Date: Sun Jun 27 21:10:57 2021 -0500 diff --git a/VERSION b/VERSION index 163bfcd5a..e4604e3af 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.1.rc15 +3.2.1 diff --git a/cmake/Modules/ProjectSetup.cmake b/cmake/Modules/ProjectSetup.cmake index 8b8704759..f43e5b95e 100644 --- a/cmake/Modules/ProjectSetup.cmake +++ b/cmake/Modules/ProjectSetup.cmake @@ -104,15 +104,21 @@ if(Git_FOUND) execute_process( COMMAND ${GIT_EXECUTABLE} describe --tags WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE TIMEMORY_GIT_DESCRIBE + OUTPUT_VARIABLE _GIT_DESCRIBE ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(_GIT_DESCRIBE) + set(TIMEMORY_GIT_DESCRIBE "${_GIT_DESCRIBE}") + endif() execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE TIMEMORY_GIT_REVISION + OUTPUT_VARIABLE _GIT_REVISION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(_GIT_REVISION) + set(TIMEMORY_GIT_REVISION "${_GIT_REVISION}") + endif() endif() if(NOT "${TIMEMORY_GIT_REVISION}" STREQUAL "unknown")