-
Notifications
You must be signed in to change notification settings - Fork 68
Add opaque host memory allocation IPC test #306
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
Open
enm-intel
wants to merge
5
commits into
oneapi-src:master
Choose a base branch
from
enm-intel:test/ipc_host_alloc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ad35bf4
feat: add tests for IPC opaque host memory handles
enm-intel aafb9b9
feat: add tests for IPC opaque host memory handles
enm-intel b949d66
feat: add tests for IPC opaque host memory handles
enm-intel e3f01f5
feat: add tests for IPC opaque host memory handles
enm-intel 85477b4
feat: add tests for IPC opaque host memory handles
enm-intel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,10 +111,10 @@ static void run_ipc_mem_access_test(ipc_mem_access_test_t test_type, | |
} | ||
#endif // __linux__ | ||
|
||
static void run_ipc_mem_access_test_opaque(ipc_mem_access_test_t test_type, | ||
size_t size, bool reserved, | ||
ze_ipc_memory_flags_t flags, | ||
bool is_immediate) { | ||
static void run_ipc_dev_mem_access_test_opaque(ipc_mem_access_test_t test_type, | ||
size_t size, bool reserved, | ||
ze_ipc_memory_flags_t flags, | ||
bool is_immediate) { | ||
ze_result_t result = zeInit(0); | ||
if (result != ZE_RESULT_SUCCESS) { | ||
throw std::runtime_error("Parent zeInit failed: " + | ||
|
@@ -196,6 +196,71 @@ static void run_ipc_mem_access_test_opaque(ipc_mem_access_test_t test_type, | |
lzt::destroy_context(context); | ||
} | ||
|
||
static void run_ipc_host_mem_access_test_opaque(size_t size, | ||
ze_ipc_memory_flags_t flags) { | ||
ze_result_t result = zeInit(0); | ||
if (result != ZE_RESULT_SUCCESS) { | ||
throw std::runtime_error("Parent zeInit failed: " + | ||
level_zero_tests::to_string(result)); | ||
} | ||
LOG_DEBUG << "[Parent] Driver initialized\n"; | ||
lzt::print_platform_overview(); | ||
|
||
// Ensure shared memory object is removed in case it already exists | ||
// -- can happen if previous test exited abnormally | ||
bipc::shared_memory_object::remove("ipc_memory_test"); | ||
|
||
ze_ipc_mem_handle_t ipc_handle = {}; | ||
|
||
auto driver = lzt::get_default_driver(); | ||
auto context = lzt::create_context(driver); | ||
auto device = lzt::zeDevice::get_instance()->get_device(); | ||
|
||
void *buffer = lzt::allocate_host_memory(size, 1, context); | ||
memset(buffer, 0, size); | ||
lzt::write_data_pattern(buffer, size, 1); | ||
|
||
ASSERT_ZE_RESULT_SUCCESS(zeMemGetIpcHandle(context, buffer, &ipc_handle)); | ||
|
||
ze_ipc_mem_handle_t ipc_handle_zero{}; | ||
ASSERT_NE(0, memcmp((void *)&ipc_handle, (void *)&ipc_handle_zero, | ||
sizeof(ipc_handle))); | ||
|
||
// Launch child | ||
#ifdef _WIN32 | ||
std::string helper_path = ".\\ipc\\test_ipc_memory_helper.exe"; | ||
#else | ||
std::string helper_path = "./ipc/test_ipc_memory_helper"; | ||
#endif | ||
boost::process::child c; | ||
try { | ||
c = boost::process::child(helper_path); | ||
} catch (const boost::process::process_error &e) { | ||
std::cerr << "Failed to launch child process: " << e.what() << std::endl; | ||
throw; | ||
} | ||
|
||
bipc::shared_memory_object shm(bipc::create_only, "ipc_memory_test", | ||
bipc::read_write); | ||
shm.truncate(sizeof(shared_data_t)); | ||
bipc::mapped_region region(shm, bipc::read_write); | ||
|
||
// Copy ipc handle data to shm | ||
shared_data_t test_data = { | ||
TEST_HOST_ACCESS, TEST_NONSOCK, to_u32(size), flags, false, ipc_handle}; | ||
std::memcpy(region.get_address(), &test_data, sizeof(shared_data_t)); | ||
|
||
// Free device memory once receiver is done | ||
c.wait(); | ||
EXPECT_EQ(c.exit_code(), 0); | ||
|
||
ASSERT_ZE_RESULT_SUCCESS(zeMemPutIpcHandle(context, ipc_handle)); | ||
bipc::shared_memory_object::remove("ipc_memory_test"); | ||
|
||
lzt::free_memory(context, buffer); | ||
lzt::destroy_context(context); | ||
} | ||
|
||
#ifdef __linux__ | ||
LZT_TEST( | ||
IpcMemoryAccessTest, | ||
|
@@ -271,71 +336,83 @@ LZT_TEST( | |
LZT_TEST( | ||
IpcMemoryAccessTestOpaqueIpcHandle, | ||
GivenL0MemoryAllocatedInChildProcessWhenUsingL0IPCThenParentProcessReadsMemoryCorrectly) { | ||
run_ipc_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, false, | ||
ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, false); | ||
run_ipc_dev_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, false, | ||
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. it might be good to state the memory placement in Test name above, i.e something like "GivenL0MemoryAllocatedInChildInDeviceMem*" so we can easily identify in GTA runs what kind passes/fails. thoughts @nrspruit ? |
||
ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, false); | ||
} | ||
|
||
LZT_TEST( | ||
IpcMemoryAccessTestOpaqueIpcHandle, | ||
GivenL0MemoryAllocatedInChildProcessWhenUsingL0IPCOnImmediateCmdListThenParentProcessReadsMemoryCorrectly) { | ||
run_ipc_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, false, | ||
ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, true); | ||
run_ipc_dev_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, false, | ||
ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, true); | ||
} | ||
|
||
LZT_TEST( | ||
IpcMemoryAccessTestOpaqueIpcHandle, | ||
GivenL0MemoryAllocatedInChildProcessBiasCachedWhenUsingL0IPCThenParentProcessReadsMemoryCorrectly) { | ||
run_ipc_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, false, | ||
ZE_IPC_MEMORY_FLAG_BIAS_CACHED, false); | ||
run_ipc_dev_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, false, | ||
ZE_IPC_MEMORY_FLAG_BIAS_CACHED, false); | ||
} | ||
|
||
LZT_TEST( | ||
IpcMemoryAccessTestOpaqueIpcHandle, | ||
GivenL0MemoryAllocatedInChildProcessBiasCachedWhenUsingL0IPCOnImmediateCmdListThenParentProcessReadsMemoryCorrectly) { | ||
run_ipc_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, false, | ||
ZE_IPC_MEMORY_FLAG_BIAS_CACHED, true); | ||
run_ipc_dev_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, false, | ||
ZE_IPC_MEMORY_FLAG_BIAS_CACHED, true); | ||
} | ||
|
||
LZT_TEST( | ||
IpcMemoryAccessTestOpaqueIpcHandle, | ||
GivenL0PhysicalMemoryAllocatedAndReservedInParentProcessWhenUsingL0IPCThenChildProcessReadsMemoryCorrectly) { | ||
run_ipc_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, true, | ||
ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, false); | ||
run_ipc_dev_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, true, | ||
ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, false); | ||
} | ||
|
||
LZT_TEST( | ||
IpcMemoryAccessTestOpaqueIpcHandle, | ||
GivenL0PhysicalMemoryAllocatedAndReservedInParentProcessWhenUsingL0IPCOnImmediateCmdListThenChildProcessReadsMemoryCorrectly) { | ||
run_ipc_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, true, | ||
ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, true); | ||
run_ipc_dev_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, true, | ||
ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, true); | ||
} | ||
|
||
LZT_TEST( | ||
IpcMemoryAccessTestOpaqueIpcHandle, | ||
GivenL0PhysicalMemoryAllocatedAndReservedInParentProcessBiasCachedWhenUsingL0IPCThenChildProcessReadsMemoryCorrectly) { | ||
run_ipc_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, true, | ||
ZE_IPC_MEMORY_FLAG_BIAS_CACHED, false); | ||
run_ipc_dev_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, true, | ||
ZE_IPC_MEMORY_FLAG_BIAS_CACHED, false); | ||
} | ||
|
||
LZT_TEST( | ||
IpcMemoryAccessTestOpaqueIpcHandle, | ||
GivenL0PhysicalMemoryAllocatedAndReservedInParentProcessBiasCachedWhenUsingL0IPCOnImmediateCmdListThenChildProcessReadsMemoryCorrectly) { | ||
run_ipc_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, true, | ||
ZE_IPC_MEMORY_FLAG_BIAS_CACHED, true); | ||
run_ipc_dev_mem_access_test_opaque(TEST_DEVICE_ACCESS, 4096, true, | ||
ZE_IPC_MEMORY_FLAG_BIAS_CACHED, true); | ||
} | ||
|
||
LZT_TEST( | ||
IpcMemoryAccessTestOpaqueIpcHandleSubDevice, | ||
GivenL0PhysicalMemoryAllocatedReservedInParentProcessWhenUsingL0IPCThenChildProcessReadsMemoryCorrectlyUsingSubDeviceQueue) { | ||
run_ipc_mem_access_test_opaque(TEST_SUBDEVICE_ACCESS, 4096, true, | ||
ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, false); | ||
run_ipc_dev_mem_access_test_opaque(TEST_SUBDEVICE_ACCESS, 4096, true, | ||
ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, false); | ||
} | ||
|
||
LZT_TEST( | ||
IpcMemoryAccessTestOpaqueIpcHandleSubDevice, | ||
GivenL0PhysicalMemoryAllocatedReservedInParentProcessWhenUsingL0IPCOnImmediateCmdListThenChildProcessReadsMemoryCorrectlyUsingSubDeviceQueue) { | ||
run_ipc_mem_access_test_opaque(TEST_SUBDEVICE_ACCESS, 4096, true, | ||
ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, true); | ||
run_ipc_dev_mem_access_test_opaque(TEST_SUBDEVICE_ACCESS, 4096, true, | ||
ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, true); | ||
} | ||
|
||
LZT_TEST( | ||
IpcMemoryAccessTestOpaqueIpcHandle, | ||
GivenUncachedHostMemoryAllocatedInParentProcessThenChildProcessReadsMemoryCorrectly) { | ||
run_ipc_host_mem_access_test_opaque(4096, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED); | ||
} | ||
|
||
LZT_TEST( | ||
IpcMemoryAccessTestOpaqueIpcHandle, | ||
GivenCachedHostMemoryAllocatedInParentProcessThenChildProcessReadsMemoryCorrectly) { | ||
run_ipc_host_mem_access_test_opaque(4096, ZE_IPC_MEMORY_FLAG_BIAS_CACHED); | ||
} | ||
|
||
} // namespace | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need new function for host mem? lot of code is duplicated right? can we have another arg to original function such as
run_ipc_mem_access_test_opaque(..., bool inDeviceMem)
that dictates whether you call allocate_host_memory() or allocate_device_memory?