Autonomic Performance Environment for eXascale (APEX)  2.3.1
apex.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2020 Kevin Huck
3  * Copyright (c) 2014-2020 University of Oregon
4  *
5  * Distributed under the Boost Software License, Version 1.0. (See accompanying
6  * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  */
8 
9 /* Copyright (c) 2014 University of Oregon
10  *
11  */
12 
13 /* required for Doxygen */
14 
17 /*
18  * APEX external API
19  *
20  */
21 
22 /*
23  * The C API is required for HPX5 support.
24  */
25 
26 #pragma once
27 
28 #ifndef APEX_H
29 #define APEX_H
30 
31 #include "apex_types.h"
32 #include "apex_export.h"
33 #include "stdbool.h"
34 #include "stdint.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * Initialization, finalization functions
42  */
43 
44 /* The functions from here on should all be documented by Doxygen. */
45 
62 APEX_EXPORT int apex_init(const char * thread_name, const uint64_t comm_rank,
63  const uint64_t comm_size);
64 
76 APEX_EXPORT const char * apex_dump(bool reset);
77 
87 APEX_EXPORT void apex_finalize();
88 
101 APEX_EXPORT void apex_cleanup();
102 
103 /*
104  * Functions for starting, stopping timers
105  */
106 
126  void * identifier);
127 
148  void * identifier, uint64_t guid);
149 
161 APEX_EXPORT void apex_stop(apex_profiler_handle profiler);
162 
176 APEX_EXPORT void apex_yield(apex_profiler_handle profiler);
177 
199  void * identifier);
200 
223  void * identifier, uint64_t guid);
224 
225 /*
226  * Functions for resetting timer values
227  */
228 
242 APEX_EXPORT void apex_reset(apex_profiler_type type, void * identifier);
243 
252 APEX_EXPORT void apex_set_state(apex_thread_state state);
253 
254 /*
255  * Function for sampling a counter value
256  */
257 
269 APEX_EXPORT void apex_sample_value(const char * name, double value);
270 
285 APEX_EXPORT void apex_new_task(apex_profiler_type type, void * identifier,
286  uint64_t task_id);
287 
297 APEX_EXPORT apex_event_type apex_register_custom_event(const char * name);
298 
311 APEX_EXPORT void apex_custom_event(apex_event_type event_type,
312  void * custom_data);
313 
314 /*
315  * Utility functions
316  */
317 
324 APEX_EXPORT const char * apex_version(void);
325 
337 APEX_EXPORT void apex_register_thread(const char * name);
338 
348 APEX_EXPORT void apex_exit_thread(void);
349 
350 /*
351  * Policy Engine functions.
352  */
353 
369 APEX_EXPORT apex_policy_handle * apex_register_policy(
370  const apex_event_type when, apex_policy_function f);
371 
385 APEX_EXPORT apex_policy_handle * apex_register_periodic_policy(
386  unsigned long period, apex_policy_function f);
387 
398 APEX_EXPORT void apex_deregister_policy(apex_policy_handle * handle);
399 
413 APEX_EXPORT apex_profile * apex_get_profile(apex_profiler_type type,
414  void * identifier);
415 
423 APEX_EXPORT double apex_current_power_high(void);
424 
457 APEX_EXPORT int apex_setup_power_cap_throttling(void); // initialize
458 
479  void * identifier,
481  apex_optimization_method_t method, unsigned long update_interval);
482 
507 APEX_EXPORT int apex_setup_throughput_tuning(
508  apex_profiler_type type,
509  void * identifier,
511  apex_event_type event_type, int num_inputs, long ** inputs, long * mins,
512  long * maxs, long * steps);
513 
521 APEX_EXPORT int apex_shutdown_throttling(void); // terminate
522 
531 APEX_EXPORT int apex_get_thread_cap(void); // for thread throttling
532 
541 APEX_EXPORT void apex_set_thread_cap(int new_cap); // for thread throttling
542 
548 APEX_EXPORT void apex_print_options(void);
549 
563 APEX_EXPORT void apex_send (uint64_t tag, uint64_t size, uint64_t target);
564 
579 APEX_EXPORT void apex_recv (uint64_t tag, uint64_t size,
580  uint64_t source_rank, uint64_t source_thread);
581 
590 APEX_EXPORT uint64_t apex_hardware_concurrency (void);
591 
592 #ifndef DOXYGEN_SHOULD_SKIP_THIS
593 
594 #define apex_macro(name, member_variable, type, default_value) \
595 void apex_set_##member_variable (type inval); \
596 type apex_get_##member_variable (void);
597 FOREACH_APEX_OPTION(apex_macro)
598 #undef apex_macro
599 
600 #define apex_macro(name, member_variable, type, default_value) \
601 void apex_set_##member_variable (type inval); \
602 type apex_get_##member_variable (void);
603 FOREACH_APEX_STRING_OPTION(apex_macro)
604 #undef apex_macro
605 
606 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
607 
608 #ifdef __cplusplus
609 }
610 #endif
611 
612 #endif //APEX_H
613 
apex_policy_function
int(* apex_policy_function)(apex_context const context)
Definition: apex_types.h:207
apex_setup_throughput_tuning
int apex_setup_throughput_tuning(apex_profiler_type type, void *identifier, apex_optimization_criteria_t criteria, apex_event_type event_type, int num_inputs, long **inputs, long *mins, long *maxs, long *steps)
Setup throttling to optimize for the specified function, using multiple input criteria.
apex_reset
void apex_reset(apex_profiler_type type, void *identifier)
Reset a timer or counter.
apex_setup_timer_throttling
int apex_setup_timer_throttling(apex_profiler_type type, void *identifier, apex_optimization_criteria_t criteria, apex_optimization_method_t method, unsigned long update_interval)
Setup throttling to optimize for the specified function.
apex_version
const char * apex_version(void)
Return the APEX version.
apex::reset
void reset(const std::string &timer_name)
Reset a timer or counter.
apex_cleanup
void apex_cleanup()
Cleanup APEX.
apex_event_type
Typedef for enumerating the different event types.
apex_recv
void apex_recv(uint64_t tag, uint64_t size, uint64_t source_rank, uint64_t source_thread)
Notify APEX that the current thread is receiving a parcel/message from another rank/locality/process.
apex_set_state
void apex_set_state(apex_thread_state state)
Set the thread state.
apex_register_custom_event
apex_event_type apex_register_custom_event(const char *name)
Register an event type with APEX.
apex_shutdown_throttling
int apex_shutdown_throttling(void)
Terminate the throttling policy.
apex_new_task
void apex_new_task(apex_profiler_type type, void *identifier, uint64_t task_id)
Create a new task (dependency).
apex_custom_event
void apex_custom_event(apex_event_type event_type, void *custom_data)
Trigger a custom event.
apex_hardware_concurrency
uint64_t apex_hardware_concurrency(void)
Get the number of possible threads supported on this system.
apex_yield
void apex_yield(apex_profiler_handle profiler)
Stop a timer, but don't increment the number of calls.
apex_profiler_type
Typedef for enumerating the different timer types.
apex_init
int apex_init(const char *thread_name, const uint64_t comm_rank, const uint64_t comm_size)
Intialize APEX.
apex_start_guid
apex_profiler_handle apex_start_guid(apex_profiler_type type, void *identifier, uint64_t guid)
Start a timer.
apex_register_periodic_policy
apex_policy_handle * apex_register_periodic_policy(unsigned long period, apex_policy_function f)
Register a policy with APEX.
apex_sample_value
void apex_sample_value(const char *name, double value)
Sample a state value.
apex_exit_thread
void apex_exit_thread(void)
Exit a thread.
apex_send
void apex_send(uint64_t tag, uint64_t size, uint64_t target)
Notify APEX that the current thread is sending a parcel/message to another rank/locality/process.
apex_types.h
apex_resume
apex_profiler_handle apex_resume(apex_profiler_type type, void *identifier)
Resume a timer.
apex_optimization_method_t
apex_optimization_method_t
Definition: apex_types.h:122
apex_register_policy
apex_policy_handle * apex_register_policy(const apex_event_type when, apex_policy_function f)
Register a policy with APEX.
apex_deregister_policy
void apex_deregister_policy(apex_policy_handle *handle)
Deregister a policy with APEX.
apex_current_power_high
double apex_current_power_high(void)
Get the current power reading.
apex_get_profile
apex_profile * apex_get_profile(apex_profiler_type type, void *identifier)
Get the current profile for the specified id.
apex_print_options
void apex_print_options(void)
Print the current APEX settings.
apex_profiler_handle
void * apex_profiler_handle
Definition: apex_types.h:25
apex_dump
const char * apex_dump(bool reset)
Dump output from APEX.
apex_finalize
void apex_finalize()
Finalize APEX.
apex_stop
void apex_stop(apex_profiler_handle profiler)
Stop a timer.
apex_optimization_criteria_t
apex_optimization_criteria_t
Definition: apex_types.h:110
apex_resume_guid
apex_profiler_handle apex_resume_guid(apex_profiler_type type, void *identifier, uint64_t guid)
Resume a timer.
apex_setup_power_cap_throttling
int apex_setup_power_cap_throttling(void)
Initialize the power cap throttling policy.
apex_set_thread_cap
void apex_set_thread_cap(int new_cap)
Set the current thread cap for throttling.
apex_register_thread
void apex_register_thread(const char *name)
Register a new thread.
apex_start
apex_profiler_handle apex_start(apex_profiler_type type, void *identifier)
Start a timer.
apex_get_thread_cap
int apex_get_thread_cap(void)
Get the current thread cap set by the throttling.