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:
parent
c508929835
commit
864ce4222f
24
test/emu/instr.c
Normal file
24
test/emu/instr.c
Normal 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;
|
||||||
|
}
|
@ -18,11 +18,18 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.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) \
|
#define INSTR_0ARG(name, mcv) \
|
||||||
static inline void name(void) \
|
static inline void name(void) \
|
||||||
{ \
|
{ \
|
||||||
struct ovni_ev ev = {0}; \
|
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_set_mcv(&ev, mcv); \
|
||||||
ovni_ev_emit(&ev); \
|
ovni_ev_emit(&ev); \
|
||||||
}
|
}
|
||||||
@ -31,7 +38,7 @@
|
|||||||
static inline void name(ta a) \
|
static inline void name(ta a) \
|
||||||
{ \
|
{ \
|
||||||
struct ovni_ev ev = {0}; \
|
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_set_mcv(&ev, mcv); \
|
||||||
ovni_payload_add(&ev, (uint8_t *) &a, sizeof(a)); \
|
ovni_payload_add(&ev, (uint8_t *) &a, sizeof(a)); \
|
||||||
ovni_ev_emit(&ev); \
|
ovni_ev_emit(&ev); \
|
||||||
@ -41,7 +48,7 @@
|
|||||||
static inline void name(ta a, tb b) \
|
static inline void name(ta a, tb b) \
|
||||||
{ \
|
{ \
|
||||||
struct ovni_ev ev = {0}; \
|
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_set_mcv(&ev, mcv); \
|
||||||
ovni_payload_add(&ev, (uint8_t *) &a, sizeof(a)); \
|
ovni_payload_add(&ev, (uint8_t *) &a, sizeof(a)); \
|
||||||
ovni_payload_add(&ev, (uint8_t *) &b, sizeof(b)); \
|
ovni_payload_add(&ev, (uint8_t *) &b, sizeof(b)); \
|
||||||
@ -52,8 +59,8 @@
|
|||||||
static inline void name(ta a, tb b, tc c) \
|
static inline void name(ta a, tb b, tc c) \
|
||||||
{ \
|
{ \
|
||||||
struct ovni_ev ev = {0}; \
|
struct ovni_ev ev = {0}; \
|
||||||
|
ovni_ev_set_clock(&ev, get_clock()); \
|
||||||
ovni_ev_set_mcv(&ev, mcv); \
|
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 *) &a, sizeof(a)); \
|
||||||
ovni_payload_add(&ev, (uint8_t *) &b, sizeof(b)); \
|
ovni_payload_add(&ev, (uint8_t *) &b, sizeof(b)); \
|
||||||
ovni_payload_add(&ev, (uint8_t *) &c, sizeof(c)); \
|
ovni_payload_add(&ev, (uint8_t *) &c, sizeof(c)); \
|
||||||
@ -68,7 +75,7 @@ instr_thread_end(void)
|
|||||||
struct ovni_ev ev = {0};
|
struct ovni_ev ev = {0};
|
||||||
|
|
||||||
ovni_ev_set_mcv(&ev, "OHe");
|
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);
|
ovni_ev_emit(&ev);
|
||||||
|
|
||||||
/* Flush the events to disk before killing the thread */
|
/* Flush the events to disk before killing the thread */
|
||||||
|
@ -13,7 +13,7 @@ instr_nanos6_type_create(int32_t typeid)
|
|||||||
struct ovni_ev ev = {0};
|
struct ovni_ev ev = {0};
|
||||||
|
|
||||||
ovni_ev_set_mcv(&ev, "6Yc");
|
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 buf[256];
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
|
@ -12,7 +12,7 @@ instr_nosv_type_create(int32_t typeid)
|
|||||||
struct ovni_ev ev = {0};
|
struct ovni_ev ev = {0};
|
||||||
|
|
||||||
ovni_ev_set_mcv(&ev, "VYc");
|
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 buf[256];
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
|
@ -104,11 +104,17 @@ function(ovni_test source)
|
|||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
"${CMAKE_SOURCE_DIR}/src/include"
|
"${CMAKE_SOURCE_DIR}/src/include"
|
||||||
|
"${CMAKE_SOURCE_DIR}/src/emu"
|
||||||
"${CMAKE_SOURCE_DIR}/src"
|
"${CMAKE_SOURCE_DIR}/src"
|
||||||
"${CMAKE_SOURCE_DIR}/include"
|
"${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")
|
set(driver "${OVNI_TEST_SOURCE_DIR}/ovni-driver.sh")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user