From ec8f5a61f393e75e4c3e3e22f84c773af66810e9 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 11 Mar 2013 13:05:52 -0700 Subject: [PATCH] Rename trim::CallSet to trace::FastCallSet This is in preparation for being able to use this code to optimize the common cases in trace::CallSet, (callsets without step or freq). --- CMakeLists.txt | 1 + cli/CMakeLists.txt | 1 - cli/cli_trim.cpp | 2 +- cli/trace_analyzer.cpp | 2 +- cli/trace_analyzer.hpp | 6 +-- common/trace_callset.hpp | 5 --- .../trace_fast_callset.cpp | 27 +++++++------ .../trace_fast_callset.hpp | 38 +++++++++---------- common/trace_model.hpp | 4 ++ 9 files changed, 40 insertions(+), 46 deletions(-) rename cli/trim_callset.cpp => common/trace_fast_callset.cpp (90%) rename cli/trim_callset.hpp => common/trace_fast_callset.hpp (75%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9394282..ac046f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -299,6 +299,7 @@ endif () add_library (common STATIC common/trace_callset.cpp common/trace_dump.cpp + common/trace_fast_callset.cpp common/trace_file.cpp common/trace_file_read.cpp common/trace_file_write.cpp diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 3165f7d..689374d 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -24,7 +24,6 @@ add_executable (apitrace cli_trim.cpp cli_resources.cpp trace_analyzer.cpp - trim_callset.cpp ) target_link_libraries (apitrace diff --git a/cli/cli_trim.cpp b/cli/cli_trim.cpp index 6694737..342e66b 100644 --- a/cli/cli_trim.cpp +++ b/cli/cli_trim.cpp @@ -203,7 +203,7 @@ trim_trace(const char *filename, struct trim_options *options) trace::ParseBookmark beginning; trace::Parser p; TraceAnalyzer analyzer(options->trim_flags); - trim::CallSet *required; + trace::FastCallSet *required; unsigned frame; int call_range_first, call_range_last; diff --git a/cli/trace_analyzer.cpp b/cli/trace_analyzer.cpp index 80ec15e..f98eaa7 100644 --- a/cli/trace_analyzer.cpp +++ b/cli/trace_analyzer.cpp @@ -760,7 +760,7 @@ TraceAnalyzer::require(trace::Call *call) /* Return a set of all the required calls, (both those calls added * explicitly with require() and those implicitly depended * upon. */ -trim::CallSet * +trace::FastCallSet * TraceAnalyzer::get_required(void) { return &required; diff --git a/cli/trace_analyzer.hpp b/cli/trace_analyzer.hpp index 6e9140a..3e4013b 100644 --- a/cli/trace_analyzer.hpp +++ b/cli/trace_analyzer.hpp @@ -29,7 +29,7 @@ #include #include "trace_callset.hpp" -#include "trim_callset.hpp" +#include "trace_fast_callset.hpp" #include "trace_parser.hpp" typedef unsigned TrimFlags; @@ -59,7 +59,7 @@ private: std::map texture_map; - trim::CallSet required; + trace::FastCallSet required; bool transformFeedbackActive; bool framebufferObjectActive; @@ -110,5 +110,5 @@ public: /* Return a set of all the required calls, (both those calls added * explicitly with require() and those implicitly depended * upon. */ - trim::CallSet *get_required(void); + trace::FastCallSet *get_required(void); }; diff --git a/common/trace_callset.hpp b/common/trace_callset.hpp index 4a4a52d..a2f8213 100644 --- a/common/trace_callset.hpp +++ b/common/trace_callset.hpp @@ -56,11 +56,6 @@ namespace trace { - - // Should match Call::no - typedef unsigned CallNo; - - // Aliases for call flags enum { FREQUENCY_NONE = 0, diff --git a/cli/trim_callset.cpp b/common/trace_fast_callset.cpp similarity index 90% rename from cli/trim_callset.cpp rename to common/trace_fast_callset.cpp index 69ed818..d7c4edc 100644 --- a/cli/trim_callset.cpp +++ b/common/trace_fast_callset.cpp @@ -31,28 +31,28 @@ #include #include -#include "trim_callset.hpp" +#include "trace_fast_callset.hpp" -using namespace trim; +using namespace trace; #define MAX_LEVEL 16 -CallRange::CallRange(CallNo first, CallNo last, int level) +FastCallRange::FastCallRange(CallNo first, CallNo last, int level) { this->first = first; this->last = last; this->level = level; - next = new CallRange*[level]; + next = new FastCallRange*[level]; } bool -CallRange::contains(CallNo call_no) +FastCallRange::contains(CallNo call_no) { return (first <= call_no && last >= call_no); } -CallSet::CallSet(): head(0, 0, MAX_LEVEL) +FastCallSet::FastCallSet(): head(0, 0, MAX_LEVEL) { head.first = std::numeric_limits::max(); head.last = std::numeric_limits::min(); @@ -88,10 +88,10 @@ random_level (void) } void -CallSet::add(CallNo first, CallNo last) +FastCallSet::add(CallNo first, CallNo last) { - CallRange **update[MAX_LEVEL]; - CallRange *node, *next; + FastCallRange **update[MAX_LEVEL]; + FastCallRange *node, *next; int i, level; /* Find node immediately before insertion point. */ @@ -112,7 +112,6 @@ CallSet::add(CallNo first, CallNo last) } /* Current range could not contain first, look at next. */ - node = node->next[0]; if (node) { @@ -146,7 +145,7 @@ CallSet::add(CallNo first, CallNo last) max_level = level; } - node = new CallRange(first, last, level); + node = new FastCallRange(first, last, level); /* Perform insertion into all lists. */ for (i = 0; i < level; i++) { @@ -176,15 +175,15 @@ MERGE_NODE_WITH_SUBSEQUENT_COVERED_NODES: } void -CallSet::add(CallNo call_no) +FastCallSet::add(CallNo call_no) { this->add(call_no, call_no); } bool -CallSet::contains(CallNo call_no) +FastCallSet::contains(CallNo call_no) { - CallRange *node; + FastCallRange *node; int i; node = &head; diff --git a/cli/trim_callset.hpp b/common/trace_fast_callset.hpp similarity index 75% rename from cli/trim_callset.hpp rename to common/trace_fast_callset.hpp index fb2c92a..22893ab 100644 --- a/cli/trim_callset.hpp +++ b/common/trace_fast_callset.hpp @@ -26,15 +26,17 @@ * *********************************************************************/ -#ifndef _TRIM_CALLSET_HPP_ -#define _TRIM_CALLSET_HPP_ +#ifndef _TRACE_FAST_CALLSET_HPP_ +#define _TRACE_FAST_CALLSET_HPP_ -namespace trim { +#include "trace_model.hpp" + +namespace trace { /* A set of call numbers. * - * This is designed as a more efficient replacement for - * std::set which is used heavily within the trim code's + * This was originally designed as a more efficient replacement for + * std::set which was used heavily within the trim code's * TraceAnalyzer. This is quite similar to the trace::CallSet with the * following differences: * @@ -52,38 +54,32 @@ namespace trim { * * This callset optimizes the addition of new calls which are * within or adjacent to existing ranges, (by either doing * nothing, expanding the limits of an existing range, or also - * merging two ranges). This keeps the length of the list down - * when succesively adding individual calls that could be - * efficiently expressed with a range. + * merging two or more ranges). * * It would not be impossible to extend this code to support the * missing features of trace::CallSet, (though the 'step' and 'freq' * features would prevent some range-extending and merging - * optimizations in some cases). Currently, trace::CallSet is not used - * in any performance-critical areas, so it may not be important to - * provide the performance imrpovements to it. + * optimizations in some cases). */ -typedef unsigned CallNo; - -class CallRange { +class FastCallRange { public: CallNo first; CallNo last; int level; - CallRange **next; + FastCallRange **next; - CallRange(CallNo first, CallNo last, int level); + FastCallRange(CallNo first, CallNo last, int level); bool contains(CallNo call_no); }; -class CallSet { +class FastCallSet { public: - CallRange head; + FastCallRange head; int max_level; - CallSet(); + FastCallSet(); void add(CallNo first, CallNo last); @@ -92,6 +88,6 @@ public: bool contains(CallNo call_no); }; -} /* namespace trim */ +} /* namespace trace */ -#endif /* _TRIM_CALLSET_HPP_ */ +#endif /* _TRACE_FAST_CALLSET_HPP_ */ diff --git a/common/trace_model.hpp b/common/trace_model.hpp index 9558225..9336321 100644 --- a/common/trace_model.hpp +++ b/common/trace_model.hpp @@ -41,6 +41,10 @@ namespace trace { +// Should match Call::no +typedef unsigned CallNo; + + typedef unsigned Id; -- 2.43.0