This commit is contained in:
shenjack 2024-05-25 13:57:59 +08:00
parent a09c6a9332
commit f6c32973ac
Signed by: shenjack
GPG Key ID: 7B1134A979775551
3 changed files with 25 additions and 36 deletions

View File

@ -26,8 +26,8 @@ pub struct CacluateConfig {
pub start: u64,
/// 结束的 id
pub end: u64,
/// 线程
pub thread_count: u32,
/// 线程 id
pub thread_id: u32,
/// 八围预期值
pub prop_expect: u32,
/// qp 预期值
@ -40,9 +40,23 @@ pub struct CacluateConfig {
pub core_affinity: Option<usize>,
}
/// 用于收集统计信息的结构体
pub struct RunStatus {
/// 工作位置
/// 每一个线程对应一组
pub work_batches: Vec<(u128, u128)>,
/// 每个线程的效率回报
pub work_speed: Vec<u32>,
/// 每个线程是否需要干活
/// work batch 大小
pub work_batch: u32,
}
/// 启动计算的调度函数
pub fn start_main(cli_config: crate::Command, outfile: PathBuf) {
if cli_config.is_single_core() {
// 单核的处理
}
// if cli_arg.bench {
// info!("开始 benchmark");
// cli_arg.thread_count = 1;
@ -99,16 +113,16 @@ pub fn cacl(config: CacluateConfig, id: u64, outfile: &PathBuf) {
// 提前准备好 team_namer
let team_namer = TeamNamer::new(&config.team).unwrap();
let mut main_namer = Namer::new_from_team_namer_unchecked(&team_namer, "dummy");
let mut main_namer = Namer::new_from_team_namer_unchecked(&team_namer, "看到这个说明有问题出现");
for i in (config.start + id..config.end).step_by(config.thread_count as usize) {
for i in config.start..config.end {
k += 1;
if k >= report_interval {
let now = std::time::Instant::now();
let d_t: std::time::Duration = now.duration_since(start_time);
let new_run_speed = k as f64 / d_t.as_secs_f64();
// 预估剩余时间
let wait_time = (config.end - i) / config.thread_count as u64 / new_run_speed as u64;
let wait_time = (config.end - i) / new_run_speed as u64;
let wait_time = chrono::Duration::seconds(wait_time as i64);
// 转换成 时:分:秒
// 根据实际运行速率来调整 report_interval

View File

@ -46,7 +46,7 @@ impl Command {
CacluateConfig {
start: self.start,
end: self.end,
thread_count: self.thread_count,
thread_id: 0,
prop_expect: self.prop_expect,
qp_expect: self.qp_expect,
team: self.team.clone(),
@ -54,6 +54,10 @@ impl Command {
core_affinity: if self.thread_count == 1 { Some(1 << self.pick_core) } else { None },
}
}
pub fn is_single_core(&self) -> bool {
self.thread_count == 1
}
}
pub fn set_thread2core(core: usize) {

View File

@ -494,35 +494,6 @@ impl Namer {
}
}
}
// let mut simd_val = self.val;
// let mut simd_val_b = self.val;
// let simd_181 = u8x32::splat(181);
// let simd_199 = u8x32::splat(199);
// let simd_128 = u8x32::splat(128);
// let simd_53 = u8x32::splat(53);
// let simd_63 = u8x32::splat(63);
// let simd_32 = u8x32::splat(32);
// for i in (0..256).step_by(32) {
// unsafe {
// let mut x = u8x32::from_slice(simd_val.get_unchecked(i..));
// let mut y = u8x32::from_slice(simd_val_b.get_unchecked(i..));
// x = (x * simd_181 + simd_199) & simd_128;
// y = (y * simd_53) & simd_63 ^ simd_32;
// x.copy_to_slice(simd_val.get_unchecked_mut(i..));
// y.copy_to_slice(simd_val_b.get_unchecked_mut(i..));
// }
// }
// let mut mod_count = 0;
// for i in 0..256 {
// unsafe {
// if simd_val.get_unchecked(i) != &0 {
// *self.name_base.get_unchecked_mut(mod_count as usize) = *simd_val_b.get_unchecked(i);
// mod_count += 1;
// }
// }
// }
// const int N = 256, M = 128, K = 64, skill_cnt = 40, max_len = 25;
let mut a: u8 = 0;
let mut b: u8 = 0;