timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
initialize.hpp
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2020, The Regents of the University of California,
4// through Lawrence Berkeley National Laboratory (subject to receipt of any
5// required approvals from the U.S. Dept. of Energy). All rights reserved.
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in all
15// copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23// SOFTWARE.
24
25/** \file runtime/initialize.hpp
26 * \headerfile runtime/initialize.hpp "timemory/runtime/initialize.hpp"
27 * Provides implementation for initialize, enumerate_components which regularly
28 * change as more features are added
29 *
30 */
31
32#pragma once
33
34#include "timemory/enum.h"
36
37#include <initializer_list>
38#include <string>
39#include <type_traits>
40#include <vector>
41
42namespace tim
43{
44//--------------------------------------------------------------------------------------//
45//
46// specializations for std::initializer_list
47//
48//--------------------------------------------------------------------------------------//
49
50template <template <typename...> class CompList, typename... CompTypes,
51 typename EnumT = int>
52inline void
53initialize(CompList<CompTypes...>& obj, std::initializer_list<EnumT> components)
54{
55 initialize(obj, std::vector<EnumT>(components));
56}
57
58//--------------------------------------------------------------------------------------//
59
60template <template <typename...> class CompList, typename... CompTypes>
61inline void
62initialize(CompList<CompTypes...>& obj, std::initializer_list<std::string> components)
63{
65}
66
67//--------------------------------------------------------------------------------------//
68
69template <template <typename...> class CompList, typename... CompTypes,
70 typename... ExtraArgs, template <typename, typename...> class Container>
71inline void
72initialize(CompList<CompTypes...>& obj,
73 const Container<std::string, ExtraArgs...>& components)
74{
76}
77
78//--------------------------------------------------------------------------------------//
79//
80/// this is for initializing with a string
81//
82template <template <typename...> class CompList, typename... CompTypes>
83inline void
84initialize(CompList<CompTypes...>& obj, const std::string& components)
85{
87}
88
89//--------------------------------------------------------------------------------------//
90
91template <
92 template <typename...> class CompList, typename... CompTypes,
93 template <typename, typename...> class Container, typename Intp,
94 typename... ExtraArgs,
95 typename std::enable_if<std::is_integral<Intp>::value ||
96 std::is_same<Intp, TIMEMORY_NATIVE_COMPONENT>::value,
97 int>::type>
98void
99initialize(CompList<CompTypes...>& obj, const Container<Intp, ExtraArgs...>& components)
100{
101 for(auto itr : components)
102 runtime::initialize(obj, itr);
103}
104
105//--------------------------------------------------------------------------------------//
106
107template <template <typename...> class CompList, typename... CompTypes,
108 template <typename, typename...> class Container, typename... ExtraArgs>
109void
110initialize(CompList<CompTypes...>& obj,
111 const Container<const char*, ExtraArgs...>& components)
112{
113 std::vector<std::string> _components;
114 _components.reserve(components.size());
115 for(auto itr : components)
116 _components.emplace_back(std::string(itr));
117 initialize(obj, _components);
118}
119
120//--------------------------------------------------------------------------------------//
121
122template <template <typename...> class CompList, typename... CompTypes>
123void
124initialize(CompList<CompTypes...>& obj, const int ncomponents, const int* components)
125{
126 for(int i = 0; i < ncomponents; ++i)
128}
129
130//======================================================================================//
131
132} // namespace tim
133
134//======================================================================================//
void initialize(Tp &obj, int idx, Arg &&arg, Args &&... args)
Definition: properties.hpp:219
Definition: kokkosp.cpp:39
void initialize(CompList< CompTypes... > &obj, std::initializer_list< EnumT > components)
Definition: initialize.hpp:53
std::vector< TIMEMORY_COMPONENT > enumerate_components(const Container< StringT, ExtraArgs... > &component_names)
description: use this function to generate an array of enumerations from a list of string that can be...
Definition: enumerate.hpp:62
tim::mpl::apply< std::string > string
Definition: macros.hpp:53
components
Definition: settings.cpp:1700
ContainerT delimit(const std::string &line, const std::string &delimiters="\"',;: ", PredicateT &&predicate=[](const std::string &s) -> std::string { return s;})
Definition: delimit.hpp:68