|
@@ -51,7 +51,8 @@ long long total_instr[STARPU_NMAX_SCHED_CTXS];
|
|
|
/* long long total_branch_instr[STARPU_NMAX_SCHED_CTXS]; */
|
|
|
long long total_fps[STARPU_NMAX_SCHED_CTXS];
|
|
|
|
|
|
-struct read_format {
|
|
|
+struct read_format
|
|
|
+{
|
|
|
uint64_t value; /* The value of the event */
|
|
|
uint64_t time_enabled; /* if PERF_FORMAT_TOTAL_TIME_ENABLED */
|
|
|
uint64_t time_running; /* if PERF_FORMAT_TOTAL_TIME_RUNNING */
|
|
@@ -67,14 +68,17 @@ static long perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu,
|
|
|
|
|
|
void print_results_for_worker(int workerid, unsigned sched_ctx, struct starpu_task *task)
|
|
|
{
|
|
|
+ ssize_t rread;
|
|
|
long long instr, /*cycles, cache_misses, cache_refs, branch_instr,*/ fps;
|
|
|
- read(fd_instr[workerid], &instr, sizeof(instr));
|
|
|
+ rread = read(fd_instr[workerid], &instr, sizeof(instr));
|
|
|
+ assert(rread == sizeof(instr));
|
|
|
/* read(fd_cycles[workerid], &cycles, sizeof(long long)); */
|
|
|
/* read(fd_cache_misses[workerid], &cache_misses, sizeof(long long)); */
|
|
|
/* read(fd_cache_refs[workerid], &cache_refs, sizeof(long long)); */
|
|
|
/* read(fd_branch_instr[workerid], &branch_instr, sizeof(long long)); */
|
|
|
- read(fd_fps[workerid], &fps, sizeof(long long));
|
|
|
-
|
|
|
+ rread = read(fd_fps[workerid], &fps, sizeof(long long));
|
|
|
+ assert(rread == sizeof(long long));
|
|
|
+
|
|
|
total_instr[sched_ctx] += instr;
|
|
|
/* total_cycles[sched_ctx] += cycles; */
|
|
|
/* total_cache_misses[sched_ctx] += cache_misses; */
|
|
@@ -100,7 +104,7 @@ void print_results_for_ctx(unsigned sched_ctx, struct starpu_task *task)
|
|
|
/* long long curr_total_cache_refs = 0; */
|
|
|
/* long long curr_total_branch_instr = 0; */
|
|
|
long long curr_total_fps = 0;
|
|
|
-
|
|
|
+
|
|
|
struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx);
|
|
|
|
|
|
struct starpu_sched_ctx_iterator it;
|
|
@@ -109,16 +113,20 @@ void print_results_for_ctx(unsigned sched_ctx, struct starpu_task *task)
|
|
|
workers->init_iterator(workers, &it);
|
|
|
while(workers->has_next(workers, &it))
|
|
|
{
|
|
|
+ ssize_t rread;
|
|
|
+
|
|
|
workerid = workers->get_next(workers, &it);
|
|
|
// Read event counter value
|
|
|
struct read_format instr, /*cycles, cache_misses, cache_refs, branch_instr,*/ fps;
|
|
|
- read(fd_instr[workerid], &instr, sizeof(struct read_format));
|
|
|
+ rread = read(fd_instr[workerid], &instr, sizeof(struct read_format));
|
|
|
+ assert(rread==sizeof(struct read_format));
|
|
|
/* read(fd_cycles[workerid], &cycles, sizeof(long long)); */
|
|
|
/* read(fd_cache_misses[workerid], &cache_misses, sizeof(long long)); */
|
|
|
/* read(fd_cache_refs[workerid], &cache_refs, sizeof(long long)); */
|
|
|
/* read(fd_branch_instr[workerid], &branch_instr, sizeof(long long)); */
|
|
|
- read(fd_fps[workerid], &fps, sizeof(struct read_format));
|
|
|
-
|
|
|
+ rread = read(fd_fps[workerid], &fps, sizeof(struct read_format));
|
|
|
+ assert(rread == sizeof(struct read_format));
|
|
|
+
|
|
|
curr_total_instr += (instr.time_enabled != 0 && instr.time_running !=0) ? instr.value * instr.time_enabled/instr.time_running : instr.value;
|
|
|
printf("w%d instr time enabled %"PRIu64" time running %"PRIu64" \n", workerid, instr.time_enabled, instr.time_running);
|
|
|
|
|
@@ -142,7 +150,7 @@ void print_results_for_ctx(unsigned sched_ctx, struct starpu_task *task)
|
|
|
printf("%d: Fps %lf k curr fps %lf k\n", sched_ctx,
|
|
|
(double)total_fps[sched_ctx]/1000,
|
|
|
(double)curr_total_fps/1000);
|
|
|
-
|
|
|
+
|
|
|
printf("%d: Task Flops %lf k %s \n", sched_ctx, task->flops/1000, (task->cl && task->cl->model) ? task->cl->model->symbol : "task null");
|
|
|
printf("-------------------------------------------\n");
|
|
|
}
|
|
@@ -153,11 +161,11 @@ void config_event(struct perf_event_attr *event, unsigned with_time, uint64_t ev
|
|
|
event->type = event_type;
|
|
|
event->size = sizeof(struct perf_event_attr);
|
|
|
event->config = config_type;
|
|
|
- event->disabled = 1; // Event is initially disabled
|
|
|
+ event->disabled = 1; // Event is initially disabled
|
|
|
event->exclude_kernel = 1; // excluding events that happen in the kernel space
|
|
|
if(with_time)
|
|
|
{
|
|
|
- /* if the PMU is multiplexing several events we measure the time spent to actually measure this event (time_running)
|
|
|
+ /* if the PMU is multiplexing several events we measure the time spent to actually measure this event (time_running)
|
|
|
and compare it to the one expected is did, thus we compute the precision of the counter*/
|
|
|
event->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED|PERF_FORMAT_TOTAL_TIME_RUNNING;
|
|
|
}
|
|
@@ -208,19 +216,19 @@ void start_monitoring_all_events_for_worker(int workerid)
|
|
|
{
|
|
|
ioctl(fd_instr[workerid], PERF_EVENT_IOC_RESET, 0);
|
|
|
ioctl(fd_instr[workerid], PERF_EVENT_IOC_ENABLE, 0);
|
|
|
-
|
|
|
+
|
|
|
/* ioctl(fd_cycles[workerid], PERF_EVENT_IOC_RESET, 0); */
|
|
|
/* ioctl(fd_cycles[workerid], PERF_EVENT_IOC_ENABLE, 0); */
|
|
|
-
|
|
|
+
|
|
|
/* ioctl(fd_cache_misses[workerid], PERF_EVENT_IOC_RESET, 0); */
|
|
|
/* ioctl(fd_cache_misses[workerid], PERF_EVENT_IOC_ENABLE, 0); */
|
|
|
-
|
|
|
+
|
|
|
/* ioctl(fd_cache_refs[workerid], PERF_EVENT_IOC_RESET, 0); */
|
|
|
/* ioctl(fd_cache_refs[workerid], PERF_EVENT_IOC_ENABLE, 0); */
|
|
|
|
|
|
/* ioctl(fd_branch_instr[workerid], PERF_EVENT_IOC_RESET, 0); */
|
|
|
/* ioctl(fd_branch_instr[workerid], PERF_EVENT_IOC_ENABLE, 0); */
|
|
|
-
|
|
|
+
|
|
|
ioctl(fd_fps[workerid], PERF_EVENT_IOC_RESET, 0);
|
|
|
ioctl(fd_fps[workerid], PERF_EVENT_IOC_ENABLE, 0);
|
|
|
}
|
|
@@ -240,7 +248,7 @@ void perf_count_handle_idle_end(unsigned sched_ctx, int worker)
|
|
|
unsigned has_starpu_scheduler;
|
|
|
unsigned has_awake_workers;
|
|
|
has_starpu_scheduler = starpu_sched_ctx_has_starpu_scheduler(sched_ctx, &has_awake_workers);
|
|
|
-
|
|
|
+
|
|
|
if(!has_starpu_scheduler && !has_awake_workers)
|
|
|
{
|
|
|
struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx);
|
|
@@ -269,7 +277,7 @@ void perf_count_handle_idle_end(unsigned sched_ctx, int worker)
|
|
|
}
|
|
|
|
|
|
void perf_count_handle_poped_task(unsigned sched_ctx, int worker,
|
|
|
- struct starpu_task *task,
|
|
|
+ struct starpu_task *task,
|
|
|
__attribute__((unused))uint32_t footprint)
|
|
|
{
|
|
|
unsigned has_starpu_scheduler;
|
|
@@ -318,9 +326,9 @@ void perf_count_init_worker(int workerid, unsigned sched_ctx)
|
|
|
void perf_count_start_ctx(unsigned sched_ctx)
|
|
|
{
|
|
|
struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx);
|
|
|
-
|
|
|
+
|
|
|
struct starpu_sched_ctx_iterator it;
|
|
|
-
|
|
|
+
|
|
|
int workerid;
|
|
|
workers->init_iterator(workers, &it);
|
|
|
while(workers->has_next(workers, &it))
|
|
@@ -333,9 +341,9 @@ void perf_count_start_ctx(unsigned sched_ctx)
|
|
|
void perf_count_end_ctx(unsigned sched_ctx)
|
|
|
{
|
|
|
struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx);
|
|
|
-
|
|
|
+
|
|
|
struct starpu_sched_ctx_iterator it;
|
|
|
-
|
|
|
+
|
|
|
int workerid;
|
|
|
workers->init_iterator(workers, &it);
|
|
|
while(workers->has_next(workers, &it))
|