Skip to content

Commit 3bb33d2

Browse files
committed
test(Sysman): Test to validate memory bandwidth counters with workload
Related-To: VLCLJ-2505 Signed-off-by: Aviral Nigam <[email protected]>
1 parent 004b011 commit 3bb33d2

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

conformance_tests/sysman/test_sysman_memory/src/test_sysman_memory.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,4 +408,61 @@ TEST_F(
408408
memoryThread.join();
409409
}
410410
}
411+
412+
TEST_F(MEMORY_TEST,
413+
GivenWorkloadWhenQueryingMemoryBandwidthCountersThenCountersIncrease) {
414+
for (auto device : devices) {
415+
uint32_t count = 0;
416+
auto mem_handles = lzt::get_mem_handles(device, count);
417+
418+
if (count == 0) {
419+
LOG_WARNING << "No memory handles found on this device!";
420+
continue;
421+
}
422+
423+
// Allocate device memory for workload
424+
const size_t buffer_size = 32 * 1024 * 1024;
425+
ze_device_mem_alloc_desc_t device_desc = {};
426+
device_desc.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC;
427+
device_desc.ordinal = 0;
428+
device_desc.flags = 0;
429+
430+
void *src_ptr = lzt::allocate_device_memory(buffer_size, 1, 0, device,
431+
lzt::get_default_context());
432+
void *dst_ptr = lzt::allocate_device_memory(buffer_size, 1, 0, device,
433+
lzt::get_default_context());
434+
435+
ASSERT_NE(src_ptr, nullptr);
436+
ASSERT_NE(dst_ptr, nullptr);
437+
438+
for (auto mem_handle : mem_handles) {
439+
ASSERT_NE(nullptr, mem_handle);
440+
441+
// Get initial bandwidth counters
442+
zes_mem_bandwidth_t bandwidth_before = {};
443+
EXPECT_EQ(ZE_RESULT_SUCCESS,
444+
zesMemoryGetBandwidth(mem_handle, &bandwidth_before));
445+
446+
// Run the workload
447+
ze_result_t result = copy_workload(device, &device_desc, src_ptr, dst_ptr,
448+
static_cast<int32_t>(buffer_size));
449+
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
450+
451+
// Get bandwidth counters after workload
452+
zes_mem_bandwidth_t bandwidth_after = {};
453+
EXPECT_EQ(ZE_RESULT_SUCCESS,
454+
zesMemoryGetBandwidth(mem_handle, &bandwidth_after));
455+
456+
// Validate that read/write counters have increased
457+
EXPECT_GE(bandwidth_after.readCounter, bandwidth_before.readCounter)
458+
<< "Read counter did not increase after workload";
459+
EXPECT_GE(bandwidth_after.writeCounter, bandwidth_before.writeCounter)
460+
<< "Write counter did not increase after workload";
461+
}
462+
463+
// Free device memory
464+
lzt::free_memory(src_ptr);
465+
lzt::free_memory(dst_ptr);
466+
}
467+
}
411468
} // namespace

0 commit comments

Comments
 (0)