Skip to content

Commit 969e3de

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 969e3de

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

conformance_tests/sysman/test_sysman_memory/src/test_sysman_memory.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,4 +408,76 @@ 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+
ze_device_properties_t deviceProperties = {
424+
ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES, nullptr};
425+
#ifdef USE_ZESINIT
426+
auto sysman_device_properties = lzt::get_sysman_device_properties(device);
427+
ze_device_handle_t core_device =
428+
lzt::get_core_device_by_uuid(sysman_device_properties.core.uuid.id);
429+
EXPECT_NE(core_device, nullptr);
430+
device = core_device;
431+
#endif // USE_ZESINIT
432+
EXPECT_EQ(ZE_RESULT_SUCCESS,
433+
zeDeviceGetProperties(device, &deviceProperties));
434+
if (deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE) {
435+
std::cout << "test subdevice id " << deviceProperties.subdeviceId;
436+
} else {
437+
std::cout << "test device is a root device" << std::endl;
438+
}
439+
440+
// Allocate device memory for workload
441+
const size_t buffer_size = 32 * 1024 * 1024;
442+
ze_device_mem_alloc_desc_t device_desc = {};
443+
device_desc.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC;
444+
device_desc.ordinal = 0;
445+
device_desc.flags = 0;
446+
447+
void *src_ptr = lzt::allocate_device_memory(buffer_size, 1, 0, device,
448+
lzt::get_default_context());
449+
void *dst_ptr = lzt::allocate_device_memory(buffer_size, 1, 0, device,
450+
lzt::get_default_context());
451+
452+
ASSERT_NE(src_ptr, nullptr);
453+
ASSERT_NE(dst_ptr, nullptr);
454+
455+
for (auto mem_handle : mem_handles) {
456+
ASSERT_NE(nullptr, mem_handle);
457+
458+
// Get initial bandwidth counters
459+
auto bandwidth_before = lzt::get_mem_bandwidth(mem_handle);
460+
461+
// Run the workload
462+
ze_result_t result = copy_workload(device, &device_desc, src_ptr, dst_ptr,
463+
static_cast<int32_t>(buffer_size));
464+
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
465+
466+
// Get bandwidth counters after workload
467+
auto bandwidth_after = lzt::get_mem_bandwidth(mem_handle);
468+
469+
// Validate that read/write counters have increased after workload
470+
EXPECT_GE(bandwidth_after.readCounter, bandwidth_before.readCounter)
471+
<< "Read counter did not increase after workload";
472+
EXPECT_GE(bandwidth_after.writeCounter, bandwidth_before.writeCounter)
473+
<< "Write counter did not increase after workload";
474+
EXPECT_GE(bandwidth_after.maxBandwidth, bandwidth_before.maxBandwidth)
475+
<< "Max bandwidth did not increase after workload";
476+
}
477+
478+
// Free device memory
479+
lzt::free_memory(src_ptr);
480+
lzt::free_memory(dst_ptr);
481+
}
482+
}
411483
} // namespace

0 commit comments

Comments
 (0)