6 #ifndef PROFILE_HPP_INCLUDE
7 #define PROFILE_HPP_INCLUDE
17 #include "geopm_hash.h"
18 #include "geopm_hint.h"
19 #include "geopm_public.h"
20 #include "geopm_time.h"
31 static inline uint64_t geopm_region_id_hash(uint64_t region_id)
33 uint64_t ret = ((region_id << 32) >> 32);
35 if (GEOPM_REGION_HASH_INVALID == ret) {
36 ret = GEOPM_REGION_HASH_UNMARKED;
41 static inline int geopm_region_id_is_mpi(uint64_t region_id)
46 static inline geopm_region_hint_e geopm_region_id_hint(uint64_t region_id)
48 geopm_region_hint_e ret;
49 if (GEOPM_REGION_HASH_UNMARKED == region_id) {
50 ret = GEOPM_REGION_HINT_UNKNOWN;
52 else if (geopm_region_id_is_mpi(region_id)) {
53 ret = GEOPM_REGION_HINT_NETWORK;
56 ret = (geopm_region_hint_e)(region_id >> 32);
57 if (!ret || ret >= GEOPM_NUM_REGION_HINT) {
58 ret = GEOPM_REGION_HINT_UNKNOWN;
64 static inline uint64_t geopm_region_id_set_hint(uint64_t
hint_type, uint64_t region_id)
69 static inline int geopm_region_id_hint_is_equal(uint64_t
hint_type, uint64_t region_id)
71 return (region_id & (
hint_type << 32)) ? 1 : 0;
117 static Profile &default_profile(
void);
143 virtual uint64_t
region(
const std::string ®ion_name,
long hint) = 0;
155 virtual void enter(uint64_t region_id) = 0;
168 virtual void exit(uint64_t region_id) = 0;
204 static int get_cpu(
void);
237 const std::string &report,
239 std::set<int> cpu_set,
240 std::shared_ptr<ApplicationStatus> app_status,
241 std::shared_ptr<ApplicationRecordLog> app_record_log,
243 std::shared_ptr<ServiceProxy> service_proxy,
244 std::shared_ptr<Scheduler> scheduler,
250 uint64_t region(
const std::string ®ion_name,
long hint)
override;
251 void enter(uint64_t region_id)
override;
252 void exit(uint64_t region_id)
override;
253 void epoch(
void)
override;
254 void shutdown(
void)
override;
255 void thread_init(uint32_t num_work_unit)
override;
256 void thread_post(
int cpu)
override;
257 std::vector<std::string> region_names(
void)
override;
258 void reset_cpu_set(
void)
override;
259 void overhead(
double overhead_sec)
override;
260 void connect(
void)
override;
265 init_app_status(
void);
267 init_app_record_log(
void);
270 set_hint(uint64_t hint);
273 std::string m_prof_name;
274 std::string m_report;
277 uint64_t m_curr_region_id;
278 uint64_t m_current_hash;
285 std::set<int> m_cpu_set;
287 std::shared_ptr<ApplicationStatus> m_app_status;
288 std::shared_ptr<ApplicationRecordLog> m_app_record_log;
289 std::stack<geopm_region_hint_e> m_hint_stack;
291 double m_overhead_time;
292 double m_overhead_time_startup;
293 double m_overhead_time_shutdown;
295 std::map<std::string, uint64_t> m_region_names;
297 std::shared_ptr<ServiceProxy> m_service_proxy;
298 std::shared_ptr<Scheduler> m_scheduler;
299 int m_pid_registered;
301 enum m_profile_const_e {
307 std::set<uint64_t> m_region_ids;
geopm_region_id_e
Definition: Profile.hpp:26
@ GEOPM_REGION_ID_MPI
Definition: Profile.hpp:28
@ GEOPM_REGION_ID_EPOCH
Definition: Profile.hpp:27
Provides an abstraction for a shared memory buffer that can be used to pass entry,...
Definition: ApplicationRecordLog.hpp:57
Object that encapsulates application process information such as the process ID, region hash,...
Definition: ApplicationStatus.hpp:27
Enables application profiling and application feedback to the control algorithm.
Definition: Profile.hpp:113
virtual uint64_t region(const std::string ®ion_name, long hint)=0
Register a region of code to be profiled.
virtual void exit(uint64_t region_id)=0
Mark a region exit point.
virtual std::vector< std::string > region_names(void)=0
virtual void overhead(double overhead_sec)=0
virtual void enter(uint64_t region_id)=0
Mark a region entry point.
virtual void reset_cpu_set(void)=0
virtual void epoch(void)=0
Signal pass through outer loop.
virtual ~Profile()=default
virtual void thread_init(uint32_t num_work_unit)=0
Update the total work for all CPUs. This method should be called by one thread in the same parallel r...
virtual void connect(void)=0
virtual void shutdown(void)=0
virtual void thread_post(int cpu)=0
Mark one unit of work completed by the thread on this CPU.
Definition: Profile.hpp:214
ProfileImp(const ProfileImp &other)=delete
bool m_is_enabled
Definition: Profile.hpp:262
ProfileImp operator=(const ProfileImp &other)=delete
Definition: Scheduler.hpp:16
Definition: Accumulator.cpp:12
uint64_t hint_type(const std::string &hint_name)
Parse a string representing the hint name.
Definition: record.cpp:80