2022-09-19 12:39:02 +02:00
|
|
|
/* Copyright (c) 2021 Barcelona Supercomputing Center (BSC)
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later */
|
2021-10-26 18:42:41 +02:00
|
|
|
|
2022-09-29 15:34:44 +02:00
|
|
|
#include <dirent.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <linux/limits.h>
|
|
|
|
#include <stdatomic.h>
|
2021-07-24 10:53:41 +02:00
|
|
|
#include <stdint.h>
|
2022-09-29 15:34:44 +02:00
|
|
|
#include <stdio.h>
|
2021-07-24 10:53:41 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#include "ovni.h"
|
2021-11-18 11:55:28 +01:00
|
|
|
#include "trace.h"
|
2021-07-24 10:53:41 +02:00
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
static void
|
|
|
|
emit(struct ovni_ev *ev, int row)
|
2021-07-24 10:53:41 +02:00
|
|
|
{
|
|
|
|
static uint64_t firstclock = 0;
|
|
|
|
int64_t delta;
|
|
|
|
|
2022-09-29 15:34:44 +02:00
|
|
|
if (firstclock == 0)
|
2021-07-24 10:53:41 +02:00
|
|
|
firstclock = ovni_ev_get_clock(ev);
|
|
|
|
|
|
|
|
delta = ovni_ev_get_clock(ev) - firstclock;
|
|
|
|
|
|
|
|
//#Paraver (19/01/38 at 03:14):00000000000000000000_ns:0:1:1(00000000000000000008:1)
|
2022-09-29 15:34:44 +02:00
|
|
|
// 2:0:1:1:7:1540663:6400010:1
|
|
|
|
// 2:0:1:1:7:1540663:6400015:1
|
|
|
|
// 2:0:1:1:7:1540663:6400017:0
|
|
|
|
// 2:0:1:1:7:1542091:6400010:1
|
|
|
|
// 2:0:1:1:7:1542091:6400015:1
|
|
|
|
// 2:0:1:1:7:1542091:6400025:1
|
|
|
|
// 2:0:1:1:7:1542091:6400017:0
|
2021-07-24 10:53:41 +02:00
|
|
|
|
2021-10-11 15:46:49 +02:00
|
|
|
printf("2:0:1:1:%d:%ld:%d:%d\n", row, delta, ev->header.category, ev->header.value);
|
2021-07-24 10:53:41 +02:00
|
|
|
}
|
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
static void
|
|
|
|
dump_events(struct ovni_trace *trace)
|
2021-07-24 10:53:41 +02:00
|
|
|
{
|
2021-10-18 12:47:51 +02:00
|
|
|
size_t i;
|
|
|
|
int f, row;
|
2021-07-24 10:53:41 +02:00
|
|
|
uint64_t minclock, lastclock;
|
|
|
|
struct ovni_ev *ev;
|
|
|
|
struct ovni_stream *stream;
|
|
|
|
|
|
|
|
/* Load events */
|
2022-09-29 15:34:44 +02:00
|
|
|
for (i = 0; i < trace->nstreams; i++) {
|
2021-07-24 10:53:41 +02:00
|
|
|
stream = &trace->stream[i];
|
|
|
|
ovni_load_next_event(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
lastclock = 0;
|
|
|
|
|
2022-09-29 15:34:44 +02:00
|
|
|
while (1) {
|
2021-07-24 10:53:41 +02:00
|
|
|
f = -1;
|
|
|
|
minclock = 0;
|
|
|
|
|
|
|
|
/* Select next event based on the clock */
|
2022-09-29 15:34:44 +02:00
|
|
|
for (i = 0; i < trace->nstreams; i++) {
|
2021-07-24 10:53:41 +02:00
|
|
|
stream = &trace->stream[i];
|
|
|
|
|
2022-09-29 15:34:44 +02:00
|
|
|
if (!stream->active)
|
2021-07-24 10:53:41 +02:00
|
|
|
continue;
|
|
|
|
|
2021-07-30 20:08:40 +02:00
|
|
|
ev = stream->cur_ev;
|
2022-09-29 15:34:44 +02:00
|
|
|
if (f < 0 || ovni_ev_get_clock(ev) < minclock) {
|
2021-07-24 10:53:41 +02:00
|
|
|
f = i;
|
|
|
|
minclock = ovni_ev_get_clock(ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-29 15:34:44 +02:00
|
|
|
// fprintf(stderr, "f=%d minclock=%u\n", f, minclock);
|
2021-07-24 10:53:41 +02:00
|
|
|
|
2022-09-29 15:34:44 +02:00
|
|
|
if (f < 0)
|
2021-07-24 10:53:41 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
stream = &trace->stream[f];
|
|
|
|
|
2022-09-29 15:34:44 +02:00
|
|
|
if (lastclock >= ovni_ev_get_clock(stream->cur_ev)) {
|
2021-07-24 10:53:41 +02:00
|
|
|
fprintf(stderr, "warning: backwards jump in time\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Emit current event */
|
2021-08-02 12:34:11 +02:00
|
|
|
row = f + 1;
|
2021-10-18 12:47:51 +02:00
|
|
|
emit(stream->cur_ev, row);
|
2021-07-24 10:53:41 +02:00
|
|
|
|
2021-07-30 20:08:40 +02:00
|
|
|
lastclock = ovni_ev_get_clock(stream->cur_ev);
|
2021-07-24 10:53:41 +02:00
|
|
|
|
|
|
|
/* Read the next one */
|
|
|
|
ovni_load_next_event(stream);
|
|
|
|
|
|
|
|
/* Unset the index */
|
|
|
|
f = -1;
|
|
|
|
minclock = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-29 15:34:44 +02:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
2021-07-24 10:53:41 +02:00
|
|
|
{
|
|
|
|
char *tracedir;
|
2021-09-23 10:38:44 +02:00
|
|
|
struct ovni_trace *trace = calloc(1, sizeof(struct ovni_trace));
|
|
|
|
|
2022-09-29 15:34:44 +02:00
|
|
|
if (trace == NULL) {
|
2021-09-23 10:38:44 +02:00
|
|
|
perror("calloc");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2021-07-24 10:53:41 +02:00
|
|
|
|
2022-09-29 15:34:44 +02:00
|
|
|
if (argc != 2) {
|
2021-07-24 10:53:41 +02:00
|
|
|
fprintf(stderr, "missing tracedir\n");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
tracedir = argv[1];
|
|
|
|
|
2022-09-29 15:34:44 +02:00
|
|
|
if (ovni_load_trace(trace, tracedir))
|
2021-07-24 10:53:41 +02:00
|
|
|
return 1;
|
|
|
|
|
2022-09-29 15:34:44 +02:00
|
|
|
if (ovni_load_streams(trace))
|
2021-07-24 10:53:41 +02:00
|
|
|
return 1;
|
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
printf("#Paraver (19/01/38 at 03:14):00000000000000000000_ns:0:1:1(%ld:1)\n",
|
2022-09-29 15:34:44 +02:00
|
|
|
trace->nstreams);
|
2021-07-24 10:53:41 +02:00
|
|
|
|
2021-08-10 10:18:12 +02:00
|
|
|
dump_events(trace);
|
2021-07-24 10:53:41 +02:00
|
|
|
|
2021-08-10 10:18:12 +02:00
|
|
|
ovni_free_streams(trace);
|
2021-07-24 10:53:41 +02:00
|
|
|
|
2021-08-03 18:42:56 +02:00
|
|
|
fflush(stdout);
|
|
|
|
|
2021-08-10 10:18:12 +02:00
|
|
|
free(trace);
|
|
|
|
|
2021-07-24 10:53:41 +02:00
|
|
|
return 0;
|
|
|
|
}
|