Add info command

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/1/head
trivernis 4 years ago
parent f217164dc0
commit 7ee06b1d35
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -21,29 +21,39 @@ impl KernelController {
.src(include_str!("kernel.cl"))
.dims(1 << 20)
.build()?;
let device = pro_que.device();
println!("Using device {}", device.name()?);
println!("Vendor: {}", device.vendor()?);
println!(
"Global Mem Size: {} bytes",
device.info(DeviceInfo::GlobalMemSize)?
);
println!(
"Max Mem Alloc: {} bytes",
device.info(DeviceInfo::MaxMemAllocSize)?
);
println!(
"Max Compute Units: {}",
device.info(DeviceInfo::MaxComputeUnits)?
);
println!(
"Max Work Group Size: {}",
device.info(DeviceInfo::MaxWorkGroupSize)?
);
println!();
println!("Using device {}", pro_que.device().name()?);
Ok(Self { pro_que })
}
pub fn print_info(&self) -> ocl::Result<()> {
let device = self.pro_que.device();
let info_keys = vec![
DeviceInfo::Type,
DeviceInfo::Vendor,
DeviceInfo::DriverVersion,
DeviceInfo::ExecutionCapabilities,
DeviceInfo::MaxComputeUnits,
DeviceInfo::MaxWorkGroupSize,
DeviceInfo::MaxClockFrequency,
DeviceInfo::GlobalMemSize,
DeviceInfo::LocalMemSize,
DeviceInfo::MaxMemAllocSize,
DeviceInfo::LocalMemType,
DeviceInfo::GlobalMemCacheType,
DeviceInfo::GlobalMemCacheSize,
DeviceInfo::OpenclCVersion,
DeviceInfo::Platform,
];
for info in info_keys {
println!("{:?}: {}", info, device.info(info)?)
}
println!();
Ok(())
}
fn available_memory(&self) -> ocl::Result<u64> {
match self.pro_que.device().info(DeviceInfo::GlobalMemSize)? {
DeviceInfoResult::GlobalMemSize(size) => Ok(size),

@ -29,6 +29,9 @@ enum Opts {
/// Benchmarks the number of tasks used for the calculations
#[structopt(name = "bench-task-count")]
BenchmarkTaskCount(BenchmarkTaskCount),
/// Prints GPU information
Info,
}
#[derive(StructOpt, Clone, Debug)]
@ -97,6 +100,7 @@ fn main() -> ocl::Result<()> {
let controller = KernelController::new()?;
match opts {
Opts::Info => controller.print_info(),
Opts::CalculatePrimes(prime_opts) => calculate_primes(prime_opts, controller),
Opts::BenchmarkTaskCount(bench_opts) => bench_task_count(bench_opts, controller),
}

Loading…
Cancel
Save