├── src ├── interface │ ├── python │ │ ├── pycaliper │ │ │ ├── loop.py │ │ │ ├── types.py │ │ │ ├── annotation.py │ │ │ ├── config_manager.py │ │ │ ├── instrumentation.py │ │ │ └── __init__.py │ │ ├── common.h │ │ ├── loop.h │ │ ├── annotation.h │ │ ├── loop.cpp │ │ ├── instrumentation.h │ │ └── config_manager.h │ ├── CMakeLists.txt │ ├── README.md │ ├── c_fortran │ │ ├── BufferedRegionProfile.h │ │ ├── CMakeLists.txt │ │ ├── wrapScopeAnnotation.h │ │ ├── wrapScopeAnnotation.cpp │ │ └── wrapAnnotation.h │ └── yaml │ │ └── caliper_types.yaml ├── services │ ├── mpit │ │ ├── mpitdesign │ │ │ ├── caliper.png │ │ │ ├── design.pdf │ │ │ ├── README │ │ │ ├── design.tex │ │ │ ├── titlepage.tex │ │ │ └── Makefile │ │ ├── CMakeLists.txt │ │ ├── TODO │ │ └── pvars_openmpi │ ├── debug │ │ └── CMakeLists.txt │ ├── ompt │ │ └── CMakeLists.txt │ ├── sampler │ │ ├── context.h.in │ │ ├── context_x86.h │ │ ├── context_ppc.h │ │ └── CMakeLists.txt │ ├── cpuinfo │ │ ├── CMakeLists.txt │ │ └── CpuInfo.cpp │ ├── mpireport │ │ └── CMakeLists.txt │ ├── report │ │ └── CMakeLists.txt │ ├── memusage │ │ └── CMakeLists.txt │ ├── recorder │ │ └── CMakeLists.txt │ ├── validator │ │ └── CMakeLists.txt │ ├── statistics │ │ └── CMakeLists.txt │ ├── trace │ │ ├── CMakeLists.txt │ │ └── TraceBufferChunk.h │ ├── kokkos │ │ ├── KokkosProfilingSymbols.hpp │ │ └── CMakeLists.txt │ ├── timer │ │ └── CMakeLists.txt │ ├── aggregate │ │ └── CMakeLists.txt │ ├── event │ │ ├── CMakeLists.txt │ │ └── AsyncEventTrigger.cpp │ ├── alloc │ │ └── CMakeLists.txt │ ├── io │ │ ├── CurIOus │ │ │ ├── README.md │ │ │ └── src │ │ │ │ ├── mount_tree.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── wrappers.h │ │ │ │ ├── file_registry.h │ │ │ │ ├── curious.c │ │ │ │ └── callbacks.h │ │ └── CMakeLists.txt │ ├── pcp │ │ └── CMakeLists.txt │ ├── tau │ │ ├── CMakeLists.txt │ │ └── README.md │ ├── papi │ │ └── CMakeLists.txt │ ├── vtune │ │ └── CMakeLists.txt │ ├── ldms │ │ ├── CMakeLists.txt │ │ └── README.md │ ├── roctx │ │ └── CMakeLists.txt │ ├── umpire │ │ └── CMakeLists.txt │ ├── pthread │ │ └── CMakeLists.txt │ ├── sysalloc │ │ └── CMakeLists.txt │ ├── variorum │ │ ├── CMakeLists.txt │ │ └── README.md │ ├── craypat │ │ └── CMakeLists.txt │ ├── adiak │ │ ├── test │ │ │ └── CMakeLists.txt │ │ └── CMakeLists.txt │ ├── libpfm │ │ ├── CMakeLists.txt │ │ └── perf_postprocessing.h │ ├── monitor │ │ └── CMakeLists.txt │ ├── nvtx │ │ └── CMakeLists.txt │ ├── symbollookup │ │ ├── CMakeLists.txt │ │ └── Lookup.h │ ├── callpath │ │ └── CMakeLists.txt │ ├── cupti │ │ └── CMakeLists.txt │ ├── roctracer │ │ └── CMakeLists.txt │ ├── rocprofiler │ │ └── CMakeLists.txt │ ├── mpiwrap │ │ └── CMakeLists.txt │ ├── topdown │ │ ├── CMakeLists.txt │ │ ├── HaswellTopdown.h │ │ └── SapphireRapidsTopdown.h │ └── templates │ │ ├── CMakeLists.txt │ │ └── README.md ├── tools │ ├── CMakeLists.txt │ ├── util │ │ └── CMakeLists.txt │ ├── cali-stat │ │ └── CMakeLists.txt │ ├── mpi-caliquery │ │ └── CMakeLists.txt │ └── cali-query │ │ ├── CMakeLists.txt │ │ └── AttributeExtract.h ├── common │ ├── test │ │ ├── caliper-common_test.config │ │ └── CMakeLists.txt │ ├── util │ │ ├── CMakeLists.txt │ │ ├── demangle.h │ │ ├── file_util.h │ │ ├── spinlock.hpp │ │ ├── demangle.cpp │ │ ├── parse_util.h │ │ ├── file_util.cpp │ │ └── split.hpp │ ├── CMakeLists.txt │ ├── SnapshotTextFormatter.h │ ├── SnapshotBuffer.h │ ├── CaliperMetadataAccessInterface.cpp │ ├── StringConverter.h │ └── NodeBuffer.h ├── caliper │ ├── test │ │ ├── test_c_api.cpp │ │ ├── test_single_config.json │ │ ├── test_config_list.json │ │ ├── test_config_and_options.json │ │ └── CMakeLists.txt │ ├── setup_serial.cpp │ ├── controllers │ │ ├── util.h │ │ ├── CMakeLists.txt │ │ └── util.cpp │ ├── machine.h │ ├── machine_serial.cpp │ ├── cali_datatracker.cpp │ ├── MpiEvents.h │ ├── OutputCommMpi.h │ └── CMakeLists.txt └── reader │ ├── QuerySpec.cpp │ ├── SnapshotTableFormatter.h │ ├── test │ ├── CMakeLists.txt │ └── test_snapshottableformatter.cpp │ ├── Formatter.h │ ├── CMakeLists.txt │ ├── JsonSplitFormatter.h │ ├── JsonFormatter.h │ ├── UserFormatter.h │ ├── TreeFormatter.h │ ├── Expand.h │ └── TableFormatter.h ├── ext ├── gotcha │ ├── include │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ ├── gotcha_dl.h │ │ ├── library_filters.h │ │ └── gotcha_auxv.h │ └── COPYRIGHT ├── CMakeLists.txt └── googletest │ ├── googletest-download_CMakeLists.txt.in │ └── CMakeLists.txt ├── doc ├── sphinx │ ├── caliper-logo-small.png │ ├── 2021_ECP_Caliper_Tutorial.pdf │ ├── caliper-services-workflow.png │ ├── screenshot-chrometracing.png │ ├── examples │ │ ├── cali-stat.output │ │ ├── cali-graph-max-nodes.output │ │ ├── snapshot-api.c │ │ ├── cali-print-agg-format-title.output │ │ ├── cali-print-agg-format.output │ │ ├── cali-query-selected.output │ │ └── cali-query-print-aggregated.output │ ├── CMakeLists.txt │ ├── ConfigManagerAPI.rst │ └── FortranSupport.rst ├── CMakeLists.txt └── doxygen │ ├── CMakeLists.txt │ ├── mainpage.dox │ └── cali.dox ├── .gitignore ├── examples ├── configs │ ├── report.calql │ ├── allocs.conf │ ├── counter_summary.conf │ ├── branch_mispred.conf │ ├── data_centric_PEBS.conf │ ├── topdown_ivybridge.conf │ └── papi_tot_ins.json └── apps │ ├── README.md │ └── cali-perfproblem-branch-mispred.py ├── codecov.yml ├── python ├── profile_caliperreader.py ├── caliper-reader │ ├── caliperreader │ │ ├── version.py │ │ ├── readererror.py │ │ └── __init__.py │ ├── pyproject.toml │ └── LICENSE └── cali2traceevent ├── test ├── ci_app_tests │ ├── README.md │ ├── example_node_info.json │ ├── ci_test_cali_before_mpi.cpp │ ├── ci_test_io.cpp │ ├── test_sampler.py │ ├── ci_test_openmp.cpp │ ├── test_tau_service.py │ ├── test_cpuinfo.py │ ├── ci_test_c_snapshot.c │ ├── test_memusageservice.py │ ├── ci_test_channel_api.c │ ├── test_file_io.py │ ├── test_templateservices.py │ ├── ci_test_collective_output_channel.cpp │ ├── ci_test_mpi_before_cali.cpp │ ├── test_callpath.py │ ├── ci_test_mpi_channel_manager.cpp │ ├── ci_test_basic.cpp │ ├── ci_test_py_ann.py │ └── test_ompt.py ├── build_metadata.cpp.in ├── cali-wrap.cpp └── CMakeLists.txt ├── .gitmodules ├── caliper.pc.in ├── cmake ├── FindITTAPI.cmake ├── get_python_install_paths.py ├── FindRocTX.cmake ├── FindCrayPAT.cmake ├── hostconfig │ ├── travis.cmake │ └── github-actions.cmake ├── FindSphinx.cmake ├── FindLibpfm.cmake ├── FindLibDw.cmake ├── FindPAPI.cmake ├── FindVariorum.cmake ├── FindRoctracer.cmake ├── FindLibunwind.cmake └── FindLDMS.cmake ├── include └── caliper │ ├── cali-manager.h │ ├── reader │ ├── CaliReader.h │ ├── CaliWriter.h │ ├── RecordProcessor.h │ ├── QueryProcessor.h │ ├── Preprocessor.h │ ├── RecordSelector.h │ ├── FlatExclusiveRegionProfile.h │ ├── FlatInclusiveRegionProfile.h │ ├── Aggregator.h │ ├── NestedExclusiveRegionProfile.h │ ├── NestedInclusiveRegionProfile.h │ └── CalQLParser.h │ ├── AsyncEvent.h │ ├── callback.hpp │ └── cali_definitions.h ├── .uberenv_config.json ├── .github └── workflows │ └── format-check.yml ├── scripts ├── formatting │ ├── autoformat-docker.sh │ ├── check-formatting-docker.sh │ ├── Dockerfile.format │ └── Dockerfile.check └── run-annotation-perftest.sh ├── caliper-config.cmake.in ├── .gitlab └── jobs │ ├── dane.yml │ ├── corona.yml │ └── lassen.yml ├── NOTICE ├── .travis.yml └── LICENSE /src/interface/python/pycaliper/loop.py: -------------------------------------------------------------------------------- 1 | from pycaliper.__pycaliper_impl.loop import * 2 | -------------------------------------------------------------------------------- /src/interface/python/pycaliper/types.py: -------------------------------------------------------------------------------- 1 | from pycaliper.__pycaliper_impl.types import * 2 | -------------------------------------------------------------------------------- /src/interface/python/pycaliper/annotation.py: -------------------------------------------------------------------------------- 1 | from pycaliper.__pycaliper_impl.annotation import * 2 | -------------------------------------------------------------------------------- /src/interface/python/pycaliper/config_manager.py: -------------------------------------------------------------------------------- 1 | from pycaliper.__pycaliper_impl.config_manager import * 2 | -------------------------------------------------------------------------------- /ext/gotcha/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | install(DIRECTORY gotcha DESTINATION include FILES_MATCHING PATTERN *.h) 2 | -------------------------------------------------------------------------------- /src/interface/python/pycaliper/instrumentation.py: -------------------------------------------------------------------------------- 1 | from pycaliper.__pycaliper_impl.instrumentation import * 2 | -------------------------------------------------------------------------------- /doc/sphinx/caliper-logo-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llnl/Caliper/HEAD/doc/sphinx/caliper-logo-small.png -------------------------------------------------------------------------------- /doc/sphinx/2021_ECP_Caliper_Tutorial.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llnl/Caliper/HEAD/doc/sphinx/2021_ECP_Caliper_Tutorial.pdf -------------------------------------------------------------------------------- /doc/sphinx/caliper-services-workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llnl/Caliper/HEAD/doc/sphinx/caliper-services-workflow.png -------------------------------------------------------------------------------- /doc/sphinx/screenshot-chrometracing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llnl/Caliper/HEAD/doc/sphinx/screenshot-chrometracing.png -------------------------------------------------------------------------------- /src/services/mpit/mpitdesign/caliper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llnl/Caliper/HEAD/src/services/mpit/mpitdesign/caliper.png -------------------------------------------------------------------------------- /src/services/mpit/mpitdesign/design.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llnl/Caliper/HEAD/src/services/mpit/mpitdesign/design.pdf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | build* 3 | TAGS 4 | .DS_Store 5 | .emacs* 6 | *.swp 7 | build/ 8 | .vscode 9 | __pycache__ 10 | *.pyc 11 | -------------------------------------------------------------------------------- /examples/configs/report.calql: -------------------------------------------------------------------------------- 1 | select 2 | sum(time.duration.ns) as Time, 3 | count() 4 | group by 5 | path 6 | format 7 | tree 8 | -------------------------------------------------------------------------------- /src/services/mpit/mpitdesign/README: -------------------------------------------------------------------------------- 1 | This contains the tex files for the document describing the design of the MPIT service in CALIPER 2 | -------------------------------------------------------------------------------- /src/services/mpit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_MPIT_MPI_SOURCES 2 | MpitServiceMPI.cpp) 3 | 4 | add_mpi_service_sources(${CALIPER_MPIT_MPI_SOURCES}) 5 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | ignore: 3 | - build/** 4 | - ext/** 5 | - test/** 6 | - **/test/** 7 | - **/rapidjson/** 8 | - **/CurIOus/** -------------------------------------------------------------------------------- /src/services/debug/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_DEBUG_SOURCES 2 | Debug.cpp) 3 | 4 | add_service_sources(${CALIPER_DEBUG_SOURCES}) 5 | add_caliper_service("debug") 6 | -------------------------------------------------------------------------------- /src/services/ompt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_OMPT_SOURCES 2 | OmptService.cpp) 3 | 4 | add_service_sources(${CALIPER_OMPT_SOURCES}) 5 | add_caliper_service("ompt") 6 | -------------------------------------------------------------------------------- /src/services/sampler/context.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #cmakedefine CALI_HAVE_CONTEXT_H 4 | 5 | #ifdef CALI_HAVE_CONTEXT_H 6 | #include "@CALI_CONTEXT_H@" 7 | #endif 8 | -------------------------------------------------------------------------------- /src/services/cpuinfo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_CPUINFO_SOURCES 2 | CpuInfo.cpp) 3 | 4 | add_service_sources(${CALIPER_CPUINFO_SOURCES}) 5 | add_caliper_service("cpuinfo") 6 | -------------------------------------------------------------------------------- /src/services/mpireport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${MPI_CXX_INCLUDE_PATH}) 2 | add_service_sources(MpiReport.cpp) 3 | add_caliper_service("mpireport CALIPER_HAVE_MPI") -------------------------------------------------------------------------------- /src/services/report/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_REPORT_SOURCES 2 | Report.cpp) 3 | 4 | add_service_sources(${CALIPER_REPORT_SOURCES}) 5 | add_caliper_service("report") 6 | -------------------------------------------------------------------------------- /src/services/sampler/context_x86.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define CALI_SAMPLER_GET_PC(ctx) ((ucontext_t*) (ctx))->uc_mcontext.gregs[REG_RIP] 6 | -------------------------------------------------------------------------------- /src/services/memusage/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_MEMUSAGE_SOURCES 2 | MemStatService.cpp) 3 | 4 | add_service_sources(${CALIPER_MEMUSAGE_SOURCES}) 5 | add_caliper_service("memstat") 6 | -------------------------------------------------------------------------------- /src/services/recorder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_RECORDER_SOURCES 2 | Recorder.cpp) 3 | 4 | add_service_sources(${CALIPER_RECORDER_SOURCES}) 5 | add_caliper_service("recorder") 6 | -------------------------------------------------------------------------------- /src/services/validator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_VALIDATOR_SOURCES 2 | validator.cpp) 3 | 4 | add_service_sources(${CALIPER_VALIDATOR_SOURCES}) 5 | add_caliper_service("validator") 6 | -------------------------------------------------------------------------------- /src/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(util) 2 | add_subdirectory(cali-query) 3 | add_subdirectory(cali-stat) 4 | if (CALIPER_HAVE_MPI) 5 | add_subdirectory(mpi-caliquery) 6 | endif() 7 | -------------------------------------------------------------------------------- /src/services/statistics/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_STATISTICS_SOURCES 2 | Statistics.cpp) 3 | 4 | add_service_sources(${CALIPER_STATISTICS_SOURCES}) 5 | add_caliper_service("statistics") 6 | -------------------------------------------------------------------------------- /src/services/trace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_TRACE_SOURCES 2 | TraceBufferChunk.cpp 3 | Trace.cpp) 4 | 5 | add_service_sources(${CALIPER_TRACE_SOURCES}) 6 | add_caliper_service("trace") 7 | -------------------------------------------------------------------------------- /src/services/kokkos/KokkosProfilingSymbols.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CALIPER_SERVICES_KOKKOS_PROFILING_SYMBOLS_HPP 2 | #define CALIPER_SERVICES_KOKKOS_PROFILING_SYMBOLS_HPP 3 | 4 | #include "types.hpp" 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/services/timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_TIMER_SOURCES 2 | Timer.cpp) 3 | 4 | add_service_sources(${CALIPER_TIMER_SOURCES}) 5 | 6 | add_caliper_service("timer") 7 | add_caliper_service("timestamp") -------------------------------------------------------------------------------- /ext/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (BUILD_TESTING) 2 | add_subdirectory(googletest EXCLUDE_FROM_ALL) 3 | endif() 4 | 5 | if (WITH_GOTCHA AND NOT USE_EXTERNAL_GOTCHA) 6 | add_subdirectory(gotcha/src) 7 | endif() 8 | 9 | -------------------------------------------------------------------------------- /src/services/aggregate/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_AGGREGATE_SOURCES 2 | Aggregate.cpp 3 | AggregationDB.cpp) 4 | 5 | add_service_sources(${CALIPER_AGGREGATE_SOURCES}) 6 | add_caliper_service(aggregate) 7 | -------------------------------------------------------------------------------- /src/interface/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Doesn't work for me :-/ 2 | # Generated wrapper manually. 3 | add_shroud( 4 | YAML_INPUT_FILE caliper_shroud.yaml 5 | YAML_OUTPUT_DIR yaml 6 | C_FORTRAN_OUTPUT_DIR c_fortran 7 | ) 8 | -------------------------------------------------------------------------------- /src/tools/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_TOOLS_UTIL_SOURCES 2 | Args.cpp) 3 | 4 | add_library(caliper-tools-util OBJECT ${CALIPER_TOOLS_UTIL_SOURCES}) 5 | target_compile_features(caliper-tools-util PUBLIC cxx_std_11) 6 | -------------------------------------------------------------------------------- /src/common/test/caliper-common_test.config: -------------------------------------------------------------------------------- 1 | CALI_CONFIG_PROFILE=file-profile1 2 | 3 | # [file-profile1] 4 | CALI_TEST_STRING_VAL="profile1 string from file" 5 | CALI_TEST_INT_VAL=99 6 | 7 | # [file-profile2] 8 | CALI_TEST_INT_VAL=42 9 | -------------------------------------------------------------------------------- /src/services/event/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_EVENT_SOURCES 2 | AsyncEventTrigger.cpp 3 | EventTrigger.cpp) 4 | 5 | add_service_sources(${CALIPER_EVENT_SOURCES}) 6 | add_caliper_service("event") 7 | add_caliper_service("async_event") -------------------------------------------------------------------------------- /doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(caliper-doc) 2 | 3 | find_package(Doxygen) 4 | find_package(Sphinx) 5 | 6 | if (DOXYGEN_FOUND) 7 | add_subdirectory(doxygen) 8 | endif() 9 | if(SPHINX_FOUND) 10 | add_subdirectory(sphinx) 11 | endif() 12 | -------------------------------------------------------------------------------- /python/profile_caliperreader.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import cProfile 5 | 6 | import caliperreader 7 | 8 | file = sys.argv[1] 9 | 10 | cr = caliperreader.CaliperReader() 11 | cProfile.run("cr.read(file)") 12 | -------------------------------------------------------------------------------- /src/services/alloc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_ALLOC_SOURCES 2 | AllocService.cpp 3 | AllocStatsService.cpp) 4 | 5 | add_service_sources(${CALIPER_ALLOC_SOURCES}) 6 | add_caliper_service("alloc") 7 | add_caliper_service("allocstats") 8 | -------------------------------------------------------------------------------- /src/services/io/CurIOus/README.md: -------------------------------------------------------------------------------- 1 | CurIOus: I/O wrapping abstraction layer 2 | ======== 3 | 4 | CurIOus is an abstraction layer for wrapping IO functions with Gotcha. 5 | Currently, it supports POSIX IO. 6 | 7 | CurIOus was written by Joy Kitson. 8 | -------------------------------------------------------------------------------- /src/services/pcp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALI_PCP_SOURCES 2 | Pcp.cpp 3 | PcpMemory.cpp) 4 | 5 | add_service_sources(${CALI_PCP_SOURCES}) 6 | 7 | add_caliper_service("pcp CALIPER_HAVE_PCP") 8 | add_caliper_service("pcp_memory CALIPER_HAVE_PCP") 9 | -------------------------------------------------------------------------------- /src/services/tau/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${TAU_INCLUDE_DIR}) 2 | 3 | set(CALIPER_TAU_SOURCES 4 | tau.cpp) 5 | 6 | add_library(caliper-tau OBJECT ${CALIPER_TAU_SOURCES}) 7 | 8 | add_mpi_service_objlib("caliper-tau") 9 | 10 | -------------------------------------------------------------------------------- /test/ci_app_tests/README.md: -------------------------------------------------------------------------------- 1 | Automated continuous integration application tests for Caliper 2 | ======================== 3 | 4 | This directory contains driver scripts and test cases for automated 5 | continuous integration full application/workflow tests. 6 | -------------------------------------------------------------------------------- /src/caliper/test/test_c_api.cpp: -------------------------------------------------------------------------------- 1 | #include "caliper/caliper-config.h" 2 | 3 | #include "caliper/cali.h" 4 | 5 | #include 6 | 7 | TEST(C_API_Test, CaliperVersion) 8 | { 9 | EXPECT_STREQ(cali_caliper_version(), CALIPER_VERSION); 10 | } 11 | -------------------------------------------------------------------------------- /src/caliper/test/test_single_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testcontroller", 3 | "description": "A test controller", 4 | "services": [ "trace", "recorder" , "event" ], 5 | "config": { 6 | "CALI_CHANNEL_FLUSH_ON_EXIT": "false" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "scripts/uberenv"] 2 | path = scripts/uberenv 3 | url = https://github.com/LLNL/uberenv.git 4 | [submodule "scripts/radiuss-spack-configs"] 5 | path = scripts/radiuss-spack-configs 6 | url = https://github.com/LLNL/radiuss-spack-configs.git 7 | -------------------------------------------------------------------------------- /test/ci_app_tests/example_node_info.json: -------------------------------------------------------------------------------- 1 | { 2 | "host": 3 | { 4 | "os": { "name": "TestOS", "version": "3.11", "kernel": "1.2.3-42" }, 5 | "name": "test42", 6 | "cluster": "test", 7 | "do_not_include": "me" 8 | }, 9 | "other": "nothing to see here" 10 | } -------------------------------------------------------------------------------- /src/services/io/CurIOus/src/mount_tree.h: -------------------------------------------------------------------------------- 1 | #ifndef MOUNT_TREE 2 | #define MOUNT_TREE 3 | 4 | void curious_init_mount_tree(void); 5 | void curious_finalize_mount_tree(void); 6 | void curious_get_filesystem(const char* full_path, char** filesystem, char** mount_point); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/tools/cali-stat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_STAT_SOURCES 2 | cali-stat.cpp) 3 | 4 | add_executable(cali-stat ${CALIPER_STAT_SOURCES}) 5 | 6 | target_link_libraries(cali-stat caliper-tools-util caliper) 7 | 8 | install(TARGETS cali-stat DESTINATION ${CMAKE_INSTALL_BINDIR}) 9 | -------------------------------------------------------------------------------- /python/caliper-reader/caliperreader/version.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020, Lawrence Livermore National Security, LLC. 2 | # See top-level LICENSE file for details. 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | __version_info__ = ("0", "4", "1") 7 | __version__ = ".".join(__version_info__) 8 | -------------------------------------------------------------------------------- /src/services/papi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${PAPI_INCLUDE_DIRS}) 2 | 3 | set(CALIPER_PAPI_SOURCES 4 | Papi.cpp) 5 | 6 | add_library(caliper-papi OBJECT ${CALIPER_PAPI_SOURCES}) 7 | 8 | add_service_objlib("caliper-papi") 9 | add_caliper_service("papi CALIPER_HAVE_PAPI") 10 | -------------------------------------------------------------------------------- /caliper.pc.in: -------------------------------------------------------------------------------- 1 | Name: ${PROJECT_NAME} 2 | Description: Caliper is a generic context annotation system. 3 | Version: ${CALIPER_VERSION} 4 | prefix=${CMAKE_INSTALL_PREFIX} 5 | includedir=${PKG_CONFIG_INCLUDEDIR} 6 | libdir=${PKG_CONFIG_LIBDIR} 7 | Libs: ${PKG_CONFIG_LIBS} 8 | Cflags: ${PKG_CONFIG_CFLAGS} 9 | -------------------------------------------------------------------------------- /src/services/vtune/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${ITT_INCLUDE_DIR}) 2 | 3 | set(CALIPER_VTUNE_SOURCES 4 | VTuneBindings.cpp) 5 | 6 | add_library(caliper-vtune OBJECT ${CALIPER_VTUNE_SOURCES}) 7 | 8 | add_service_objlib("caliper-vtune") 9 | add_caliper_service("vtune CALIPER_HAVE_VTUNE") 10 | -------------------------------------------------------------------------------- /examples/configs/allocs.conf: -------------------------------------------------------------------------------- 1 | CALI_ALLOC_TRACK_RANGES=false 2 | CALI_ALLOC_RECORD_ACTIVE_MEM=true 3 | 4 | CALI_REPORT_CONFIG="SELECT * FORMAT json(quote-all)" 5 | CALI_REPORT_FILENAME=alloc.json 6 | 7 | CALI_TIMER_OFFSET=true 8 | 9 | CALI_SERVICES_ENABLE=alloc:sysalloc:pthread:event:trace:report:timestamp 10 | -------------------------------------------------------------------------------- /src/reader/QuerySpec.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | #include "caliper/reader/QuerySpec.h" 5 | 6 | const cali::QuerySpec::FunctionSignature cali::QuerySpec::FunctionSignatureTerminator { -1, nullptr, -1, -1, nullptr }; 7 | -------------------------------------------------------------------------------- /src/services/ldms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${LDMS_INCLUDE_DIRS}) 2 | 3 | set(CALIPER_LDMS_SOURCES 4 | LdmsForwarder.cpp) 5 | 6 | add_library(caliper-ldms OBJECT ${CALIPER_LDMS_SOURCES}) 7 | 8 | add_service_objlib("caliper-ldms") 9 | add_caliper_service("ldms CALIPER_HAVE_LDMS") 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/services/roctx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_ROCTX_SOURCES 2 | RocTX.cpp) 3 | 4 | add_library(caliper-roctx OBJECT ${CALIPER_ROCTX_SOURCES}) 5 | target_include_directories(caliper-roctx PRIVATE ${ROCTX_INCLUDE_DIRS}) 6 | 7 | add_service_objlib("caliper-roctx") 8 | add_caliper_service("roctx CALIPER_HAVE_ROCTX") 9 | -------------------------------------------------------------------------------- /src/services/umpire/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_UMPIRE_SOURCES 2 | UmpireStatistics.cpp) 3 | 4 | add_library(caliper-umpire OBJECT ${CALIPER_UMPIRE_SOURCES}) 5 | target_link_libraries(caliper-umpire PRIVATE umpire) 6 | 7 | add_service_objlib("caliper-umpire") 8 | add_caliper_service("umpire CALIPER_HAVE_UMPIRE") 9 | -------------------------------------------------------------------------------- /python/caliper-reader/caliperreader/readererror.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020, Lawrence Livermore National Security, LLC. 2 | # See top-level LICENSE file for details. 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | class ReaderError(Exception): 7 | def __init__(self, message): 8 | self.message = message 9 | -------------------------------------------------------------------------------- /src/interface/python/common.h: -------------------------------------------------------------------------------- 1 | #ifndef CALI_INTERFACE_PYTHON_COMMON_HPP 2 | #define CALI_INTERFACE_PYTHON_COMMON_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | namespace py = pybind11; 11 | 12 | #endif /* CALI_INTERFACE_PYTHON_COMMON_HPP */ -------------------------------------------------------------------------------- /src/services/pthread/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${gotcha_INCLUDE_DIRS}) 2 | 3 | set(CALIPER_PTHREAD_SOURCES 4 | PthreadService.cpp) 5 | 6 | add_library(caliper-pthread OBJECT ${CALIPER_PTHREAD_SOURCES}) 7 | 8 | add_service_objlib("caliper-pthread") 9 | add_caliper_service("pthread CALIPER_HAVE_GOTCHA") 10 | -------------------------------------------------------------------------------- /src/common/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(UTIL_SOURCES 2 | util/demangle.cpp 3 | util/file_util.cpp 4 | util/format_util.cpp 5 | util/parse_util.cpp 6 | util/unitfmt.c 7 | util/vlenc.c) 8 | 9 | list(APPEND CALIPER_COMMON_SOURCES ${UTIL_SOURCES}) 10 | set(CALIPER_COMMON_SOURCES ${CALIPER_COMMON_SOURCES} PARENT_SCOPE) 11 | -------------------------------------------------------------------------------- /src/services/sysalloc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${gotcha_INCLUDE_DIRS}) 2 | 3 | set(CALIPER_SYSALLOC_SOURCES 4 | SysAllocService.cpp) 5 | 6 | add_library(caliper-sysalloc OBJECT ${CALIPER_SYSALLOC_SOURCES}) 7 | 8 | add_service_objlib("caliper-sysalloc") 9 | add_caliper_service("sysalloc CALIPER_HAVE_GOTCHA") 10 | -------------------------------------------------------------------------------- /src/services/variorum/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${VARIORUM_INCLUDE_DIRS}) 2 | 3 | set(CALIPER_VARIORUM_SOURCES 4 | Variorum.cpp) 5 | 6 | add_library(caliper-variorum OBJECT ${CALIPER_VARIORUM_SOURCES}) 7 | 8 | add_service_objlib("caliper-variorum") 9 | add_caliper_service("variorum CALIPER_HAVE_VARIORUM") 10 | -------------------------------------------------------------------------------- /src/services/craypat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_CRAYPAT_SOURCES 2 | CrayPAT.cpp) 3 | 4 | add_library(caliper-craypat OBJECT ${CALIPER_CRAYPAT_SOURCES}) 5 | target_include_directories(caliper-craypat PRIVATE ${CRAYPAT_INCLUDE_DIRS}) 6 | 7 | add_service_objlib("caliper-craypat") 8 | add_caliper_service("craypat CALIPER_HAVE_CRAYPAT") 9 | -------------------------------------------------------------------------------- /src/services/adiak/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_ADIAK_SERVICES_TEST_SOURCES 2 | test_adiak.cpp) 3 | 4 | add_executable(test_adiak_services ${CALIPER_ADIAK_SERVICES_TEST_SOURCES}) 5 | target_link_libraries(test_adiak_services caliper ${adiak_LIBRARIES} gtest_main) 6 | 7 | add_test(NAME test-adiak-services COMMAND test_adiak_services) 8 | -------------------------------------------------------------------------------- /examples/configs/counter_summary.conf: -------------------------------------------------------------------------------- 1 | CALI_LIBPFM_ENABLE_SAMPLING=false 2 | CALI_LIBPFM_RECORD_COUNTERS=true 3 | CALI_LIBPFM_EVENTS=branches,branch-misses,bus-cycles,cache-misses,cache-references,cpu-cycles,instructions,ref-cycles 4 | 5 | CALI_RECORDER_FILENAME=counter_summary.cali 6 | 7 | CALI_SERVICES_ENABLE=libpfm:pthread:recorder:event:trace 8 | -------------------------------------------------------------------------------- /src/interface/README.md: -------------------------------------------------------------------------------- 1 | # Fortran and C interface wrappers 2 | 3 | The Fortran and C interface is generated with Shroud: https://github.com/LLNL/shroud/. 4 | Make sure to use a recent version (post July 1st, 2020). 5 | 6 | To re-generate the interface, use 7 | 8 | $ shroud --outdir-c-fortran c_fortran --outdir-yaml yaml caliper_shroud.yaml 9 | -------------------------------------------------------------------------------- /src/services/kokkos/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_KOKKOS_SOURCES 2 | KokkosProfilingSymbols.cpp 3 | KokkosLookup.cpp 4 | KokkosTime.cpp 5 | ) 6 | 7 | add_library(caliper-kokkos OBJECT ${CALIPER_KOKKOS_SOURCES}) 8 | 9 | add_service_objlib("caliper-kokkos") 10 | add_caliper_service("kokkostime") 11 | add_caliper_service("kokkoslookup") 12 | -------------------------------------------------------------------------------- /doc/doxygen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(DOXYFILE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) 2 | set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) 3 | 4 | configure_file(${DOXYFILE_SRC} ${DOXYFILE_OUT} @ONLY) 5 | 6 | add_custom_target(caliper_doxygen_doc ALL 7 | COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT} 8 | COMMENT "Building Doxygen documentation") 9 | -------------------------------------------------------------------------------- /examples/configs/branch_mispred.conf: -------------------------------------------------------------------------------- 1 | CALI_LIBPFM_ENABLE_SAMPLING=false 2 | CALI_LIBPFM_RECORD_COUNTERS=true 3 | CALI_LIBPFM_EVENTS=branch-misses,branches 4 | 5 | CALI_REPORT_CONFIG="SELECT *,percentage(libpfm.counter.branch-misses,libpfm.counter.branches) GROUP BY function format table" 6 | 7 | CALI_SERVICES_ENABLE=libpfm:pthread:event:trace:timestamp:report 8 | -------------------------------------------------------------------------------- /python/caliper-reader/caliperreader/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020, Lawrence Livermore National Security, LLC. 2 | # See top-level LICENSE file for details. 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .caliperreader import CaliperReader, read_caliper_globals, read_caliper_contents 7 | from .caliperstreamreader import CaliperStreamReader 8 | -------------------------------------------------------------------------------- /src/services/libpfm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${LIBPFM_INCLUDE_DIR}) 2 | 3 | set(CALIPER_LIBPFM_SOURCES 4 | Libpfm.cpp 5 | perf_postprocessing.cpp 6 | perf_util.c) 7 | 8 | add_library(caliper-libpfm OBJECT ${CALIPER_LIBPFM_SOURCES}) 9 | 10 | add_service_objlib("caliper-libpfm") 11 | add_caliper_service("libpfm CALIPER_HAVE_LIBPFM") 12 | -------------------------------------------------------------------------------- /src/services/monitor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_MONITOR_SOURCES 2 | LoopMonitor.cpp 3 | RegionMonitor.cpp 4 | Timeseries.cpp) 5 | 6 | add_service_sources(${CALIPER_MONITOR_SOURCES}) 7 | 8 | add_caliper_service("loop_monitor") 9 | add_caliper_service("region_monitor") 10 | add_caliper_service("timeseries") 11 | # add_caliper_service("thread_monitor") 12 | -------------------------------------------------------------------------------- /src/services/sampler/context_ppc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define _PPC_REG_PC 32 6 | 7 | #if __WORDSIZE == 32 8 | #define CALI_SAMPLER_GET_PC(ctx) (((ucontext_t*) (ctx))->uc_mcontext.uc_regs->gregs[_PPC_REG_PC]) 9 | #else 10 | #define CALI_SAMPLER_GET_PC(ctx) (((ucontext_t*) (ctx))->uc_mcontext.gp_regs[_PPC_REG_PC]) 11 | #endif 12 | -------------------------------------------------------------------------------- /src/services/nvtx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_NVTX_SOURCES 2 | Nvtx.cpp) 3 | 4 | add_library(caliper-nvtx OBJECT ${CALIPER_NVTX_SOURCES}) 5 | target_include_directories(caliper-nvtx PRIVATE ${CALI_NVTX_INCLUDE_DIRS}) 6 | 7 | add_service_objlib("caliper-nvtx") 8 | 9 | add_caliper_service("nvtx CALIPER_HAVE_NVTX") 10 | add_caliper_service("nvprof CALIPER_HAVE_NVTX") 11 | -------------------------------------------------------------------------------- /cmake/FindITTAPI.cmake: -------------------------------------------------------------------------------- 1 | # Find Intel VTune Task API 2 | 3 | find_path(ITT_INCLUDE_DIR 4 | NAMES ittnotify.h 5 | HINTS ${ITT_PREFIX}/include) 6 | 7 | find_library(ITT_LIBRARY 8 | NAMES ittnotify 9 | HINTS ${ITT_PREFIX}/lib) 10 | 11 | include(FindPackageHandleStandardArgs) 12 | 13 | find_package_handle_standard_args(ITT 14 | DEFAULT_MSG 15 | ITT_LIBRARY 16 | ITT_INCLUDE_DIR) -------------------------------------------------------------------------------- /src/services/symbollookup/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_SYMBOLLOOKUP_SOURCES 2 | LookupLibdw.cpp 3 | SymbolLookup.cpp) 4 | 5 | add_library(caliper-symbollookup OBJECT ${CALIPER_SYMBOLLOOKUP_SOURCES}) 6 | target_include_directories(caliper-symbollookup PRIVATE ${LIBDW_INCLUDE_DIR}) 7 | 8 | add_service_objlib("caliper-symbollookup") 9 | add_caliper_service("symbollookup CALIPER_HAVE_LIBDW") 10 | -------------------------------------------------------------------------------- /test/build_metadata.cpp.in: -------------------------------------------------------------------------------- 1 | const char* cali_perftest_build_metadata[][2] = { 2 | { "compiler", "@CMAKE_CXX_COMPILER_ID@" }, 3 | { "compiler_version", "@CMAKE_CXX_COMPILER_VERSION@" }, 4 | { "cmake_build_type", "@CMAKE_BUILD_TYPE@" }, 5 | { "build_time", "@CALI_BUILD_TIME@" }, 6 | { "git_branch", "@CALI_GIT_BRANCH@" }, 7 | { nullptr, nullptr } 8 | }; 9 | -------------------------------------------------------------------------------- /include/caliper/cali-manager.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | #pragma once 5 | 6 | #include "wrapConfigManager.h" 7 | 8 | #ifdef __cplusplus 9 | #include "ConfigManager.h" 10 | #include "ChannelController.h" 11 | 12 | extern "C" 13 | { 14 | #endif 15 | 16 | #ifdef __cplusplus 17 | } // extern "C" 18 | #endif 19 | -------------------------------------------------------------------------------- /src/services/mpit/mpitdesign/design.tex: -------------------------------------------------------------------------------- 1 | \documentclass[pdftex,11pt,letterpaper]{report} 2 | \usepackage[pdftex]{graphicx} 3 | \usepackage{setspace} 4 | \usepackage{caption} 5 | \usepackage{subcaption} 6 | \usepackage{url} 7 | 8 | 9 | \begin{document} 10 | \bibliographystyle{plain} 11 | \input{./titlepage.tex} 12 | 13 | \input{./introduction.tex} 14 | 15 | \input{./pvars.tex} 16 | 17 | \end{document} 18 | -------------------------------------------------------------------------------- /src/services/io/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(CurIOus/src) 2 | 3 | set(CALIPER_IO_SOURCES 4 | IOService.cpp) 5 | 6 | add_library(caliper-ioservice OBJECT ${CALIPER_IO_SOURCES}) 7 | 8 | target_include_directories(caliper-ioservice PRIVATE "CurIOus/include") 9 | 10 | add_service_objlib("caliper-ioservice") 11 | add_service_objlib("caliper-CurIOus") 12 | 13 | add_caliper_service("io CALIPER_HAVE_GOTCHA") 14 | -------------------------------------------------------------------------------- /src/services/callpath/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${LIBUNWIND_INCLUDE_DIRS}) 2 | if (CALIPER_HAVE_LIBDW) 3 | include_directories(${LIBDW_INCLUDE_DIR}) 4 | endif() 5 | 6 | set(CALIPER_CALLPATH_SOURCES 7 | Callpath.cpp) 8 | 9 | add_library(caliper-callpath OBJECT ${CALIPER_CALLPATH_SOURCES}) 10 | 11 | add_service_objlib("caliper-callpath") 12 | add_caliper_service("callpath CALIPER_HAVE_LIBUNWIND") 13 | -------------------------------------------------------------------------------- /src/tools/mpi-caliquery/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories("../cali-query") 2 | include_directories(${MPI_CXX_INCLUDE_PATH}) 3 | 4 | add_executable(mpi-caliquery 5 | $ 6 | $ 7 | mpi-caliquery.cpp) 8 | 9 | target_link_libraries(mpi-caliquery caliper ${MPI_CXX_LIBRARIES}) 10 | 11 | install(TARGETS mpi-caliquery DESTINATION ${CMAKE_INSTALL_BINDIR}) 12 | -------------------------------------------------------------------------------- /src/interface/python/pycaliper/__init__.py: -------------------------------------------------------------------------------- 1 | from pycaliper.__pycaliper_impl import ( 2 | __version__, 3 | config_preset, 4 | init, 5 | is_initialized, 6 | ) 7 | 8 | import pycaliper.annotation 9 | import pycaliper.config_manager 10 | import pycaliper.high_level 11 | import pycaliper.instrumentation 12 | import pycaliper.loop 13 | import pycaliper.types 14 | 15 | from pycaliper.high_level import annotate_function 16 | -------------------------------------------------------------------------------- /src/services/cupti/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_CUPTI_SOURCES 2 | Cupti.cpp 3 | CuptiEventSampling.cpp 4 | CuptiTrace.cpp) 5 | 6 | add_library(caliper-cupti OBJECT ${CALIPER_CUPTI_SOURCES}) 7 | target_include_directories(caliper-cupti PRIVATE ${CALI_CUPTI_INCLUDE_DIRS}) 8 | 9 | add_service_objlib("caliper-cupti") 10 | 11 | add_caliper_service("cupti CALIPER_HAVE_CUPTI") 12 | add_caliper_service("cuptitrace CALIPER_HAVE_CUPTI") -------------------------------------------------------------------------------- /src/services/roctracer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_ROCTRACER_SOURCES 2 | RocTracer.cpp) 3 | 4 | add_library(caliper-roctracer OBJECT ${CALIPER_ROCTRACER_SOURCES}) 5 | target_compile_definitions(caliper-roctracer PRIVATE __HIP_PLATFORM_AMD__) 6 | target_include_directories(caliper-roctracer PRIVATE ${ROCTRACER_INCLUDE_DIRS}) 7 | 8 | add_service_objlib("caliper-roctracer") 9 | add_caliper_service("roctracer CALIPER_HAVE_ROCTRACER") 10 | -------------------------------------------------------------------------------- /.uberenv_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "package_name" : "caliper", 3 | "package_version" : "master", 4 | "package_final_phase" : "initconfig", 5 | "package_source_dir" : "../..", 6 | "spack_url": "https://github.com/spack/spack.git", 7 | "spack_branch": "v1.0.2", 8 | "spack_configs_path": "scripts/radiuss-spack-configs", 9 | "spack_packages_path": "scripts/radiuss-spack-configs/spack_repo/llnl_radiuss/packages", 10 | "spack_setup_clingo": false 11 | } 12 | -------------------------------------------------------------------------------- /src/services/adiak/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${adiak_INCLUDE_DIRS}) 2 | 3 | set(CALIPER_ADIAK_SOURCES 4 | AdiakExport.cpp 5 | AdiakImport.cpp) 6 | 7 | add_library(caliper-adiak OBJECT ${CALIPER_ADIAK_SOURCES}) 8 | 9 | add_service_objlib("caliper-adiak") 10 | 11 | add_caliper_service("adiak_export CALIPER_HAVE_ADIAK") 12 | add_caliper_service("adiak_import CALIPER_HAVE_ADIAK") 13 | 14 | if (BUILD_TESTING) 15 | add_subdirectory(test) 16 | endif() 17 | -------------------------------------------------------------------------------- /ext/gotcha/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(GOTCHA_SOURCES 2 | gotcha_utils.c 3 | gotcha.c 4 | gotcha_auxv.c 5 | libc_wrappers.c 6 | elf_ops.c 7 | hash.c 8 | tool.c 9 | library_filters.c 10 | gotcha_dl.c 11 | translations.c 12 | ) 13 | 14 | add_library(caliper-gotcha OBJECT ${GOTCHA_SOURCES}) 15 | set_property(TARGET caliper-gotcha PROPERTY POSITION_INDEPENDENT_CODE TRUE) 16 | target_include_directories(caliper-gotcha PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../include") 17 | -------------------------------------------------------------------------------- /src/services/variorum/README.md: -------------------------------------------------------------------------------- 1 | Variorum Service 2 | ================ 3 | 4 | The Variorum service implements a monitoring service of power usage at runtime. 5 | It implements the `snapshot` callback for adding data to Caliper snapshot 6 | records. 7 | 8 | With the following configuration, Caliper will export its 9 | data to a cali file: 10 | 11 | ``` 12 | $ CALI_SERVICES_ENABLE=aggregate,event,variorum,recorder \ 13 | CALI_VARIORUM_DOMAINS=power_node_watts \ 14 | ``` 15 | -------------------------------------------------------------------------------- /cmake/get_python_install_paths.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import sysconfig 3 | 4 | if len(sys.argv) != 3 or sys.argv[1] not in ("purelib", "platlib"): 5 | raise RuntimeError( 6 | "Usage: python get_python_install_paths.py " 7 | ) 8 | 9 | install_dir = sysconfig.get_path(sys.argv[1], sys.argv[2], {"userbase": "", "base": ""}) 10 | 11 | if install_dir.startswith("/"): 12 | install_dir = install_dir[1:] 13 | 14 | print(install_dir, end="") 15 | -------------------------------------------------------------------------------- /src/services/mpit/mpitdesign/titlepage.tex: -------------------------------------------------------------------------------- 1 | \begin{titlepage} 2 | \begin{center} 3 | 4 | \rule{\linewidth}{0.5mm} 5 | 6 | \textsc{\large CALIPER} 7 | ~\\[1cm] 8 | \includegraphics[width=0.5\textwidth]{./caliper.png}~\\[1cm] 9 | 10 | {\Huge \linespread{2}\sc{Enabling introspection of MPI libraries through the MPI\_T interface}} 11 | 12 | \vspace{10pt} 13 | 14 | \rule{\linewidth}{0.5mm} 15 | 16 | \vfill 17 | 18 | Authors:\\ 19 | Srinivasan Ramesh\\ 20 | 21 | \vfill 22 | {\large \today} 23 | 24 | \end{center} 25 | \end{titlepage} 26 | -------------------------------------------------------------------------------- /src/caliper/setup_serial.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | #include "caliper/caliper-config.h" 5 | 6 | #include "caliper/ConfigManager.h" 7 | 8 | #include "../services/Services.h" 9 | 10 | namespace cali 11 | { 12 | 13 | void add_submodule_controllers_and_services() 14 | { 15 | services::add_default_service_specs(); 16 | } 17 | 18 | void init_submodules() 19 | { 20 | add_submodule_controllers_and_services(); 21 | } 22 | 23 | } // namespace cali 24 | -------------------------------------------------------------------------------- /doc/doxygen/mainpage.dox: -------------------------------------------------------------------------------- 1 | /** 2 | \mainpage The Caliper API reference. 3 | 4 | \section main_user Caliper user APIs 5 | 6 | \li For documentation on the macro, C++, and C source-code annotation APIs, 7 | see \ref AnnotationAPI. 8 | \li The \ref ControlChannelAPI provides means to access and 9 | control built-in %Caliper configurations and enable measurements 10 | from within a target program. 11 | 12 | \section main_cxx C++ API reference 13 | For the complete C++ API reference, see \ref cali. 14 | 15 | \section main_c C API reference 16 | See cali.h. 17 | */ -------------------------------------------------------------------------------- /src/caliper/test/test_config_list.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "testcontroller_a", 4 | "description": "Test controller A", 5 | "services": [ "trace", "recorder" , "event" ], 6 | "config": { 7 | "CALI_CHANNEL_FLUSH_ON_EXIT": "false" 8 | } 9 | }, 10 | { 11 | "name": "testcontroller_b", 12 | "description": "Test controller B", 13 | "services": [ "trace", "recorder" , "event" ], 14 | "config": { 15 | "CALI_CHANNEL_FLUSH_ON_EXIT": "false" 16 | } 17 | } 18 | ] -------------------------------------------------------------------------------- /src/services/io/CurIOus/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_CurIOus_SOURCES 2 | callbacks.c 3 | curious.c 4 | dynamic_array.c 5 | file_registry.c 6 | mount_tree.c 7 | wrappers.c) 8 | 9 | add_library(caliper-CurIOus OBJECT ${CALIPER_CurIOus_SOURCES}) 10 | 11 | target_include_directories(caliper-CurIOus PRIVATE ${gotcha_INCLUDE_DIRS}) 12 | target_include_directories(caliper-CurIOus PRIVATE "../include") 13 | 14 | set_target_properties(caliper-CurIOus PROPERTIES C_STANDARD 11) 15 | set_target_properties(caliper-CurIOus PROPERTIES C_STANDARD_REQUIRED ON) 16 | -------------------------------------------------------------------------------- /src/interface/python/loop.h: -------------------------------------------------------------------------------- 1 | #ifndef CALI_INTERFACE_PYTHON_LOOP_H 2 | #define CALI_INTERFACE_PYTHON_LOOP_H 3 | 4 | #include "common.h" 5 | 6 | namespace cali 7 | { 8 | 9 | class PythonLoop 10 | { 11 | public: 12 | 13 | PythonLoop(const char* name); 14 | 15 | void start_iteration(int i); 16 | 17 | void end_iteration(); 18 | 19 | void end(); 20 | 21 | private: 22 | 23 | cali_id_t m_iter_attr; 24 | }; 25 | 26 | void create_caliper_loop_mod(py::module_& caliper_loop_mod); 27 | 28 | } // namespace cali 29 | 30 | #endif /* CALI_INTERFACE_PYTHON_LOOP_H */ -------------------------------------------------------------------------------- /src/services/libpfm/perf_postprocessing.h: -------------------------------------------------------------------------------- 1 | #ifndef CALIPER_PERF_POSTPROCESSING_H 2 | #define CALIPER_PERF_POSTPROCESSING_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | const std::string datasource_mem_lvl(uint64_t data_src); 10 | const std::string datasource_mem_hit(uint64_t datasource); 11 | const std::string datasource_mem_op(uint64_t datasource); 12 | const std::string datasource_mem_snoop(uint64_t datasource); 13 | const std::string datasource_mem_tlb(uint64_t datasource); 14 | 15 | #endif //CALIPER_PERF_POSTPROCESSING_H 16 | -------------------------------------------------------------------------------- /src/services/rocprofiler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_ROCPROFILER_SOURCES 2 | RocProfiler.cpp 3 | RocTX.cpp) 4 | 5 | add_library(caliper-rocprofiler OBJECT ${CALIPER_ROCPROFILER_SOURCES}) 6 | target_link_libraries(caliper-rocprofiler PRIVATE 7 | rocprofiler-sdk::rocprofiler-sdk 8 | rocprofiler-sdk-roctx::rocprofiler-sdk-roctx) 9 | 10 | add_service_objlib("caliper-rocprofiler") 11 | 12 | add_caliper_service("rocprofiler CALIPER_HAVE_ROCPROFILER") 13 | add_caliper_service("roctracer CALIPER_HAVE_ROCPROFILER") 14 | add_caliper_service("roctx CALIPER_HAVE_ROCPROFILER") 15 | -------------------------------------------------------------------------------- /cmake/FindRocTX.cmake: -------------------------------------------------------------------------------- 1 | # Find RocTX libraries/headers 2 | 3 | find_path(ROCM_PATH 4 | NAMES include/roctracer/roctx.h 5 | ) 6 | 7 | find_library(ROCTX_LIBRARIES 8 | NAMES roctx64 9 | HINTS ${ROCM_PATH}/lib 10 | ) 11 | 12 | find_path(ROCTX_INCLUDE_DIRS 13 | NAMES roctx.h 14 | HINTS ${ROCM_PATH}/include/roctracer 15 | ) 16 | 17 | include(FindPackageHandleStandardArgs) 18 | 19 | find_package_handle_standard_args(ROCTX 20 | DEFAULT_MSG 21 | ROCTX_LIBRARIES 22 | ROCTX_INCLUDE_DIRS 23 | ) 24 | 25 | mark_as_advanced( 26 | ROCTX_INCLUDE_DIRS 27 | ROCTX_LIBRARIES 28 | ) 29 | -------------------------------------------------------------------------------- /ext/googletest/googletest-download_CMakeLists.txt.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(googletest NONE) 4 | 5 | include(ExternalProject) 6 | ExternalProject_Add(googletest 7 | GIT_REPOSITORY "https://github.com/google/googletest.git" 8 | GIT_TAG "v1.16.0" 9 | SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-download/googletest-src" 10 | BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-download/googletest-build" 11 | CONFIGURE_COMMAND "" 12 | BUILD_COMMAND "" 13 | INSTALL_COMMAND "" 14 | TEST_COMMAND "" 15 | ) 16 | -------------------------------------------------------------------------------- /src/caliper/controllers/util.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | #pragma once 5 | #ifndef CALI_CONTROLLERS_UTIL_H 6 | #define CALI_CONTROLLERS_UTIL_H 7 | 8 | #include "caliper/ConfigManager.h" 9 | 10 | #include 11 | 12 | namespace cali 13 | { 14 | 15 | namespace util 16 | { 17 | 18 | std::string build_tree_format_spec(config_map_t&, const cali::ConfigManager::Options&, const char* initial = ""); 19 | 20 | } 21 | 22 | } // namespace cali 23 | 24 | #endif // CALI_CONTROLLERS_UTIL_H 25 | -------------------------------------------------------------------------------- /src/common/util/demangle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file demangle.h 5 | /// Helper function for demangling C++ identifiers 6 | 7 | #pragma once 8 | 9 | #ifndef UTIL_DEMANGLE_H 10 | #define UTIL_DEMANGLE_H 11 | 12 | #include 13 | 14 | namespace cali 15 | { 16 | namespace util 17 | { 18 | 19 | /// \brief Return demangled name for C++ binary identifier \a name 20 | std::string demangle(const char* name); 21 | 22 | } // namespace util 23 | } // namespace cali 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /examples/configs/data_centric_PEBS.conf: -------------------------------------------------------------------------------- 1 | CALI_LIBPFM_EVENTS=MEM_TRANS_RETIRED:LATENCY_ABOVE_THRESHOLD 2 | CALI_LIBPFM_SAMPLE_PERIOD=10000 3 | CALI_LIBPFM_PRECISE_IP=2 4 | CALI_LIBPFM_CONFIG1=20 5 | CALI_LIBPFM_SAMPLE_ATTRIBUTES=time,tid,cpu,addr,weight,data_src 6 | 7 | CALI_RECORDER_FILENAME=memory_load_samples.cali 8 | 9 | CALI_ALLOC_RESOLVE_ADDRESSES=true 10 | 11 | CALI_REPORT_CONFIG="SELECT *,sum(libpfm.weight),count() GROUP BY alloc.label#libpfm.addr FORMAT TABLE ORDER BY count DESC" 12 | 13 | CALI_SERVICES_ENABLE=libpfm:pthread:recorder:trace:symbollookup:callpath:alloc:instlookup:report 14 | -------------------------------------------------------------------------------- /cmake/FindCrayPAT.cmake: -------------------------------------------------------------------------------- 1 | # Find CrayPAT libraries/headers 2 | 3 | find_path(CRAYPAT_ROOT 4 | NAMES include/pat_api.h 5 | ) 6 | 7 | find_library(CRAYPAT_LIBRARIES 8 | NAMES _pat_base 9 | HINTS ${CRAYPAT_ROOT}/lib 10 | ) 11 | 12 | find_path(CRAYPAT_INCLUDE_DIRS 13 | NAMES pat_api.h 14 | HINTS ${CRAYPAT_ROOT}/include 15 | ) 16 | 17 | include(FindPackageHandleStandardArgs) 18 | 19 | find_package_handle_standard_args(CRAYPAT 20 | DEFAULT_MSG 21 | CRAYPAT_LIBRARIES 22 | CRAYPAT_INCLUDE_DIRS 23 | ) 24 | 25 | mark_as_advanced( 26 | CRAYPAT_INCLUDE_DIRS 27 | CRAYPAT_LIBRARIES 28 | ) 29 | -------------------------------------------------------------------------------- /python/cali2traceevent: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2024, Lawrence Livermore National Security, LLC. 4 | # See top-level LICENSE file for details. 5 | # 6 | # SPDX-License-Identifier: BSD-3-Clause 7 | 8 | import os 9 | import os.path 10 | import sys 11 | 12 | exe_file = os.path.realpath(os.path.expanduser(__file__)) 13 | cali_prefix = os.path.dirname(os.path.dirname(exe_file)) 14 | cali_lib_path = os.path.join(cali_prefix, "lib64", "caliper") 15 | sys.path.insert(0, cali_lib_path) 16 | 17 | from cali2traceevent import main 18 | 19 | if __name__ == "__main__": 20 | sys.exit(main()) 21 | -------------------------------------------------------------------------------- /src/caliper/test/test_config_and_options.json: -------------------------------------------------------------------------------- 1 | { 2 | "configs": [ 3 | { 4 | "name": "testcontroller", 5 | "description": "A test controller", 6 | "services": [ "trace", "recorder" , "event" ], 7 | "categories": [ "testcategory" ], 8 | "config": { 9 | "CALI_CHANNEL_FLUSH_ON_EXIT": "false" 10 | } 11 | } 12 | ], 13 | "options": [ 14 | { 15 | "name": "testoption", 16 | "description": "A test option", 17 | "category": "testcategory" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /cmake/hostconfig/travis.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "") 2 | 3 | set(WITH_ADIAK Off CACHE BOOL "") 4 | set(WITH_LIBUNWIND On CACHE BOOL "") 5 | set(WITH_NVPROF Off CACHE BOOL "") 6 | set(WITH_CUPTI Off CACHE BOOL "") 7 | set(WITH_PAPI Off CACHE BOOL "") 8 | set(WITH_LIBDW On CACHE BOOL "") 9 | set(WITH_LIBPFM Off CACHE BOOL "") 10 | set(WITH_SAMPLER On CACHE BOOL "") 11 | set(WITH_MPIT Off CACHE BOOL "") 12 | set(WITH_VTUNE Off CACHE BOOL "") 13 | 14 | set(WITH_DOCS Off CACHE BOOL "") 15 | set(BUILD_TESTING On CACHE BOOL "") 16 | -------------------------------------------------------------------------------- /src/tools/cali-query/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_QUERY_COMMON_SOURCES 2 | query_common.cpp) 3 | 4 | set(CALIPER_QUERY_SOURCES 5 | AttributeExtract.cpp 6 | cali-query.cpp) 7 | 8 | add_library(query-common OBJECT ${CALIPER_QUERY_COMMON_SOURCES}) 9 | target_compile_features(query-common PUBLIC cxx_std_11) 10 | 11 | add_executable(cali-query 12 | $ 13 | $ 14 | ${CALIPER_QUERY_SOURCES}) 15 | 16 | target_link_libraries(cali-query caliper) 17 | target_link_libraries(cali-query Threads::Threads) 18 | 19 | install(TARGETS cali-query DESTINATION ${CMAKE_INSTALL_BINDIR}) 20 | -------------------------------------------------------------------------------- /.github/workflows/format-check.yml: -------------------------------------------------------------------------------- 1 | name: Check code formatting 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | cpp-format-check: 11 | runs-on: ubuntu-24.04 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | 16 | - name: Install clang-format 17 | run: | 18 | sudo apt-get update 19 | sudo apt-get install -y --no-install-recommends \ 20 | build-essential \ 21 | clang-format-17 22 | 23 | - name: Test formatting 24 | run: | 25 | ./scripts/formatting/check-formatting.sh /usr/bin/clang-format-17 -------------------------------------------------------------------------------- /src/reader/SnapshotTableFormatter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file SnapshotTableFormatter.h 5 | /// \brief Defines SnapshotTableFormatter class 6 | 7 | #ifndef CALI_SNAPSHOTTABLEFORMATTER_H 8 | #define CALI_SNAPSHOTTABLEFORMATTER_H 9 | 10 | #include "caliper/common/Entry.h" 11 | 12 | #include 13 | 14 | namespace cali 15 | { 16 | 17 | class CaliperMetadataAccessInterface; 18 | 19 | std::ostream& format_record_as_table(CaliperMetadataAccessInterface& db, const std::vector&, std::ostream& os); 20 | 21 | } // namespace cali 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /test/ci_app_tests/ci_test_cali_before_mpi.cpp: -------------------------------------------------------------------------------- 1 | // Test Caliper MPI runtime: Caliper init before mpi init 2 | 3 | #include 4 | 5 | #include 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | CALI_CXX_MARK_FUNCTION; 10 | 11 | MPI_Init(&argc, &argv); 12 | MPI_Barrier(MPI_COMM_WORLD); 13 | 14 | // some MPI functions to test the wrapper blacklist/whitelist 15 | 16 | int val = 42; 17 | 18 | MPI_Bcast(&val, 1, MPI_INT, 0, MPI_COMM_WORLD); 19 | 20 | int in = val, out; 21 | 22 | MPI_Reduce(&in, &out, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); 23 | 24 | MPI_Barrier(MPI_COMM_WORLD); 25 | 26 | MPI_Finalize(); 27 | } 28 | -------------------------------------------------------------------------------- /ext/gotcha/src/gotcha_dl.h: -------------------------------------------------------------------------------- 1 | #ifndef GOTCHA_DL_H 2 | #define GOTCHA_DL_H 3 | 4 | #include "hash.h" 5 | #include "tool.h" 6 | 7 | void handle_libdl(); 8 | extern void update_all_library_gots(hash_table_t *bindings); 9 | extern long lookup_exported_symbol(const char *name, const struct link_map *lib, 10 | void **symbol); 11 | extern int prepare_symbol(struct internal_binding_t *binding); 12 | extern void **getInternalBindingAddressPointer(struct internal_binding_t **in); 13 | 14 | extern gotcha_wrappee_handle_t orig_dlopen_handle; 15 | extern gotcha_wrappee_handle_t orig_dlsym_handle; 16 | 17 | extern struct gotcha_binding_t dl_binds[]; 18 | #endif 19 | -------------------------------------------------------------------------------- /src/common/util/file_util.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file file_util.h 5 | /// Helper functions dealing with files 6 | 7 | #pragma once 8 | 9 | #ifndef UTIL_FILEUTIL_H 10 | #define UTIL_FILEUTIL_H 11 | 12 | #include 13 | 14 | namespace cali 15 | { 16 | 17 | namespace util 18 | { 19 | 20 | /// \brief Create a random filename 21 | /// 22 | /// The filename is created from the current date/time, PID, 23 | /// and a random string. 24 | std::string create_filename(const char* ext = ".cali"); 25 | 26 | } // namespace util 27 | 28 | } // namespace cali 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /doc/sphinx/examples/cali-stat.output: -------------------------------------------------------------------------------- 1 | Number of records 2 | Total Nodes Snapshots 3 | 169 124 45 4 | 5 | Number of elements 6 | Total Nodes Tree refs Direct val 7 | 680 496 134 50 8 | 9 | Data size (est.) 10 | Total Nodes Snapshots 11 | 5.26172KiB 4.01953KiB 1.24219KiB 12 | 13 | Elements/snapshot 14 | Min Max Average 15 | 2 5 4.08889 16 | 17 | Attributes referenced in snapshot records 18 | Total Average Refs/Elem 19 | 381 8.46667 0.560294 20 | -------------------------------------------------------------------------------- /examples/configs/topdown_ivybridge.conf: -------------------------------------------------------------------------------- 1 | CALI_LIBPFM_ENABLE_SAMPLING=false 2 | CALI_LIBPFM_RECORD_COUNTERS=true 3 | CALI_LIBPFM_EVENTS=BR_MISP_RETIRED.ALL_BRANCHES,CPU_CLK_UNHALTED.THREAD_P,CYCLE_ACTIVITY.CYCLES_NO_EXECUTE,CYCLE_ACTIVITY.STALLS_L1D_PENDING,CYCLE_ACTIVITY.STALLS_L2_PENDING,CYCLE_ACTIVITY.STALLS_LDM_PENDING,IDQ.MS_UOPS,IDQ_UOPS_NOT_DELIVERED.CORE,INT_MISC.RECOVERY_CYCLES,MACHINE_CLEARS.COUNT,MEM_LOAD_UOPS_RETIRED.L3_HIT,MEM_LOAD_UOPS_RETIRED.L3_MISS,RESOURCE_STALLS.SB,RS_EVENTS.EMPTY_CYCLES,UOPS_EXECUTED.THREAD,UOPS_EXECUTED.CORE_CYCLES_GE_1,UOPS_EXECUTED.CORE_CYCLES_GE_2,UOPS_ISSUED.ANY,UOPS_RETIRED.RETIRE_SLOTS 4 | 5 | CALI_SERVICES_ENABLE=libpfm:pthread:event:trace:report:timestamp 6 | -------------------------------------------------------------------------------- /doc/doxygen/cali.dox: -------------------------------------------------------------------------------- 1 | /** 2 | \namespace cali 3 | \brief Contains the %Caliper C++ API 4 | 5 | \namespace util 6 | \brief Various utility functions and classes 7 | 8 | \defgroup AnnotationAPI Annotation API 9 | \brief The user-facing source-code annotation API 10 | 11 | \defgroup ControlChannelAPI Control Channel API 12 | \brief An API for controlling %Caliper built-in performance measurement configurations. 13 | 14 | The control channel API provides means to access and control built-in %Caliper 15 | configurations and enable measurements from within a target program. 16 | 17 | \defgroup ReaderAPI Reader API 18 | \brief Facilities for post-processing and exporting %Caliper output 19 | */ 20 | -------------------------------------------------------------------------------- /cmake/FindSphinx.cmake: -------------------------------------------------------------------------------- 1 | # @file FindSphinx.cmake 2 | # Find the Sphinx documentation generator 3 | # 4 | # Adapted from 5 | # http://ericscottbarr.com/blog/2012/03/sphinx-and-cmake-beautiful-documentation-for-c-projects/ 6 | # 7 | # If successful the following variables will be defined 8 | # SPHINX_FOUND 9 | # SPHINX_EXECUTABLE 10 | 11 | find_program(SPHINX_EXECUTABLE 12 | NAMES sphinx-build sphinx-build2 13 | HINTS 14 | $ENV{SPHINX_DIR} 15 | PATH_SUFFIXES bin 16 | DOC "Sphinx documentation generator") 17 | 18 | include(FindPackageHandleStandardArgs) 19 | 20 | find_package_handle_standard_args(Sphinx DEFAULT_MSG SPHINX_EXECUTABLE) 21 | 22 | mark_as_advanced(SPHINX_EXECUTABLE) 23 | -------------------------------------------------------------------------------- /src/caliper/machine.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file machine.h 5 | /// Machine utility functions (internal API) 6 | 7 | #pragma once 8 | 9 | #ifndef CALI_CALIPER_MACHINE_H 10 | #define CALI_CALIPER_MACHINE_H 11 | 12 | namespace cali 13 | { 14 | 15 | namespace machine 16 | { 17 | 18 | /// \brief Describe the hardware level 19 | enum MachineLevel { None, Process, Socket, Node }; 20 | 21 | /// \brief Determine rank of the calling process/thread on the given \a level 22 | int get_rank_for(MachineLevel level); 23 | 24 | } // namespace machine 25 | 26 | } // namespace cali 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/services/mpit/mpitdesign/Makefile: -------------------------------------------------------------------------------- 1 | DOCNAME=design 2 | SOURCES = $(wildcard *.tex) $(wildcard text/*.tex) $(wildcard figs/*.pdf) \ 3 | $(wildcard figs/*.jpg) $(wildcard *.bib) 4 | 5 | all: $(DOCNAME).pdf 6 | 7 | $(DOCNAME).pdf: $(SOURCES) $(DOCNAME).bbl 8 | -pdflatex $(LATEXFLAGS) $(DOCNAME) 9 | -bibtex $(DOCNAME) 10 | -pdflatex $(LATEXFLAGS) $(DOCNAME) 11 | -pdflatex $(LATEXFLAGS) $(DOCNAME) 12 | 13 | $(DOCNAME).bbl: $(wildcard *.bib) 14 | -pdflatex $(LATEXFLAGS) $(DOCNAME) 15 | -bibtex $(DOCNAME) 16 | -pdflatex $(LATEXFLAGS) $(DOCNAME) 17 | 18 | clean: 19 | $(RM) $(DOCNAME).bbl $(DOCNAME).brf $(DOCNAME).aux $(DOCNAME).dvi $(DOCNAME).ps $(DOCNAME).pdf *.log $(DOCNAME).blg 20 | 21 | -------------------------------------------------------------------------------- /scripts/formatting/autoformat-docker.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | if [ command -v docker >/dev/null 2>&1 ]; then 4 | echo "Autoformatting with Docker requires Docker to be available" 5 | exit 1 6 | fi 7 | 8 | set -e 9 | 10 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 11 | 12 | curr_dir=$(pwd) 13 | 14 | cd $SCRIPT_DIR 15 | cd .. 16 | cd .. 17 | 18 | echo "Bulding Docker image" 19 | docker build -t caliper-autoformat -f ./scripts/formatting/Dockerfile.format . 20 | 21 | echo "Running Docker container to autoformat code with clang-format 17.0.6" 22 | docker run --rm -v $(pwd):/home/jovyan --name caliper-autoformat-container caliper-autoformat 23 | 24 | cd $curr_dir -------------------------------------------------------------------------------- /src/services/mpit/TODO: -------------------------------------------------------------------------------- 1 | Features that we must implememt: 2 | 1. Handle allocation: 3 | a. Wrap all routines for the purpose of allocating PVAR handles bound to MPI objects 4 | For eg. We wrap MPI_Comm_create, but not MPI_Comm_split - handle all such use cases 5 | b. How do we support MPI objects such as MPI_Requests, MPI Messages? 6 | 2. Integrate CALIPER with a tracing tool / file such as OTF2 for viewing PVAR changes over time 7 | 3. Add functionality to sample a PVAR of a given name, instead of sampling ALL PVARs inside a snapshot - this should control overheads 8 | 4. Add functionality to write CVARs from CALIPER - I think the same design for allocating PVAR handles would work for CVARs? 9 | 10 | -------------------------------------------------------------------------------- /scripts/formatting/check-formatting-docker.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | if [ command -v docker >/dev/null 2>&1 ]; then 4 | echo "Formatting check with Docker requires Docker to be available" 5 | exit 1 6 | fi 7 | 8 | set -e 9 | 10 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 11 | 12 | curr_dir=$(pwd) 13 | 14 | cd $SCRIPT_DIR 15 | cd .. 16 | cd .. 17 | 18 | echo "Bulding Docker image" 19 | docker build -t caliper-check-format -f ./scripts/formatting/Dockerfile.check . 20 | 21 | echo "Running Docker container to check formatting of code with clang-format 17.0.6" 22 | docker run --rm -v $(pwd):/home/jovyan --name caliper-check-format-container caliper-check-format 23 | 24 | cd $curr_dir -------------------------------------------------------------------------------- /python/caliper-reader/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "caliper-reader" 7 | version = "0.4.1" 8 | description = "A Python library for reading Caliper .cali files" 9 | authors = [ 10 | { name="David Boehme", email="boehme3@llnl.gov" }, 11 | ] 12 | readme = "README.md" 13 | license = {file = "LICENSE"} 14 | classifiers = [ 15 | "Programming Language :: Python :: 3", 16 | "Development Status :: 5 - Production/Stable", 17 | "License :: OSI Approved :: BSD License", 18 | "Operating System :: OS Independent", 19 | ] 20 | requires-python = ">=3.6" 21 | 22 | [project.urls] 23 | "Homepage" = "https://github.com/LLNL/Caliper" 24 | -------------------------------------------------------------------------------- /cmake/hostconfig/github-actions.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "") 2 | 3 | set(WITH_ADIAK Off CACHE BOOL "") 4 | set(WITH_CUPTI Off CACHE BOOL "") 5 | set(WITH_FORTRAN On CACHE BOOL "") 6 | set(WITH_LIBDW On CACHE BOOL "") 7 | set(WITH_LIBPFM Off CACHE BOOL "") 8 | set(WITH_LIBUNWIND On CACHE BOOL "") 9 | set(WITH_MPI Off CACHE BOOL "") 10 | set(WITH_MPIT Off CACHE BOOL "") 11 | set(WITH_NVPROF Off CACHE BOOL "") 12 | set(WITH_PAPI Off CACHE BOOL "") 13 | set(WITH_SAMPLER On CACHE BOOL "") 14 | set(WITH_VTUNE Off CACHE BOOL "") 15 | set(WITH_PYTHON_BINDINGS On CACHE BOOL "") 16 | 17 | set(WITH_DOCS Off CACHE BOOL "") 18 | set(BUILD_TESTING On CACHE BOOL "") 19 | -------------------------------------------------------------------------------- /src/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_COMMON_SOURCES 2 | Attribute.cpp 3 | CaliperMetadataAccessInterface.cpp 4 | CompressedSnapshotRecord.cpp 5 | Entry.cpp 6 | Log.cpp 7 | NodeBuffer.cpp 8 | OutputStream.cpp 9 | RuntimeConfig.cpp 10 | SnapshotBuffer.cpp 11 | SnapshotTextFormatter.cpp 12 | StringConverter.cpp 13 | Variant.cpp 14 | cali_types.c 15 | cali_variant.c) 16 | 17 | add_subdirectory(util) 18 | 19 | add_library(caliper-common OBJECT 20 | ${CALIPER_COMMON_SOURCES}) 21 | 22 | target_compile_options(caliper-common PRIVATE ${Wall_flag}) 23 | target_compile_features(caliper-common PUBLIC cxx_std_11) 24 | target_compile_features(caliper-common PRIVATE c_std_99) 25 | 26 | if (BUILD_TESTING) 27 | add_subdirectory(test) 28 | endif() 29 | -------------------------------------------------------------------------------- /src/caliper/machine_serial.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | #include "caliper/caliper-config.h" 5 | 6 | #include "machine.h" 7 | 8 | #include "caliper/common/Log.h" 9 | 10 | namespace cali 11 | { 12 | 13 | namespace machine 14 | { 15 | 16 | int get_rank_for(MachineLevel level) 17 | { 18 | switch (level) { 19 | case MachineLevel::Process: 20 | return 0; 21 | case MachineLevel::Node: 22 | return 0; 23 | default: 24 | Log(0).stream() << "machine::get_rank_for(MachineLevel): level " << level << " is not supported" << std::endl; 25 | } 26 | 27 | return -1; 28 | } 29 | 30 | } // namespace machine 31 | 32 | } // namespace cali 33 | -------------------------------------------------------------------------------- /src/common/util/spinlock.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file spinlock.hpp 5 | /// \brief spinlock class 6 | 7 | #ifndef UTIL_SPINLOCK_HPP 8 | #define UTIL_SPINLOCK_HPP 9 | 10 | #include 11 | 12 | namespace cali 13 | { 14 | namespace util 15 | { 16 | 17 | class spinlock 18 | { 19 | std::atomic_flag m_lock = ATOMIC_FLAG_INIT; 20 | 21 | public: 22 | 23 | spinlock() {} 24 | 25 | void lock() 26 | { 27 | while (m_lock.test_and_set(std::memory_order_acquire)) 28 | ; 29 | } 30 | 31 | void unlock() { m_lock.clear(std::memory_order_release); } 32 | }; 33 | 34 | } // namespace util 35 | } // namespace cali 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /caliper-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include(CMakeFindDependencyMacro) 4 | 5 | include("${CMAKE_CURRENT_LIST_DIR}/caliper-targets.cmake") 6 | 7 | set_and_check(caliper_INCLUDE_DIR "@PACKAGE_caliper_INSTALL_INCLUDE_DIR@") 8 | 9 | if (@CALIPER_HAVE_ADIAK@) 10 | if (NOT TARGET adiak::adiak) 11 | set(CALIPER_ADIAK_DIR @adiak_DIR@) 12 | if (NOT adiak_DIR) 13 | set(adiak_DIR ${CALIPER_ADIAK_DIR}) 14 | endif() 15 | find_dependency( 16 | adiak 17 | CONFIG 18 | NO_DEFAULT_PATH 19 | PATHS 20 | ${adiak_DIR} 21 | ${adiak_DIR}/lib/cmake/adiak 22 | ${PACKAGE_PREFIX_DIR} 23 | ${PACKAGE_PREFIX_DIR}/lib/cmake/adiak 24 | ) 25 | endif() 26 | endif() 27 | 28 | check_required_components(caliper) 29 | -------------------------------------------------------------------------------- /src/interface/c_fortran/BufferedRegionProfile.h: -------------------------------------------------------------------------------- 1 | #include "caliper/RegionProfile.h" 2 | 3 | namespace cali 4 | { 5 | 6 | class BufferedRegionProfile : private RegionProfile 7 | { 8 | struct BufferedRegionProfileImpl; 9 | std::shared_ptr mP; 10 | 11 | public: 12 | 13 | BufferedRegionProfile(); 14 | ~BufferedRegionProfile(); 15 | 16 | void start(); 17 | void stop(); 18 | 19 | void clear(); 20 | 21 | void fetch_exclusive_region_times(const char* region_type = ""); 22 | void fetch_inclusive_region_times(const char* region_type = ""); 23 | 24 | double total_profiling_time() const; 25 | double total_region_time() const; 26 | double region_time(const char* region) const; 27 | }; 28 | 29 | } // namespace cali 30 | -------------------------------------------------------------------------------- /src/services/mpiwrap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${gotcha_INCLUDE_DIRS}) 2 | 3 | set(WRAP_FLAGS "-w") 4 | 5 | if (CALIPER_MPIWRAP_USE_GOTCHA) 6 | set(WRAP_FLAGS "${WRAP_FLAGS}G") 7 | endif() 8 | 9 | set(WRAP ${CMAKE_CURRENT_SOURCE_DIR}/wrap.py) 10 | include(${PROJECT_SOURCE_DIR}/cmake/WrapConfig.cmake) 11 | 12 | add_wrapped_file(Wrapper.cpp Wrapper.w) 13 | 14 | set(CALIPER_MPIWRAP_SOURCES 15 | MpiTracing.cpp 16 | MpiPattern.cpp 17 | MpiWrap.cpp 18 | Wrapper.cpp) 19 | 20 | add_library(caliper-mpiwrap OBJECT ${CALIPER_MPIWRAP_SOURCES}) 21 | target_compile_features(caliper-mpiwrap PUBLIC cxx_std_11) 22 | target_include_directories(caliper-mpiwrap PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) 23 | 24 | add_service_objlib(caliper-mpiwrap) 25 | add_caliper_service("mpi CALIPER_HAVE_MPI") -------------------------------------------------------------------------------- /src/services/topdown/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_TOPDOWN_SOURCES 2 | IntelTopdown.cpp 3 | TopdownCalculator.cpp 4 | HaswellTopdown.cpp) 5 | 6 | 7 | if (WITH_PAPI_RDPMC) 8 | message(STATUS "PAPI uses rdpmc") 9 | if (CALIPER_HAVE_ARCH STREQUAL "sapphirerapids") 10 | message(WARNING "Trying to use rdpmc for topdown on Sapphire Rapids will likely result in invalid values!") 11 | endif() 12 | list(APPEND CALIPER_TOPDOWN_SOURCES SapphireRapidsTopdown_rdpmc.cpp) 13 | else() 14 | message(STATUS "PAPI does not use rdpmc") 15 | list(APPEND CALIPER_TOPDOWN_SOURCES SapphireRapidsTopdown_read.cpp) 16 | endif () 17 | 18 | add_library(caliper-topdown OBJECT ${CALIPER_TOPDOWN_SOURCES}) 19 | 20 | add_service_objlib("caliper-topdown") 21 | add_caliper_service("topdown CALIPER_HAVE_PAPI") 22 | -------------------------------------------------------------------------------- /doc/sphinx/examples/cali-graph-max-nodes.output: -------------------------------------------------------------------------------- 1 | graph { 2 | 0 [label=":usr"]; 3 | 1 [label=":int"]; 4 | 2 [label=":uint"]; 5 | 3 [label=":string"]; 6 | 4 [label=":addr"]; 7 | 5 [label=":double"]; 8 | 6 [label=":bool"]; 9 | 7 [label=":type"]; 10 | 8 [label=":cali.attribute.name"]; 11 | 3 -- 8; 12 | 9 [label="cali.attribute.name:cali.attribute.type"]; 13 | 7 -- 9; 14 | 10 [label="cali.attribute.name:cali.attribute.prop"]; 15 | 1 -- 10; 16 | 11 [label="cali.attribute.prop:12"]; 17 | 3 -- 11; 18 | 12 [label="cali.attribute.name:cali.caliper.version"]; 19 | 11 -- 12; 20 | 13 [label="cali.attribute.prop:148"]; 21 | 0 -- 13; 22 | 14 [label="cali.attribute.name:cali.key.attribute"]; 23 | 13 -- 14; 24 | 15 [label="cali.attribute.prop:213"]; 25 | 1 -- 15; 26 | } 27 | -------------------------------------------------------------------------------- /.gitlab/jobs/dane.yml: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Copyright (c) 2022-25, Lawrence Livermore National Security, LLC and RADIUSS 3 | # project contributors. See the COPYRIGHT file for details. 4 | # 5 | # SPDX-License-Identifier: (MIT) 6 | ############################################################################## 7 | 8 | # Override reproducer section to define project specific variables. 9 | .dane_reproducer_vars: 10 | script: 11 | - !reference [.reproducer_vars, script] 12 | 13 | # With GitLab CI, included files cannot be empty. 14 | variables: 15 | INCLUDED_FILE_CANNOT_BE_EMPTY: "True" 16 | 17 | ## Template for extra jobs defined by the project. 18 | master: 19 | variables: 20 | SPEC: " +tests ~papi" 21 | extends: .job_on_dane 22 | -------------------------------------------------------------------------------- /src/caliper/controllers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_CONTROLLERS_SOURCES 2 | controllers/CudaActivityProfileController.cpp 3 | controllers/CudaActivityReportController.cpp 4 | controllers/HatchetRegionProfileController.cpp 5 | controllers/HatchetSampleProfileController.cpp 6 | controllers/LoopReportController.cpp 7 | controllers/OpenMPReportController.cpp 8 | controllers/ROCmActivityProfileController.cpp 9 | controllers/ROCmActivityReportController.cpp 10 | controllers/RuntimeReportController.cpp 11 | controllers/SampleReportController.cpp 12 | controllers/SpotController.cpp 13 | controllers/controllers.cpp 14 | controllers/util.cpp) 15 | 16 | list(APPEND CALIPER_RUNTIME_SOURCES ${CALIPER_CONTROLLERS_SOURCES}) 17 | set(CALIPER_RUNTIME_SOURCES ${CALIPER_RUNTIME_SOURCES} PARENT_SCOPE) 18 | -------------------------------------------------------------------------------- /src/reader/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_READER_TEST_SOURCES 2 | test_aggregator.cpp 3 | test_calireader.cpp 4 | test_calqlparser.cpp 5 | test_filter.cpp 6 | test_flatexclusiveregionprofile.cpp 7 | test_flatinclusiveregionprofile.cpp 8 | test_metadb.cpp 9 | test_nestedexclusiveregionprofile.cpp 10 | test_nestedinclusiveregionprofile.cpp 11 | test_nodebuffer.cpp 12 | test_preprocessor.cpp 13 | test_snapshottableformatter.cpp) 14 | 15 | add_executable(test_caliper-reader 16 | $ 17 | $ 18 | ${CALIPER_READER_TEST_SOURCES}) 19 | 20 | target_link_libraries(test_caliper-reader gtest_main) 21 | target_compile_features(test_caliper-reader PUBLIC cxx_std_11) 22 | 23 | add_test(NAME test-caliper-reader COMMAND test_caliper-reader) 24 | -------------------------------------------------------------------------------- /src/common/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_COMMON_TEST_SOURCES 2 | test_c_variant.cpp 3 | test_compressedsnapshotrecord.cpp 4 | test_runtimeconfig.cpp 5 | test_snapshotbuffer.cpp 6 | test_snapshottextformatter.cpp 7 | test_stringconverter.cpp 8 | test_variant.cpp) 9 | 10 | add_executable(test_caliper-common 11 | $ 12 | ${CALIPER_COMMON_TEST_SOURCES}) 13 | 14 | target_link_libraries(test_caliper-common gtest_main) 15 | target_compile_features(test_caliper-common PUBLIC cxx_std_11) 16 | 17 | add_custom_target(caliper-common_test.config ALL 18 | COMMAND ${CMAKE_COMMAND} -E create_symlink 19 | ${CMAKE_CURRENT_SOURCE_DIR}/caliper-common_test.config 20 | ${CMAKE_CURRENT_BINARY_DIR}/caliper-common_test.config) 21 | 22 | add_test(NAME test-caliper-common COMMAND test_caliper-common) 23 | -------------------------------------------------------------------------------- /src/interface/c_fortran/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_INTERFACE_SOURCES 2 | BufferedRegionProfile.cpp 3 | wrapAnnotation.cpp 4 | wrapBufferedRegionProfile.cpp 5 | wrapConfigManager.cpp 6 | wrapScopeAnnotation.cpp 7 | utilCaliper.cpp) 8 | 9 | if (CALIPER_HAVE_FORTRAN) 10 | list(APPEND CALIPER_INTERFACE_SOURCES 11 | wrapfcaliper.F) 12 | set_source_files_properties(wrapfcaliper.F PROPERTIES Fortran_FORMAT FREE) 13 | endif() 14 | 15 | add_library(caliper-interface OBJECT ${CALIPER_INTERFACE_SOURCES}) 16 | target_compile_features(caliper-interface PUBLIC cxx_std_11) 17 | 18 | if (CALIPER_HAVE_FORTRAN) 19 | target_include_directories( 20 | caliper-interface 21 | PUBLIC 22 | "$" 23 | "$" 24 | ) 25 | endif() -------------------------------------------------------------------------------- /src/services/io/CurIOus/src/wrappers.h: -------------------------------------------------------------------------------- 1 | #ifndef IO_WRAPPERS 2 | #define IO_WRAPPERS 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" 12 | { 13 | #endif 14 | 15 | /********* 16 | * Types * 17 | *********/ 18 | 19 | // This just keeps all the data about the original function in one place 20 | typedef struct io_function_data { 21 | curious_api_t api; 22 | gotcha_wrappee_handle_t handle; 23 | } io_function_data_t; 24 | 25 | void curious_apply_wrappers(curious_apis_t apis); 26 | void curious_disable_wrappers(void); 27 | 28 | // See io_arhs.h under include/curious for structs to serve as io_args 29 | // to callbacks for corresponding functions 30 | 31 | #ifdef __cplusplus 32 | } // extern "C" 33 | #endif 34 | #endif 35 | -------------------------------------------------------------------------------- /src/tools/cali-query/AttributeExtract.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file AttributeExtract.h 5 | /// \brief A class to extract attributes as snapshots 6 | 7 | #pragma once 8 | 9 | #include "caliper/reader/RecordProcessor.h" 10 | 11 | #include 12 | 13 | namespace cali 14 | { 15 | 16 | /// This class is a node processor that converts attribute nodes into a snapshot record, 17 | /// and forwards them to a snapshot processor 18 | class AttributeExtract 19 | { 20 | struct AttributeExtractImpl; 21 | std::shared_ptr mP; 22 | 23 | public: 24 | 25 | AttributeExtract(SnapshotProcessFn snap_fn); 26 | 27 | ~AttributeExtract(); 28 | 29 | void operator() (CaliperMetadataAccessInterface&, const Node*); 30 | }; 31 | 32 | } // namespace cali 33 | -------------------------------------------------------------------------------- /src/reader/Formatter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file Formatter.h 5 | /// Output formatter base class 6 | 7 | #pragma once 8 | 9 | #include "caliper/reader/RecordProcessor.h" 10 | 11 | namespace cali 12 | { 13 | 14 | class CaliperMetadataAccessInterface; 15 | 16 | /// \class Formatter 17 | /// \brief Abstract base class for output formatters. 18 | /// \ingroup ReaderAPI 19 | 20 | class Formatter 21 | { 22 | public: 23 | 24 | virtual ~Formatter() {} 25 | 26 | /// Process a snapshot record. 27 | virtual void process_record(CaliperMetadataAccessInterface&, const EntryList&) = 0; 28 | 29 | /// Flush processed contents to stream. Need not be implemented for stream formatters. 30 | virtual void flush(CaliperMetadataAccessInterface&, std::ostream&) {} 31 | }; 32 | 33 | } // namespace cali 34 | -------------------------------------------------------------------------------- /test/ci_app_tests/ci_test_io.cpp: -------------------------------------------------------------------------------- 1 | #include "caliper/cali.h" 2 | #include "caliper/cali-manager.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | int main(int argc, char* argv[]) 11 | { 12 | const char* cfg = argc > 1 ? argv[1] : ""; 13 | 14 | cali::ConfigManager mgr; 15 | mgr.set_default_parameter("aggregate_across_ranks", "false"); 16 | 17 | if (!mgr.add(cfg)) { 18 | std::cerr << "ci_test_io: error: " << mgr.error_msg() << std::endl; 19 | return 1; 20 | } 21 | 22 | mgr.start(); 23 | 24 | CALI_MARK_FUNCTION_BEGIN; 25 | 26 | int fd = open(argv[0], O_RDONLY); 27 | 28 | if (fd == -1) 29 | return 2; 30 | 31 | char buf[16]; 32 | if (read(fd, buf, 16) != 16) 33 | return 3; 34 | 35 | close(fd); 36 | 37 | CALI_MARK_FUNCTION_END; 38 | 39 | mgr.flush(); 40 | } 41 | -------------------------------------------------------------------------------- /src/reader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_READER_SOURCES 2 | Aggregator.cpp 3 | CaliReader.cpp 4 | CaliWriter.cpp 5 | CaliperMetadataDB.cpp 6 | CalQLParser.cpp 7 | Expand.cpp 8 | FlatExclusiveRegionProfile.cpp 9 | FlatInclusiveRegionProfile.cpp 10 | FormatProcessor.cpp 11 | NestedExclusiveRegionProfile.cpp 12 | NestedInclusiveRegionProfile.cpp 13 | Preprocessor.cpp 14 | QueryProcessor.cpp 15 | QuerySpec.cpp 16 | RecordSelector.cpp 17 | SnapshotTableFormatter.cpp 18 | SnapshotTree.cpp 19 | TableFormatter.cpp 20 | TreeFormatter.cpp 21 | JsonFormatter.cpp 22 | JsonSplitFormatter.cpp 23 | UserFormatter.cpp) 24 | 25 | add_library(caliper-reader OBJECT 26 | ${CALIPER_READER_SOURCES}) 27 | 28 | target_compile_options(caliper-reader PRIVATE ${Wall_flag}) 29 | target_compile_features(caliper-reader PUBLIC cxx_std_11) 30 | 31 | if (BUILD_TESTING) 32 | add_subdirectory(test) 33 | endif() 34 | -------------------------------------------------------------------------------- /src/services/sampler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_SAMPLER_SOURCES 2 | Sampler.cpp) 3 | 4 | if (${CMAKE_SYSTEM_PROCESSOR} MATCHES x86) 5 | set(CALI_HAVE_CONTEXT_H true) 6 | set(CALI_CONTEXT_H "context_x86.h") 7 | elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES ppc) 8 | set(CALI_HAVE_CONTEXT_H true) 9 | set(CALI_CONTEXT_H "context_ppc.h") 10 | else() 11 | message(WARNING "Unknown architecture ${CMAKE_SYSTEM_PROCESSOR}") 12 | endif() 13 | 14 | configure_file( 15 | ${CMAKE_CURRENT_SOURCE_DIR}/context.h.in 16 | ${CMAKE_CURRENT_BINARY_DIR}/context.h) 17 | 18 | include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) 19 | 20 | if (CALIPER_HAVE_LIBUNWIND) 21 | include_directories(${LIBUNWIND_INCLUDE_DIRS}) 22 | endif() 23 | 24 | add_library(caliper-sampler OBJECT ${CALIPER_SAMPLER_SOURCES}) 25 | 26 | add_service_objlib("caliper-sampler") 27 | add_caliper_service("sampler CALIPER_HAVE_SAMPLER") 28 | -------------------------------------------------------------------------------- /doc/sphinx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build Sphinx documentation 2 | # Adapted from 3 | # http://ericscottbarr.com/blog/2012/03/sphinx-and-cmake-beautiful-documentation-for-c-projects/ 4 | 5 | if(NOT DEFINED SPHINX_THEME) 6 | set(SPHINX_THEME classic) 7 | endif() 8 | 9 | if(NOT DEFINED SPHINX_THEME_DIR) 10 | set(SPHINX_THEME_DIR) 11 | endif() 12 | 13 | set(BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build") 14 | set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees") 15 | set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html") 16 | 17 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" 18 | "${BINARY_BUILD_DIR}/conf.py" 19 | @ONLY) 20 | 21 | add_custom_target(caliper_sphinx_doc ALL 22 | ${SPHINX_EXECUTABLE} 23 | -q -b html 24 | -c "${BINARY_BUILD_DIR}" 25 | -d "${SPHINX_CACHE_DIR}" 26 | "${CMAKE_CURRENT_SOURCE_DIR}" 27 | "${SPHINX_HTML_DIR}" 28 | COMMENT "Building Sphinx documentation") 29 | -------------------------------------------------------------------------------- /src/caliper/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_TEST_SOURCES 2 | test_attribute.cpp 3 | test_blackboard.cpp 4 | test_c_api.cpp 5 | test_c_wrapper.cpp 6 | test_channel_api.cpp 7 | test_channel_controller.cpp 8 | test_configmanager.cpp 9 | test_metadatatree.cpp 10 | test_postprocess_snapshot.cpp 11 | test_c_snapshot.cpp 12 | test_regionfilter.cpp) 13 | 14 | add_executable(test_caliper ${CALIPER_TEST_SOURCES}) 15 | 16 | target_link_libraries(test_caliper caliper gtest_main) 17 | 18 | set(CALIPER_TEST_JSON_FILES 19 | test_single_config.json 20 | test_config_list.json 21 | test_config_and_options.json) 22 | 23 | foreach(file ${CALIPER_TEST_JSON_FILES}) 24 | add_custom_target(${file} ALL 25 | COMMAND ${CMAKE_COMMAND} -E create_symlink 26 | ${CMAKE_CURRENT_SOURCE_DIR}/${file} 27 | ${CMAKE_CURRENT_BINARY_DIR}/${file}) 28 | endforeach() 29 | 30 | add_test(NAME test-caliper COMMAND test_caliper) 31 | -------------------------------------------------------------------------------- /src/reader/JsonSplitFormatter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file Json.h 5 | /// Json output formatter 6 | 7 | #pragma once 8 | 9 | #include "Formatter.h" 10 | 11 | #include 12 | 13 | namespace cali 14 | { 15 | 16 | class CaliperMetadataAccessInterface; 17 | struct QuerySpec; 18 | 19 | /// \brief Prints snapshot records as sparse JSON 20 | /// \ingroup ReaderAPI 21 | class JsonSplitFormatter : public Formatter 22 | { 23 | struct JsonSplitFormatterImpl; 24 | std::shared_ptr mP; 25 | 26 | public: 27 | 28 | JsonSplitFormatter(const QuerySpec& spec); 29 | 30 | ~JsonSplitFormatter(); 31 | 32 | void process_record(CaliperMetadataAccessInterface&, const EntryList&); 33 | 34 | void flush(CaliperMetadataAccessInterface&, std::ostream& os); 35 | }; 36 | 37 | } // namespace cali 38 | -------------------------------------------------------------------------------- /src/reader/JsonFormatter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file Json.h 5 | /// Json output formatter 6 | 7 | #pragma once 8 | 9 | #include "Formatter.h" 10 | 11 | #include 12 | 13 | namespace cali 14 | { 15 | 16 | class CaliperMetadataAccessInterface; 17 | class OutputStream; 18 | 19 | struct QuerySpec; 20 | 21 | /// \brief Prints snapshot records as sparse JSON 22 | /// \ingroup ReaderAPI 23 | class JsonFormatter : public Formatter 24 | { 25 | struct JsonFormatterImpl; 26 | std::shared_ptr mP; 27 | 28 | public: 29 | 30 | JsonFormatter(OutputStream& os, const QuerySpec& spec); 31 | 32 | ~JsonFormatter(); 33 | 34 | void process_record(CaliperMetadataAccessInterface&, const EntryList&); 35 | 36 | void flush(CaliperMetadataAccessInterface&, std::ostream& os); 37 | }; 38 | 39 | } // namespace cali 40 | -------------------------------------------------------------------------------- /src/reader/UserFormatter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | ///@file Format.h 5 | /// Format output formatter declarations 6 | 7 | #ifndef CALI_FORMAT_H 8 | #define CALI_FORMAT_H 9 | 10 | #include "Formatter.h" 11 | 12 | #include 13 | 14 | namespace cali 15 | { 16 | 17 | class CaliperMetadataAccessInterface; 18 | class OutputStream; 19 | struct QuerySpec; 20 | 21 | /// \brief Prints snapshot records using a user-defined format string 22 | /// \ingroup ReaderAPI 23 | 24 | class UserFormatter : public Formatter 25 | { 26 | struct FormatImpl; 27 | std::shared_ptr mP; 28 | 29 | public: 30 | 31 | UserFormatter(OutputStream& os, const QuerySpec& spec); 32 | 33 | ~UserFormatter(); 34 | 35 | void process_record(CaliperMetadataAccessInterface&, const EntryList&); 36 | }; 37 | 38 | } // namespace cali 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/reader/TreeFormatter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file TreeFormatter.h 5 | /// \brief TreeFormatter output formatter 6 | 7 | #pragma once 8 | 9 | #include "Formatter.h" 10 | 11 | #include 12 | #include 13 | 14 | namespace cali 15 | { 16 | 17 | class CaliperMetadataAccessInterface; 18 | struct QuerySpec; 19 | 20 | /// \brief Print a set of snapshot records in a tree 21 | /// \ingroup ReaderAPI 22 | 23 | class TreeFormatter : public Formatter 24 | { 25 | struct TreeFormatterImpl; 26 | std::shared_ptr mP; 27 | 28 | public: 29 | 30 | TreeFormatter(const QuerySpec& spec); 31 | 32 | ~TreeFormatter(); 33 | 34 | void process_record(CaliperMetadataAccessInterface&, const EntryList&); 35 | 36 | void flush(CaliperMetadataAccessInterface&, std::ostream& os); 37 | }; 38 | 39 | } // namespace cali 40 | -------------------------------------------------------------------------------- /src/services/symbollookup/Lookup.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | #pragma once 5 | 6 | #ifndef CALI_SYMBOLLOOKUP_LOOKUP_H 7 | #define CALI_SYMBOLLOOKUP_LOOKUP_H 8 | 9 | #include 10 | #include 11 | 12 | namespace cali 13 | { 14 | 15 | namespace symbollookup 16 | { 17 | 18 | class Lookup 19 | { 20 | struct LookupImpl; 21 | std::unique_ptr mP; 22 | 23 | public: 24 | 25 | enum Kind { Name = 1, File = 2, Line = 4, Module = 8 }; 26 | 27 | struct Result { 28 | std::string name; 29 | std::string file; 30 | int line; 31 | std::string module; 32 | bool success; 33 | }; 34 | 35 | Result lookup(uint64_t address, int what) const; 36 | 37 | Lookup(); 38 | ~Lookup(); 39 | }; 40 | 41 | } // namespace symbollookup 42 | 43 | } // namespace cali 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /test/ci_app_tests/test_sampler.py: -------------------------------------------------------------------------------- 1 | # Sampler/symbollookup tests 2 | 3 | import unittest 4 | 5 | import calipertest as cat 6 | 7 | class CaliperSamplerTest(unittest.TestCase): 8 | """ Caliper sampler test case """ 9 | 10 | def test_hatchet_sample_profile(self): 11 | target_cmd = [ './ci_test_macros', '5000', 'hatchet-sample-profile(use.mpi=false,output=stdout,output.format=cali)' ] 12 | query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] 13 | 14 | caliper_config = { 15 | 'CALI_LOG_VERBOSITY' : '0' 16 | } 17 | 18 | query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) 19 | snapshots = cat.get_snapshots_from_text(query_output) 20 | 21 | self.assertTrue(len(snapshots) > 0) 22 | 23 | self.assertTrue(cat.has_snapshot_with_keys( 24 | snapshots, { 'loop', 'region' })) 25 | 26 | if __name__ == "__main__": 27 | unittest.main() 28 | -------------------------------------------------------------------------------- /src/interface/c_fortran/wrapScopeAnnotation.h: -------------------------------------------------------------------------------- 1 | // wrapScopeAnnotation.h 2 | // This file is generated by Shroud 0.13.0. Do not edit. 3 | /** 4 | * \file wrapScopeAnnotation.h 5 | * \brief Shroud generated wrapper for ScopeAnnotation class 6 | */ 7 | // For C users and C++ implementation 8 | 9 | #ifndef WRAPSCOPEANNOTATION_H 10 | #define WRAPSCOPEANNOTATION_H 11 | 12 | #include "typesCaliper.h" 13 | 14 | // splicer begin class.ScopeAnnotation.CXX_declarations 15 | // splicer end class.ScopeAnnotation.CXX_declarations 16 | 17 | #ifdef __cplusplus 18 | extern "C" 19 | { 20 | #endif 21 | 22 | // splicer begin class.ScopeAnnotation.C_declarations 23 | // splicer end class.ScopeAnnotation.C_declarations 24 | 25 | cali_ScopeAnnotation* cali_ScopeAnnotation_begin(const char* name, cali_ScopeAnnotation* SHC_rv); 26 | 27 | void cali_ScopeAnnotation_end(cali_ScopeAnnotation* self); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif // WRAPSCOPEANNOTATION_H 34 | -------------------------------------------------------------------------------- /include/caliper/reader/CaliReader.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file CaliReader.h 5 | /// \brief CaliReader class definition 6 | 7 | #pragma once 8 | 9 | #include "RecordProcessor.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace cali 16 | { 17 | 18 | class CaliperMetadataDB; 19 | 20 | class CaliReader 21 | { 22 | struct CaliReaderImpl; 23 | std::unique_ptr mP; 24 | 25 | public: 26 | 27 | CaliReader(); 28 | ~CaliReader(); 29 | 30 | bool error() const; 31 | std::string error_msg() const; 32 | 33 | void read(std::istream& is, CaliperMetadataDB& db, NodeProcessFn node_proc, SnapshotProcessFn snap_proc); 34 | void read(const std::string& filename, CaliperMetadataDB& db, NodeProcessFn node_proc, SnapshotProcessFn snap_proc); 35 | }; 36 | 37 | } // namespace cali 38 | -------------------------------------------------------------------------------- /include/caliper/reader/CaliWriter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file CaliWriter.h 5 | /// \brief CaliWriter implementation 6 | 7 | #pragma once 8 | 9 | #include "caliper/common/Entry.h" 10 | 11 | #include 12 | #include 13 | 14 | namespace cali 15 | { 16 | 17 | class CaliperMetadataAccessInterface; 18 | class Node; 19 | class OutputStream; 20 | 21 | class CaliWriter 22 | { 23 | struct CaliWriterImpl; 24 | std::shared_ptr mP; 25 | 26 | public: 27 | 28 | CaliWriter() {} 29 | 30 | CaliWriter(OutputStream& os); 31 | 32 | ~CaliWriter(); 33 | 34 | size_t num_written() const; 35 | 36 | void write_snapshot(const CaliperMetadataAccessInterface&, const std::vector&); 37 | 38 | void write_globals(const CaliperMetadataAccessInterface&, const std::vector&); 39 | }; 40 | 41 | } // namespace cali 42 | -------------------------------------------------------------------------------- /test/ci_app_tests/ci_test_openmp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | int main(int argc, char* argv[]) 10 | { 11 | cali_config_set("CALI_CALIPER_ATTRIBUTE_DEFAULT_SCOPE", "process"); 12 | 13 | cali::ConfigManager mgr; 14 | 15 | if (argc > 1) 16 | mgr.add(argv[1]); 17 | if (mgr.error()) { 18 | std::cerr << mgr.error_msg() << std::endl; 19 | return EXIT_FAILURE; 20 | } 21 | 22 | mgr.start(); 23 | 24 | CALI_MARK_FUNCTION_BEGIN; 25 | 26 | omp_set_num_threads(2); 27 | 28 | int sum = 0; 29 | 30 | #pragma omp parallel for reduction(+ : sum) 31 | for (int i = 0; i < 42; ++i) { 32 | sum += i; 33 | } 34 | 35 | // use value to prevent loop elision 36 | cali_set_global_int_byname("ci_test_openmp.result", sum); 37 | 38 | CALI_MARK_FUNCTION_END; 39 | 40 | mgr.flush(); 41 | } -------------------------------------------------------------------------------- /src/caliper/cali_datatracker.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | // Caliper data tracking C interface implementation 5 | 6 | #include "caliper/cali_datatracker.h" 7 | #include "caliper/Caliper.h" 8 | 9 | #include 10 | #include 11 | 12 | using namespace cali; 13 | 14 | void cali_datatracker_track(const void* ptr, const char* label, size_t size) 15 | { 16 | Caliper::instance().memory_region_begin(ptr, label, 1, 1, &size); 17 | } 18 | 19 | void cali_datatracker_track_dimensional( 20 | const void* ptr, 21 | const char* label, 22 | size_t elem_size, 23 | const size_t* dimensions, 24 | size_t ndims 25 | ) 26 | { 27 | Caliper::instance().memory_region_begin(ptr, label, elem_size, ndims, dimensions); 28 | } 29 | 30 | void cali_datatracker_untrack(const void* ptr) 31 | { 32 | Caliper::instance().memory_region_end(ptr); 33 | } 34 | -------------------------------------------------------------------------------- /src/services/io/CurIOus/src/file_registry.h: -------------------------------------------------------------------------------- 1 | #ifndef FILE_REGISTRY 2 | #define FILE_REGISTRY 3 | 4 | #define STDIO_FILESYS "stdio" 5 | 6 | /********* 7 | * Types * 8 | *********/ 9 | 10 | typedef struct curious_file_record { 11 | char* path; 12 | char* filesystem; 13 | char* mount_point; 14 | } curious_file_record_t; 15 | 16 | /********************** 17 | * Internal Functions * 18 | **********************/ 19 | 20 | void curious_init_file_registry(); 21 | void curious_finalize_file_registry(); 22 | void destroy_curious_file_record(curious_file_record_t* record); 23 | // Should be called whenever a new file is opened, 24 | // so that we can store information on that file 25 | int curious_register_file_by_fd(int fd); 26 | int curious_register_file(const char* path, int fd, char* filesystem, char* mount_point); 27 | int curious_deregister_file(int fd); 28 | curious_file_record_t* get_curious_file_record(int fd); 29 | #endif 30 | -------------------------------------------------------------------------------- /scripts/formatting/Dockerfile.format: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | 3 | USER root 4 | 5 | ENV LOCAL_USER=jovyan \ 6 | LOCAL_UID=1001 \ 7 | HOME=/home/jovyan 8 | 9 | RUN apt-get update \ 10 | && apt-get -qq install -y --no-install-recommends \ 11 | adduser \ 12 | build-essential \ 13 | clang-format-17 \ 14 | && rm -rf /var/lib/apt/lists/* 15 | 16 | RUN adduser \ 17 | --disabled-password \ 18 | --gecos "Default user" \ 19 | --uid ${LOCAL_UID} \ 20 | --home ${HOME} \ 21 | --force-badname \ 22 | ${LOCAL_USER} 23 | 24 | COPY --chown=${LOCAL_USER} --chmod=777 ./scripts /home/jovyan/ 25 | COPY --chown=${LOCAL_USER} --chmod=666 ./src /home/jovyan/ 26 | COPY --chown=${LOCAL_USER} --chmod=666 ./include /home/jovyan/ 27 | COPY --chown=${LOCAL_USER} --chmod=666 ./examples /home/jovyan/ 28 | COPY --chown=${LOCAL_USER} --chmod=666 ./test /home/jovyan/ 29 | 30 | USER ${LOCAL_USER} 31 | 32 | ENTRYPOINT [ "/home/jovyan/scripts/formatting/autoformat.sh", "/usr/bin/clang-format-17" ] 33 | -------------------------------------------------------------------------------- /scripts/formatting/Dockerfile.check: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | 3 | USER root 4 | 5 | ENV LOCAL_USER=jovyan \ 6 | LOCAL_UID=1001 \ 7 | HOME=/home/jovyan 8 | 9 | RUN apt-get update \ 10 | && apt-get -qq install -y --no-install-recommends \ 11 | adduser \ 12 | build-essential \ 13 | clang-format-17 \ 14 | && rm -rf /var/lib/apt/lists/* 15 | 16 | RUN adduser \ 17 | --disabled-password \ 18 | --gecos "Default user" \ 19 | --uid ${LOCAL_UID} \ 20 | --home ${HOME} \ 21 | --force-badname \ 22 | ${LOCAL_USER} 23 | 24 | COPY --chown=${LOCAL_USER} --chmod=777 ./scripts /home/jovyan/ 25 | COPY --chown=${LOCAL_USER} --chmod=666 ./src /home/jovyan/ 26 | COPY --chown=${LOCAL_USER} --chmod=666 ./include /home/jovyan/ 27 | COPY --chown=${LOCAL_USER} --chmod=666 ./examples /home/jovyan/ 28 | COPY --chown=${LOCAL_USER} --chmod=666 ./test /home/jovyan/ 29 | 30 | USER ${LOCAL_USER} 31 | 32 | ENTRYPOINT [ "/home/jovyan/scripts/formatting/check-formatting.sh", "/usr/bin/clang-format-17" ] 33 | -------------------------------------------------------------------------------- /src/common/util/demangle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | #include "demangle.h" 5 | 6 | #ifndef _WIN32 7 | #include 8 | #endif 9 | 10 | #include 11 | 12 | namespace cali 13 | { 14 | namespace util 15 | { 16 | 17 | std::string demangle(const char* name) 18 | { 19 | #ifdef _WIN32 20 | // not sure how to demangle on Windows, make it a no-op for now. 21 | return name; 22 | #else 23 | std::string result; 24 | 25 | if (!name) 26 | return result; 27 | 28 | char* demangled = nullptr; 29 | int status = -1; 30 | 31 | if (name[0] == '_' && name[1] == 'Z') 32 | demangled = abi::__cxa_demangle(name, nullptr, 0, &status); 33 | 34 | if (status == 0) 35 | result = demangled; 36 | else 37 | result = name; 38 | 39 | free(demangled); 40 | 41 | return result; 42 | #endif 43 | } 44 | 45 | } // namespace util 46 | 47 | } // namespace cali -------------------------------------------------------------------------------- /src/services/templates/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_SERVICE_TEMPLATE_SOURCES 2 | MeasurementService.cpp) 3 | 4 | # Use the add_service_sources() macro to add sources without external dependencies. 5 | # For services that do have external dependencies (a third-party library), create 6 | # an object library instead and use the add_service_objectlib macro instead: 7 | # 8 | # include_directories(${_INCLUDE_DIRS}) 9 | # add_library(caliper-templateservices OBJECT ${CALIPER_SERVICE_TEMPLATE_SOURCES}) 10 | # 11 | # add_service_objlib("caliper-templateservices") 12 | add_service_sources(${CALIPER_SERVICE_TEMPLATE_SOURCES}) 13 | 14 | # Use the add_caliper_service() macro to add the service(s). 15 | # The first word in the string must be the name used in the service's 16 | # CaliperService variable name and name element. The second (optional) word 17 | # is a #ifdef condition in caliper-config.h that must be met for the 18 | # service. 19 | add_caliper_service("measurement_template CALIPER_BUILD_TESTING") 20 | -------------------------------------------------------------------------------- /src/caliper/MpiEvents.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file MpiEvents.h 5 | /// \brief Caliper-MPI internal callbacks 6 | 7 | #include "caliper/callback.hpp" 8 | 9 | namespace cali 10 | { 11 | 12 | class Caliper; 13 | class Channel; 14 | 15 | /// \brief The MPI callbacks 16 | struct MpiEvents { 17 | typedef util::callback mpi_env_cbvec; 18 | 19 | /// \brief MPI has been initialized. 20 | /// 21 | /// This callback will be called by the MPI wrapper service (mpi) once 22 | /// when MPI is initialized. This may happen during or after MPI_Init(). 23 | mpi_env_cbvec mpi_init_evt; 24 | 25 | /// \brief MPI is about to be finalized. 26 | mpi_env_cbvec mpi_finalize_evt; 27 | }; 28 | 29 | /// \brief Return the MpiEvents instance for the given channel. 30 | MpiEvents* mpiwrap_get_events(Channel* chn); // defined in mpiwrap/Wrapper.w 31 | 32 | } // namespace cali 33 | -------------------------------------------------------------------------------- /include/caliper/reader/RecordProcessor.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file RecordProcessor.h 5 | /// \brief Various type definitions for the reader API 6 | /// \ingroup ReaderAPI 7 | 8 | #pragma once 9 | 10 | #include "../common/Entry.h" 11 | 12 | #include 13 | #include 14 | 15 | namespace cali 16 | { 17 | class CaliperMetadataAccessInterface; 18 | 19 | typedef std::vector EntryList; 20 | 21 | typedef std::function NodeProcessFn; 22 | typedef std::function NodeFilterFn; 23 | 24 | typedef std::function SnapshotProcessFn; 25 | typedef std::function 26 | SnapshotFilterFn; 27 | 28 | } // namespace cali 29 | -------------------------------------------------------------------------------- /src/common/SnapshotTextFormatter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file SnapshotTextFormatter.h 5 | /// \brief Interface for Snapshot text formatter 6 | 7 | #ifndef CALI_SNAPSHOT_TEXT_FORMATTER_H 8 | #define CALI_SNAPSHOT_TEXT_FORMATTER_H 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace cali 16 | { 17 | 18 | class CaliperMetadataAccessInterface; 19 | class Entry; 20 | 21 | class SnapshotTextFormatter 22 | { 23 | struct SnapshotTextFormatterImpl; 24 | std::unique_ptr mP; 25 | 26 | public: 27 | 28 | SnapshotTextFormatter(const std::string& format_str = ""); 29 | 30 | ~SnapshotTextFormatter(); 31 | 32 | void reset(const std::string& format_str); 33 | 34 | std::ostream& print(std::ostream&, const CaliperMetadataAccessInterface&, const std::vector&); 35 | }; 36 | 37 | } // namespace cali 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/services/tau/README.md: -------------------------------------------------------------------------------- 1 | TAU Service 2 | -------------------------------- 3 | 4 | The TAU service publishes Caliper trace or aggregation data to TAU 5 | profiles or traces. 6 | 7 | To enable the TAU service when configuring CMake for Caliper, add 8 | the following CMake variables: 9 | 10 | ``` 11 | -DWITH_TAU=TRUE \ 12 | -DTAU_PREFIX=/path/to/tau2 \ 13 | -DTAU_MAKEFILE=$TAU_MAKEFILE \ 14 | -DTAU_ARCH=x86_64 \ 15 | ``` 16 | 17 | Where `TAU_PREFIX` is set to the root TAU installation directory, 18 | `TAU_MAKEFILE` specifies the TAU configuration you want to use, and 19 | `TAU_ARCH` specifies the compute platform (when cross-compiling). 20 | 21 | For example, when configuring on a system where TAU is configured with 22 | pthread, papi and pgi compiler support, you might specify: 23 | 24 | ``` 25 | -DWITH_TAU=TRUE \ 26 | -DTAU_PREFIX=$HOME/src/tau2 \ 27 | -DTAU_MAKEFILE=$HOME/src/tau2/craycnl/lib/Makefile.tau-pgi-pthread-papi \ 28 | -DTAU_ARCH=craycnl \ 29 | ``` 30 | 31 | For any/all questions please contact tau-bugs@cs.uoregon.edu. 32 | -------------------------------------------------------------------------------- /.gitlab/jobs/corona.yml: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Copyright (c) 2022-23, Lawrence Livermore National Security, LLC and RADIUSS 3 | # project contributors. See the COPYRIGHT file for details. 4 | # 5 | # SPDX-License-Identifier: (MIT) 6 | ############################################################################## 7 | 8 | # Override reproducer section to define project specific variables. 9 | .corona_reproducer_vars: 10 | script: 11 | - !reference [.reproducer_vars, script] 12 | 13 | # With GitLab CI, included files cannot be empty. 14 | variables: 15 | INCLUDED_FILE_CANNOT_BE_EMPTY: "True" 16 | 17 | # The correct way is now to use llvm-amdgpu compiler directly as done in shared spec 18 | ### Template for extra jobs defined by the project. 19 | #clang14.0.6-rocm5.4.1: 20 | # variables: 21 | # SPEC: "%llvm@14.0.6 +rocm amdgpu_target=gfx906 ^hip@5.4.1 " 22 | # extends: .job_on_corona 23 | 24 | master: 25 | variables: 26 | SPEC: " +tests" 27 | extends: .job_on_corona 28 | -------------------------------------------------------------------------------- /examples/apps/README.md: -------------------------------------------------------------------------------- 1 | Caliper example applications 2 | ========================================== 3 | 4 | This directory contains a set of small example programs to demonstrate 5 | the use of various Caliper APIs. 6 | 7 | * The [cxx-example](cxx-example.cpp) program demonstrates Caliper's C++ 8 | annotation macros and the `ConfigManager` API 9 | * The [cali-regionprofile](cali-regionprofile.cpp) example demonstrates 10 | the `RegionProfile` class to query Caliper region times within a C++ application 11 | * The [cali-functional](cali-functional.cpp) example demonstrates a template-based 12 | inline function annotation interface (experimental feature). 13 | * The [cali-memtracking](cali-memtracking.cpp) and 14 | [cali-memtracking-macros](cali-memtracking-macros.cpp) examples demonstrate Caliper 15 | APIs to mark and name allocated memory regions for subsequent analysis with Caliper. 16 | * The [cali-print-snapshot](cali-print-snapshot.c) example demonstrates the C interface 17 | to pull and process Caliper snapshots at runtime. 18 | -------------------------------------------------------------------------------- /test/ci_app_tests/test_tau_service.py: -------------------------------------------------------------------------------- 1 | # report / C config test 2 | 3 | import unittest 4 | 5 | import calipertest as cat 6 | 7 | class CaliperReportTest(unittest.TestCase): 8 | """ Caliper TAU service test case """ 9 | 10 | def test_tau(self): 11 | target_cmd = [ './ci_test_mpi_before_cali' ] 12 | 13 | caliper_config = { 14 | 'CALI_SERVICES_ENABLE' : 'tau', 15 | 'CALI_LOG_VERBOSITY' : '0', 16 | 'TAU_PROFILE' : '0', 17 | 'TAU_TRACE' : '0' 18 | } 19 | 20 | #query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) 21 | query_output = cat.run_test(target_cmd, caliper_config) 22 | #snapshots = cat.get_snapshots_from_text(query_output) 23 | 24 | #self.assertTrue(len(snapshots) == 5) 25 | 26 | #self.assertTrue(cat.has_snapshot_with_attributes( 27 | #snapshots, { 'iteration#fooloop': '3', 'count': '1' })) 28 | 29 | if __name__ == "__main__": 30 | unittest.main() 31 | -------------------------------------------------------------------------------- /include/caliper/AsyncEvent.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2024, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file AsyncEvent.h 5 | /// %Caliper C++ interface for asynchronous events 6 | 7 | #pragma once 8 | #ifndef CALI_ASYNC_EVENT_H 9 | #define CALI_ASYNC_EVENT_H 10 | 11 | #include 12 | #include 13 | 14 | namespace cali 15 | { 16 | 17 | class Node; 18 | 19 | class TimedAsyncEvent 20 | { 21 | using clock = std::chrono::steady_clock; 22 | 23 | Node* end_tree_node_; 24 | std::chrono::time_point start_time_; 25 | 26 | explicit TimedAsyncEvent(Node* node) : end_tree_node_ { node }, start_time_ { clock::now() } { } 27 | 28 | public: 29 | 30 | #if __cplusplus >= 201402L 31 | constexpr TimedAsyncEvent() : end_tree_node_ { nullptr } { } 32 | #else 33 | TimedAsyncEvent() : end_tree_node_ { nullptr } { } 34 | #endif 35 | 36 | void end(); 37 | 38 | static TimedAsyncEvent begin(const char* message); 39 | }; 40 | 41 | } // namespace cali 42 | 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/reader/Expand.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | ///@file Expand.h 5 | /// Expand output formatter declarations 6 | 7 | #ifndef CALI_EXPAND_H 8 | #define CALI_EXPAND_H 9 | 10 | #include "Formatter.h" 11 | 12 | #include 13 | 14 | namespace cali 15 | { 16 | 17 | class CaliperMetadataAccessInterface; 18 | class OutputStream; 19 | struct QuerySpec; 20 | 21 | /// \brief Prints expanded snapshot records in CSV form 22 | /// \ingroup ReaderAPI 23 | 24 | class Expand : public Formatter 25 | { 26 | struct ExpandImpl; 27 | std::shared_ptr mP; 28 | 29 | public: 30 | 31 | Expand(OutputStream& os, const std::string& filter_string); 32 | Expand(OutputStream& os, const QuerySpec& spec); 33 | 34 | ~Expand(); 35 | 36 | void operator() (CaliperMetadataAccessInterface&, const EntryList&) const; 37 | 38 | void process_record(CaliperMetadataAccessInterface&, const EntryList&); 39 | }; 40 | 41 | } // namespace cali 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /scripts/run-annotation-perftest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | depth=28 4 | width=200 5 | 6 | EXE=$(pwd)/test/cali-annotation-perftest 7 | ARGS="-d ${depth} -w ${width}" 8 | 9 | # Run Caliper annotation benchmarks. Designed to run on LLNL dane (56 cores/socket) 10 | 11 | for threads in 1 4 56 12 | do 13 | # Annotations only, no active measurement config 14 | OMP_NUM_THREADS=${threads} \ 15 | ${EXE} ${ARGS} -P "spot,metadata(perftest.experiment=annotations)" 16 | 17 | # Aggregation (as used in e.g. runtime-report) 18 | OMP_NUM_THREADS=${threads} \ 19 | CALI_SERVICES_ENABLE=aggregate,event,timestamp \ 20 | CALI_EVENT_ENABLE_SNAPSHOT_INFO=false \ 21 | CALI_TIMER_SNAPSHOT_DURATION=true \ 22 | ${EXE} ${ARGS} -P "spot,metadata(perftest.experiment=aggregation)" 23 | 24 | # Trace w/ snapshot info 25 | OMP_NUM_THREADS=${threads} \ 26 | CALI_SERVICES_ENABLE=event,trace,timestamp \ 27 | ${EXE} ${ARGS} -P "spot,metadata(perftest.experiment=trace)" 28 | done 29 | 30 | mv *.cali ${HOME}/experiments/caliper/annotation-perftest/ 31 | -------------------------------------------------------------------------------- /src/interface/python/annotation.h: -------------------------------------------------------------------------------- 1 | #ifndef CALI_INTERFACE_PYTHON_ANNOTATION_H 2 | #define CALI_INTERFACE_PYTHON_ANNOTATION_H 3 | 4 | #include "common.h" 5 | 6 | namespace cali 7 | { 8 | 9 | class PythonAnnotation : public cali::Annotation 10 | { 11 | public: 12 | 13 | PythonAnnotation(const char* name); 14 | 15 | PythonAnnotation(const char* name, cali_attr_properties opt); 16 | 17 | PythonAnnotation& begin(); 18 | 19 | PythonAnnotation& begin(int data); 20 | 21 | PythonAnnotation& begin(double data); 22 | 23 | PythonAnnotation& begin(const char* data); 24 | 25 | PythonAnnotation& begin(cali_attr_type type, const std::string& data); 26 | 27 | PythonAnnotation& set(int data); 28 | 29 | PythonAnnotation& set(double data); 30 | 31 | PythonAnnotation& set(const char* data); 32 | 33 | PythonAnnotation& set(cali_attr_type type, const std::string& data); 34 | }; 35 | 36 | void create_caliper_annotation_mod(py::module_& caliper_annotation_mod); 37 | 38 | } // namespace cali 39 | 40 | #endif /* CALI_INTERFACE_PYTHON_ANNOTATION_H */ -------------------------------------------------------------------------------- /src/reader/TableFormatter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file Table.h 5 | /// \brief Table output formatter 6 | 7 | #ifndef CALI_TABLE_H 8 | #define CALI_TABLE_H 9 | 10 | #include "Formatter.h" 11 | 12 | #include 13 | #include 14 | 15 | namespace cali 16 | { 17 | 18 | class CaliperMetadataAccessInterface; 19 | struct QuerySpec; 20 | 21 | /// \brief Print a set of snapshot records in a human-readable table 22 | /// \ingroup ReaderAPI 23 | 24 | class TableFormatter : public Formatter 25 | { 26 | struct TableImpl; 27 | std::shared_ptr mP; 28 | 29 | public: 30 | 31 | TableFormatter(const std::string& fields, const std::string& sort_fields); 32 | TableFormatter(const QuerySpec& spec); 33 | 34 | ~TableFormatter(); 35 | 36 | void process_record(CaliperMetadataAccessInterface&, const EntryList&); 37 | 38 | void flush(CaliperMetadataAccessInterface&, std::ostream& os); 39 | }; 40 | 41 | } // namespace cali 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/services/event/AsyncEventTrigger.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2024, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | // AsyncEventTrigger.cpp 5 | // Caliper async event trigger 6 | 7 | #include "../Services.h" 8 | 9 | #include "caliper/Caliper.h" 10 | 11 | #include "caliper/common/Log.h" 12 | 13 | using namespace cali; 14 | 15 | namespace 16 | { 17 | 18 | void async_event_trigger_register(Caliper*, Channel* channel) 19 | { 20 | channel->events().async_event.connect([](Caliper* c, ChannelBody* chB, SnapshotView info){ 21 | if (!info.empty()) 22 | c->push_snapshot(chB, info); 23 | }); 24 | 25 | Log(1).stream() << channel->name() << ": registered async_event service\n"; 26 | } 27 | 28 | const char* s_spec = R"json( 29 | { 30 | "name": "async_event", 31 | "description": "Trigger snapshots for asynchronous events" 32 | })json"; 33 | 34 | } // namespace [anonymous] 35 | 36 | namespace cali 37 | { 38 | 39 | CaliperService async_event_service { ::s_spec, ::async_event_trigger_register }; 40 | 41 | } -------------------------------------------------------------------------------- /include/caliper/callback.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file callback.hpp 5 | /// \brief Callback manager template class 6 | 7 | #ifndef UTIL_CALLBACK_HPP 8 | #define UTIL_CALLBACK_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace cali 14 | { 15 | namespace util 16 | { 17 | 18 | template 19 | class callback 20 | { 21 | std::vector> mCb; 22 | 23 | public: 24 | 25 | void connect(std::function f) { mCb.push_back(f); } 26 | 27 | bool empty() const { return mCb.empty(); } 28 | 29 | template 30 | void operator() (Args&&... a) 31 | { 32 | for (auto& f : mCb) 33 | f(a...); 34 | } 35 | 36 | template 37 | R accumulate(Op op, R init, Args&&... a) 38 | { 39 | for (auto& f : mCb) 40 | init = Op(init, f(a...)); 41 | 42 | return init; 43 | } 44 | }; 45 | 46 | } // namespace util 47 | } // namespace cali 48 | #endif -------------------------------------------------------------------------------- /ext/googletest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # --- googletest: download googletest at configure time 3 | # 4 | 5 | configure_file(googletest-download_CMakeLists.txt.in googletest-download/CMakeLists.txt) 6 | 7 | execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . 8 | RESULT_VARIABLE result 9 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download) 10 | 11 | if (result) 12 | message(FATAL_ERROR "CMake step for googletest failed: ${result}") 13 | endif() 14 | 15 | execute_process(COMMAND ${CMAKE_COMMAND} --build . 16 | RESULT_VARIABLE result 17 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download) 18 | 19 | if (result) 20 | message(FATAL_ERROR "Build step for googletest failed: ${result}") 21 | endif() 22 | 23 | # Prevent overriding our compiler/linker settings 24 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 25 | 26 | # Add googletest directories. Defines gtest and gtest-main targets. 27 | add_subdirectory( 28 | ${CMAKE_CURRENT_BINARY_DIR}/googletest-download/googletest-src 29 | ${CMAKE_CURRENT_BINARY_DIR}/googletest-download/googletest-build) 30 | -------------------------------------------------------------------------------- /ext/gotcha/COPYRIGHT: -------------------------------------------------------------------------------- 1 | GOTCHA is developed by Lawrence Livermore National Security. 2 | The following copyrights apply: 3 | 4 | Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 5 | the Lawrence Livermore National Laboratory. Written by David Poliakoff 'poliakoff1 at llnl dot gov' 6 | and Matthew LeGendre 'legendre1 at llnl dot gov'. CODE-730558. All rights reserved. 7 | 8 | This program is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License (as published by the Free Software 10 | Foundation) version 2.1 dated February 1999. This program is distributed in 11 | the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 12 | IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 13 | the terms and conditions of the GNU Lesser General Public License for more details. 14 | You should have received a copy of the GNU Lesser General Public License along 15 | with this program; if not, write to the Free Software Foundation, Inc., 59 16 | Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | 18 | -------------------------------------------------------------------------------- /src/caliper/controllers/util.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | #include "util.h" 5 | 6 | #include "../../services/Services.h" 7 | 8 | #include 9 | 10 | using namespace cali; 11 | 12 | std::string util::build_tree_format_spec(config_map_t& config, const ConfigManager::Options& opts, const char* initial) 13 | { 14 | std::string format = initial; 15 | 16 | if (opts.is_set("max_column_width")) 17 | format.append("column-width=").append(opts.get("max_column_width")); 18 | if (opts.is_enabled("print.metadata")) { 19 | auto avail_services = services::get_available_services(); 20 | bool have_adiak = 21 | std::find(avail_services.begin(), avail_services.end(), "adiak_import") != avail_services.end(); 22 | 23 | if (have_adiak) 24 | config["CALI_SERVICES_ENABLE"].append(",adiak_import"); 25 | 26 | format.append(format.length() > 0 ? "," : "").append("print-globals"); 27 | } 28 | 29 | return std::string("tree(") + format + ")"; 30 | } 31 | -------------------------------------------------------------------------------- /src/services/trace/TraceBufferChunk.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | #pragma once 5 | 6 | #include "caliper/Caliper.h" 7 | #include "caliper/SnapshotRecord.h" 8 | 9 | #include 10 | 11 | namespace trace 12 | { 13 | class TraceBufferChunk 14 | { 15 | size_t m_size; 16 | size_t m_pos; 17 | size_t m_nrec; 18 | 19 | unsigned char* m_data; 20 | 21 | TraceBufferChunk* m_next; 22 | 23 | public: 24 | 25 | TraceBufferChunk(size_t s) : m_size(s), m_pos(0), m_nrec(0), m_data(new unsigned char[s]), m_next(0) {} 26 | 27 | ~TraceBufferChunk(); 28 | 29 | void append(TraceBufferChunk* chunk); 30 | void reset(); 31 | 32 | size_t flush(cali::Caliper* c, cali::SnapshotFlushFn proc_fn); 33 | 34 | void save_snapshot(cali::SnapshotView s); 35 | bool fits(cali::SnapshotView s) const; 36 | 37 | struct UsageInfo { 38 | size_t nchunks; 39 | size_t reserved; 40 | size_t used; 41 | }; 42 | 43 | UsageInfo info() const; 44 | }; 45 | } // namespace trace 46 | -------------------------------------------------------------------------------- /include/caliper/reader/QueryProcessor.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file QueryProcessor.h 5 | /// QueryProcessor class 6 | 7 | #pragma once 8 | 9 | #include "RecordProcessor.h" 10 | 11 | #include 12 | #include 13 | 14 | namespace cali 15 | { 16 | 17 | class CaliperMetadataAccessInterface; 18 | class OutputStream; 19 | struct QuerySpec; 20 | 21 | /// \brief Execute a given query (filter, aggregation, and output formatting) 22 | /// on a series of snapshot records. 23 | class QueryProcessor 24 | { 25 | struct QueryProcessorImpl; 26 | std::shared_ptr mP; 27 | 28 | public: 29 | 30 | QueryProcessor(const QuerySpec&, OutputStream& stream); 31 | 32 | ~QueryProcessor(); 33 | 34 | void process_record(CaliperMetadataAccessInterface&, const EntryList&); 35 | void flush(CaliperMetadataAccessInterface&); 36 | 37 | void operator() (CaliperMetadataAccessInterface& db, const EntryList& rec) { process_record(db, rec); } 38 | }; 39 | 40 | } // namespace cali 41 | -------------------------------------------------------------------------------- /test/ci_app_tests/test_cpuinfo.py: -------------------------------------------------------------------------------- 1 | # CpuInfo tests 2 | 3 | import unittest 4 | 5 | import calipertest as calitest 6 | 7 | class CaliperCpuInfoTest(unittest.TestCase): 8 | """ Caliper CpuInfo test case """ 9 | 10 | def test_papi(self): 11 | target_cmd = [ './ci_test_basic' ] 12 | query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] 13 | 14 | caliper_config = { 15 | 'CALI_SERVICES_ENABLE' : 'event,cpuinfo,trace,recorder', 16 | 'CALI_RECORDER_FILENAME' : 'stdout', 17 | 'CALI_LOG_VERBOSITY' : '0' 18 | } 19 | 20 | query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) 21 | snapshots = calitest.get_snapshots_from_text(query_output) 22 | 23 | self.assertTrue(len(snapshots) > 1) 24 | 25 | self.assertTrue(calitest.has_snapshot_with_keys( 26 | snapshots, { 'cpuinfo.cpu', 27 | 'cpuinfo.numa_node', 28 | 'myphase', 29 | 'iteration' })) 30 | 31 | 32 | if __name__ == "__main__": 33 | unittest.main() 34 | -------------------------------------------------------------------------------- /src/interface/python/loop.cpp: -------------------------------------------------------------------------------- 1 | #include "loop.h" 2 | 3 | namespace cali 4 | { 5 | 6 | PythonLoop::PythonLoop(const char* name) 7 | { 8 | if (cali_loop_attr_id == CALI_INV_ID) { 9 | cali_init(); 10 | } 11 | cali_begin_string(cali_loop_attr_id, name); 12 | m_iter_attr = cali_make_loop_iteration_attribute(name); 13 | } 14 | 15 | void PythonLoop::start_iteration(int i) 16 | { 17 | cali_begin_int(m_iter_attr, i); 18 | } 19 | 20 | void PythonLoop::end_iteration() 21 | { 22 | cali_end(m_iter_attr); 23 | } 24 | 25 | void PythonLoop::end() 26 | { 27 | cali_end(cali_loop_attr_id); 28 | } 29 | 30 | void create_caliper_loop_mod(py::module_& caliper_loop_mod) 31 | { 32 | py::class_ loop_type(caliper_loop_mod, "Loop"); 33 | loop_type.def(py::init(), "Create a loop annotation."); 34 | loop_type.def("start_iteration", &PythonLoop::start_iteration, "Start a loop iteration."); 35 | loop_type.def("end_iteration", &PythonLoop::end_iteration, "End a loop iteration."); 36 | loop_type.def("end", &PythonLoop::end, "End the loop annotation."); 37 | } 38 | 39 | } // namespace cali -------------------------------------------------------------------------------- /test/ci_app_tests/ci_test_c_snapshot.c: -------------------------------------------------------------------------------- 1 | // Caliper continuous integration test app for C snapshot interface 2 | 3 | #include "caliper/cali.h" 4 | 5 | #include 6 | 7 | int main() 8 | { 9 | cali_begin_string_byname("ci_test_c", "snapshot"); 10 | 11 | /* Test w/o event trigger info */ 12 | cali_push_snapshot(CALI_SCOPE_PROCESS | CALI_SCOPE_THREAD, 0, NULL, NULL); 13 | 14 | cali_id_t event_str_attr = cali_create_attribute("string_arg", CALI_TYPE_STRING, CALI_ATTR_DEFAULT); 15 | cali_id_t event_val_attr = cali_create_attribute("int_arg", CALI_TYPE_INT, CALI_ATTR_ASVALUE); 16 | 17 | int event_val = 42; 18 | const char* event_str = "teststring"; 19 | 20 | cali_id_t event_attr[2] = { event_str_attr, event_val_attr }; 21 | cali_variant_t event_data[2] = { cali_make_variant(CALI_TYPE_STRING, event_str, strlen(event_str)), 22 | cali_make_variant_from_int(event_val) }; 23 | 24 | cali_push_snapshot(CALI_SCOPE_PROCESS | CALI_SCOPE_THREAD, 2, event_attr, event_data); 25 | 26 | cali_end_byname("ci_test_c"); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /test/ci_app_tests/test_memusageservice.py: -------------------------------------------------------------------------------- 1 | # MemUsage tests 2 | 3 | import unittest 4 | 5 | import calipertest as calitest 6 | 7 | class CaliperMemusageServiceTest(unittest.TestCase): 8 | """ Caliper MemUsage service test case """ 9 | 10 | def test_memstat(self): 11 | target_cmd = [ './ci_test_basic' ] 12 | query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] 13 | 14 | caliper_config = { 15 | 'CALI_SERVICES_ENABLE' : 'event,memstat,trace,recorder', 16 | 'CALI_RECORDER_FILENAME' : 'stdout', 17 | 'CALI_LOG_VERBOSITY' : '0' 18 | } 19 | 20 | query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) 21 | snapshots = calitest.get_snapshots_from_text(query_output) 22 | 23 | self.assertTrue(len(snapshots) > 1) 24 | 25 | self.assertTrue(calitest.has_snapshot_with_keys( 26 | snapshots, { 'memstat.vmsize', 27 | 'memstat.data', 28 | 'myphase', 29 | 'iteration' })) 30 | 31 | if __name__ == "__main__": 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /src/caliper/OutputCommMpi.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file OutputCommMpi.h 5 | /// OutputCommMpi class 6 | 7 | #pragma once 8 | 9 | #ifndef CALI_OUTPUT_COMM_MPI_H 10 | #define CALI_OUTPUT_COMM_MPI_H 11 | 12 | #include "CustomOutputController.h" 13 | 14 | #include 15 | 16 | #include 17 | 18 | namespace cali 19 | { 20 | 21 | class Aggregator; 22 | class CaliperMetadataDB; 23 | 24 | /// \brief A CustomOutputController::Comm implementation for MPI 25 | class OutputCommMpi : public internal::CustomOutputController::Comm 26 | { 27 | struct OutputCommMpiImpl; 28 | std::shared_ptr mP; 29 | 30 | public: 31 | 32 | OutputCommMpi(); 33 | 34 | OutputCommMpi(MPI_Comm comm); 35 | 36 | ~OutputCommMpi(); 37 | 38 | int rank() const override; 39 | 40 | int bcast_int(int val) const override; 41 | std::string bcast_str(const std::string& str) const override; 42 | 43 | void cross_aggregate(CaliperMetadataDB& db, Aggregator& agg) const override; 44 | }; 45 | 46 | } // namespace cali 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/reader/test/test_snapshottableformatter.cpp: -------------------------------------------------------------------------------- 1 | #include "../SnapshotTableFormatter.h" 2 | 3 | #include "caliper/reader/CaliperMetadataDB.h" 4 | 5 | #include "caliper/common/Node.h" 6 | 7 | #include 8 | 9 | #include 10 | 11 | using namespace cali; 12 | 13 | TEST(SnapshotTableFormatter, Format) 14 | { 15 | CaliperMetadataDB db; 16 | 17 | Attribute a = db.create_attribute("aaaa", CALI_TYPE_INT, CALI_ATTR_ASVALUE); 18 | Attribute b = db.create_attribute("bb", CALI_TYPE_UINT, CALI_ATTR_ASVALUE); 19 | Attribute s = db.create_attribute("str", CALI_TYPE_STRING, CALI_ATTR_DEFAULT); 20 | 21 | IdMap idmap; 22 | Node* node = db.merge_node(101, s.id(), CALI_INV_ID, Variant("a string value"), idmap); 23 | 24 | std::vector rec; 25 | rec.push_back(Entry(a, Variant(42))); 26 | rec.push_back(Entry(b, Variant(4242))); 27 | rec.push_back(Entry(node)); 28 | 29 | std::ostringstream os; 30 | format_record_as_table(db, rec, os); 31 | 32 | std::string expect = 33 | "aaaa : 42 \n" 34 | "bb : 4242 \n" 35 | "str : a string value\n"; 36 | 37 | EXPECT_EQ(os.str(), expect); 38 | } 39 | -------------------------------------------------------------------------------- /include/caliper/cali_definitions.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | * See top-level LICENSE file for details. 3 | */ 4 | 5 | /** 6 | * \file cali_definitions.h 7 | * \brief Various type definitions for the %Caliper runtime system. 8 | */ 9 | 10 | #ifndef CALI_CALI_DEFINITIONS_H 11 | #define CALI_CALI_DEFINITIONS_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | typedef enum { 19 | CALI_SCOPE_PROCESS = 1, 20 | CALI_SCOPE_THREAD = 2, 21 | CALI_SCOPE_TASK = 4, 22 | CALI_SCOPE_CHANNEL = 8 23 | } cali_context_scope_t; 24 | 25 | /** 26 | * Flush options 27 | */ 28 | typedef enum { 29 | /** Clear trace and aggregation buffers after flush. */ 30 | CALI_FLUSH_CLEAR_BUFFERS = 1 31 | } cali_flush_opt; 32 | 33 | /** 34 | * Channel creation options 35 | */ 36 | typedef enum { 37 | /** Leave the channel inactive after it is created. */ 38 | CALI_CHANNEL_LEAVE_INACTIVE = 1, 39 | /** Allow reading configuration entries from environment variables. */ 40 | CALI_CHANNEL_ALLOW_READ_ENV = 2 41 | } cali_channel_opt; 42 | 43 | #ifdef __cplusplus 44 | } // extern "C" 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/services/ldms/README.md: -------------------------------------------------------------------------------- 1 | # LDMS Connector/Forwarder 2 | 3 | The LDMS Connector/Fowarder publishes Caliper messages to LDMS for analysis and visualization. It requires LDMS to be installed. You can find the current LDMS installation here: [OVIS](https://github.com/ovis-hpc/ovis) 4 | 5 | - Installation guidelines can be found here: [LDMS Quickstart Guide](https://ovis-hpc.readthedocs.io/en/latest/ldms/ldms-quickstart.html) 6 | - The following environmental variables are required to successfully publish Caliper messages to LDMS: 7 | ``` 8 | export CALIPER_LDMS_STREAM="caliper-perf-data" 9 | export CALIPER_LDMS_XPRT="sock" 10 | export CALIPER_LDMS_HOST="localhost" 11 | export CALIPER_LDMS_PORT="412" 12 | export CALIPER_LDMS_AUTH="munge" 13 | export LD_LIBRARY_PATH="[path_to_LDMS_lib64]":$LD_LIBRARY_PATH 14 | export PATH="[path_to_LDMS_bin_directory]":"[path_to_LDMS_sbin_directory]":$PATH 15 | ``` 16 | - The following environmental variable allows you to debug your LDMS connection and confirm if messages are being pushed by the application and Caliper: 17 | ``` 18 | export CALIPER_LDMS_VERBOSE = 1 19 | ``` 20 | Set ```CALIPER_LDMS_VERBOSE = 0``` to turn off debug messages. 21 | -------------------------------------------------------------------------------- /test/ci_app_tests/ci_test_channel_api.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | const char* channel_cfg[][2] = { { "CALI_CHANNEL_FLUSH_ON_EXIT", "false" }, { NULL, NULL } }; 6 | 7 | cali_configset_t cfg = cali_create_configset(channel_cfg); 8 | 9 | cali_configset_set(cfg, "CALI_SERVICES_ENABLE", "event,trace,recorder"); 10 | cali_configset_set(cfg, "CALI_RECORDER_FILENAME", "stdout"); 11 | 12 | cali_id_t chn_a = cali_create_channel("channel.a", 0, cfg); 13 | cali_id_t chn_b = cali_create_channel("channel.b", 0, cfg); 14 | 15 | cali_delete_configset(cfg); 16 | 17 | CALI_MARK_BEGIN("foo"); 18 | 19 | cali_set_int_byname("b", 4); 20 | 21 | cali_deactivate_channel(chn_b); 22 | cali_set_int_byname("a", 2); 23 | cali_end_byname("a"); 24 | cali_activate_channel(chn_b); 25 | 26 | cali_deactivate_channel(chn_a); 27 | cali_set_int_byname("c", 8); 28 | cali_end_byname("c"); 29 | cali_activate_channel(chn_a); 30 | 31 | CALI_MARK_END("foo"); 32 | 33 | cali_channel_flush(chn_a, 0); 34 | cali_channel_flush(chn_b, 0); 35 | 36 | cali_delete_channel(chn_a); 37 | cali_delete_channel(chn_b); 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /cmake/FindLibpfm.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # - Find libpfm 3 | # 4 | # LIBPFM_INCLUDE_DIR - Path to libpfm.h 5 | # LIBPFM_LIBRARY - List of libraries for using libpfm 6 | # LIBPFM_FOUND - True if libpfm was found 7 | 8 | set(LIBPFM_INSTALL "" CACHE PATH "libpfm install directory") 9 | 10 | if(LIBPFM_INSTALL) 11 | # install dir specified, only search them 12 | find_path(LIBPFM_INCLUDE_DIR "perfmon/pfmlib_perf_event.h" 13 | PATHS ${LIBPFM_INSTALL} ${LIBPFM_INSTALL}/include 14 | NO_DEFAULT_PATH) 15 | 16 | find_library(LIBPFM_LIBRARY pfm 17 | PATHS ${LIBPFM_INSTALL} ${LIBPFM_INSTALL}/lib 18 | NO_DEFAULT_PATH) 19 | else() 20 | # no install dir specified, look in default and PAPI 21 | find_path(LIBPFM_INCLUDE_DIR "perfmon/pfmlib_perf_event.h" 22 | HINTS ${PAPI_INCLUDE_DIRS} ${PAPI_INCLUDE_DIRS}/libpfm4/include) 23 | 24 | find_library(LIBPFM_LIBRARY pfm 25 | HINTS ${PAPI_LIBRARIES} ${PAPI_LIBRARIES}/libpfm4/include) 26 | endif() 27 | 28 | include(FindPackageHandleStandardArgs) 29 | find_package_handle_standard_args(Libpfm DEFAULT_MSG LIBPFM_LIBRARY LIBPFM_INCLUDE_DIR) 30 | 31 | mark_as_advanced(LIBPFM_LIBRARY LIBPFM_INCLUDE_DIR) 32 | -------------------------------------------------------------------------------- /include/caliper/reader/Preprocessor.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file Preprocessor.h 5 | /// \brief Defines the Preprocessor class 6 | 7 | #ifndef CALI_PREPROCESSOR_H 8 | #define CALI_PREPROCESSOR_H 9 | 10 | #include "QuerySpec.h" 11 | #include "RecordProcessor.h" 12 | 13 | #include 14 | #include 15 | 16 | namespace cali 17 | { 18 | 19 | class CaliperMetadataAccessInterface; 20 | 21 | /// \brief Preprocess %Caliper records. Handles the CalQL \a LET clause. 22 | /// \ingroup ReaderAPI 23 | 24 | class Preprocessor 25 | { 26 | struct PreprocessorImpl; 27 | std::shared_ptr mP; 28 | 29 | public: 30 | 31 | Preprocessor(const QuerySpec& spec); 32 | 33 | ~Preprocessor(); 34 | 35 | EntryList process(CaliperMetadataAccessInterface&, const EntryList&); 36 | 37 | void operator() (CaliperMetadataAccessInterface& db, const EntryList& rec, SnapshotProcessFn push) 38 | { 39 | push(db, process(db, rec)); 40 | } 41 | 42 | static const QuerySpec::FunctionSignature* preprocess_defs(); 43 | }; 44 | 45 | } // namespace cali 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/caliper/reader/RecordSelector.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file RecordSelector.h 5 | /// \brief Defines RecordSelector 6 | 7 | #ifndef CALI_RECORDSELECTOR_H 8 | #define CALI_RECORDSELECTOR_H 9 | 10 | #include "QuerySpec.h" 11 | #include "RecordProcessor.h" 12 | 13 | #include 14 | 15 | namespace cali 16 | { 17 | 18 | class CaliperMetadataAccessInterface; 19 | 20 | /// \brief Filter for snapshot records 21 | /// \ingroup ReaderAPI 22 | 23 | class RecordSelector 24 | { 25 | struct RecordSelectorImpl; 26 | std::shared_ptr mP; 27 | 28 | public: 29 | 30 | RecordSelector(const std::string& filter_string); 31 | RecordSelector(const QuerySpec& spec); 32 | RecordSelector(const QuerySpec::Condition& cond); 33 | 34 | ~RecordSelector(); 35 | 36 | bool pass(const CaliperMetadataAccessInterface&, const EntryList&); 37 | 38 | void operator() (CaliperMetadataAccessInterface&, const EntryList&, SnapshotProcessFn) const; 39 | 40 | static std::vector parse(const std::string&); 41 | }; 42 | 43 | } // namespace cali 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /test/ci_app_tests/test_file_io.py: -------------------------------------------------------------------------------- 1 | # File and directory creation test cases 2 | 3 | import os 4 | import unittest 5 | 6 | import calipertest as cat 7 | 8 | class CaliperFileIOTest(unittest.TestCase): 9 | """ Caliper file and directory creation test case """ 10 | 11 | def test_createdir(self): 12 | target_cmd = [ './ci_test_macros', '0', 'hatchet-region-profile,use.mpi=false,output.format=json,output=foo/bar/test.json' ] 13 | 14 | caliper_config = { 15 | 'CALI_LOG_VERBOSITY' : '0' 16 | } 17 | 18 | if os.path.exists('foo/bar/test.json'): 19 | os.remove('foo/bar/test.json') 20 | if os.path.exists('foo/bar'): 21 | os.removedirs('foo/bar') 22 | 23 | self.assertFalse(os.path.exists('foo/bar')) 24 | 25 | cat.run_test(target_cmd, caliper_config) 26 | 27 | self.assertTrue(os.path.isdir('foo/bar')) 28 | self.assertTrue(os.path.isfile('foo/bar/test.json')) 29 | 30 | if os.path.exists('foo/bar/test.json'): 31 | os.remove('foo/bar/test.json') 32 | if os.path.exists('foo/bar'): 33 | os.removedirs('foo/bar') 34 | 35 | 36 | if __name__ == "__main__": 37 | unittest.main() 38 | -------------------------------------------------------------------------------- /test/ci_app_tests/test_templateservices.py: -------------------------------------------------------------------------------- 1 | # Template service tests 2 | 3 | import unittest 4 | 5 | import calipertest as calitest 6 | 7 | class CaliperTemplateServicesTest(unittest.TestCase): 8 | """ Caliper template services test cases """ 9 | 10 | def test_measurement_template(self): 11 | target_cmd = [ './ci_test_basic' ] 12 | query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] 13 | 14 | caliper_config = { 15 | 'CALI_SERVICES_ENABLE' : 'event,measurement_template,trace,recorder', 16 | 'CALI_MEASUREMENT_TEMPLATE_NAMES' : 'ci_test', 17 | 'CALI_RECORDER_FILENAME' : 'stdout', 18 | 'CALI_LOG_VERBOSITY' : '0' 19 | } 20 | 21 | query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) 22 | snapshots = calitest.get_snapshots_from_text(query_output) 23 | 24 | self.assertTrue(len(snapshots) > 1) 25 | 26 | self.assertTrue(calitest.has_snapshot_with_keys( 27 | snapshots, { 'myphase', 28 | 'measurement.val.ci_test', 29 | 'measurement.ci_test' })) 30 | 31 | if __name__ == "__main__": 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /src/interface/python/instrumentation.h: -------------------------------------------------------------------------------- 1 | #ifndef CALI_INTERFACE_PYTHON_INSTRUMENTATION_H 2 | #define CALI_INTERFACE_PYTHON_INSTRUMENTATION_H 3 | 4 | #include "common.h" 5 | 6 | namespace cali 7 | { 8 | 9 | class PythonAttribute 10 | { 11 | public: 12 | 13 | PythonAttribute(const char* name, cali_attr_type type); 14 | 15 | PythonAttribute(const char* name, cali_attr_type type, cali_attr_properties opt); 16 | 17 | static PythonAttribute find_attribute(const char* name); 18 | 19 | const char* name() const; 20 | 21 | cali_attr_type type() const; 22 | 23 | cali_attr_properties properties() const; 24 | 25 | void begin(); 26 | 27 | void begin(int val); 28 | 29 | void begin(double val); 30 | 31 | void begin(const char* val); 32 | 33 | void set(int val); 34 | 35 | void set(double val); 36 | 37 | void set(const char* val); 38 | 39 | void end(); 40 | 41 | private: 42 | 43 | PythonAttribute(cali_id_t id); 44 | 45 | cali_id_t m_attr_id; 46 | }; 47 | 48 | // TODO add "byname" functions to module 49 | 50 | void create_caliper_instrumentation_mod(py::module_& caliper_instrumentation_mod); 51 | 52 | } // namespace cali 53 | 54 | #endif /* CALI_INTERFACE_PYTHON_INSTRUMENTATION_H */ -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | This work was produced under the auspices of the U.S. Department of 2 | Energy by Lawrence Livermore National Laboratory under Contract 3 | DE-AC52-07NA27344. 4 | 5 | This work was prepared as an account of work sponsored by an agency of 6 | the United States Government. Neither the United States Government nor 7 | Lawrence Livermore National Security, LLC, nor any of their employees 8 | makes any warranty, expressed or implied, or assumes any legal liability 9 | or responsibility for the accuracy, completeness, or usefulness of any 10 | information, apparatus, product, or process disclosed, or represents that 11 | its use would not infringe privately owned rights. 12 | 13 | Reference herein to any specific commercial product, process, or service 14 | by trade name, trademark, manufacturer, or otherwise does not necessarily 15 | constitute or imply its endorsement, recommendation, or favoring by the 16 | United States Government or Lawrence Livermore National Security, LLC. 17 | 18 | The views and opinions of authors expressed herein do not necessarily 19 | state or reflect those of the United States Government or Lawrence 20 | Livermore National Security, LLC, and shall not be used for advertising 21 | or product endorsement purposes. 22 | -------------------------------------------------------------------------------- /test/ci_app_tests/ci_test_collective_output_channel.cpp: -------------------------------------------------------------------------------- 1 | // Test CollectiveOutputChannel 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | int main(int argc, char* argv[]) 14 | { 15 | MPI_Init(&argc, &argv); 16 | 17 | int rank = 0; 18 | MPI_Comm_rank(MPI_COMM_WORLD, &rank); 19 | 20 | std::shared_ptr channel; 21 | std::string errmsg; 22 | 23 | std::tie(channel, errmsg) = cali::make_collective_output_channel(argc > 1 ? argv[1] : ""); 24 | 25 | if (!channel) { 26 | std::cerr << "Caliper error: " << errmsg << std::endl; 27 | MPI_Abort(MPI_COMM_WORLD, -1); 28 | } 29 | 30 | channel->start(); 31 | 32 | { 33 | CALI_CXX_MARK_FUNCTION; 34 | 35 | MPI_Barrier(MPI_COMM_WORLD); 36 | } 37 | 38 | channel->stop(); 39 | 40 | if (argc > 2 && strcmp(argv[2], "channel_defined_stream") == 0) 41 | channel->collective_flush(MPI_COMM_WORLD); 42 | else 43 | channel->collective_flush(std::cout, MPI_COMM_WORLD); 44 | 45 | MPI_Finalize(); 46 | } -------------------------------------------------------------------------------- /cmake/FindLibDw.cmake: -------------------------------------------------------------------------------- 1 | # Try to find LIBDW headers and libraries. 2 | # 3 | # Usage of this module as follows: 4 | # 5 | # find_package(ElfUtils) 6 | # 7 | # Variables used by this module, they can change the default behaviour and need 8 | # to be set before calling find_package: 9 | # 10 | # LIBDW_PREFIX Set this variable to the root installation of 11 | # libpapi if the module has problems finding the 12 | # proper installation path. 13 | # 14 | # Variables defined by this module: 15 | # 16 | # LIBDW_FOUND System has LIBDW libraries and headers 17 | # LIBDW_LIBRARIES The LIBDW library 18 | # LIBDW_INCLUDE_DIRS The location of LIBDW headers 19 | 20 | if (LIBDW_INCLUDE_DIR AND LIBDW_LIBRARY) 21 | set(LIBDW_FIND_QUIETLY true) 22 | endif() 23 | 24 | find_path(LIBDW_INCLUDE_DIR elfutils/libdw.h 25 | HINTS ${LIBDW_PREFIX}/include 26 | ) 27 | 28 | find_library(LIBDW_LIBRARY 29 | NAMES dw 30 | HINTS ${LIBDW_PREFIX}/lib 31 | ) 32 | 33 | include(FindPackageHandleStandardArgs) 34 | find_package_handle_standard_args(LIBDW DEFAULT_MSG 35 | LIBDW_LIBRARY 36 | LIBDW_INCLUDE_DIR 37 | ) 38 | 39 | mark_as_advanced( 40 | LIBDW_INCLUDE_DIR 41 | LIBDW_LIBRARY 42 | ) 43 | -------------------------------------------------------------------------------- /cmake/FindPAPI.cmake: -------------------------------------------------------------------------------- 1 | # Try to find PAPI headers and libraries. 2 | # 3 | # Usage of this module as follows: 4 | # 5 | # find_package(PAPI) 6 | # 7 | # Variables used by this module, they can change the default behaviour and need 8 | # to be set before calling find_package: 9 | # 10 | # PAPI_PREFIX Set this variable to the root installation of 11 | # libpapi if the module has problems finding the 12 | # proper installation path. 13 | # 14 | # Variables defined by this module: 15 | # 16 | # PAPI_FOUND System has PAPI libraries and headers 17 | # PAPI_LIBRARIES The PAPI library 18 | # PAPI_INCLUDE_DIRS The location of PAPI headers 19 | 20 | find_path(PAPI_PREFIX 21 | NAMES include/papi.h 22 | ) 23 | 24 | find_library(PAPI_LIBRARIES 25 | NAMES papi 26 | HINTS ${PAPI_PREFIX}/lib 27 | ) 28 | 29 | find_path(PAPI_INCLUDE_DIRS 30 | NAMES papi.h 31 | HINTS ${PAPI_PREFIX}/include 32 | ) 33 | 34 | include(FindPackageHandleStandardArgs) 35 | find_package_handle_standard_args(PAPI DEFAULT_MSG 36 | PAPI_LIBRARIES 37 | PAPI_INCLUDE_DIRS 38 | ) 39 | 40 | mark_as_advanced( 41 | PAPI_PREFIX_DIRS 42 | PAPI_LIBRARIES 43 | PAPI_INCLUDE_DIRS 44 | ) 45 | -------------------------------------------------------------------------------- /test/ci_app_tests/ci_test_mpi_before_cali.cpp: -------------------------------------------------------------------------------- 1 | // Test Caliper MPI runtime: mpi init before caliper init 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MPI_Init(&argc, &argv); 11 | 12 | int rank = 0; 13 | MPI_Comm_rank(MPI_COMM_WORLD, &rank); 14 | 15 | cali::ConfigManager mgr; 16 | 17 | if (argc > 1) 18 | mgr.add(argv[1]); 19 | if (mgr.error()) { 20 | if (rank == 0) 21 | std::cerr << mgr.error_msg() << std::endl; 22 | 23 | MPI_Abort(MPI_COMM_WORLD, -1); 24 | } 25 | 26 | mgr.start(); 27 | 28 | { 29 | CALI_CXX_MARK_FUNCTION; 30 | 31 | // some MPI functions to test the wrapper blacklist/whitelist 32 | 33 | MPI_Barrier(MPI_COMM_WORLD); 34 | 35 | int val = 42; 36 | 37 | MPI_Bcast(&val, 1, MPI_INT, 0, MPI_COMM_WORLD); 38 | 39 | int in = val, out; 40 | CALI_MARK_COMM_REGION_BEGIN("reduction"); 41 | MPI_Reduce(&in, &out, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); 42 | MPI_Barrier(MPI_COMM_WORLD); 43 | CALI_MARK_COMM_REGION_END("reduction"); 44 | } 45 | 46 | mgr.flush(); 47 | 48 | MPI_Finalize(); 49 | } 50 | -------------------------------------------------------------------------------- /include/caliper/reader/FlatExclusiveRegionProfile.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file FlatExclusiveRegionProfile.h 5 | /// FlatExclusiveRegionProfile class 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace cali 16 | { 17 | 18 | class CaliperMetadataAccessInterface; 19 | class Entry; 20 | 21 | /// \brief Calculate a flat exclusive region profile 22 | class FlatExclusiveRegionProfile 23 | { 24 | struct FlatExclusiveRegionProfileImpl; 25 | std::shared_ptr mP; 26 | 27 | public: 28 | 29 | FlatExclusiveRegionProfile( 30 | CaliperMetadataAccessInterface& db, 31 | const char* metric_attr_name, 32 | const char* region_attr_name = "" 33 | ); 34 | 35 | void operator() (CaliperMetadataAccessInterface& db, const std::vector& rec); 36 | 37 | /// \brief Return tuple with { { region name -> value } map, sum in given region type, total sum } 38 | std::tuple, double, double> result() const; 39 | }; 40 | 41 | } // namespace cali 42 | -------------------------------------------------------------------------------- /include/caliper/reader/FlatInclusiveRegionProfile.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file FlatInclusiveRegionProfile.h 5 | /// FlatInclusiveRegionProfile class 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace cali 16 | { 17 | 18 | class CaliperMetadataAccessInterface; 19 | class Entry; 20 | 21 | /// \brief Calculate a flat exclusive region profile 22 | class FlatInclusiveRegionProfile 23 | { 24 | struct FlatInclusiveRegionProfileImpl; 25 | std::shared_ptr mP; 26 | 27 | public: 28 | 29 | FlatInclusiveRegionProfile( 30 | CaliperMetadataAccessInterface& db, 31 | const char* metric_attr_name, 32 | const char* region_attr_name = "" 33 | ); 34 | 35 | void operator() (CaliperMetadataAccessInterface& db, const std::vector& rec); 36 | 37 | /// \brief Return tuple with { { region name -> value } map, sum in given region type, total sum } 38 | std::tuple, double, double> result() const; 39 | }; 40 | 41 | } // namespace cali 42 | -------------------------------------------------------------------------------- /test/ci_app_tests/test_callpath.py: -------------------------------------------------------------------------------- 1 | # callpath service tests 2 | 3 | import unittest 4 | 5 | import calipertest as cat 6 | 7 | class CaliperCallpathTest(unittest.TestCase): 8 | """ Caliper callpath smoketest """ 9 | 10 | def test_callpath(self): 11 | target_cmd = [ './ci_test_alloc' ] 12 | query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] 13 | 14 | caliper_config = { 15 | 'CALI_SERVICES_ENABLE' : 'callpath,trace,recorder', 16 | 'CALI_CALLPATH_USE_NAME' : 'true', 17 | 'CALI_RECORDER_FILENAME' : 'stdout', 18 | 'CALI_LOG_VERBOSITY' : '0' 19 | } 20 | 21 | query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) 22 | snapshots = cat.get_snapshots_from_text(query_output) 23 | 24 | self.assertTrue(len(snapshots) == 3) 25 | 26 | self.assertTrue(cat.has_snapshot_with_keys( 27 | snapshots, { 'callpath.address', 'callpath.regname', 'test_alloc.allocated.0', 'region' })) 28 | 29 | sreg = cat.get_snapshot_with_keys(snapshots, { 'callpath.regname', 'test_alloc.allocated.0' }) 30 | 31 | self.assertTrue('main' in sreg.get('callpath.regname')) 32 | 33 | if __name__ == "__main__": 34 | unittest.main() 35 | -------------------------------------------------------------------------------- /doc/sphinx/examples/snapshot-api.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Caliper snapshot processing example 3 | */ 4 | 5 | #include 6 | 7 | #include 8 | 9 | struct list_elem { 10 | cali_id_t attr_id; 11 | const char* attr_name; 12 | cali_variant_t val; 13 | list_elem* next; 14 | } 15 | 16 | int append_to_list(void* arg, cali_id_t attr_id, cali_variant_t val) 17 | { 18 | struct list_elem* elem = malloc(sizeof(struct list_elem)); 19 | 20 | elem.attr_id = attr_id; 21 | elem.attr_name = cali_attribute_name(attr_id); 22 | elem.val = val; 23 | 24 | struct list_elem** ptr = (struct list_elem**) arg; 25 | 26 | elem.next = *ptr; 27 | *ptr = elem; 28 | 29 | return 0; /* continue unpacking */ 30 | } 31 | 32 | 33 | int main() 34 | { 35 | unsigned char buf[256]; 36 | size_t snap_len = 0; 37 | 38 | snap_len = cali_sigsafe_pull_snapshot(CALI_SCOPE_THREAD, 256, buf, 39 | 0, NULL, NULL, NULL); 40 | 41 | if (snap_len > 255) 42 | fprintf(stderr, "Insufficient snapshot buffer space, contents cut\n"); 43 | 44 | if (snap_len > 0) { 45 | struct list_elem* list = NULL; 46 | 47 | cali_unpack_snapshot(buf, append_to_list, &list); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /include/caliper/reader/Aggregator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file Aggregator.h 5 | /// \brief Defines the Aggregator class 6 | 7 | #ifndef CALI_AGGREGATOR_H 8 | #define CALI_AGGREGATOR_H 9 | 10 | #include "QuerySpec.h" 11 | #include "RecordProcessor.h" 12 | 13 | #include 14 | #include 15 | 16 | namespace cali 17 | { 18 | 19 | class CaliperMetadataAccessInterface; 20 | 21 | /// \brief Perform aggregation operations on Caliper data 22 | /// \ingroup ReaderAPI 23 | 24 | class Aggregator 25 | { 26 | struct AggregatorImpl; 27 | std::shared_ptr mP; 28 | 29 | public: 30 | 31 | Aggregator(const QuerySpec& spec); 32 | 33 | ~Aggregator(); 34 | 35 | void add(CaliperMetadataAccessInterface&, const EntryList&); 36 | 37 | void operator() (CaliperMetadataAccessInterface& db, const EntryList& list) { add(db, list); } 38 | 39 | void flush(CaliperMetadataAccessInterface&, SnapshotProcessFn push); 40 | 41 | static const QuerySpec::FunctionSignature* aggregation_defs(); 42 | 43 | static std::string get_aggregation_attribute_name(const QuerySpec::AggregationOp& op); 44 | }; 45 | 46 | } // namespace cali 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/caliper/reader/NestedExclusiveRegionProfile.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file NestedExclusiveRegionProfile.h 5 | /// NestedExclusiveRegionProfile class 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace cali 16 | { 17 | 18 | class CaliperMetadataAccessInterface; 19 | class Entry; 20 | 21 | /// \brief Calculate a flat exclusive region profile 22 | class NestedExclusiveRegionProfile 23 | { 24 | struct NestedExclusiveRegionProfileImpl; 25 | std::shared_ptr mP; 26 | 27 | public: 28 | 29 | NestedExclusiveRegionProfile( 30 | CaliperMetadataAccessInterface& db, 31 | const char* metric_attr_name, 32 | const char* region_attr_name = "" 33 | ); 34 | 35 | void operator() (CaliperMetadataAccessInterface& db, const std::vector& rec); 36 | 37 | /// \brief Return tuple with { { region name -> value } map, sum in given region type, total sum } 38 | std::tuple, double, double> result() const; 39 | }; 40 | 41 | } // namespace cali 42 | -------------------------------------------------------------------------------- /include/caliper/reader/NestedInclusiveRegionProfile.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file NestedInclusiveRegionProfile.h 5 | /// NestedInclusiveRegionProfile class 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace cali 16 | { 17 | 18 | class CaliperMetadataAccessInterface; 19 | class Entry; 20 | 21 | /// \brief Calculate a flat exclusive region profile 22 | class NestedInclusiveRegionProfile 23 | { 24 | struct NestedInclusiveRegionProfileImpl; 25 | std::shared_ptr mP; 26 | 27 | public: 28 | 29 | NestedInclusiveRegionProfile( 30 | CaliperMetadataAccessInterface& db, 31 | const char* metric_attr_name, 32 | const char* region_attr_name = "" 33 | ); 34 | 35 | void operator() (CaliperMetadataAccessInterface& db, const std::vector& rec); 36 | 37 | /// \brief Return tuple with { { region name -> value } map, sum in given region type, total sum } 38 | std::tuple, double, double> result() const; 39 | }; 40 | 41 | } // namespace cali 42 | -------------------------------------------------------------------------------- /test/ci_app_tests/ci_test_mpi_channel_manager.cpp: -------------------------------------------------------------------------------- 1 | // Test MpiChannelManager 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | int main(int argc, char* argv[]) 16 | { 17 | MPI_Init(&argc, &argv); 18 | 19 | int worldrank = 0; 20 | MPI_Comm subcomm; 21 | MPI_Comm_rank(MPI_COMM_WORLD, &worldrank); 22 | MPI_Comm_split(MPI_COMM_WORLD, worldrank % 2, worldrank, &subcomm); 23 | 24 | cali::ConfigManager mgr; 25 | if (argc > 1) 26 | mgr.add(argv[1]); 27 | 28 | if (mgr.error()) { 29 | std::cerr << "Caliper error: " << mgr.error_msg() << std::endl; 30 | MPI_Abort(MPI_COMM_WORLD, -1); 31 | } 32 | 33 | cali::MpiChannelManager mpimgr(subcomm); 34 | mpimgr.add(mgr); 35 | mpimgr.start(); 36 | 37 | { 38 | CALI_CXX_MARK_FUNCTION; 39 | 40 | MPI_Barrier(subcomm); 41 | } 42 | 43 | MPI_Barrier(MPI_COMM_WORLD); 44 | 45 | mpimgr.stop(); 46 | 47 | if (worldrank % 2 == 0) 48 | mpimgr.collective_flush(); 49 | 50 | MPI_Comm_free(&subcomm); 51 | MPI_Finalize(); 52 | } -------------------------------------------------------------------------------- /src/caliper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_RUNTIME_SOURCES 2 | Annotation.cpp 3 | AnnotationBinding.cpp 4 | AsyncEvent.cpp 5 | Blackboard.cpp 6 | Caliper.cpp 7 | ChannelController.cpp 8 | ConfigManager.cpp 9 | CustomOutputController.cpp 10 | MemoryPool.cpp 11 | MetadataTree.cpp 12 | RegionFilter.cpp 13 | RegionProfile.cpp 14 | api.cpp 15 | builtin_configmanager.cpp 16 | cali.cpp 17 | cali_datatracker.cpp 18 | config_sanity_check.cpp) 19 | 20 | if (CALIPER_HAVE_MPI) 21 | list(APPEND CALIPER_RUNTIME_SOURCES 22 | aggregate_over_mpi.cpp 23 | collective_flush.cpp 24 | CollectiveOutputChannel.cpp 25 | OutputCommMpi.cpp 26 | MpiChannelManager.cpp 27 | machine_mpi.cpp 28 | setup_mpi.cpp) 29 | else() 30 | list(APPEND CALIPER_RUNTIME_SOURCES 31 | machine_serial.cpp 32 | setup_serial.cpp) 33 | endif() 34 | 35 | add_subdirectory(controllers) 36 | 37 | add_library(caliper-runtime OBJECT ${CALIPER_RUNTIME_SOURCES}) 38 | 39 | target_compile_options(caliper-runtime PRIVATE ${Wall_flag}) 40 | target_compile_features(caliper-runtime PUBLIC cxx_std_11) 41 | 42 | if (CALIPER_HAVE_MPI) 43 | target_include_directories(caliper-runtime PRIVATE ${MPI_CXX_INCLUDE_PATH}) 44 | endif() 45 | 46 | if (BUILD_TESTING) 47 | add_subdirectory(test) 48 | endif() 49 | -------------------------------------------------------------------------------- /src/interface/c_fortran/wrapScopeAnnotation.cpp: -------------------------------------------------------------------------------- 1 | // wrapScopeAnnotation.cpp 2 | // This file is generated by Shroud 0.13.0. Do not edit. 3 | 4 | #include "caliper/cali.h" 5 | #include 6 | #include "wrapScopeAnnotation.h" 7 | 8 | // splicer begin class.ScopeAnnotation.CXX_definitions 9 | // splicer end class.ScopeAnnotation.CXX_definitions 10 | 11 | extern "C" 12 | { 13 | 14 | // splicer begin class.ScopeAnnotation.C_definitions 15 | // splicer end class.ScopeAnnotation.C_definitions 16 | 17 | cali_ScopeAnnotation* cali_ScopeAnnotation_begin(const char* name, cali_ScopeAnnotation* SHC_rv) 18 | { 19 | // splicer begin class.ScopeAnnotation.method.begin 20 | cali::ScopeAnnotation* SHCXX_rv = new cali::ScopeAnnotation(name); 21 | SHC_rv->addr = static_cast(SHCXX_rv); 22 | SHC_rv->idtor = 1; 23 | return SHC_rv; 24 | // splicer end class.ScopeAnnotation.method.begin 25 | } 26 | 27 | void cali_ScopeAnnotation_end(cali_ScopeAnnotation* self) 28 | { 29 | cali::ScopeAnnotation* SH_this = static_cast(self->addr); 30 | // splicer begin class.ScopeAnnotation.method.end 31 | delete SH_this; 32 | self->addr = nullptr; 33 | // splicer end class.ScopeAnnotation.method.end 34 | } 35 | 36 | } // extern "C" 37 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | dist: bionic 3 | os: linux 4 | 5 | addons: 6 | apt: 7 | sources: 8 | - ubuntu-toolchain-r-test 9 | packages: 10 | - openmpi-bin 11 | - libopenmpi-dev 12 | - libunwind-dev 13 | - libdw-dev 14 | - gfortran 15 | 16 | # The base build matrix 17 | compiler: 18 | - gcc 19 | - clang 20 | env: 21 | - WITH_MPI=On WITH_FORTRAN=Off WITH_GOTCHA=On 22 | - WITH_MPI=On WITH_FORTRAN=Off WITH_GOTCHA=Off 23 | 24 | # Add explicit job for mpi off, fortran on, and coverage 25 | jobs: 26 | include: 27 | - compiler: gcc 28 | env: WITH_MPI=Off WITH_FORTRAN=On WITH_GOTCHA=On COVERAGE="-DCMAKE_C_FLAGS=-coverage -DCMAKE_CXX_FLAGS=-coverage" 29 | 30 | script: 31 | - basedir=$(pwd) 32 | - cd $basedir/python/caliper-reader 33 | - python -B -m unittest discover -s tests/ 34 | - mkdir $basedir/build && cd $basedir/build 35 | - cmake -C ../cmake/hostconfig/travis.cmake ${COVERAGE} -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} -DWITH_FORTRAN=${WITH_FORTRAN} -DWITH_MPI=${WITH_MPI} -DWITH_GOTCHA=${WITH_GOTCHA} .. 36 | - make -j8 37 | - export OMPI_MCA_btl_base_warn_component_unused=0 38 | - ctest --output-on-failure 39 | 40 | after_success: 41 | - if [[ -n "${COVERAGE}" ]] ; then bash <(curl -s https://codecov.io/bash) ; fi 42 | -------------------------------------------------------------------------------- /test/ci_app_tests/ci_test_basic.cpp: -------------------------------------------------------------------------------- 1 | // --- Caliper continuous integration test app for C++ annotation class 2 | 3 | #include "caliper/cali.h" 4 | 5 | #include 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | std::map metadata = { { "meta.int", cali::Variant(42) } }; 10 | 11 | // Test proper escaping 12 | cali_set_string_byname(" =\\weird \"\"attribute\"= ", " \\\\ weird,\" name\","); 13 | cali_set_global_string_byname(" =\\weird \"\" global attribute\"= ", " \\\\ weird,\" name\","); 14 | 15 | if (argc > 1 && strcmp(argv[1], "newline") == 0) 16 | cali_set_string_byname("newline", "A newline:\n!"); 17 | 18 | cali::Annotation phase_ann("myphase", metadata); 19 | std::size_t size = 8; 20 | cali::Annotation size_annot("dgs"); 21 | size_annot.begin(size); 22 | phase_ann.begin("initialization"); 23 | const int count = 4; 24 | phase_ann.end(); 25 | 26 | cali::Annotation copy_ann = phase_ann; 27 | copy_ann.begin("loop"); 28 | 29 | cali::Annotation iter_ann("iteration", CALI_ATTR_ASVALUE); 30 | iter_ann.begin(uint64_t(5)); 31 | for (int i = 0; i < count; ++i) { 32 | cali::Annotation::Guard g_iter_ann(iter_ann.begin(i)); 33 | } 34 | 35 | phase_ann = copy_ann; 36 | phase_ann.end(); 37 | } 38 | -------------------------------------------------------------------------------- /.gitlab/jobs/lassen.yml: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Copyright (c) 2022-23, Lawrence Livermore National Security, LLC and RADIUSS 3 | # project contributors. See the COPYRIGHT file for details. 4 | # 5 | # SPDX-License-Identifier: (MIT) 6 | ############################################################################## 7 | 8 | # Override reproducer section to define project specific variables. 9 | .lassen_reproducer_vars: 10 | script: 11 | - !reference [.reproducer_vars, script] 12 | 13 | # With GitLab CI, included files cannot be empty. 14 | variables: 15 | INCLUDED_FILE_CANNOT_BE_EMPTY: "True" 16 | 17 | ######################## 18 | # Overridden shared jobs 19 | ######################## 20 | # We duplicate the shared jobs description and add necessary changes for RAJA. 21 | # We keep ${PROJECT__VARIANTS} and ${PROJECT__DEPS} So that 22 | # the comparison with the original job is easier. 23 | 24 | # No overridden jobs so far. 25 | 26 | ############ 27 | # Extra jobs 28 | ############ 29 | # We do not recommend using ${PROJECT__VARIANTS} and 30 | # ${PROJECT__DEPS} in the extra jobs. There is not reason not to fully 31 | # describe the spec here. 32 | 33 | master: 34 | variables: 35 | SPEC: " +tests" 36 | extends: .job_on_lassen 37 | -------------------------------------------------------------------------------- /src/services/templates/README.md: -------------------------------------------------------------------------------- 1 | # Caliper Service Templates 2 | 3 | The service templates serve as templates, demos, and documentation for aspiring 4 | Caliper service developers. 5 | 6 | ## MeasurementService 7 | 8 | The MeasurementService template demonstrates a performance measurement service 9 | (e.g., for reading hardware counters, timestamps, and other kinds of 10 | performance data at runtime). It implements the `snapshot` callback for adding 11 | data to Caliper snapshot records. 12 | 13 | To try it out, build Caliper with testing turned on: 14 | 15 | $ mkdir build && cd build 16 | $ cmake -DBUILD_TESTING=On .. 17 | $ make 18 | $ make cxx-example 19 | 20 | Try it using the cxx-example app: 21 | 22 | $ CALI_SERVICES_ENABLE=event,measurement_template,trace,report \ 23 | CALI_MEASUREMENT_TEMPLATE_NAMES=test \ 24 | CALI_REPORT_CONFIG="select max(measurement.val.test),sum(measurement.test) group by prop:nested format tree" \ 25 | ./examples/apps/cxx-example none 26 | Path max#measurement.val.test sum#measurement.test 27 | main 708 260 28 | mainloop 684 220 29 | foo 648 72 30 | init 272 44 31 | -------------------------------------------------------------------------------- /cmake/FindVariorum.cmake: -------------------------------------------------------------------------------- 1 | # Try to find Variorum headers and libraries. 2 | # 3 | # Usage of this module as follows: 4 | # 5 | # find_package(Variorum) 6 | # 7 | # Variables used by this module, they can change the default behaviour and need 8 | # to be set before calling find_package: 9 | # 10 | # VARIORUM_PREFIX Set this variable to the root installation of 11 | # libvariorum if the module has problems finding the 12 | # proper installation path. 13 | # 14 | # Variables defined by this module: 15 | # 16 | # VARIORUM_FOUND System has Variorum libraries and headers 17 | # VARIORUM_LIBRARIES The Variorum PAPI library 18 | # VARIORUM_INCLUDE_DIRS The location of Variorum header 19 | 20 | find_path(VARIORUM_PREFIX 21 | NAMES include/variorum.h 22 | ) 23 | 24 | find_library(VARIORUM_LIBRARIES 25 | NAMES variorum 26 | HINTS ${VARIORUM_PREFIX}/lib 27 | ) 28 | 29 | find_path(VARIORUM_INCLUDE_DIRS 30 | NAMES variorum.h 31 | HINTS ${VARIORUM_PREFIX}/include 32 | ) 33 | 34 | include(FindPackageHandleStandardArgs) 35 | find_package_handle_standard_args(VARIORUM DEFAULT_MSG 36 | VARIORUM_LIBRARIES 37 | VARIORUM_INCLUDE_DIRS 38 | ) 39 | 40 | mark_as_advanced( 41 | VARIORUM_PREFIX_DIRS 42 | VARIORUM_LIBRARIES 43 | VARIORUM_INCLUDE_DIRS 44 | ) 45 | -------------------------------------------------------------------------------- /examples/configs/papi_tot_ins.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": [ 3 | { "name" : "tot_ins", 4 | "description" : "Instructions", 5 | "category" : "metric", 6 | "services" : [ "papi" ], 7 | "config" : { "CALI_PAPI_COUNTERS": "PAPI_TOT_INS" }, 8 | "query" : [ 9 | { "level": "local", "select": [ "sum(sum#papi.PAPI_TOT_INS) as Instr." ] }, 10 | { "level": "cross", "select": [ 11 | "avg(sum#sum#papi.PAPI_TOT_INS) as \"Instr. (avg)\"", 12 | "sum(sum#sum#papi.PAPI_TOT_INS) as \"Instr. (total)\"" 13 | ] 14 | } 15 | ] 16 | }, 17 | { "name" : "ref_cyc", 18 | "description" : "Cycles", 19 | "category" : "metric", 20 | "services" : [ "papi" ], 21 | "config" : { "CALI_PAPI_COUNTERS": "PAPI_REF_CYC" }, 22 | "query" : [ 23 | { "level": "local", "select": [ "sum(sum#papi.PAPI_REF_CYC) as Cycles" ] }, 24 | { "level": "cross", "select": [ 25 | "avg(sum#sum#papi.PAPI_REF_CYC) as \"Cycles (avg)\"", 26 | "sum(sum#sum#papi.PAPI_REF_CYC) as \"Cycles (total)\"" 27 | ] 28 | } 29 | ] 30 | } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /examples/apps/cali-perfproblem-branch-mispred.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024, Lawrence Livermore National Security, LLC. 2 | # See top-level LICENSE file for details. 3 | 4 | from pycaliper.high_level import annotate_function 5 | from pycaliper.annotation import Annotation 6 | 7 | import numpy as np 8 | 9 | @annotate_function() 10 | def init(arraySize: int, sort: bool) -> np.array: 11 | data = np.random.randint(256, size=arraySize) 12 | if sort: 13 | data = np.sort(data) 14 | return data 15 | 16 | 17 | @annotate_function() 18 | def work(data: np.array): 19 | data_sum = 0 20 | for _ in range(100): 21 | for val in np.nditer(data): 22 | if val >= 128: 23 | data_sum += val 24 | print("sum =", data_sum) 25 | 26 | 27 | @annotate_function() 28 | def benchmark(arraySize: int, sort: bool): 29 | sorted_ann = Annotation("sorted") 30 | sorted_ann.set(sort) 31 | print("Intializing benchmark data with sort =", sort) 32 | data = init(arraySize, sort) 33 | print("Calculating sum of values >= 128") 34 | work(data) 35 | print("Done!") 36 | sorted_ann.end() 37 | 38 | 39 | @annotate_function() 40 | def main(): 41 | arraySize = 32768 42 | benchmark(arraySize, True) 43 | benchmark(arraySize, False) 44 | 45 | 46 | if __name__ == "__main__": 47 | main() 48 | 49 | -------------------------------------------------------------------------------- /doc/sphinx/examples/cali-print-agg-format-title.output: -------------------------------------------------------------------------------- 1 | Main Factorial Time 2 | init 1813 3 | body/init 114 4 | body/loop 1214 5 | body/loop 529 6 | body/loop init 215 7 | body/loop init 15 8 | body/loop init 15 9 | body/loop comp/init 101 10 | body/loop init 15 11 | body/loop comp/init 36 12 | body/loop comp/comp/init 37 13 | body/loop init 14 14 | body/loop comp/init 36 15 | body/loop comp/comp/init 36 16 | body/loop comp/comp/comp/init 36 17 | body/loop comp 21 18 | body/loop comp 14 19 | body/loop comp/comp 16 20 | body/loop comp/comp/comp 14 21 | body/loop comp/comp/comp/comp 14 22 | body/loop 69 23 | body/loop 183 24 | body/loop 164 25 | body/loop 210 26 | body/conclusion 37 27 | -------------------------------------------------------------------------------- /doc/sphinx/examples/cali-print-agg-format.output: -------------------------------------------------------------------------------- 1 | main factorial time.inclusive.duration 2 | init 1813 3 | body/init 114 4 | body/loop 1214 5 | body/loop 529 6 | body/loop init 215 7 | body/loop init 15 8 | body/loop init 15 9 | body/loop comp/init 101 10 | body/loop init 15 11 | body/loop comp/init 36 12 | body/loop comp/comp/init 37 13 | body/loop init 14 14 | body/loop comp/init 36 15 | body/loop comp/comp/init 36 16 | body/loop comp/comp/comp/init 36 17 | body/loop comp 21 18 | body/loop comp 14 19 | body/loop comp/comp 16 20 | body/loop comp/comp/comp 14 21 | body/loop comp/comp/comp/comp 14 22 | body/loop 69 23 | body/loop 183 24 | body/loop 164 25 | body/loop 210 26 | body/conclusion 37 27 | -------------------------------------------------------------------------------- /src/interface/c_fortran/wrapAnnotation.h: -------------------------------------------------------------------------------- 1 | // wrapAnnotation.h 2 | // This file is generated by Shroud 0.13.0. Do not edit. 3 | /** 4 | * \file wrapAnnotation.h 5 | * \brief Shroud generated wrapper for Annotation class 6 | */ 7 | // For C users and C++ implementation 8 | 9 | #ifndef WRAPANNOTATION_H 10 | #define WRAPANNOTATION_H 11 | 12 | #include "typesCaliper.h" 13 | 14 | // splicer begin class.Annotation.CXX_declarations 15 | // splicer end class.Annotation.CXX_declarations 16 | 17 | #ifdef __cplusplus 18 | extern "C" 19 | { 20 | #endif 21 | 22 | // splicer begin class.Annotation.C_declarations 23 | // splicer end class.Annotation.C_declarations 24 | 25 | cali_Annotation* cali_Annotation_new(const char* key, cali_Annotation* SHC_rv); 26 | 27 | cali_Annotation* cali_Annotation_new_with_properties(const char* key, int properties, cali_Annotation* SHC_rv); 28 | 29 | void cali_Annotation_delete(cali_Annotation* self); 30 | 31 | void cali_Annotation_begin_int(cali_Annotation* self, int val); 32 | 33 | void cali_Annotation_begin_string(cali_Annotation* self, const char* val); 34 | 35 | void cali_Annotation_set_int(cali_Annotation* self, int val); 36 | 37 | void cali_Annotation_set_string(cali_Annotation* self, const char* val); 38 | 39 | void cali_Annotation_end(cali_Annotation* self); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif // WRAPANNOTATION_H 46 | -------------------------------------------------------------------------------- /ext/gotcha/src/library_filters.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of GOTCHA. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/LLNL/gotcha/blob/master/COPYRIGHT 5 | This program is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU Lesser General Public License (as published by the Free 7 | Software Foundation) version 2.1 dated February 1999. This program is 8 | distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 9 | without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR 10 | PURPOSE. See the terms and conditions of the GNU Lesser General Public License 11 | for more details. You should have received a copy of the GNU Lesser General 12 | Public License along with this program; if not, write to the Free Software 13 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 14 | */ 15 | 16 | // TODO: Determine whether this interface should stay on in this form 17 | 18 | #ifndef GOTCHA_LIBRARY_FILTERS_H 19 | #define GOTCHA_LIBRARY_FILTERS_H 20 | #include 21 | 22 | #include "gotcha_utils.h" 23 | 24 | int alwaysTrue(struct link_map *candidate KNOWN_UNUSED); 25 | extern int (*libraryFilterFunc)(struct link_map *); 26 | 27 | int trueIfNameMatches(struct link_map *target); 28 | int trueIfLast(struct link_map *target); 29 | #endif 30 | -------------------------------------------------------------------------------- /src/services/mpit/pvars_openmpi: -------------------------------------------------------------------------------- 1 | = CALIPER: PVAR at index: 0 with name: mpool_hugepage_bytes_allocated has a class: MPI_T_PVAR_CLASS_SIZE 2 | == CALIPER: PVAR at index: 0 with name: mpool_hugepage_bytes_allocated has description: Number of bytes currently allocated in the mpool hugepage component 3 | == CALIPER: PVAR at index: 1 with name: osc_rdma_put_retry_count has a class: MPI_T_PVAR_CLASS_COUNTER 4 | == CALIPER: PVAR at index: 1 with name: osc_rdma_put_retry_count has description: Number of times put transaction were retried due to resource limitations 5 | == CALIPER: PVAR at index: 1 with name: osc_rdma_put_retry_count is bound to an MPI object of type MPI_T_BIND_MPI_WIN. Not doing anything here. 6 | == CALIPER: PVAR at index: 2 with name: osc_rdma_get_retry_count has a class: MPI_T_PVAR_CLASS_COUNTER 7 | == CALIPER: PVAR at index: 2 with name: osc_rdma_get_retry_count has description: Number of times get transaction were retried due to resource limitations 8 | == CALIPER: PVAR at index: 2 with name: osc_rdma_get_retry_count is bound to an MPI object of type MPI_T_BIND_MPI_WIN. Not doing anything here. 9 | == CALIPER: PVAR at index: 3 with name: pml_monitoring_flush has a 10 | 11 | ===FAILURE at this point!====== 12 | OpenMPI exports 20 variables overall, but fails when allocating handles for PVARs bound to MPI_COMM objects. See "KNOWN_BUGS" file for more info 13 | =============================== 14 | -------------------------------------------------------------------------------- /include/caliper/reader/CalQLParser.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file CalQLParser.h 5 | /// \brief CalQLParser definition 6 | 7 | #pragma once 8 | 9 | #include "QuerySpec.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace cali 16 | { 17 | 18 | /// \brief Create a QuerySpec specification from a given %CalQL expression. 19 | /// \ingroup ReaderAPI 20 | 21 | class CalQLParser 22 | { 23 | struct CalQLParserImpl; 24 | std::unique_ptr mP; 25 | 26 | public: 27 | 28 | /// \brief Read %CalQL expression from the given input stream \a is. 29 | CalQLParser(std::istream& is); 30 | /// \brief Read %CalQL expression from \a str. 31 | CalQLParser(const char* str); 32 | 33 | ~CalQLParser(); 34 | 35 | /// \brief Indicate if there was an error parsing the %CalQL expression. 36 | bool error() const; 37 | 38 | /// \brief Approximate position of a parser error in the given string or stream. 39 | std::istream::pos_type error_pos(); 40 | 41 | /// \brief A descriptive error message in case of a parse error. 42 | std::string error_msg() const; 43 | 44 | /// \brief Returns the query specification object for the given %CalQL expression. 45 | QuerySpec spec() const; 46 | }; 47 | 48 | } // namespace cali 49 | -------------------------------------------------------------------------------- /doc/sphinx/ConfigManagerAPI.rst: -------------------------------------------------------------------------------- 1 | ConfigManager API reference 2 | =============================== 3 | 4 | Caliper provides several built-in performance measurement and reporting 5 | configurations. These can be activated from within a program with the 6 | `ConfigManager` API using a short configuration string. Configuration 7 | strings can be hard-coded in the program or provided by the user in some 8 | form, e.g. as a command-line parameter or in the programs's configuration 9 | file. 10 | 11 | To access and control the built-in configurations, create a 12 | :cpp:class:`cali::ConfigManager` object. Add a configuration string with `add()`, 13 | start the requested configuration channels with `start()`, and trigger 14 | output with `flush()`: 15 | 16 | .. code-block:: c++ 17 | 18 | #include 19 | 20 | int main(int argc, char* argv[]) 21 | { 22 | cali::ConfigManager mgr; 23 | 24 | if (argc > 1) 25 | mgr.add(argv[1]); 26 | if (mgr.error()) 27 | std::cerr << "Config error: " << mgr.error_msg() << std::endl; 28 | // ... 29 | mgr.start(); // start requested performance measurement channels 30 | // ... (program execution) 31 | mgr.flush(); // write performance results 32 | } 33 | 34 | 35 | API Reference 36 | ------------------------------- 37 | 38 | .. doxygengroup:: ControlChannelAPI 39 | :project: caliper 40 | :members: 41 | -------------------------------------------------------------------------------- /src/services/io/CurIOus/src/curious.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "callbacks.h" 5 | #include "wrappers.h" 6 | #include "file_registry.h" 7 | #include "mount_tree.h" 8 | 9 | static curious_t next_inst = 0; 10 | static int active_insts = 0; 11 | static curious_apis_t wrapped_apis = 0; 12 | 13 | int curious_init(curious_apis_t apis) 14 | { 15 | if (0 == active_insts) { 16 | //First-time setup 17 | curious_init_file_registry(); 18 | curious_init_callback_registry(); 19 | } 20 | 21 | ++active_insts; 22 | 23 | //If there are any APIs which were requested 24 | //that aren't already wrapped, wrap them 25 | curious_apis_t missing_apis = apis & ~wrapped_apis; 26 | if (missing_apis) { 27 | curious_apply_wrappers(missing_apis); 28 | wrapped_apis |= missing_apis; 29 | } 30 | 31 | return ++next_inst; 32 | } 33 | 34 | void curious_finalize(curious_t curious_inst) 35 | { 36 | //Turn everything off if we don't have any active instances... 37 | if (0 == --active_insts) { 38 | curious_finalize_callback_registry(); 39 | curious_disable_wrappers(); 40 | curious_finalize_file_registry(); 41 | 42 | // ...and just remove the callbacks from this instance of CURIOUS otherwise 43 | } else { 44 | curious_deregister_callbacks(curious_inst); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /doc/sphinx/FortranSupport.rst: -------------------------------------------------------------------------------- 1 | Fortran support 2 | ================================ 3 | 4 | Caliper provides Fortran wrappers for the annotation and ConfigManager 5 | APIs. To build Caliper with Fortran support, enable the ``WITH_FORTRAN`` 6 | option in the CMake configuration: 7 | 8 | .. code-block:: sh 9 | 10 | $ cmake -DWITH_FORTRAN=On .. 11 | 12 | Using the Fortran module 13 | -------------------------------- 14 | 15 | The Fortran wrapper module requires Fortran 2003, and Caliper must be built 16 | with the same compiler as the target program. 17 | 18 | The Caliper fortran module is installed in ``include/caliper/fortran/`` in the 19 | Caliper installation directory. Simply add this directory to the application 20 | include path and import it with ``use caliper_mod`` where needed. 21 | Remember to also link libcaliper to the target program. 22 | 23 | Caliper Fortran API 24 | -------------------------------- 25 | 26 | The Caliper Fortran API supports a subset of the C and C++ annotation APIs. 27 | The simplest options are the :cpp:func:`cali_begin_region()` and 28 | :cpp:func:`cali_end_region()` functions. 29 | 30 | The Fortran API also supports the Caliper ConfigManager API (:doc:`ConfigManagerAPI`). 31 | The example in examples/apps/fortran-example.f demonstrates the annotation and 32 | ConfigManager APIs for Fortran: 33 | 34 | .. literalinclude:: ../../examples/apps/fortran-example.f 35 | :language: Fortran 36 | -------------------------------------------------------------------------------- /cmake/FindRoctracer.cmake: -------------------------------------------------------------------------------- 1 | # Find ROCTracer libraries/headers 2 | 3 | find_path(ROCM_PATH 4 | NAMES include/roctracer/roctracer.h 5 | ) 6 | 7 | find_library(ROCTRACER_LIBROCTRACER 8 | NAMES roctracer64 9 | HINTS ${ROCM_PATH}/lib 10 | ) 11 | find_library(ROCTRACER_LIBHSARUNTIME 12 | NAMES hsa-runtime64 13 | HINTS ${ROCM_PATH}/lib 14 | ) 15 | find_library(ROCTRACER_LIBHSAKMT 16 | NAMES hsakmt 17 | HINTS ${ROCM_PATH}/lib 18 | ) 19 | find_library(ROCTRACER_LIBHSAKMT 20 | NAMES hsakmt 21 | HINTS ${ROCM_PATH}/lib 22 | ) 23 | find_library(ROCTRACER_AMDHIP64 24 | NAMES amdhip64 25 | HINTS ${ROCM_PATH}/lib 26 | ) 27 | 28 | find_path(ROCTRACER_INCLUDE_DIR 29 | NAMES roctracer.h 30 | HINTS ${ROCM_PATH}/include/roctracer 31 | ) 32 | 33 | find_path(HIP_INCLUDE_DIR 34 | NAMES hip/hip_runtime.h 35 | HINTS ${ROCM_PATH}/include) 36 | 37 | set(ROCTRACER_INCLUDE_DIRS 38 | ${ROCTRACER_INCLUDE_DIR} 39 | ${HIP_INCLUDE_DIR} 40 | ) 41 | set(ROCTRACER_LIBRARIES 42 | ${ROCTRACER_LIBROCTRACER} 43 | ${ROCTRACER_LIBHSARUNTIME} 44 | ${ROCTRACER_LIBHSAKMT} 45 | ${ROCTRACER_AMDHIP64} 46 | ) 47 | 48 | include(FindPackageHandleStandardArgs) 49 | 50 | find_package_handle_standard_args(ROCTRACER 51 | DEFAULT_MSG 52 | ROCTRACER_LIBROCTRACER 53 | ROCTRACER_LIBHSARUNTIME 54 | ROCTRACER_LIBHSAKMT 55 | ROCTRACER_INCLUDE_DIRS 56 | ) 57 | 58 | mark_as_advanced( 59 | ROCTRACER_INCLUDE_DIRS 60 | ROCTRACER_LIBRARIES 61 | ) 62 | -------------------------------------------------------------------------------- /doc/sphinx/examples/cali-query-selected.output: -------------------------------------------------------------------------------- 1 | event.set#factorial=comp,cali.snapshot.event.set=70,cali.snapshot.event.attr.level=1,factorial=init,iteration=3,main=body/loop,cali.caliper.version=1.5.dev,time.inclusive.duration=15 2 | event.begin#factorial=init,cali.snapshot.event.begin=70,cali.snapshot.event.attr.level=2,factorial=comp,iteration=3,main=body/loop,cali.caliper.version=1.5.dev 3 | event.set#factorial=comp,cali.snapshot.event.set=70,cali.snapshot.event.attr.level=1,factorial=comp/init,iteration=3,main=body/loop,cali.caliper.version=1.5.dev,time.inclusive.duration=36 4 | event.begin#factorial=init,cali.snapshot.event.begin=70,cali.snapshot.event.attr.level=2,factorial=comp/comp,iteration=3,main=body/loop,cali.caliper.version=1.5.dev 5 | event.set#factorial=comp,cali.snapshot.event.set=70,cali.snapshot.event.attr.level=1,factorial=comp/comp/init,iteration=3,main=body/loop,cali.caliper.version=1.5.dev,time.inclusive.duration=37 6 | event.end#factorial=comp,cali.snapshot.event.end=70,cali.snapshot.event.attr.level=1,factorial=comp/comp/comp,iteration=3,main=body/loop,cali.caliper.version=1.5.dev,time.inclusive.duration=14 7 | event.end#factorial=comp,cali.snapshot.event.end=70,cali.snapshot.event.attr.level=0,factorial=comp/comp,iteration=3,main=body/loop,cali.caliper.version=1.5.dev 8 | event.end#factorial=comp,cali.snapshot.event.end=70,cali.snapshot.event.attr.level=0,factorial=comp,iteration=3,main=body/loop,cali.caliper.version=1.5.dev 9 | -------------------------------------------------------------------------------- /cmake/FindLibunwind.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # - Find libunwind 3 | # 4 | # LIBUNWIND_PREFIX - Set to the libunwind installation directory 5 | # 6 | # LIBUNWIND_INCLUDE_DIRS - Path to libunwind.h 7 | # LIBUNWIND_LIBRARIES - List of libraries for using libunwind 8 | # LIBUNWIND_FOUND - True if libunwind was found 9 | 10 | if(LIBUNWIND_PREFIX) 11 | # When prefix is explicitly provided, only look there 12 | find_library(LIBUNWIND_LIBRARIES 13 | NAMES unwind 14 | PATHS ${LIBUNWIND_PREFIX}/lib 15 | NO_DEFAULT_PATH) 16 | 17 | find_path(LIBUNWIND_INCLUDE_DIRS 18 | NAMES libunwind.h 19 | PATHS ${LIBUNWIND_PREFIX}/include 20 | NO_DEFAULT_PATH) 21 | 22 | if(NOT LIBUNWIND_LIBRARIES OR NOT LIBUNWIND_INCLUDE_DIRS) 23 | message(WARNING "LIBUNWIND_PREFIX was set to '${LIBUNWIND_PREFIX}' but libunwind was not found there") 24 | endif() 25 | else() 26 | # Try to find libunwind in standard locations 27 | find_path(LIBUNWIND_PREFIX 28 | include/libunwind.h) 29 | 30 | find_library(LIBUNWIND_LIBRARIES 31 | NAMES unwind 32 | HINTS ${LIBUNWIND_PREFIX}/lib) 33 | 34 | find_path(LIBUNWIND_INCLUDE_DIRS 35 | NAMES libunwind.h 36 | HINTS ${LIBUNWIND_PREFIX}/include) 37 | endif() 38 | 39 | include(FindPackageHandleStandardArgs) 40 | find_package_handle_standard_args(Libunwind DEFAULT_MSG LIBUNWIND_LIBRARIES LIBUNWIND_INCLUDE_DIRS) 41 | 42 | mark_as_advanced(LIBUNWIND_LIBRARIES LIBUNWIND_INCLUDE_DIRS) 43 | -------------------------------------------------------------------------------- /doc/sphinx/examples/cali-query-print-aggregated.output: -------------------------------------------------------------------------------- 1 | main=init,time.inclusive.duration=1813 2 | main=body/init,time.inclusive.duration=114 3 | main=body/loop,time.inclusive.duration=1214 4 | iteration=0,main=body/loop,time.inclusive.duration=529 5 | iteration=0,main=body/loop,time.inclusive.duration=215 6 | iteration=1,main=body/loop,time.inclusive.duration=15 7 | iteration=2,main=body/loop,time.inclusive.duration=15 8 | iteration=2,main=body/loop,time.inclusive.duration=101 9 | iteration=3,main=body/loop,time.inclusive.duration=15 10 | iteration=3,main=body/loop,time.inclusive.duration=36 11 | iteration=3,main=body/loop,time.inclusive.duration=37 12 | iteration=4,main=body/loop,time.inclusive.duration=14 13 | iteration=4,main=body/loop,time.inclusive.duration=36 14 | iteration=4,main=body/loop,time.inclusive.duration=36 15 | iteration=4,main=body/loop,time.inclusive.duration=36 16 | iteration=0,main=body/loop,time.inclusive.duration=21 17 | iteration=1,main=body/loop,time.inclusive.duration=14 18 | iteration=2,main=body/loop,time.inclusive.duration=16 19 | iteration=3,main=body/loop,time.inclusive.duration=14 20 | iteration=4,main=body/loop,time.inclusive.duration=14 21 | iteration=1,main=body/loop,time.inclusive.duration=69 22 | iteration=2,main=body/loop,time.inclusive.duration=183 23 | iteration=3,main=body/loop,time.inclusive.duration=164 24 | iteration=4,main=body/loop,time.inclusive.duration=210 25 | main=body/conclusion,time.inclusive.duration=37 26 | -------------------------------------------------------------------------------- /src/services/topdown/HaswellTopdown.h: -------------------------------------------------------------------------------- 1 | #ifndef CALI_TOPDOWN_HASWELL_TOPDOWN_H 2 | #define CALI_TOPDOWN_HASWELL_TOPDOWN_H 3 | 4 | #include "TopdownCalculator.h" 5 | 6 | namespace cali 7 | { 8 | namespace topdown 9 | { 10 | 11 | class HaswellTopdown : public TopdownCalculator 12 | { 13 | public: 14 | 15 | HaswellTopdown(IntelTopdownLevel level); 16 | 17 | virtual ~HaswellTopdown() = default; 18 | 19 | virtual bool setup_config(Caliper& c, Channel& channel) const override; 20 | 21 | virtual std::vector compute_toplevel(const std::vector& rec) override; 22 | virtual std::size_t get_num_expected_toplevel() const override; 23 | virtual std::vector compute_retiring(const std::vector& rec) override; 24 | virtual std::size_t get_num_expected_retiring() const override; 25 | virtual std::vector compute_backend_bound(const std::vector& rec) override; 26 | virtual std::size_t get_num_expected_backend_bound() const override; 27 | virtual std::vector compute_frontend_bound(const std::vector& rec) override; 28 | virtual std::size_t get_num_expected_frontend_bound() const override; 29 | virtual std::vector compute_bad_speculation(const std::vector& rec) override; 30 | virtual std::size_t get_num_expected_bad_speculation() const override; 31 | }; 32 | 33 | } // namespace topdown 34 | } // namespace cali 35 | 36 | #endif /* CALI_TOPDOWN_HASWELL_TOPDOWN_H */ -------------------------------------------------------------------------------- /test/cali-wrap.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | // A minimal Caliper instrumentation demo 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | int doWork(int* inArray, int size) 11 | { 12 | int reduce_var = 0; 13 | for (int i = 0; i < size; i++) { 14 | inArray[i] = i * i; 15 | reduce_var += i * i; 16 | } 17 | return reduce_var; 18 | } 19 | 20 | template 21 | T* initialize(size_t data_size, T initial_value) 22 | { 23 | T* array = (T*) malloc(sizeof(T) * data_size); 24 | for (size_t i = 0; i < data_size; i++) { 25 | array[i] = initial_value; 26 | } 27 | return array; 28 | } 29 | 30 | auto doWorkWrapped = cali::wrap_function_and_args("doWork", doWork); 31 | 32 | int main(int argc, char* argv[]) 33 | { 34 | constexpr int data_size = 1000000; 35 | constexpr int iterations = 10; 36 | int data_size_increment = data_size / iterations; 37 | cali::wrap("Program", [&]() { 38 | int* inArray; 39 | cali::wrap("Initialization", [&]() { 40 | inArray = cali::wrap_with_args("initializer", initialize, data_size, 0); 41 | }); 42 | for (int size = data_size_increment; size <= data_size; size += data_size_increment) { 43 | doWorkWrapped(inArray, size); 44 | } 45 | }); 46 | } 47 | -------------------------------------------------------------------------------- /src/services/io/CurIOus/src/callbacks.h: -------------------------------------------------------------------------------- 1 | #ifndef IO_CALLBACKS 2 | #define IO_CALLBACKS 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" 8 | { 9 | #endif 10 | 11 | /********* 12 | * Types * 13 | *********/ 14 | 15 | typedef struct curious_callback_data { 16 | //a function to be called either before or after an IO function 17 | curious_callback_f callback; 18 | //arbitrary usr-defined information which can be passed to the callback function 19 | //(note: the user is responsible for freeing this, if necessary) 20 | void* usr_args; 21 | //indicates which CURIOUS instance registered this callback 22 | curious_t curious_inst; 23 | } curious_callback_data_t; 24 | 25 | /********************** 26 | * Internal Functions * 27 | **********************/ 28 | 29 | void curious_call_callbacks(curious_callback_type_t type, void* io_args); 30 | void curious_destroy_curious_callback_data(curious_callback_data_t* self); 31 | void curious_init_callback_registry(void); 32 | void curious_finalize_callback_registry(void); 33 | 34 | // Prefix is just for consistency with curious_register_callback, not an indication 35 | // that this function is a part of the external API 36 | void curious_deregister_callbacks(curious_t curious_inst); 37 | 38 | /***************** 39 | * API Functions * 40 | *****************/ 41 | 42 | // See curious.h under include/curious for API functions 43 | 44 | #ifdef __cplusplus 45 | } // extern "C" 46 | #endif 47 | #endif 48 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CALIPER_TEST_APPS 2 | cali-annotation-perftest 3 | cali-flush-perftest 4 | cali-test) 5 | 6 | find_package(OpenMP) 7 | 8 | execute_process( 9 | COMMAND 10 | date "+%F %T" 11 | OUTPUT_VARIABLE 12 | CALI_BUILD_TIME 13 | OUTPUT_STRIP_TRAILING_WHITESPACE) 14 | execute_process( 15 | COMMAND 16 | git branch --show-current 17 | OUTPUT_VARIABLE 18 | CALI_GIT_BRANCH 19 | OUTPUT_STRIP_TRAILING_WHITESPACE) 20 | 21 | configure_file(build_metadata.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/build_metadata.cpp) 22 | 23 | foreach(app ${CALIPER_TEST_APPS}) 24 | add_executable(${app} 25 | ${app}.cpp 26 | ${CMAKE_CURRENT_BINARY_DIR}/build_metadata.cpp) 27 | target_link_libraries(${app} caliper) 28 | endforeach() 29 | 30 | if (CALIPER_HAVE_ADIAK) 31 | target_include_directories(cali-annotation-perftest PRIVATE ${adiak_INCLUDE_DIRS}) 32 | target_link_libraries(cali-annotation-perftest ${adiak_LIBRARIES}) 33 | endif() 34 | 35 | set(CALIPER_TEST_OMP_APPS 36 | cali-annotation-perftest 37 | cali-flush-perftest) 38 | 39 | if (${OpenMP_FOUND}) 40 | foreach (app ${CALIPER_TEST_OMP_APPS}) 41 | target_compile_options(${app} 42 | PRIVATE ${OpenMP_CXX_FLAGS}) 43 | target_link_libraries(${app} 44 | ${OpenMP_CXX_FLAGS}) 45 | endforeach() 46 | endif() 47 | 48 | target_link_libraries(cali-annotation-perftest 49 | caliper-tools-util) 50 | target_link_libraries(cali-flush-perftest 51 | caliper-tools-util) 52 | 53 | add_subdirectory(ci_app_tests) 54 | -------------------------------------------------------------------------------- /src/common/util/parse_util.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file parse_util.h 5 | /// Helper functions to parse config strings etc. 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace cali 14 | { 15 | namespace util 16 | { 17 | 18 | /// \brief Check if \a c is in \a separators 19 | inline bool is_one_of(char c, const char* characters) 20 | { 21 | for (const char* ptr = characters; *ptr != '\0'; ++ptr) 22 | if (*ptr == c) 23 | return true; 24 | 25 | return false; 26 | } 27 | 28 | /// \brief Read from stream \a is until whitespace or one of the characters in 29 | /// \a separators is found. 30 | std::string read_word(std::istream& is, const char* separators = ","); 31 | 32 | /// \brief Reads text within (start_char, end_char) region, skipping 33 | /// over any such regions nested within. 34 | std::string read_nested_text(std::istream& is, char start_char, char end_char); 35 | 36 | /// \brief Read character from stream \a is, skipping whitespace. 37 | char read_char(std::istream& is); 38 | 39 | inline std::pair str_to_uint64(const char* str) 40 | { 41 | uint64_t ret = 0; 42 | const char* p = str; 43 | for (; *p >= '0' && *p <= '9'; ++p) 44 | ret = ret * 10 + static_cast(*p - '0'); 45 | return std::make_pair(p != str, ret); 46 | } 47 | 48 | } // namespace util 49 | } // namespace cali -------------------------------------------------------------------------------- /cmake/FindLDMS.cmake: -------------------------------------------------------------------------------- 1 | # Try to find LDMS headers and libraries. 2 | # 3 | # Usage of this module as follows: 4 | # 5 | # find_package(LDMS) 6 | # 7 | # Variables used by this module, they can change the default behaviour and need 8 | # to be set before calling find_package: 9 | # 10 | # LDMS_PREFIX Set this variable to the root installation of 11 | # LDMS if the module has problems finding the 12 | # proper installation path. 13 | # 14 | # Variables defined by this module: 15 | # 16 | # LDMS_FOUND System has LDMS libraries and headers 17 | # LDMS_LIBRARIES The LDMS library 18 | # LDMS_INCLUDE_DIRS The location of LDMS headers 19 | 20 | find_library(LDMS_LIBLDMS 21 | NAMES ldms 22 | PATHS /usr/lib64 /usr/lib /opt/ovis/lib 23 | ) 24 | 25 | find_library(LDMS_LIBSTREAM 26 | NAMES ldmsd_stream 27 | PATHS /usr/lib64 /usr/lib /opt/ovis/lib 28 | ) 29 | 30 | find_path(LDMS_INCLUDE_DIRS 31 | NAMES "ldms.h" "ldmsd_stream.h" 32 | PATH_SUFFIXES "ldms" 33 | ) 34 | message(STATUS "libldms.so => ${LDMS_LIBRARIES}") 35 | message(STATUS "ldmsd_stream.h => ${LDMS_INCLUDE_DIRS}") 36 | message(STATUS "ldms.h => ${LDMS_INCLUDE_DIRS}") 37 | 38 | include(FindPackageHandleStandardArgs) 39 | find_package_handle_standard_args(LDMS DEFAULT_MSG 40 | LDMS_LIBLDMS 41 | LDMS_LIBSTREAM 42 | LDMS_INCLUDE_DIRS 43 | ) 44 | 45 | mark_as_advanced( 46 | LDMS_PREFIX_DIRS 47 | LDMS_LIBLDMS 48 | LDMS_LIBSTREAM 49 | LDMS_INCLUDE_DIRS 50 | ) 51 | -------------------------------------------------------------------------------- /src/common/util/file_util.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | #include "file_util.h" 5 | 6 | #ifdef _WIN32 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace 17 | { 18 | 19 | // --- helpers 20 | 21 | std::string random_string(std::string::size_type len) 22 | { 23 | static std::mt19937 rgen(std::chrono::system_clock::now().time_since_epoch().count()); 24 | 25 | static const char characters[] = 26 | "0123456789" 27 | "abcdefghiyklmnopqrstuvwxyz" 28 | "ABCDEFGHIJKLMNOPQRSTUVWXZY"; 29 | 30 | std::uniform_int_distribution<> random(0, sizeof(characters) - 2); 31 | std::string s(len, '-'); 32 | 33 | generate_n(s.begin(), len, [&]() { return characters[random(rgen)]; }); 34 | 35 | return s; 36 | } 37 | 38 | } // namespace 39 | 40 | namespace cali 41 | { 42 | 43 | namespace util 44 | { 45 | 46 | std::string create_filename(const char* ext) 47 | { 48 | char timestring[16]; 49 | time_t tm = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); 50 | strftime(timestring, sizeof(timestring), "%y%m%d-%H%M%S", localtime(&tm)); 51 | 52 | int pid = static_cast(getpid()); 53 | 54 | return std::string(timestring) + "_" + std::to_string(pid) + "_" + random_string(12) + ext; 55 | } 56 | 57 | } // namespace util 58 | 59 | } // namespace cali 60 | -------------------------------------------------------------------------------- /src/common/SnapshotBuffer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file SnapshotBuffer.h 5 | /// \brief SnapshotBuffer class 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace cali 12 | { 13 | 14 | class CompressedSnapshotRecord; 15 | class CompressedSnapshotRecordView; 16 | 17 | /// \brief Serialize/deserialize a set of nodes 18 | class SnapshotBuffer 19 | { 20 | std::size_t m_count; 21 | 22 | std::size_t m_pos; 23 | std::size_t m_reserved_len; 24 | 25 | unsigned char* m_buffer; 26 | 27 | unsigned char* reserve(std::size_t min); 28 | 29 | public: 30 | 31 | SnapshotBuffer(); 32 | SnapshotBuffer(std::size_t size); 33 | 34 | ~SnapshotBuffer(); 35 | 36 | SnapshotBuffer(const SnapshotBuffer&) = delete; 37 | SnapshotBuffer& operator= (const SnapshotBuffer&) = delete; 38 | 39 | void append(const CompressedSnapshotRecord& rec); 40 | 41 | std::size_t count() const { return m_count; } 42 | 43 | std::size_t size() const { return m_pos; } 44 | 45 | const unsigned char* data() const { return m_buffer; } 46 | 47 | /// \brief Expose buffer for read from external source (e.g., MPI), 48 | /// and set count and size. 49 | unsigned char* import(std::size_t size, std::size_t count); 50 | 51 | /// \brief Run function \a fn on each snapshot 52 | void for_each(std::function fn) const; 53 | }; 54 | 55 | } // namespace cali 56 | -------------------------------------------------------------------------------- /ext/gotcha/src/gotcha_auxv.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of GOTCHA. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/LLNL/gotcha/blob/master/COPYRIGHT 5 | This program is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU Lesser General Public License (as published by the Free 7 | Software Foundation) version 2.1 dated February 1999. This program is 8 | distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 9 | without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR 10 | PURPOSE. See the terms and conditions of the GNU Lesser General Public License 11 | for more details. You should have received a copy of the GNU Lesser General 12 | Public License along with this program; if not, write to the Free Software 13 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 14 | */ 15 | 16 | #ifndef GOTCHA_AUXV_H 17 | #define GOTCHA_AUXV_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | int is_vdso(const struct link_map *map); 31 | unsigned int get_auxv_pagesize(); 32 | 33 | // Do not use, exposed only for unit testing 34 | int parse_auxv_contents(); 35 | struct link_map *get_vdso_from_auxv(); 36 | struct link_map *get_vdso_from_aliases(); 37 | struct link_map *get_vdso_from_maps(); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/services/topdown/SapphireRapidsTopdown.h: -------------------------------------------------------------------------------- 1 | #ifndef CALI_TOPDOWN_SAPPHIRE_RAPIDS_TOPDOWN_H 2 | #define CALI_TOPDOWN_SAPPHIRE_RAPIDS_TOPDOWN_H 3 | 4 | #include "TopdownCalculator.h" 5 | 6 | namespace cali 7 | { 8 | namespace topdown 9 | { 10 | 11 | class SapphireRapidsTopdown : public TopdownCalculator 12 | { 13 | public: 14 | 15 | SapphireRapidsTopdown(IntelTopdownLevel level); 16 | 17 | virtual ~SapphireRapidsTopdown() = default; 18 | 19 | virtual bool setup_config(Caliper& c, Channel& channel) const override; 20 | 21 | virtual std::vector compute_toplevel(const std::vector& rec) override; 22 | 23 | virtual std::size_t get_num_expected_toplevel() const override; 24 | 25 | virtual std::vector compute_retiring(const std::vector& rec) override; 26 | 27 | virtual std::size_t get_num_expected_retiring() const override; 28 | 29 | virtual std::vector compute_backend_bound(const std::vector& rec) override; 30 | 31 | virtual std::size_t get_num_expected_backend_bound() const override; 32 | 33 | virtual std::vector compute_frontend_bound(const std::vector& rec) override; 34 | 35 | virtual std::size_t get_num_expected_frontend_bound() const override; 36 | 37 | virtual std::vector compute_bad_speculation(const std::vector& rec) override; 38 | 39 | virtual std::size_t get_num_expected_bad_speculation() const override; 40 | }; 41 | 42 | } // namespace topdown 43 | } // namespace cali 44 | 45 | #endif /* CALI_TOPDOWN_SAPPHIRE_RAPIDS_TOPDOWN_H */ -------------------------------------------------------------------------------- /src/common/CaliperMetadataAccessInterface.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file CaliperMetadataQueryInterface.cpp 5 | /// Caliper metadata access interface implementation 6 | 7 | #include "caliper/common/CaliperMetadataAccessInterface.h" 8 | 9 | using namespace cali; 10 | 11 | std::vector CaliperMetadataAccessInterface::find_attributes_with(const Attribute& meta) const 12 | { 13 | std::vector vec = get_all_attributes(); 14 | std::vector ret; 15 | 16 | for (Attribute attr : vec) 17 | if (!attr.get(meta).empty()) 18 | ret.push_back(attr); 19 | 20 | return ret; 21 | } 22 | 23 | std::vector CaliperMetadataAccessInterface::find_attributes_with_prop(int prop) const 24 | { 25 | std::vector vec = get_all_attributes(); 26 | std::vector ret; 27 | 28 | for (Attribute attr : vec) 29 | if (attr.properties() & prop) 30 | ret.push_back(attr); 31 | 32 | return ret; 33 | } 34 | 35 | namespace cali 36 | { 37 | 38 | Entry get_path_entry(const CaliperMetadataAccessInterface& db, const Entry& e) 39 | { 40 | Entry ret; 41 | 42 | if (e.is_reference()) { 43 | for (Node* node = e.node(); node; node = node->parent()) 44 | if (db.get_attribute(node->attribute()).is_nested()) { 45 | ret = Entry(node); 46 | break; 47 | } 48 | } 49 | 50 | return ret; 51 | } 52 | 53 | } // namespace cali 54 | -------------------------------------------------------------------------------- /src/common/StringConverter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file StringConverter.h 5 | /// A class to convert strings into various other data types. 6 | /// This is primarily a convenience class to transparently replace 7 | /// cali::Variant's former string conversion capabilities. 8 | 9 | #pragma once 10 | 11 | #include "caliper/common/cali_types.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace cali 18 | { 19 | 20 | class StringConverter 21 | { 22 | std::string m_str; 23 | 24 | public: 25 | 26 | StringConverter() : m_str() {} 27 | 28 | StringConverter(const std::string& str) : m_str(str) {} 29 | 30 | cali_id_t to_id() const; 31 | 32 | bool to_bool(bool* okptr = nullptr) const; 33 | 34 | int to_int(bool* okptr = nullptr) const; 35 | int64_t to_int64(bool* okptr = nullptr) const; 36 | uint64_t to_uint(bool* okptr = nullptr, int base = 10) const; 37 | 38 | double to_double(bool* okptr = nullptr) const; 39 | 40 | std::string to_string(bool* okptr = nullptr) const 41 | { 42 | if (okptr) 43 | *okptr = true; 44 | return m_str; 45 | } 46 | 47 | std::vector to_stringlist(const char* separators = ",", bool* okptr = nullptr) const; 48 | 49 | std::vector rec_list(bool* okptr = nullptr) const; 50 | 51 | std::map rec_dict(bool* okptr = nullptr) const; 52 | }; 53 | 54 | } // namespace cali 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2024, Lawrence Livermore National Security, LLC. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /test/ci_app_tests/ci_test_py_ann.py: -------------------------------------------------------------------------------- 1 | # --- Caliper continuous integration test app for Python annotation interface 2 | 3 | import sys 4 | 5 | sys.path.insert(0, "@PYPATH_TESTING@") 6 | 7 | from pycaliper import config_preset 8 | from pycaliper.instrumentation import ( 9 | Attribute, 10 | set_global_byname, 11 | begin_byname, 12 | set_byname, 13 | end_byname, 14 | ) 15 | from pycaliper.types import CALI_TYPE_INT, CALI_ATTR_ASVALUE 16 | from pycaliper.config_manager import ConfigManager 17 | 18 | 19 | def main(): 20 | config_preset({"CALI_CHANNEL_FLUSH_ON_EXIT": "false"}) 21 | 22 | mgr = ConfigManager() 23 | if len(sys.argv) > 1: 24 | mgr.add(sys.argv[1]) 25 | 26 | if mgr.error(): 27 | print("Caliper config error:", mgr.err_msg(), file=sys.stderr) 28 | exit(-1) 29 | 30 | mgr.start() 31 | 32 | set_global_byname("global.double", 42.42) 33 | set_global_byname("global.int", 1337) 34 | set_global_byname("global.string", "my global string") 35 | set_global_byname("global.uint", 42) 36 | 37 | iter_attr = Attribute("iteration", CALI_TYPE_INT, CALI_ATTR_ASVALUE) 38 | 39 | begin_byname("phase", "loop") 40 | 41 | for i in range(4): 42 | iter_attr.begin(i) 43 | iter_attr.end() 44 | 45 | end_byname("phase") 46 | 47 | begin_byname("ci_test_c_ann.setbyname") 48 | 49 | set_byname("attr.int", 20) 50 | set_byname("attr.dbl", 1.25) 51 | set_byname("attr.str", "fidibus") 52 | 53 | end_byname("ci_test_c_ann.setbyname") 54 | 55 | mgr.flush() 56 | 57 | 58 | if __name__ == "__main__": 59 | main() 60 | -------------------------------------------------------------------------------- /src/common/NodeBuffer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// \file NodeBuffer.h 5 | /// \brief NodeBuffer class 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace cali 14 | { 15 | 16 | class Node; 17 | 18 | /// \brief Serialize/deserialize a set of nodes 19 | class NodeBuffer 20 | { 21 | size_t m_count; 22 | 23 | size_t m_pos; 24 | size_t m_reserved_len; 25 | 26 | unsigned char* m_buffer; 27 | 28 | unsigned char* reserve(size_t min); 29 | 30 | public: 31 | 32 | struct NodeInfo { 33 | cali_id_t node_id; 34 | cali_id_t attr_id; 35 | cali_id_t parent_id; 36 | Variant value; 37 | }; 38 | 39 | NodeBuffer(); 40 | NodeBuffer(size_t size); 41 | 42 | ~NodeBuffer(); 43 | 44 | NodeBuffer(const NodeBuffer&) = delete; 45 | NodeBuffer& operator= (const NodeBuffer&) = delete; 46 | 47 | void append(const NodeInfo& info); 48 | void append(const Node* node); 49 | 50 | size_t count() const { return m_count; } 51 | 52 | size_t size() const { return m_pos; } 53 | 54 | const unsigned char* data() const { return m_buffer; } 55 | 56 | /// \brief Expose buffer for read from external source (e.g., MPI), 57 | /// and set count and size. 58 | unsigned char* import(size_t size, size_t count); 59 | 60 | /// \brief Run function \a fn on each element 61 | void for_each(std::function fn) const; 62 | }; 63 | 64 | } // namespace cali 65 | -------------------------------------------------------------------------------- /src/common/util/split.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | /// @file split.hpp 5 | /// @brief String split operation 6 | 7 | #ifndef UTIL_SPLIT_HPP 8 | #define UTIL_SPLIT_HPP 9 | 10 | namespace cali 11 | { 12 | namespace util 13 | { 14 | 15 | template 16 | void split(String input, Char sep, OutputIterator out) 17 | { 18 | String str; 19 | 20 | for (Char c : input) { 21 | if (c == sep) { 22 | *out++ = str; 23 | str.clear(); 24 | } else { 25 | str.push_back(c); 26 | } 27 | } 28 | 29 | if (!str.empty()) 30 | *out++ = str; 31 | } 32 | 33 | template 34 | void tokenize(String input, const Char* tokens, OutputIterator out) 35 | { 36 | String str; 37 | 38 | for (Char c : input) { 39 | bool is_token_char = false; 40 | for (const Char* tc = tokens; *tc; ++tc) 41 | if (c == *tc) { 42 | is_token_char = true; 43 | break; 44 | } 45 | 46 | if (is_token_char) { 47 | if (!str.empty()) 48 | *out++ = str; 49 | str.clear(); 50 | 51 | str.push_back(c); 52 | *out++ = str; 53 | str.clear(); 54 | } else { 55 | str.push_back(c); 56 | } 57 | } 58 | 59 | if (!str.empty()) 60 | *out++ = str; 61 | } 62 | 63 | } // namespace util 64 | } // namespace cali 65 | #endif 66 | -------------------------------------------------------------------------------- /src/interface/python/config_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef CALI_INTERFACE_PYTHON_CONFIG_MANAGER_H 2 | #define CALI_INTERFACE_PYTHON_CONFIG_MANAGER_H 3 | 4 | #include "common.h" 5 | 6 | #include 7 | 8 | namespace cali 9 | { 10 | class PythonConfigManager : public cali::ConfigManager 11 | { 12 | public: 13 | 14 | PythonConfigManager(); 15 | 16 | PythonConfigManager(const char* config_str); 17 | 18 | // void add_config_spec(const char *json); 19 | 20 | void add_config_spec(py::dict json); 21 | 22 | // void add_option_spec(const char *json); 23 | 24 | void add_option_spec(py::dict json); 25 | 26 | void py_add(const char* config_string); 27 | 28 | // void load(const char *filename); 29 | 30 | // void set_default_parameter(const char *key, const char *value); 31 | 32 | // void set_default_parameter_for_config(const char *config, const char *key, 33 | // const char *value); 34 | 35 | // bool error() const; 36 | 37 | // Set to __repr__ 38 | // bool error_msg() const; 39 | 40 | // void start(); 41 | 42 | // void stop(); 43 | 44 | // void flush(); 45 | 46 | void check(const char* config_str); 47 | 48 | // std::vector available_config_specs() const; 49 | 50 | // std::string get_documentation_for_spec(const char *name) const; 51 | 52 | // static std::vector get_config_docstrings(); 53 | }; 54 | 55 | void create_caliper_config_manager_mod(py::module_& caliper_config_manager_mod); 56 | 57 | } // namespace cali 58 | 59 | #endif /* CALI_INTERFACE_PYTHON_CONFIG_MANAGER_H */ -------------------------------------------------------------------------------- /src/interface/yaml/caliper_types.yaml: -------------------------------------------------------------------------------- 1 | # caliper_types.yaml 2 | # This file is generated by Shroud 0.12.2. Do not edit. 3 | # Types generated by Shroud for library 'Caliper' 4 | typemap: 5 | - namespace: cali 6 | declarations: cali 7 | - type: Annotation 8 | fields: 9 | base: shadow 10 | wrap_header: 11 | - typesCaliper.h 12 | c_type: cali_Annotation 13 | f_module_name: caliper_mod 14 | f_derived_type: annotation 15 | f_capsule_data_type: cali_SHROUD_capsule_data 16 | f_to_c: "{f_var}%cxxmem" 17 | - type: BufferedRegionProfile 18 | fields: 19 | base: shadow 20 | wrap_header: 21 | - typesCaliper.h 22 | c_type: cali_BufferedRegionProfile 23 | f_module_name: caliper_mod 24 | f_derived_type: bufferedregionprofile 25 | f_capsule_data_type: cali_SHROUD_capsule_data 26 | f_to_c: "{f_var}%cxxmem" 27 | - type: ConfigManager 28 | fields: 29 | base: shadow 30 | wrap_header: 31 | - typesCaliper.h 32 | c_type: cali_ConfigManager 33 | f_module_name: caliper_mod 34 | f_derived_type: configmanager 35 | f_capsule_data_type: cali_SHROUD_capsule_data 36 | f_to_c: "{f_var}%cxxmem" 37 | - type: ScopeAnnotation 38 | fields: 39 | base: shadow 40 | wrap_header: 41 | - typesCaliper.h 42 | c_type: cali_ScopeAnnotation 43 | f_module_name: caliper_mod 44 | f_derived_type: scopeannotation 45 | f_capsule_data_type: cali_SHROUD_capsule_data 46 | f_to_c: "{f_var}%cxxmem" 47 | -------------------------------------------------------------------------------- /src/services/cpuinfo/CpuInfo.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC. 2 | // See top-level LICENSE file for details. 3 | 4 | #include "../Services.h" 5 | 6 | #include "caliper/Caliper.h" 7 | #include "caliper/SnapshotRecord.h" 8 | 9 | #include "caliper/common/Attribute.h" 10 | #include "caliper/common/Log.h" 11 | 12 | #include 13 | #include 14 | 15 | using namespace cali; 16 | 17 | namespace 18 | { 19 | 20 | Attribute cpu_attr; 21 | Attribute node_attr; 22 | 23 | void snapshot_cb(Caliper*, SnapshotView, SnapshotBuilder& rec) 24 | { 25 | #ifdef SYS_getcpu 26 | unsigned cpu = 0, node = 0; 27 | 28 | if (syscall(SYS_getcpu, &cpu, &node, NULL) == 0) { 29 | rec.append(cpu_attr, cali_make_variant_from_uint(cpu)); 30 | rec.append(node_attr, cali_make_variant_from_uint(node)); 31 | } 32 | #endif 33 | } 34 | 35 | void cpuinfo_register(Caliper* c, Channel* chn) 36 | { 37 | cpu_attr = c->create_attribute( 38 | "cpuinfo.cpu", 39 | CALI_TYPE_UINT, 40 | CALI_ATTR_ASVALUE | CALI_ATTR_SKIP_EVENTS | CALI_ATTR_SCOPE_THREAD 41 | ); 42 | node_attr = c->create_attribute( 43 | "cpuinfo.numa_node", 44 | CALI_TYPE_UINT, 45 | CALI_ATTR_ASVALUE | CALI_ATTR_SKIP_EVENTS | CALI_ATTR_SCOPE_THREAD 46 | ); 47 | 48 | chn->events().snapshot.connect(snapshot_cb); 49 | 50 | Log(1).stream() << chn->name() << ": Registered cpuinfo service" << std::endl; 51 | } 52 | 53 | } // namespace 54 | 55 | namespace cali 56 | { 57 | 58 | CaliperService cpuinfo_service = { "cpuinfo", ::cpuinfo_register }; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /python/caliper-reader/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2021, Lawrence Livermore National Security, LLC. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /test/ci_app_tests/test_ompt.py: -------------------------------------------------------------------------------- 1 | # OmptService tests 2 | 3 | import json 4 | import unittest 5 | 6 | import calipertest as cat 7 | 8 | class CaliperOpenMPMetrics(unittest.TestCase): 9 | """ Caliper OpenMP/OMPT test case """ 10 | 11 | def test_ioservice(self): 12 | target_cmd = [ './ci_test_openmp', 'hatchet-region-profile,openmp.times,output=stdout,output.format=json-split' ] 13 | 14 | caliper_config = { 15 | 'CALI_LOG_VERBOSITY' : '0' 16 | } 17 | 18 | obj = json.loads( cat.run_test(target_cmd, caliper_config)[0] ) 19 | 20 | self.assertTrue( { 'data', 'columns', 'column_metadata', 'nodes' }.issubset(set(obj.keys())) ) 21 | 22 | expected = { 23 | 'path', 24 | 'time', 25 | 'Time (barrier)', 26 | 'Time (work)' 27 | } 28 | 29 | self.assertTrue(expected.issubset(set(obj['columns']))) 30 | 31 | def test_openmpreport_regions(self): 32 | target_cmd = [ './ci_test_openmp', 'openmp-report,output=stdout' ] 33 | 34 | caliper_config = { 35 | 'CALI_LOG_VERBOSITY' : '0' 36 | } 37 | 38 | report_targets = [ 39 | 'Path #Threads Time (thread) Time (total) Work % Barrier % Time (work) Time (barrier)' 40 | ] 41 | 42 | report_output,_ = cat.run_test(target_cmd, caliper_config) 43 | lines = report_output.decode().splitlines() 44 | 45 | for target in report_targets: 46 | for line in lines: 47 | if target in line: 48 | break 49 | 50 | if __name__ == "__main__": 51 | unittest.main() 52 | --------------------------------------------------------------------------------