SST 12.1.0
Structural Simulation Toolkit
syncProfileTool.h
1// Copyright 2009-2022 NTESS. Under the terms
2// of Contract DE-NA0003525 with NTESS, the U.S.
3// Government retains certain rights in this software.
4//
5// Copyright (c) 2009-2022, NTESS
6// All rights reserved.
7//
8// This file is part of the SST software package. For license
9// information, see the LICENSE file in the top level directory of the
10// distribution.
11
12#ifndef SST_CORE_PROFILE_SYNCPROFILETOOL_H
13#define SST_CORE_PROFILE_SYNCPROFILETOOL_H
14
15#include "sst/core/eli/elementinfo.h"
16#include "sst/core/sst_types.h"
17#include "sst/core/ssthandler.h"
18#include "sst/core/warnmacros.h"
19
20#include <chrono>
21#include <map>
22
23namespace SST {
24
25namespace Profile {
26
27// Initial version of sync profiling tool. The API is not yet complete.
29{
30public:
31 SST_ELI_REGISTER_PROFILETOOL_DERIVED_API(SST::Profile::SyncProfileTool, SST::Profile::ProfileTool, Params&)
32
33 // Still to enable the level param in the class
34 SST_ELI_DOCUMENT_PARAMS(
35 // { "level", "Level at which to track profile (global, type, component, subcomponent)", "component" },
36 )
37 // enum class Profile_Level { Global, Type, Component, Subcomponent };
38
39 SyncProfileTool(const std::string& name, Params& params);
40
41 virtual void syncManagerStart() {}
42 virtual void syncManagerEnd() {}
43};
44
45
46/**
47 Profile tool that will count the number of times a handler is
48 called
49 */
51{
52
53public:
54 SST_ELI_REGISTER_PROFILETOOL(
57 "sst",
58 "profile.sync.count",
59 SST_ELI_ELEMENT_VERSION(0, 1, 0),
60 "Profiler that will count calls to sync"
61 )
62
63 SyncProfileToolCount(const std::string& name, Params& params);
64
65 virtual ~SyncProfileToolCount() {}
66
67 void syncManagerStart() override;
68
69 void outputData(FILE* fp) override;
70
71private:
72 uint64_t syncmanager_count = 0;
73};
74
75/**
76 Profile tool that will count the number of times a handler is
77 called
78 */
79template <typename T>
81{
82public:
83 SyncProfileToolTime(const std::string& name, Params& params);
84
85 virtual ~SyncProfileToolTime() {}
86
87 void syncManagerStart() override { start_time_ = T::now(); }
88
89 void syncManagerEnd() override
90 {
91 auto total_time = T::now() - start_time_;
92 syncmanager_time += std::chrono::duration_cast<std::chrono::nanoseconds>(total_time).count();
93 syncmanager_count++;
94 }
95
96 void outputData(FILE* fp) override;
97
98private:
99 uint64_t syncmanager_time = 0;
100 uint64_t syncmanager_count = 0;
101
102 typename T::time_point start_time_;
103};
104
105} // namespace Profile
106} // namespace SST
107
108#endif // SST_CORE_PROFILE_SYNCPROFILETOOL_H
Parameter store.
Definition: params.h:56
ProfileTool is a class loadable through the factory which allows dynamic addition of profiling capabi...
Definition: profiletool.h:30
Profile tool that will count the number of times a handler is called.
Definition: syncProfileTool.h:51
Profile tool that will count the number of times a handler is called.
Definition: syncProfileTool.h:81
Definition: syncProfileTool.h:29