chore(clap): Replace use of deprecated attributes

Replace deprecated #[clap(...)] attributes to #[arg]/#[command] and remove redundant use of value_parser
This commit is contained in:
Himess
2025-09-07 16:00:58 +03:00
committed by Nicolas Sarlin
parent 5d70ae4232
commit 6fde90ad9c
8 changed files with 67 additions and 75 deletions

View File

@@ -9,15 +9,15 @@ use tfhe_hpu_backend::asm::{self};
/// Define CLI arguments
use clap::Parser;
#[derive(clap::Parser, Debug, Clone)]
#[clap(long_about = "DOp format management")]
#[command(long_about = "DOp format management")]
pub struct Args {
// Input/Output configuration --------------------------------------------
/// Convert from the given file. If file not available cast String in AsmOp
#[clap(short, long, value_parser)]
#[arg(short, long)]
from: String,
/// Output file
#[clap(short, long, value_parser)]
#[arg(short, long)]
to: String,
}

View File

@@ -12,70 +12,67 @@ use tfhe_hpu_backend::fw::{self, Fw, FwParameters};
use clap::Parser;
use tfhe_hpu_backend::prelude::{HpuConfig, HpuParameters, ShellString};
#[derive(clap::Parser, Debug, Clone)]
#[clap(long_about = "Translate IOp or Stream of IOps in DOps stream")]
#[command(long_about = "Translate IOp or Stream of IOps in DOps stream")]
pub struct Args {
// Configuration -----------------------------------------------------
/// Toml top-level configuration file
/// Enable to retrieved runtime configuration register
#[clap(
#[arg(
long,
value_parser,
default_value = "${HPU_BACKEND_DIR}/config_store/${HPU_CONFIG}/hpu_config.toml"
)]
pub config: ShellString,
/// Hpu rtl parameters
/// Enable to retrieved the associated tfhe-rs parameters and other Rtl parameters
#[clap(
#[arg(
long,
value_parser,
default_value = "${HPU_MOCKUP_DIR}/params/gaussian_64b_fast.toml"
)]
pub params: ShellString,
/// Supported nu
/// Number of linear operation supported
#[clap(long, value_parser, default_value_t = 5)]
#[arg(long, default_value_t = 5)]
nu: usize,
/// Fw kind
#[clap(long, value_parser, default_value = "Ilp")]
#[arg(long, default_value = "Ilp")]
fw_kind: fw::FwName,
/// Number of Heap slots
#[clap(long, value_parser, default_value_t = 512)]
#[arg(long, default_value_t = 512)]
heap: usize,
/// Kogge configuration file
#[clap(
#[arg(
long,
value_parser,
default_value = "${HPU_BACKEND_DIR}/config_store/${HPU_CONFIG}/kogge_cfg.toml"
)]
kogge_cfg: ShellString,
/// Use ipip configuration
#[clap(long, value_parser, default_value_t = false)]
#[arg(long, default_value_t = false)]
use_ipip: bool,
/// Use ipip configuration
#[clap(long, value_parser, default_value_t = false)]
#[arg(long, default_value_t = false)]
use_bpip_opportunism: bool,
/// Try to fill the batch fifo
#[clap(long, value_parser, default_value_t = true)]
#[arg(long, default_value_t = true)]
fill_batch_fifo: bool,
/// Use the minimum batch size for a PE
#[clap(long, value_parser, default_value_t = false)]
#[arg(long, default_value_t = false)]
min_batch_size: bool,
/// Use the minimum batch size for a PE
#[clap(long, value_parser, default_value_t = false)]
#[arg(long, default_value_t = false)]
use_tiers: bool,
/// Flush PBS batches to force a specific scheduling
#[clap(long, value_parser, default_value_t = true)]
#[arg(long, default_value_t = true)]
flush: bool,
/// Flush PBS batches behaviour
@@ -84,11 +81,11 @@ pub struct Args {
/// NoPBS,
/// Opportunist,
/// Timeout(usize),
#[clap(long, value_parser, default_value = "Patient")]
#[arg(long, default_value = "Patient")]
flush_behaviour: FlushBehaviour,
/// Integer bit width
#[clap(long, value_parser, default_value_t = 8)]
#[arg(long, default_value_t = 8)]
integer_w: usize,
// Override params --------------------------------------------------
@@ -96,22 +93,22 @@ pub struct Args {
// configuration file
// Used to override some parameters at runtime
/// Override Number of Register
#[clap(long, value_parser)]
#[arg(long)]
register: Option<usize>,
/// Override HPU lookahead buffer depth
/// Number of instruction that are considered in advance
#[clap(long, value_parser)]
#[arg(long)]
isc_depth: Option<usize>,
// Input/Output configuration --------------------------------------------
/// Expand the given IOpcode
/// NB: couldn't use `convert_file` and `expand` at the same time
#[clap(short, long, value_parser)]
#[arg(short, long)]
expand: Vec<asm::AsmIOpcode>,
/// Output folder
#[clap(long, value_parser, default_value = "output")]
#[arg(long, default_value = "output")]
out_folder: String,
}

View File

@@ -17,7 +17,7 @@ use tracing_subscriber::fmt::MakeWriter;
#[derive(Clone, Debug, Subcommand)]
pub enum Command {
#[clap(about = "Read register")]
#[command(about = "Read register")]
Read {
/// Register name
#[arg(short, long)]
@@ -26,7 +26,7 @@ pub enum Command {
range: usize,
},
#[clap(about = "Write register")]
#[command(about = "Write register")]
Write {
/// Register name
#[arg(short, long)]
@@ -35,23 +35,23 @@ pub enum Command {
value: u32,
},
#[clap(about = "Dump given register section")]
#[command(about = "Dump given register section")]
Dump {
/// Section name
#[arg(index = 1)]
name: Vec<Section>,
},
#[clap(about = "Reset given register section")]
#[command(about = "Reset given register section")]
Reset {
/// Section name
#[arg(index = 1)]
name: Vec<Section>,
},
#[clap(about = "Flush ackq")]
#[command(about = "Flush ackq")]
Flush,
#[clap(about = "Memory Zone read (Hbm)")]
#[command(about = "Memory Zone read (Hbm)")]
MzRead {
/// Hbm pc
#[arg(long, value_parser=maybe_hex::<usize>)]
@@ -61,7 +61,7 @@ pub enum Command {
size: usize,
},
#[clap(about = "Memory Zone write (Hbm)")]
#[command(about = "Memory Zone write (Hbm)")]
MzWrite {
/// Hbm pc
#[arg(long, value_parser=maybe_hex::<usize>)]
@@ -74,13 +74,13 @@ pub enum Command {
pattern: u8,
},
#[clap(about = "Trace Dump")]
#[command(about = "Trace Dump")]
TraceDump {
#[arg(short, long, default_value_t = String::from("trace.json"))]
file: String,
},
#[clap(about = "Resets all HPU processing logic")]
#[command(about = "Resets all HPU processing logic")]
SoftReset {},
}

View File

@@ -9,15 +9,15 @@ use tfhe_hpu_backend::asm;
/// Define CLI arguments
use clap::Parser;
#[derive(clap::Parser, Debug, Clone)]
#[clap(long_about = "IOp format management")]
#[command(long_about = "IOp format management")]
pub struct Args {
// Input/Output configuration --------------------------------------------
/// Convert from the given file. If file not available cast String in AsmOp
#[clap(short, long, value_parser)]
#[arg(short, long)]
from: String,
/// Output file
#[clap(short, long, value_parser)]
#[arg(short, long)]
to: String,
}

View File

@@ -14,24 +14,22 @@ use tfhe_hpu_mockup::{HpuSim, MockupOptions, MockupParameters};
/// Define CLI arguments
use clap::Parser;
#[derive(clap::Parser, Debug, Clone)]
#[clap(long_about = "Hpu Simulation mockup.")]
#[command(long_about = "Hpu Simulation mockup.")]
pub struct Args {
// Configuration ----------------------------------------------------
/// Fpga fake configuration
/// Toml file similar to the one used with the real hpu-backend
/// Enable to retrieved ipc_name, register_file and board definition
#[clap(
#[arg(
long,
value_parser,
default_value = "${HPU_BACKEND_DIR}/config_store/${HPU_CONFIG}/hpu_config.toml"
)]
pub config: ShellString,
/// Hpu rtl parameters
/// Enable to retrieved the associated tfhe-rs parameters and other Rtl parameters
#[clap(
#[arg(
long,
value_parser,
default_value = "${HPU_MOCKUP_DIR}/params/gaussian_64b_fast.toml"
)]
pub params: ShellString,
@@ -41,30 +39,30 @@ pub struct Args {
// configuration file
// Used to override some parameters at runtime
/// Override Number of Register
#[clap(long, value_parser)]
#[arg(long)]
register: Option<usize>,
/// Override HPU lookahead buffer depth
/// Number of instruction that are considered in advance
#[clap(long, value_parser)]
#[arg(long)]
isc_depth: Option<usize>,
// Simulation configuration -----------------------------------------
/// Frequency in MHz
/// Only use for report display
#[clap(long, value_parser, default_value_t = 300)]
#[arg(long, default_value_t = 300)]
freq_mhz: usize,
/// Simulation quantum in micro_seconds.
/// Maximum simulation time drift between mockup and backend
#[clap(long, value_parser, default_value_t = 1_000_000)]
#[arg(long, default_value_t = 1_000_000)]
quantum_us: usize,
/// Consider all received ciphertext as trivial ciphertext
/// Execute Pbs in a trivial manner and display value in tracing::debug
/// Useful for IOp algorithm debug
/// WARN: Only work if user application send trivial ciphertext
#[clap(long, value_parser)]
#[arg(long)]
trivial: bool,
// Dump configuration ----------------------------------------------------
@@ -72,27 +70,27 @@ pub struct Args {
/// Specify simulus dump folder.
/// NB: The Rtl stimulus (i.e. Input/Output, Keys, Lut) should be generated by the client.
/// Only used to dump IOp/DOp and the inner register values (c.f. dump-reg)
#[clap(long, value_parser)]
#[arg(long)]
dump_out: Option<String>,
/// Activate the dump of intermediate register value. Only work if dump-out is also specified
#[clap(long, value_parser)]
#[arg(long)]
dump_reg: bool,
// Reports configuration -------------------------------------------------
// Use to activate some performances reports
/// Specify reports dump folder. When not specified, no reports were generated
#[clap(long, value_parser)]
#[arg(long)]
report_out: Option<String>,
/// Activate the execution trace export for later analysis
#[clap(long, value_parser)]
#[arg(long)]
report_trace: bool,
// Log configuration -------------------------------------------------
/// Write trace message in the file (instead of on stdio)
/// NB: Use RUST_LOG env variable to set the verbosity
#[clap(long, value_parser)]
#[arg(long)]
log_out: Option<String>,
}

View File

@@ -25,15 +25,14 @@ use rand::{Rng, SeedableRng};
pub use clap::Parser;
pub use clap_num::maybe_hex;
#[derive(clap::Parser, Debug, Clone, serde::Serialize)]
#[clap(
#[command(
long_about = "HPU stimulus generation application: Start operation on HPU for RTL test purpose."
)]
pub struct Args {
// Fpga configuration ------------------------------------------------------
/// Toml top-level configuration file
#[clap(
#[arg(
long,
value_parser,
default_value = "${HPU_BACKEND_DIR}/config_store/${HPU_CONFIG}/hpu_config.toml"
)]
pub config: ShellString,
@@ -41,24 +40,24 @@ pub struct Args {
// Exec configuration ----------------------------------------------------
/// Select integer width to bench
/// If None default to All available one (c.f. Firmware configuration)
#[clap(long, value_parser)]
#[arg(long)]
pub integer_w: Vec<usize>,
/// Iop to expand and simulate
/// If None default to All IOp
#[clap(long, value_parser)]
#[arg(long)]
pub iop: Vec<hpu_asm::AsmIOpcode>,
/// Number of iteration for each IOp
#[clap(long, value_parser, default_value_t = 1)]
#[arg(long, default_value_t = 1)]
pub iter: usize,
/// Force ct input values
#[clap(long, value_parser=maybe_hex::<u128>)]
#[arg(long, value_parser = maybe_hex::<u128>)]
pub src: Vec<u128>,
/// Force immediat input values
#[clap(long, value_parser=maybe_hex::<u128>)]
#[arg(long, value_parser = maybe_hex::<u128>)]
pub imm: Vec<u128>,
/// Fallback prototype
@@ -69,25 +68,25 @@ pub struct Args {
/// * N, Nat, Native -> Full size integer;
/// * H, Half -> Half size integer;
/// * B, Bool -> boolean value;
#[clap(long, value_parser)]
#[arg(long)]
pub user_proto: Option<hpu_asm::IOpProto>,
/// Seed used for some rngs
#[clap(long, value_parser)]
#[arg(long)]
pub seed: Option<u128>,
// Debug option ----------------------------------------------------------
#[cfg(feature = "hpu-debug")]
/// Hpu io dump path
#[clap(long, value_parser)]
#[arg(long)]
pub io_dump: Option<String>,
/// Use trivial encrypt ciphertext
#[clap(long, value_parser)]
#[arg(long)]
pub trivial: bool,
/// Override the firmware implementation used
#[clap(long, value_parser)]
#[arg(long)]
pub fw_impl: Option<String>,
}

View File

@@ -112,20 +112,19 @@ fn main() {
pub use clap::Parser;
/// Define CLI arguments
#[derive(clap::Parser, Debug, Clone, serde::Serialize)]
#[clap(long_about = "HPU example that shows the use of the HighLevelAPI.")]
#[command(long_about = "HPU example that shows the use of the HighLevelAPI.")]
pub struct Args {
// Fpga configuration ------------------------------------------------------
/// Toml top-level configuration file
#[clap(
#[arg(
long,
value_parser,
default_value = "${HPU_BACKEND_DIR}/config_store/${HPU_CONFIG}/hpu_config.toml"
)]
pub config: ShellString,
// Exec configuration ----------------------------------------------------
/// Seed used for some rngs
#[clap(long, value_parser)]
#[arg(long)]
pub seed: Option<u128>,
}
let args = Args::parse();

View File

@@ -31,23 +31,22 @@ fn main() {
/// Define CLI arguments
#[derive(clap::Parser, Debug, Clone, serde::Serialize)]
#[clap(long_about = "HPU example that shows the use of the HighLevelAPI.")]
#[command(long_about = "HPU example that shows the use of the HighLevelAPI.")]
pub struct Args {
#[clap(
#[arg(
long,
value_parser,
default_value = "${HPU_BACKEND_DIR}/config_store/${HPU_CONFIG}/hpu_config.toml"
)]
pub config: ShellString,
/// Number of rows in matrix A
#[clap(long, value_parser, default_value_t = 2)]
#[arg(long, default_value_t = 2)]
pub m: usize,
/// Number of columns in matrix A and Number of rows in matrix B
#[clap(long, value_parser, default_value_t = 2)]
#[arg(long, default_value_t = 2)]
pub n: usize,
/// Number of columns in matrix B
#[clap(long, value_parser, default_value_t = 2)]
#[arg(long, default_value_t = 2)]
pub p: usize,
}
let args = Args::parse();