-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1685 from omarahmed1111/v0.9.5rc
Candidate for the v0.9.5 release tag
- Loading branch information
Showing
5 changed files
with
211 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See LICENSE.TXT | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
if(NOT UR_DPCXX) | ||
# Tests that require kernels can't be used if we aren't generating | ||
# device binaries | ||
message(WARNING | ||
"UR_DPCXX is not defined, skipping some adapter tests for level_zero") | ||
else() | ||
add_adapter_test(level_zero | ||
FIXTURE KERNELS | ||
SOURCES | ||
urProgramLink.cpp | ||
urKernelCreateWithNativeHandle.cpp | ||
ENVIRONMENT | ||
"UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_level_zero>\"" | ||
) | ||
# TODO: valgrind tests require very new environment. | ||
# Enable once all L0 runners are updated. | ||
# add_adapter_memcheck_test(level_zero | ||
# ENVIRONMENT | ||
# "UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_level_zero>\"" | ||
# ) | ||
|
||
target_link_libraries(test-adapter-level_zero PRIVATE | ||
LevelZeroLoader | ||
LevelZeroLoader-Headers | ||
) | ||
|
||
target_include_directories(test-adapter-level_zero PRIVATE | ||
${PROJECT_SOURCE_DIR}/source | ||
${PROJECT_SOURCE_DIR}/source/adapters/level_zero | ||
LevelZeroLoader-Headers | ||
) | ||
|
||
add_dependencies(test-adapter-level_zero | ||
generate_device_binaries kernel_names_header) | ||
endif() | ||
|
||
if(NOT WIN32) | ||
# Make L0 use CallMap from a seprate shared lib so that we can access the map | ||
# from the tests. This only seems to work on linux | ||
add_library(zeCallMap SHARED zeCallMap.cpp) | ||
target_compile_definitions(ur_adapter_level_zero PRIVATE UR_L0_CALL_COUNT_IN_TESTS) | ||
target_link_libraries(ur_adapter_level_zero PRIVATE zeCallMap) | ||
|
||
add_adapter_test(level_zero_ze_calls | ||
FIXTURE DEVICES | ||
SOURCES | ||
event_cache_tests.cpp | ||
ENVIRONMENT | ||
"UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_level_zero>\"" | ||
"UR_L0_LEAKS_DEBUG=1" | ||
) | ||
|
||
target_link_libraries(test-adapter-level_zero_ze_calls PRIVATE zeCallMap) | ||
|
||
add_adapter_test(level_zero_multi_queue | ||
FIXTURE DEVICES | ||
SOURCES | ||
multi_device_event_cache_tests.cpp | ||
ENVIRONMENT | ||
"UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_level_zero>\"" | ||
"UR_L0_LEAKS_DEBUG=1" | ||
) | ||
|
||
target_link_libraries(test-adapter-level_zero_multi_queue PRIVATE zeCallMap) | ||
endif() |
This file contains 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
107 changes: 107 additions & 0 deletions
107
test/adapters/level_zero/multi_device_event_cache_tests.cpp
This file contains 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 |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See LICENSE.TXT | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include "ur_print.hpp" | ||
#include "uur/fixtures.h" | ||
#include "uur/raii.h" | ||
|
||
#include <map> | ||
#include <string> | ||
|
||
extern std::map<std::string, int> *ZeCallCount; | ||
|
||
using urMultiQueueMultiDeviceEventCacheTest = uur::urAllDevicesTest; | ||
TEST_F(urMultiQueueMultiDeviceEventCacheTest, | ||
GivenMultiSubDeviceWithQueuePerSubDeviceThenEventIsSharedBetweenQueues) { | ||
uint32_t max_sub_devices = 0; | ||
ASSERT_SUCCESS( | ||
uur::GetDevicePartitionMaxSubDevices(devices[0], max_sub_devices)); | ||
if (max_sub_devices < 2) { | ||
GTEST_SKIP(); | ||
} | ||
ur_device_partition_property_t prop; | ||
prop.type = UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN; | ||
prop.value.affinity_domain = | ||
UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE; | ||
|
||
ur_device_partition_properties_t properties{ | ||
UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES, | ||
nullptr, | ||
&prop, | ||
1, | ||
}; | ||
uint32_t numSubDevices = 0; | ||
ASSERT_SUCCESS( | ||
urDevicePartition(devices[0], &properties, 0, nullptr, &numSubDevices)); | ||
std::vector<ur_device_handle_t> sub_devices; | ||
sub_devices.reserve(numSubDevices); | ||
ASSERT_SUCCESS(urDevicePartition(devices[0], &properties, numSubDevices, | ||
sub_devices.data(), nullptr)); | ||
uur::raii::Context context1 = nullptr; | ||
ASSERT_SUCCESS( | ||
urContextCreate(1, &sub_devices[0], nullptr, context1.ptr())); | ||
ASSERT_NE(nullptr, context1); | ||
uur::raii::Context context2 = nullptr; | ||
ASSERT_SUCCESS( | ||
urContextCreate(1, &sub_devices[1], nullptr, context2.ptr())); | ||
ASSERT_NE(nullptr, context2); | ||
ur_queue_handle_t queue1 = nullptr; | ||
ASSERT_SUCCESS(urQueueCreate(context1, sub_devices[0], 0, &queue1)); | ||
ur_queue_handle_t queue2 = nullptr; | ||
ASSERT_SUCCESS(urQueueCreate(context2, sub_devices[1], 0, &queue2)); | ||
uur::raii::Event event = nullptr; | ||
uur::raii::Event eventWait = nullptr; | ||
uur::raii::Event eventWaitDummy = nullptr; | ||
(*ZeCallCount)["zeCommandListAppendWaitOnEvents"] = 0; | ||
EXPECT_SUCCESS(urEventCreateWithNativeHandle(nullptr, context2, nullptr, | ||
eventWait.ptr())); | ||
EXPECT_SUCCESS(urEventCreateWithNativeHandle(nullptr, context1, nullptr, | ||
eventWaitDummy.ptr())); | ||
EXPECT_SUCCESS( | ||
urEnqueueEventsWait(queue1, 1, eventWaitDummy.ptr(), eventWait.ptr())); | ||
EXPECT_SUCCESS( | ||
urEnqueueEventsWait(queue2, 1, eventWait.ptr(), event.ptr())); | ||
EXPECT_EQ((*ZeCallCount)["zeCommandListAppendWaitOnEvents"], 2); | ||
ASSERT_SUCCESS(urEventRelease(eventWaitDummy.get())); | ||
ASSERT_SUCCESS(urEventRelease(eventWait.get())); | ||
ASSERT_SUCCESS(urEventRelease(event.get())); | ||
ASSERT_SUCCESS(urQueueRelease(queue2)); | ||
ASSERT_SUCCESS(urQueueRelease(queue1)); | ||
} | ||
|
||
TEST_F(urMultiQueueMultiDeviceEventCacheTest, | ||
GivenMultiDeviceWithQueuePerDeviceThenMultiDeviceEventIsCreated) { | ||
if (devices.size() < 2) { | ||
GTEST_SKIP(); | ||
} | ||
uur::raii::Context context1 = nullptr; | ||
ASSERT_SUCCESS(urContextCreate(1, &devices[0], nullptr, context1.ptr())); | ||
ASSERT_NE(nullptr, context1); | ||
uur::raii::Context context2 = nullptr; | ||
ASSERT_SUCCESS(urContextCreate(1, &devices[1], nullptr, context2.ptr())); | ||
ASSERT_NE(nullptr, context2); | ||
ur_queue_handle_t queue1 = nullptr; | ||
ASSERT_SUCCESS(urQueueCreate(context1, devices[0], 0, &queue1)); | ||
ur_queue_handle_t queue2 = nullptr; | ||
ASSERT_SUCCESS(urQueueCreate(context2, devices[1], 0, &queue2)); | ||
uur::raii::Event event = nullptr; | ||
uur::raii::Event eventWait = nullptr; | ||
uur::raii::Event eventWaitDummy = nullptr; | ||
(*ZeCallCount)["zeCommandListAppendWaitOnEvents"] = 0; | ||
EXPECT_SUCCESS(urEventCreateWithNativeHandle(nullptr, context2, nullptr, | ||
eventWait.ptr())); | ||
EXPECT_SUCCESS(urEventCreateWithNativeHandle(nullptr, context1, nullptr, | ||
eventWaitDummy.ptr())); | ||
EXPECT_SUCCESS( | ||
urEnqueueEventsWait(queue1, 1, eventWaitDummy.ptr(), eventWait.ptr())); | ||
EXPECT_SUCCESS( | ||
urEnqueueEventsWait(queue2, 1, eventWait.ptr(), event.ptr())); | ||
EXPECT_EQ((*ZeCallCount)["zeCommandListAppendWaitOnEvents"], 3); | ||
ASSERT_SUCCESS(urEventRelease(eventWaitDummy.get())); | ||
ASSERT_SUCCESS(urEventRelease(eventWait.get())); | ||
ASSERT_SUCCESS(urEventRelease(event.get())); | ||
ASSERT_SUCCESS(urQueueRelease(queue2)); | ||
ASSERT_SUCCESS(urQueueRelease(queue1)); | ||
} |