Skip to content

Commit 15b910d

Browse files
committed
Fix ray tracing memory mapping on systems without ReBAR, fix System Latency math calculation, clarify VRAM/RAM bandwidth labels, and silence verbose diagnostics prints
1 parent 969f39f commit 15b910d

5 files changed

Lines changed: 17 additions & 39 deletions

File tree

gpubench-core/src/benchmarks/fp32.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ impl Benchmark for Fp32Bench {
7272
// Wait, the cpp code's `Run` is just 1 dispatch?
7373
// Ah, the CLI runner orchestrates the `Run` iteration loop.
7474
for iter in 0..5 {
75-
println!("[DIAGNOSTIC] FP32 iter {}", iter);
7675
let temp_buffer = context.create_buffer(8 * 1024 * 1024, None)?;
7776
context.set_kernel_arg_buffer(self.kernel, 0, temp_buffer)?;
7877
context.dispatch(self.kernel, 1024, 1, 1, 64, 1, 1)?;

gpubench-core/src/benchmarks/membw.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ impl Benchmark for MemBwBench {
6868
let mut actual_iters = 0;
6969

7070
while start.elapsed().as_secs_f64() < 2.5 {
71-
println!("[DIAGNOSTIC] MemBw iter {}", actual_iters);
7271
context.dispatch(self.kernel, workgroups, 1, 1, 512, 1, 1)?;
7372
context.wait_idle()?;
7473
actual_iters += 1;

gpubench-core/src/vulkan.rs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ pub struct VulkanContext {
7777

7878
impl VulkanContext {
7979
pub fn new() -> Result<Self, String> {
80-
println!("[DIAGNOSTIC] VulkanContext::new() called");
8180
let core = VULKAN_CORE.as_ref().map_err(|e| e.clone())?;
8281
let instance = &core.1;
8382

@@ -165,7 +164,6 @@ impl ComputeContext for VulkanContext {
165164
}
166165

167166
fn pick_device(&mut self, index: u32) -> Result<(), String> {
168-
println!("[DIAGNOSTIC] VulkanContext::pick_device() called with index {}", index);
169167
if index as usize >= self.physical_devices.len() {
170168
return Err("Invalid device index".to_string());
171169
}
@@ -242,7 +240,6 @@ impl ComputeContext for VulkanContext {
242240

243241
device_info.p_next = &features2_create as *const _ as *const std::ffi::c_void;
244242

245-
println!("[DIAGNOSTIC] create_device executing");
246243
let device = unsafe { instance.create_device(pdevice, &device_info, None).map_err(|e| e.to_string())? };
247244

248245
let rt_pipeline = if self.device_infos[self.selected_device_idx as usize].ray_tracing_support {
@@ -252,8 +249,7 @@ impl ComputeContext for VulkanContext {
252249
let rt_as = if self.device_infos[self.selected_device_idx as usize].ray_tracing_support {
253250
Some(AccelerationStructure::new(instance, &device))
254251
} else { None };
255-
256-
println!("[DIAGNOSTIC] create_device success");
252+
257253
let queue = unsafe { device.get_device_queue(queue_family_index, 0) };
258254

259255
let pool_info = vk::CommandPoolCreateInfo::default()
@@ -306,9 +302,6 @@ impl ComputeContext for VulkanContext {
306302
let mem_type_idx = self.find_memory_type(mem_req.memory_type_bits, properties).unwrap_or_else(|_| {
307303
self.find_memory_type(mem_req.memory_type_bits, vk::MemoryPropertyFlags::HOST_VISIBLE | vk::MemoryPropertyFlags::HOST_COHERENT).unwrap()
308304
});
309-
310-
println!("[DIAGNOSTIC] create_buffer: using mem_type_idx {}", mem_type_idx);
311-
312305
let mut alloc_flags = vk::MemoryAllocateFlagsInfo::default().flags(vk::MemoryAllocateFlags::DEVICE_ADDRESS);
313306
let alloc_info = vk::MemoryAllocateInfo::default()
314307
.allocation_size(mem_req.size)
@@ -318,19 +311,15 @@ impl ComputeContext for VulkanContext {
318311
let memory = unsafe { device.allocate_memory(&alloc_info, None).map_err(|e| e.to_string())? };
319312
unsafe { device.bind_buffer_memory(buffer, memory, 0).map_err(|e| e.to_string())? };
320313

321-
if let Some(data) = host_ptr {
322-
let ptr = unsafe { device.map_memory(memory, 0, size as u64, vk::MemoryMapFlags::empty()).map_err(|e| e.to_string())? };
323-
unsafe { std::ptr::copy_nonoverlapping(data.as_ptr(), ptr as *mut u8, data.len().min(size)) };
324-
unsafe { device.unmap_memory(memory) };
325-
}
326-
327314
let id = self.next_buffer_id;
328315
self.next_buffer_id += 1;
329316
let bda_info = vk::BufferDeviceAddressInfo::default().buffer(buffer);
330-
let bda = unsafe { device.get_buffer_device_address(&bda_info) };
331-
println!("[DIAGNOSTIC] create_buffer: id={}, size={}, align={}, bda=0x{:X}", id, size, mem_req.alignment, bda);
332-
333317
self.buffers.insert(id, VulkanBuffer { buffer, memory, _size: size });
318+
319+
if let Some(data) = host_ptr {
320+
self.write_buffer(id, 0, data)?;
321+
}
322+
334323
Ok(id)
335324
}
336325

@@ -1176,12 +1165,9 @@ impl ComputeContext for VulkanContext {
11761165

11771166
impl Drop for VulkanContext {
11781167
fn drop(&mut self) {
1179-
println!("[DIAGNOSTIC] VulkanContext::drop() called");
11801168
if let Some(device) = &self.device {
11811169
unsafe {
1182-
println!("[DIAGNOSTIC] device_wait_idle");
11831170
let _ = device.device_wait_idle();
1184-
println!("[DIAGNOSTIC] destroying kernels");
11851171
for (_, k) in self.kernels.drain() {
11861172
device.destroy_pipeline(k.pipeline, None);
11871173
device.destroy_pipeline_layout(k.pipeline_layout, None);
@@ -1192,13 +1178,9 @@ impl Drop for VulkanContext {
11921178
device.destroy_buffer(vbuf.buffer, None);
11931179
device.free_memory(vbuf.memory, None);
11941180
}
1195-
println!("[DIAGNOSTIC] destroying fence");
11961181
device.destroy_fence(self.fence, None);
1197-
println!("[DIAGNOSTIC] destroying pool");
11981182
device.destroy_command_pool(self.command_pool, None);
1199-
println!("[DIAGNOSTIC] destroying device");
12001183
device.destroy_device(None);
1201-
println!("[DIAGNOSTIC] Drop complete");
12021184
}
12031185
}
12041186
}

gpubench-gui/src/main.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -421,24 +421,18 @@ impl Application for GPUBenchApp {
421421
),
422422
Command::perform(
423423
async move {
424-
println!("[DIAGNOSTIC] Waiting 500ms to allow UI redraw...");
425424
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
426-
println!("[DIAGNOSTIC] spawn_blocking started");
427425
let res = tokio::task::spawn_blocking(move || {
428-
println!("[DIAGNOSTIC] run_benchmarks executing");
429-
let r = run_benchmarks(
426+
run_benchmarks(
430427
&tests_to_run,
431428
&vec![d_idx],
432429
&vec![b_str],
433430
false,
434431
false,
435432
false,
436433
progress_callback
437-
);
438-
println!("[DIAGNOSTIC] run_benchmarks finished");
439-
r
434+
)
440435
}).await;
441-
println!("[DIAGNOSTIC] spawn_blocking finished, await result: {:?}", res.is_ok());
442436
},
443437
|_| Message::BenchmarksComplete
444438
)
@@ -759,10 +753,10 @@ impl Application for GPUBenchApp {
759753
};
760754

761755
let sys_content = column![
762-
metric_row("MemBandwidth", "Max Bandwidth", self.gpu_bw, "GB/s", "Measures the maximum rate at which data can be read from or stored into the GPU's VRAM. Critical for high-resolution textures and large datasets."),
763-
metric_row("SysMemBandwidth", "System Bandwidth", self.sys_mem_bw, "GB/s", "Measures the maximum multi-threaded bandwidth to the host's system RAM. Important for CPU-to-GPU data transfers and general system performance."),
764-
metric_row("SysMemBandwidth", "Sys Bandwidth (1 Thread)", self.sys_mem_bw_single, "GB/s", "Measures single-threaded bandwidth to system RAM, which indicates memory channel efficiency and latency-bound transfer speeds."),
765-
metric_row("SysMemLatency", "System Latency", self.sys_mem_lat, "ns", "Measures the time it takes to fetch a single un-cached piece of data from system memory. Lower is better. Essential for game engines and unpredictable data access."),
756+
metric_row("MemBandwidth", "GPU VRAM Bandwidth", self.gpu_bw, "GB/s", "Measures the maximum rate at which data can be read from or stored into the GPU's VRAM. Critical for high-resolution textures and large datasets."),
757+
metric_row("SysMemBandwidth", "System RAM Bandwidth", self.sys_mem_bw, "GB/s", "Measures the maximum multi-threaded bandwidth to the host's system RAM. Important for CPU-to-GPU data transfers and general system performance."),
758+
metric_row("SysMemBandwidth", "System RAM (1 Thread)", self.sys_mem_bw_single, "GB/s", "Measures single-threaded bandwidth to system RAM, which indicates memory channel efficiency and latency-bound transfer speeds."),
759+
metric_row("SysMemLatency", "System RAM Latency", self.sys_mem_lat, "ns", "Measures the time it takes to fetch a single un-cached piece of data from system memory. Lower is better. Essential for game engines and unpredictable data access."),
766760
].spacing(12).into();
767761

768762
let compute_content = column![
@@ -880,8 +874,10 @@ impl GPUBenchApp {
880874

881875
let mut value = ((res.operations as f64) / (res.time_ms / 1000.0)) as f32;
882876

883-
if res.metric == "ms/op" || res.metric == "ns" {
877+
if res.metric == "ms/op" {
884878
value = (res.time_ms as f32) / (res.operations as f32);
879+
} else if res.metric == "ns" {
880+
value = ((res.time_ms * 1_000_000.0) as f32) / (res.operations as f32);
885881
} else if res.metric == "GIS/s" || res.metric == "GRays/s" || res.metric == "GB/s" {
886882
value /= 1e9;
887883
} else if res.metric == "TFLOPS" || res.metric == "TOPS" {

gpubench-sys/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ fn main() {
44
.build();
55

66
println!("cargo:rustc-link-search=native={}/build", dst.display());
7+
println!("cargo:rustc-link-search=native={}/build/Release", dst.display());
8+
println!("cargo:rustc-link-search=native={}/build/Debug", dst.display());
79
println!("cargo:rustc-link-lib=static=gpubench_lib");
810
println!("cargo:rustc-link-lib=vulkan");
911

0 commit comments

Comments
 (0)