Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chaining and auto bundler generalization #155

Merged
merged 3 commits into from
Feb 15, 2021

Conversation

jrmadsen
Copy link
Collaborator

Overview

  • Bundlers now support chaining together function calls for most functions
  • New function for checking whether component properties/metadata has been specialized
    • component::properties<T>::specialized()
    • component::metadata<T>::specialized()
  • improvements to component::data_tracker and data::handler
  • utility::transient_function: alternative to std::function which never allocates on the heap and takes less time to compile
    • this should only be used in synchronous calls and cannot be referenced
    • future updates will use this more often for initialization functions
  • the "auto" bundlers now contain significantly less code thanks to a new auto_base_bundler static polymorphic base class
    • SIGNIFICANTLY reduced the amount of auto-bundler code
    • A similar technique will be applied to non-auto component bundlers but this is more complicated for various reasons
  • Minor fixes timemory.analysis
  • Added operator() for various operations
  • Added trait::default_runtime_enabled trait. This can be specialized to have a component default to being disabled at runtime
  • bundlers can now execute functions

New Features

Bundler Chaining

The vast majority of bundler member functions return references to itself, thus, you can now chain member function calls like .start().store(i).audit(i). Additionally, there is a execute(...) member function which will execute some function and store the result (w/o copying) so you can return the result after the chain completes. Here is an example:

using bundler_t = component_tuple<wall_clock, peak_rss, data_tracker_integer>;
int foo(int i)
{
    bundler_t _obj{ "foo" };
    _obj.start().store(std::plus<int>{}, i)

    return ...;
}

int bar(int i)
{
    // returns the result of foo(i)
    return bundle_t{ "bar" }.start().audit(i).execute(foo, i).stop().return_result();
}

Transient Function

struct foo
{
    using transient_type = utility::transient_function<void(foo&)>;

    // transient_function replaces std::function usage here
    foo(transient_type _init_func = [](foo&) {})
    {
        _init_func(*this);
    }
};

void bar()
{
    foo _obj{ [](foo& f) { ... } };
}

Bug fixes

  • Statistics
    • There was a SFINAE error in math::compute<T>::min(...) and math::compute<T>::max(...) that was causing min/max to not get computed correctly in statistics

- metadata::specialized()
- properties::specialized()
- bundle chaining
- significant data tracker improvements
- move semantics in data handler
- generic serialization to stringstream
- IMPORTANT PATCH TO STATISTICS MIN/MAX
- default runtime enabled
- functor support for operation::mark, operation::push_node, operation::pop_node, operation::store
- transient_function
- significant improvement to unity of to auto bundlers via static polymorphic base
- bundle_execute for holding an execution result in-between timemory bundler calls
- migrated some component_bundle stuff to general implementation
- variadic/functional.cpp
- some fixes to analysis
@codecov
Copy link

codecov bot commented Feb 15, 2021

Codecov Report

Merging #155 (15c4c24) into develop (5e90eb8) will increase coverage by 0.65%.
The diff coverage is 91.75%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #155      +/-   ##
===========================================
+ Coverage    79.36%   80.00%   +0.65%     
===========================================
  Files          235      240       +5     
  Lines        16146    16680     +534     
===========================================
+ Hits         12812    13343     +531     
- Misses        3334     3337       +3     
Impacted Files Coverage Δ
source/timemory/components/base/declaration.hpp 30.00% <ø> (ø)
source/timemory/components/properties.hpp 66.67% <ø> (ø)
source/timemory/mpl/apply.hpp 94.60% <ø> (ø)
source/timemory/mpl/math.hpp 96.71% <ø> (+0.16%) ⬆️
source/timemory/mpl/type_traits.hpp 100.00% <ø> (ø)
source/timemory/mpl/types.hpp 100.00% <ø> (ø)
source/timemory/operations/types/generic.hpp 80.96% <ø> (ø)
source/timemory/storage/definition.hpp 79.53% <0.00%> (+0.44%) ⬆️
source/timemory/utility/mangler.hpp 100.00% <ø> (ø)
source/timemory/operations/types/node.hpp 80.00% <56.25%> (-8.05%) ⬇️
... and 65 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e90eb8...15c4c24. Read the comment docs.

@jrmadsen jrmadsen merged commit 9ec9ffc into develop Feb 15, 2021
@jrmadsen jrmadsen deleted the chaining-and-auto-bundler-generalization branch February 15, 2021 17:54
jrmadsen added a commit that referenced this pull request Jun 28, 2021
* Support chaining and more

- metadata::specialized()
- properties::specialized()
- bundle chaining
- significant data tracker improvements
- move semantics in data handler
- generic serialization to stringstream
- IMPORTANT PATCH TO STATISTICS MIN/MAX
- default runtime enabled
- functor support for operation::mark, operation::push_node, operation::pop_node, operation::store
- transient_function
- significant improvement to unity of to auto bundlers via static polymorphic base
- bundle_execute for holding an execution result in-between timemory bundler calls
- migrated some component_bundle stuff to general implementation
- variadic/functional.cpp
- some fixes to analysis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant