Files
fail/src/core/util/CMakeLists.txt
Horst Schirmeier 6300a2b364 util: SumTree implementation
The SumTree implements an efficient tree data structure for
"roulette-wheel" sampling, or "sampling with fault expansion", i.e.,
sampling of trace entries / pilots without replacement and with a
picking probability proportional to the entries' sizes.

For every sample, the naive approach picks a random number between 0
and the sum of all entry sizes minus one.  It then iterates over all
entries and sums their sizes until the sum exceeds the random number.
The current entry gets picked.  The main disadvantage is the linear
complexity, which gets unpleasant for millions of entries.

The core idea behind the SumTree implementation is to maintain the
size sum of groups of entries, kept in "buckets".  Thereby, a bucket
can be quickly jumped over.  To keep bucket sizes (and thereby linear
search times) bounded, more bucket hierarchy levels are introduced
when a defined bucket size limit is reached.

Note that the current implementation is built for a pure growth phase
(when the tree gets filled with pilots from the database), followed by
a sampling phase when the tree gets emptied.  It does not handle a
mixed add/remove case very smartly, although it should remain
functional.

Change-Id: If05e9700bc84761b5bc31006402641e7112b3a72
2014-07-03 15:42:25 +02:00

95 lines
2.8 KiB
CMake

set(SRCS
CommandLine.cc
CommandLine.hpp
ElfReader.cc
ElfReader.hpp
Database.hpp
Database.cc
DatabaseProtobufAdapter.hpp
DatabaseProtobufAdapter.cc
Demangler.hpp
Demangler.cc
Disassembler.hpp
Disassembler.cc
DwarfReader.cc
DwarfReader.hpp
elfinfo/elfinfo.cc
elfinfo/elfinfo.h
gzstream/gzstream.C
gzstream/gzstream.h
Logger.cc
Logger.hpp
MemoryMap.cc
MemoryMap.hpp
ProtoStream.cc
ProtoStream.hpp
SynchronizedCounter.cc
SynchronizedCounter.hpp
SynchronizedMap.hpp
SynchronizedQueue.hpp
WallclockTimer.cc
WallclockTimer.hpp
AliasedRegistry.hpp
AliasedRegistry.cc
AliasedRegisterable.hpp
)
# required by ProtoStream.cc:
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# required by Synchronized*.cc, MemoryMap.* (needs icl, which came with 1.46):
find_package(Boost 1.46 COMPONENTS thread regex system REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
# libiberty required by Demangler.cc:
find_package(LibIberty REQUIRED)
include_directories(${LibIberty_INCLUDE_DIRS})
# libz required by gzstream
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIRS})
# libelf and libdwarf required by ElfReader/DwarfReader
find_package(LibElf REQUIRED)
find_package(LibDwarf REQUIRED)
include_directories(${LIBELF_INCLUDE_DIRS})
include_directories(${LIBDWARF_INCLUDE_DIRS})
# objdump required by Diassembler.cc
set(THE_OBJDUMP "${ARCH_TOOL_PREFIX}objdump")
find_program(FAIL_OBJDUMP "${THE_OBJDUMP}" DOC "binutils object dump tool")
if(${FAIL_OBJDUMP} STREQUAL FAIL_OBJDUMP-NOTFOUND)
message(FATAL_ERROR "Cannot find objdump exeuctable (tried: ${THE_OBJDUMP}")
else()
message(STATUS "[Fail*] objdump binary -> ${FAIL_OBJDUMP}")
endif()
mark_as_advanced(FAIL_OBJDUMP)
# compile smarthops calculator if needed
if(CONFIG_INJECTIONPOINT_HOPS)
add_subdirectory(smarthops)
set(ADDITIONAL_LIBS fail-smarthops)
endif(CONFIG_INJECTIONPOINT_HOPS)
add_library(fail-util ${SRCS})
add_dependencies(fail-util fail-comm)
target_link_libraries(fail-util fail-comm ${ADDITIONAL_LIBS} ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${LibIberty_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBDWARF_LIBRARIES} ${LIBELF_LIBRARIES})
option(BUILD_LLVM_DISASSEMBLER "Build the LLVM-based disassembler (LLVM 3.3 preferred, for 3.1 and 3.2 read doc/how-to-build.txt)" OFF)
if (BUILD_LLVM_DISASSEMBLER)
add_subdirectory(llvmdisassembler)
endif (BUILD_LLVM_DISASSEMBLER)
### Tests
add_executable(memorymap-test testing/memorymap-test.cc)
target_link_libraries(memorymap-test fail-util)
add_test(NAME memorymap-test WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/testing COMMAND memorymap-test)
add_executable(sumtree-test testing/SumTreeTest.cc)
add_test(NAME sumtree-test WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/testing COMMAND sumtree-test)