Skip to content

Commit 266571e

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 266571e

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

conformance_tests/sysman/test_sysman_memory/src/test_sysman_memory.cpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,4 +408,75 @@ 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+
std::cout << "test device name " << deviceProperties.name << " uuid "
435+
<< lzt::to_string(deviceProperties.uuid);
436+
437+
// Allocate device memory for workload
438+
const size_t buffer_size = 32 * 1024 * 1024;
439+
ze_device_mem_alloc_desc_t device_desc = {};
440+
device_desc.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC;
441+
device_desc.ordinal = 0;
442+
device_desc.flags = 0;
443+
444+
void *src_ptr = lzt::allocate_device_memory(buffer_size, 1, 0, device,
445+
lzt::get_default_context());
446+
void *dst_ptr = lzt::allocate_device_memory(buffer_size, 1, 0, device,
447+
lzt::get_default_context());
448+
449+
ASSERT_NE(src_ptr, nullptr);
450+
ASSERT_NE(dst_ptr, nullptr);
451+
452+
for (auto mem_handle : mem_handles) {
453+
ASSERT_NE(nullptr, mem_handle);
454+
455+
// Get initial bandwidth counters
456+
zes_mem_bandwidth_t bandwidth_before = {};
457+
EXPECT_EQ(ZE_RESULT_SUCCESS,
458+
zesMemoryGetBandwidth(mem_handle, &bandwidth_before));
459+
460+
// Run the workload
461+
ze_result_t result = copy_workload(device, &device_desc, src_ptr, dst_ptr,
462+
static_cast<int32_t>(buffer_size));
463+
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
464+
465+
// Get bandwidth counters after workload
466+
zes_mem_bandwidth_t bandwidth_after = {};
467+
EXPECT_EQ(ZE_RESULT_SUCCESS,
468+
zesMemoryGetBandwidth(mem_handle, &bandwidth_after));
469+
470+
// Validate that read/write counters have increased
471+
EXPECT_GE(bandwidth_after.readCounter, bandwidth_before.readCounter)
472+
<< "Read counter did not increase after workload";
473+
EXPECT_GE(bandwidth_after.writeCounter, bandwidth_before.writeCounter)
474+
<< "Write counter did not increase after workload";
475+
}
476+
477+
// Free device memory
478+
lzt::free_memory(src_ptr);
479+
lzt::free_memory(dst_ptr);
480+
}
481+
}
411482
} // namespace

0 commit comments

Comments
 (0)