Loading...
Searching...
No Matches
starpu_profiling.h
Go to the documentation of this file.
/* StarPU --- Runtime system for heterogeneous multicore architectures.
*
* Copyright (C) 2009-2025 University of Bordeaux, CNRS (LaBRI UMR 5800), Inria
* Copyright (C) 2020-2020 Federal University of Rio Grande do Sul (UFRGS)
*
* StarPU is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* StarPU is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU Lesser General Public License in COPYING.LGPL for more details.
*/
#include <starpu.h>
#ifndef __STARPU_PROFILING_H__
#define __STARPU_PROFILING_H__
#include <errno.h>
#include <time.h>
#include <starpu_config.h>
#ifdef STARPU_PAPI
#include <papi.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define STARPU_PROFILING_DISABLE 0
#define STARPU_PROFILING_ENABLE 1
struct starpu_profiling_task_info
{
struct timespec submit_time;
struct timespec push_start_time;
struct timespec push_end_time;
struct timespec pop_start_time;
struct timespec pop_end_time;
struct timespec acquire_data_start_time;
struct timespec acquire_data_end_time;
struct timespec start_time;
struct timespec end_time;
struct timespec release_data_start_time;
struct timespec release_data_end_time;
struct timespec callback_start_time;
struct timespec callback_end_time;
/* TODO add expected length, expected start/end ? */
int workerid;
uint64_t used_cycles;
uint64_t stall_cycles;
double energy_consumed;
#ifdef STARPU_PAPI
long long int papi_values[PAPI_MAX_HWCTRS];
int papi_event_set;
#endif
};
struct starpu_profiling_worker_info
{
struct timespec start_time;
struct timespec total_time;
struct timespec executing_time;
struct timespec callback_time;
struct timespec waiting_time;
struct timespec sleeping_time;
struct timespec scheduling_time;
struct timespec all_executing_time;
struct timespec all_callback_time;
struct timespec all_waiting_time;
struct timespec all_sleeping_time;
struct timespec all_scheduling_time;
int executed_tasks;
uint64_t used_cycles;
uint64_t stall_cycles;
double energy_consumed;
/* TODO: add wasted time due to failed tasks */
double flops;
};
struct starpu_profiling_bus_info
{
struct timespec start_time;
struct timespec total_time;
int long long transferred_bytes;
int transfer_count;
};
void starpu_profiling_init(void);
void starpu_profiling_set_id(int new_id);
int starpu_profiling_status_set(int status);
int starpu_profiling_status_get(void);
#ifdef BUILDING_STARPU
#include <common/utils.h>
#ifdef __GNUC__
extern int _starpu_profiling;
#define starpu_profiling_status_get() ( \
{ \
int __ret; \
ANNOTATE_HAPPENS_AFTER(&_starpu_profiling); \
__ret = _starpu_profiling; \
ANNOTATE_HAPPENS_BEFORE(&_starpu_profiling); \
__ret; \
})
#endif
#endif
int starpu_profiling_worker_get_info(int workerid, struct starpu_profiling_worker_info *worker_info);
int starpu_bus_get_count(void);
int starpu_bus_get_id(int src, int dst);
int starpu_bus_get_src(int busid);
int starpu_bus_get_dst(int busid);
void starpu_bus_set_direct(int busid, int direct);
int starpu_bus_get_direct(int busid);
void starpu_bus_set_ngpus(int busid, int ngpus);
int starpu_bus_get_ngpus(int busid);
int starpu_bus_get_profiling_info(int busid, struct starpu_profiling_bus_info *bus_info);
/* Some helper functions to manipulate profiling API output */
/* Reset timespec */
static __starpu_inline void starpu_timespec_clear(struct timespec *tsp)
{
tsp->tv_sec = 0;
tsp->tv_nsec = 0;
}
#define STARPU_NS_PER_S 1000000000
/* Computes result = a + b */
static __starpu_inline void starpu_timespec_add(struct timespec *a,
struct timespec *b,
struct timespec *result)
{
result->tv_sec = a->tv_sec + b->tv_sec;
result->tv_nsec = a->tv_nsec + b->tv_nsec;
if (result->tv_nsec >= STARPU_NS_PER_S)
{
++(result)->tv_sec;
result->tv_nsec -= STARPU_NS_PER_S;
}
}
/* Computes res += b */
static __starpu_inline void starpu_timespec_accumulate(struct timespec *result,
struct timespec *a)
{
result->tv_sec += a->tv_sec;
result->tv_nsec += a->tv_nsec;
if (result->tv_nsec >= STARPU_NS_PER_S)
{
++(result)->tv_sec;
result->tv_nsec -= STARPU_NS_PER_S;
}
}
/* Computes result = a - b */
static __starpu_inline void starpu_timespec_sub(const struct timespec *a,
const struct timespec *b,
struct timespec *result)
{
result->tv_sec = a->tv_sec - b->tv_sec;
result->tv_nsec = a->tv_nsec - b->tv_nsec;
if ((result)->tv_nsec < 0)
{
--(result)->tv_sec;
result->tv_nsec += STARPU_NS_PER_S;
}
}
#define starpu_timespec_cmp(a, b, CMP) \
(((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_nsec CMP(b)->tv_nsec) : ((a)->tv_sec CMP(b)->tv_sec))
double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end);
double starpu_timing_timespec_to_us(struct timespec *ts);
void starpu_profiling_bus_helper_display_summary(void);
void starpu_profiling_worker_helper_display_summary(void);
void starpu_data_display_memory_stats(void);
#ifdef __cplusplus
}
#endif
#endif /* __STARPU_PROFILING_H__ */
starpu_profiling_bus_info::transferred_bytes
int long long transferred_bytes
Definition starpu_profiling.h:183
starpu_profiling_worker_info::executing_time
struct timespec executing_time
Definition starpu_profiling.h:125
starpu_profiling_task_info::acquire_data_end_time
struct timespec acquire_data_end_time
Definition starpu_profiling.h:71
starpu_profiling_worker_info::waiting_time
struct timespec waiting_time
Definition starpu_profiling.h:132
starpu_profiling_task_info::workerid
int workerid
Definition starpu_profiling.h:91
starpu_profiling_worker_info::stall_cycles
uint64_t stall_cycles
Definition starpu_profiling.h:164
starpu_profiling_worker_info::all_waiting_time
struct timespec all_waiting_time
Definition starpu_profiling.h:150
starpu_profiling_task_info::callback_end_time
struct timespec callback_end_time
Definition starpu_profiling.h:86
starpu_profiling_bus_info::transfer_count
int transfer_count
Definition starpu_profiling.h:185
starpu_profiling_task_info::submit_time
struct timespec submit_time
Definition starpu_profiling.h:57
starpu_profiling_bus_info::total_time
struct timespec total_time
Definition starpu_profiling.h:181
starpu_profiling_task_info::callback_start_time
struct timespec callback_start_time
Definition starpu_profiling.h:84
starpu_profiling_worker_info::all_scheduling_time
struct timespec all_scheduling_time
Definition starpu_profiling.h:156
starpu_profiling_worker_info::energy_consumed
double energy_consumed
Definition starpu_profiling.h:166
starpu_profiling_task_info::pop_start_time
struct timespec pop_start_time
Definition starpu_profiling.h:64
starpu_profiling_worker_info::all_callback_time
struct timespec all_callback_time
Definition starpu_profiling.h:147
starpu_profiling_worker_info::used_cycles
uint64_t used_cycles
Definition starpu_profiling.h:162
starpu_profiling_task_info::push_end_time
struct timespec push_end_time
Definition starpu_profiling.h:62
starpu_profiling_worker_info::all_executing_time
struct timespec all_executing_time
Definition starpu_profiling.h:144
starpu_profiling_task_info::energy_consumed
double energy_consumed
Definition starpu_profiling.h:98
starpu_profiling_worker_info::executed_tasks
int executed_tasks
Definition starpu_profiling.h:159
starpu_profiling_task_info::stall_cycles
uint64_t stall_cycles
Definition starpu_profiling.h:96
starpu_profiling_bus_info::start_time
struct timespec start_time
Definition starpu_profiling.h:179
starpu_profiling_worker_info::callback_time
struct timespec callback_time
Definition starpu_profiling.h:128
starpu_profiling_worker_info::all_sleeping_time
struct timespec all_sleeping_time
Definition starpu_profiling.h:153
starpu_profiling_task_info::acquire_data_start_time
struct timespec acquire_data_start_time
Definition starpu_profiling.h:69
starpu_profiling_task_info::release_data_end_time
struct timespec release_data_end_time
Definition starpu_profiling.h:81
starpu_profiling_task_info::pop_end_time
struct timespec pop_end_time
Definition starpu_profiling.h:66
starpu_profiling_task_info::push_start_time
struct timespec push_start_time
Definition starpu_profiling.h:60
starpu_profiling_worker_info::total_time
struct timespec total_time
Definition starpu_profiling.h:122
starpu_profiling_task_info::release_data_start_time
struct timespec release_data_start_time
Definition starpu_profiling.h:79
starpu_profiling_task_info::start_time
struct timespec start_time
Definition starpu_profiling.h:74
starpu_profiling_worker_info::sleeping_time
struct timespec sleeping_time
Definition starpu_profiling.h:136
starpu_profiling_task_info::papi_values
long long int papi_values[PAPI_MAX_HWCTRS]
Definition starpu_profiling.h:102
starpu_profiling_worker_info::scheduling_time
struct timespec scheduling_time
Definition starpu_profiling.h:140
starpu_profiling_task_info::end_time
struct timespec end_time
Definition starpu_profiling.h:76
starpu_profiling_task_info::used_cycles
uint64_t used_cycles
Definition starpu_profiling.h:94
starpu_profiling_worker_info::start_time
struct timespec start_time
Definition starpu_profiling.h:120
starpu_profiling_worker_helper_display_summary
void starpu_profiling_worker_helper_display_summary(void)
starpu_profiling_bus_helper_display_summary
void starpu_profiling_bus_helper_display_summary(void)
starpu_profiling_init
void starpu_profiling_init(void)
starpu_bus_get_profiling_info
int starpu_bus_get_profiling_info(int busid, struct starpu_profiling_bus_info *bus_info)
starpu_bus_get_id
int starpu_bus_get_id(int src, int dst)
starpu_bus_get_src
int starpu_bus_get_src(int busid)
starpu_timing_timespec_to_us
double starpu_timing_timespec_to_us(struct timespec *ts)
starpu_profiling_worker_get_info
int starpu_profiling_worker_get_info(int workerid, struct starpu_profiling_worker_info *worker_info)
starpu_bus_get_direct
int starpu_bus_get_direct(int busid)
starpu_bus_get_count
int starpu_bus_get_count(void)
starpu_bus_get_dst
int starpu_bus_get_dst(int busid)
starpu_data_display_memory_stats
void starpu_data_display_memory_stats(void)
starpu_bus_get_ngpus
int starpu_bus_get_ngpus(int busid)
starpu_bus_set_direct
void starpu_bus_set_direct(int busid, int direct)
starpu_profiling_status_set
int starpu_profiling_status_set(int status)
starpu_timing_timespec_delay_us
double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end)
starpu_profiling_set_id
void starpu_profiling_set_id(int new_id)
starpu_bus_set_ngpus
void starpu_bus_set_ngpus(int busid, int ngpus)
starpu_profiling_status_get
int starpu_profiling_status_get(void)
starpu_profiling_bus_info
Definition starpu_profiling.h:177
starpu_profiling_task_info
Definition starpu_profiling.h:55
starpu_profiling_worker_info
Definition starpu_profiling.h:118
starpu.h
starpu_config.h