-
Notifications
You must be signed in to change notification settings - Fork 66
Add CTS for scratch register reading. #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
#include "test_debug.hpp" | ||
#include "test_debug_utils.hpp" | ||
#include "test_harness/zet_intel_gpu_debug.h" | ||
|
||
namespace lzt = level_zero_tests; | ||
|
||
|
@@ -1376,6 +1377,128 @@ void zetDebugReadWriteRegistersTest::run_read_write_registers_test( | |
} | ||
} | ||
|
||
void zetDebugReadWriteRegistersTest::run_read_registers_test( | ||
std::vector<ze_device_handle_t> &devices, bool use_sub_devices) { | ||
for (auto &device : devices) { | ||
print_device(device); | ||
if (!is_debug_supported(device)) | ||
continue; | ||
|
||
synchro->clear_debugger_signal(); | ||
debugHelper = launch_process(LONG_RUNNING_KERNEL_INTERRUPTED_SCRATCH, | ||
device, use_sub_devices); | ||
|
||
zet_debug_event_t module_event; | ||
attach_and_get_module_event(debugHelper.id(), synchro, device, debugSession, | ||
module_event); | ||
|
||
if (module_event.flags & ZET_DEBUG_EVENT_FLAG_NEED_ACK) { | ||
LOG_DEBUG << "[Debugger] Acking event: " | ||
<< lzt::debuggerEventTypeString[module_event.type]; | ||
lzt::debug_ack_event(debugSession, &module_event); | ||
} | ||
|
||
uint64_t gpu_buffer_va = 0; | ||
synchro->wait_for_application_signal(); | ||
if (!synchro->get_app_gpu_buffer_address(gpu_buffer_va)) { | ||
FAIL() << "[Debugger] Could not get a valid GPU buffer VA"; | ||
} | ||
synchro->clear_application_signal(); | ||
|
||
zet_debug_memory_space_desc_t memorySpaceDesc; | ||
memorySpaceDesc.type = ZET_DEBUG_MEMORY_SPACE_TYPE_DEFAULT; | ||
int sizeToRead = 512; | ||
uint8_t *kernel_buffer = new uint8_t[sizeToRead]; | ||
// set buffer[0] to 0 to break the loop. See debug_loop_slm.cl | ||
kernel_buffer[0] = 0; | ||
memorySpaceDesc.address = gpu_buffer_va; | ||
|
||
ze_device_thread_t device_threads = {}; | ||
device_threads.slice = UINT32_MAX; | ||
device_threads.subslice = UINT32_MAX; | ||
device_threads.eu = UINT32_MAX; | ||
device_threads.thread = UINT32_MAX; | ||
|
||
LOG_INFO << "[Debugger] Stopping all device threads"; | ||
// give time to app to launch the kernel | ||
std::this_thread::sleep_for(std::chrono::seconds(6)); | ||
lzt::debug_interrupt(debugSession, device_threads); | ||
|
||
std::vector<ze_device_thread_t> stopped_threads; | ||
if (!find_stopped_threads(debugSession, device, device_threads, true, | ||
stopped_threads)) { | ||
delete[] kernel_buffer; | ||
FAIL() << "[Debugger] Did not find stopped threads"; | ||
} | ||
|
||
LOG_INFO << "[Debugger] Reading/Writing Thread Scratch Register on " | ||
"interrupted threads"; | ||
|
||
for (auto &stopped_thread : stopped_threads) { | ||
std::vector<zet_debug_regset_properties_t> register_set_properties = | ||
lzt::get_register_set_properties(device); | ||
if (lzt::is_heapless_mode(stopped_thread, device, debugSession)) { | ||
for (auto ®ister_set : register_set_properties) { | ||
if ((register_set.type == | ||
ZET_DEBUG_REGSET_TYPE_THREAD_SCRATCH_INTEL_GPU) && | ||
(register_set.generalFlags & ZET_DEBUG_REGSET_FLAG_READABLE)) { | ||
LOG_DEBUG << "[Debugger] Register set type " << register_set.type | ||
<< " is readable"; | ||
size_t reg_size_in_bytes = | ||
register_set.count * register_set.byteSize; | ||
|
||
uint64_t *thread_scratch_reg_values = | ||
new uint64_t[reg_size_in_bytes]; | ||
ASSERT_EQ(zetDebugReadRegisters( | ||
debugSession, stopped_thread, | ||
ZET_DEBUG_REGSET_TYPE_DEBUG_SCRATCH_INTEL_GPU, 0, | ||
register_set.count, thread_scratch_reg_values), | ||
ZE_RESULT_SUCCESS); | ||
} else { | ||
FAIL() << "[Debugger] Register set type " << register_set.type | ||
<< " is NOT readable"; | ||
} | ||
if (register_set.generalFlags & ZET_DEBUG_REGSET_FLAG_WRITEABLE) { | ||
FAIL() << "[Debugger] Register set type " << register_set.type | ||
<< " should NOT be Writable"; | ||
} else { | ||
LOG_INFO << "[Debugger] Register set " << register_set.type | ||
<< " type is NOT writeable"; | ||
} | ||
} | ||
} else { | ||
GTEST_SKIP() << "Test is not supported on this device"; | ||
} | ||
} | ||
|
||
lzt::debug_write_memory(debugSession, device_threads, memorySpaceDesc, 1, | ||
kernel_buffer); | ||
delete[] kernel_buffer; | ||
|
||
LOG_INFO << "[Debugger] resuming interrupted threads"; | ||
lzt::debug_resume(debugSession, device_threads); | ||
debugHelper.wait(); | ||
|
||
std::vector<zet_debug_event_type_t> expectedEvents = { | ||
ZET_DEBUG_EVENT_TYPE_MODULE_UNLOAD, ZET_DEBUG_EVENT_TYPE_PROCESS_EXIT}; | ||
|
||
if (!check_events(debugSession, expectedEvents)) { | ||
FAIL() << "[Debugger] Did not receive expected events"; | ||
} | ||
|
||
lzt::debug_detach(debugSession); | ||
ASSERT_EQ(debugHelper.exit_code(), 0); | ||
} | ||
} | ||
|
||
TEST_F( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Query why cant we use the same test case which @bmyates mentioned in our sync? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then we might need to modify the kernel too. Kernel is not allocating any local memory as such. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any difficulty in modifing the kernel? I hope scratch is forced using IGC_OPTs, so maybe with these options kernel modification might not be required There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes please try to use the same test. The kernel should not need to allocate any local memory. Local memory is for SLM - scratch is different. The compiler will determine if scratch is needed or not based on register usage. Try to use same kernel. If scratch isnt allocated then we can try to use IGC opt. If we still are not getting any spills I can give some suggestions to modify kernel |
||
zetDebugReadWriteRegistersTest, | ||
GivenActiveDebugSessionWhenReadingScratchRegistersThenDataReadIsDoneSuccessfully) { | ||
auto driver = lzt::get_default_driver(); | ||
auto devices = lzt::get_devices(driver); | ||
run_read_registers_test(devices, false); | ||
} | ||
|
||
TEST_F( | ||
zetDebugReadWriteRegistersTest, | ||
GivenActiveDebugSessionWhenReadingAndWritingRegistersThenValidDataReadAndDataWrittenSuccessfully) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.