Store the first and last clock of emu events

Allows the tests to know the relative clock that will appear in the PRV
trace (with one rank only).
This commit is contained in:
Rodrigo Arias 2023-02-24 11:55:54 +01:00 committed by Rodrigo Arias Mallo
parent c508929835
commit 864ce4222f
5 changed files with 46 additions and 9 deletions

24
test/emu/instr.c Normal file
View File

@ -0,0 +1,24 @@
/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#include "instr.h"
int first_clock_set = 0;
int64_t first_clock; /* First clock */
int64_t last_clock; /* Clock from the last event */
int64_t get_clock(void)
{
last_clock = ovni_clock_now();
if (first_clock_set == 0) {
first_clock = last_clock;
first_clock_set = 1;
}
return last_clock;
}
int64_t get_delta(void)
{
return last_clock - first_clock;
}

View File

@ -18,11 +18,18 @@
#include <time.h>
#include <unistd.h>
extern int first_clock_set;
extern int64_t first_clock;
extern int64_t last_clock;
int64_t get_clock(void);
int64_t get_delta(void);
#define INSTR_0ARG(name, mcv) \
static inline void name(void) \
{ \
struct ovni_ev ev = {0}; \
ovni_ev_set_clock(&ev, ovni_clock_now()); \
ovni_ev_set_clock(&ev, get_clock()); \
ovni_ev_set_mcv(&ev, mcv); \
ovni_ev_emit(&ev); \
}
@ -31,7 +38,7 @@
static inline void name(ta a) \
{ \
struct ovni_ev ev = {0}; \
ovni_ev_set_clock(&ev, ovni_clock_now()); \
ovni_ev_set_clock(&ev, get_clock()); \
ovni_ev_set_mcv(&ev, mcv); \
ovni_payload_add(&ev, (uint8_t *) &a, sizeof(a)); \
ovni_ev_emit(&ev); \
@ -41,7 +48,7 @@
static inline void name(ta a, tb b) \
{ \
struct ovni_ev ev = {0}; \
ovni_ev_set_clock(&ev, ovni_clock_now()); \
ovni_ev_set_clock(&ev, get_clock()); \
ovni_ev_set_mcv(&ev, mcv); \
ovni_payload_add(&ev, (uint8_t *) &a, sizeof(a)); \
ovni_payload_add(&ev, (uint8_t *) &b, sizeof(b)); \
@ -52,8 +59,8 @@
static inline void name(ta a, tb b, tc c) \
{ \
struct ovni_ev ev = {0}; \
ovni_ev_set_clock(&ev, get_clock()); \
ovni_ev_set_mcv(&ev, mcv); \
ovni_ev_set_clock(&ev, ovni_clock_now()); \
ovni_payload_add(&ev, (uint8_t *) &a, sizeof(a)); \
ovni_payload_add(&ev, (uint8_t *) &b, sizeof(b)); \
ovni_payload_add(&ev, (uint8_t *) &c, sizeof(c)); \
@ -68,7 +75,7 @@ instr_thread_end(void)
struct ovni_ev ev = {0};
ovni_ev_set_mcv(&ev, "OHe");
ovni_ev_set_clock(&ev, ovni_clock_now());
ovni_ev_set_clock(&ev, get_clock());
ovni_ev_emit(&ev);
/* Flush the events to disk before killing the thread */

View File

@ -13,7 +13,7 @@ instr_nanos6_type_create(int32_t typeid)
struct ovni_ev ev = {0};
ovni_ev_set_mcv(&ev, "6Yc");
ovni_ev_set_clock(&ev, ovni_clock_now());
ovni_ev_set_clock(&ev, get_clock());
char buf[256];
char *p = buf;

View File

@ -12,7 +12,7 @@ instr_nosv_type_create(int32_t typeid)
struct ovni_ev ev = {0};
ovni_ev_set_mcv(&ev, "VYc");
ovni_ev_set_clock(&ev, ovni_clock_now());
ovni_ev_set_clock(&ev, get_clock());
char buf[256];
char *p = buf;

View File

@ -104,11 +104,17 @@ function(ovni_test source)
include_directories(
"${CMAKE_SOURCE_DIR}/src/include"
"${CMAKE_SOURCE_DIR}/src/emu"
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/include"
)
add_executable("${OVNI_TEST_NAME}" "${OVNI_TEST_SOURCE}")
target_link_libraries("${OVNI_TEST_NAME}" PRIVATE ovni)
add_executable("${OVNI_TEST_NAME}"
"${OVNI_TEST_SOURCE}"
"${CMAKE_SOURCE_DIR}/test/emu/instr.c"
)
target_link_libraries("${OVNI_TEST_NAME}" PRIVATE ovni emu)
set(driver "${OVNI_TEST_SOURCE_DIR}/ovni-driver.sh")