1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use crate::error::Result;
use crate::{ArgDeviceType, ArgMemType, ArgPageType, CmdTlbLatency};
use serde_derive::Serialize;
#[derive(Clone, Debug, Default, Serialize)]
pub struct DataPoint {
pub hostname: String,
pub device_type: Option<ArgDeviceType>,
pub device_codename: Option<String>,
pub device_id: Option<u16>,
pub memory_type: Option<ArgMemType>,
pub memory_location: Option<u16>,
pub page_type: Option<ArgPageType>,
pub range_bytes: Option<usize>,
pub stride_bytes: Option<usize>,
pub threads: Option<u32>,
pub grid_size: Option<u32>,
pub block_size: Option<u32>,
pub iotlb_flush: Option<bool>,
pub throttle_reasons: Option<String>,
pub clock_rate_mhz: Option<u32>,
pub cycle_counter_overhead_cycles: Option<u32>,
pub stride_id: Option<usize>,
pub tlb_status: Option<String>,
pub index_bytes: Option<i64>,
pub cycles: Option<u32>,
pub ns: Option<u32>,
}
impl DataPoint {
pub fn from_cmd_options(cmd: &CmdTlbLatency) -> Result<DataPoint> {
let hostname = hostname::get()
.map_err(|_| "Couldn't get hostname")?
.into_string()
.map_err(|_| "Couldn't convert hostname into UTF-8 string")?;
let dp = DataPoint {
hostname,
device_type: Some(ArgDeviceType::GPU),
device_id: Some(cmd.device_id),
memory_type: Some(cmd.mem_type),
memory_location: Some(cmd.mem_location),
page_type: Some(cmd.page_type),
..DataPoint::default()
};
Ok(dp)
}
}