Commit ec57e918 authored by Sven Liefgen's avatar Sven Liefgen
Browse files

Add amount of rows to yaml

parent 5e591e74
......@@ -11,14 +11,20 @@ fn main() {
if let Ok(xlap) = env::var("XLAP") {
let yaml = fs::read_to_string(&xlap).unwrap();
let yaml = YamlLoader::load_from_str(yaml.as_str()).unwrap().pop().unwrap();
let yaml = YamlLoader::load_from_str(yaml.as_str())
.unwrap()
.pop()
.unwrap();
// Create XLAP array containing a table for each kind
let packet_types = &yaml["packet_types"];
let packet_types_count = packet_types.as_hash().unwrap().len();
let mut static_xlap = format!("static XLAP: [AtomicPtr<TimestampTable>; {}] = [\n", packet_types_count);
let mut static_xlap = format!(
"static XLAP: [AtomicPtr<TimestampTable>; {}] = [\n",
packet_types_count
);
for _ in 0..packet_types_count {
static_xlap.push_str(" AtomicPtr::new(std::ptr::null_mut()),\n");
}
......@@ -48,15 +54,20 @@ fn main() {
}
timestamp_id_enum.push_str("}\n");
// Create TS_ROWS
let count = &yaml["rows"].as_i64().unwrap_or(4098);
let ts_rows = format!("const TS_ROWS: usize = {};\n", count);
fs::write(
&dest_path,
format!("{}\n{}\n{}\n",
static_xlap,
kind_consts,
timestamp_id_enum,
)
)
.unwrap();
format!(
"{}\n{}\n{}\n{}\n",
ts_rows, static_xlap, kind_consts, timestamp_id_enum,
),
)
.unwrap();
println!("cargo::rerun-if-changed=build.rs");
println!("cargo::rerun-if-changed=src/lib.rs");
println!("cargo::rerun-if-changed={}", xlap);
......
use std::time::Instant;
use std::convert::AsRef;
use std::io::prelude::*;
use std::sync::atomic::AtomicPtr;
use std::sync::atomic::Ordering;
use std::io::prelude::*;
use std::convert::AsRef;
use std::time::Instant;
use strum::{EnumCount, EnumIter, IntoEnumIterator, AsRefStr};
use strum::{AsRefStr, EnumCount, EnumIter, IntoEnumIterator};
// Include the correct function for cycle counts depending on the architecture
#[cfg(target_arch = "x86")]
......@@ -51,19 +51,21 @@ pub unsafe fn timestamp_value(kind: usize, row: usize, id: TimestampId, value: I
/// Update the clock value of a cyclestamp by setting it to an explicit value
#[inline(always)]
pub unsafe fn cyclestamp_value(kind: usize, row: usize, id: TimestampId, value: u64) {
(*XLAP[kind].load(Ordering::Acquire)).rows[row % TS_ROWS].timestamp[id as usize].c = value;
(*XLAP[kind].load(Ordering::Acquire)).rows[row % TS_ROWS].timestamp[id as usize].c = value;
}
/// Update the clock value of a timestamp
#[inline(always)]
pub unsafe fn timestamp_clock(kind: usize, row: usize, id: TimestampId) {
(*XLAP[kind].load(Ordering::Acquire)).rows[row % TS_ROWS].timestamp[id as usize].t = Instant::now();
(*XLAP[kind].load(Ordering::Acquire)).rows[row % TS_ROWS].timestamp[id as usize].t =
Instant::now();
}
/// Update the cycle value of a timestamp
#[inline(always)]
pub unsafe fn timestamp_cycle(kind: usize, row: usize, id: TimestampId) {
(*XLAP[kind].load(Ordering::Acquire)).rows[row % TS_ROWS].timestamp[id as usize].c = current_cycle();
(*XLAP[kind].load(Ordering::Acquire)).rows[row % TS_ROWS].timestamp[id as usize].c =
current_cycle();
}
impl TimestampTable {
......
data_files:
sender: "rtn2018/20180417_testbed/sender.csv"
receiver: "rtn2018/20180417_testbed/receiver.csv"
threads:
- app_send
- trans_send
- trans_recv
- app_recv
cycle_reference:
app_send:
Start: PrrtSendStart
Stop: PrrtSendEnd
trans_send:
Start: PrrtTransmitStart
Stop: LinkTransmitEnd
trans_recv:
Start: LinkReceive
Stop: PrrtReturnPackage
app_recv:
Start: PrrtReceivePackage
Stop: PrrtDeliver
time_reference:
sender:
Start: PrrtSendStart
Stop: LinkTransmitEnd
receiver:
Start: LinkReceive
Stop: PrrtDeliver
stamps:
PrrtSendStart:
Source: sender
Thread: app_send
Type: time
PrrtSubmitPackage:
Source: sender
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment