Skip to content

Commit

Permalink
Reworked the CTS tests to be in terms of multi-queue.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Woloszyn <[email protected]>
  • Loading branch information
AWoloszyn committed Nov 4, 2024
1 parent 5c137b2 commit f3019a6
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 159 deletions.
27 changes: 10 additions & 17 deletions runtime/src/iree/hal/cts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ set(IREE_ALL_CTS_TESTS
"command_buffer_fill_buffer"
"command_buffer_update_buffer"
"driver"
"multi_device_copy"
"multi_device_dispatch"
"multi_device_driver"
"multi_queue_copy"
"multi_queue_dispatch"
"multi_queue_driver"
"event"
"executable_cache"
"file"
Expand All @@ -31,7 +31,7 @@ set(IREE_ALL_CTS_TESTS
set(IREE_EXECUTABLE_CTS_TESTS
"command_buffer_dispatch"
"command_buffer_dispatch_constants"
"multi_device_dispatch"
"multi_queue_dispatch"
"executable_cache"
PARENT_SCOPE
)
Expand All @@ -44,13 +44,6 @@ set(IREE_ALL_CTS_EXECUTABLE_SOURCES
PARENT_SCOPE
)

set (IREE_MULTI_DEVICE_CTS_TESTS
"multi_device_copy"
"multi_device_dispatch"
"multi_device_driver"
PARENT_SCOPE
)

iree_cc_library(
NAME
cts_test_base
Expand Down Expand Up @@ -170,9 +163,9 @@ iree_cc_library(

iree_cc_library(
NAME
multi_device_copy_test_library
multi_queue_copy_test_library
HDRS
"multi_device_copy_test.h"
"multi_queue_copy_test.h"
DEPS
::cts_test_base
iree::base
Expand All @@ -183,9 +176,9 @@ iree_cc_library(

iree_cc_library(
NAME
multi_device_dispatch_test_library
multi_queue_dispatch_test_library
HDRS
"multi_device_dispatch_test.h"
"multi_queue_dispatch_test.h"
DEPS
::cts_test_base
iree::base
Expand All @@ -196,9 +189,9 @@ iree_cc_library(

iree_cc_library(
NAME
multi_device_driver_test_library
multi_queue_driver_test_library
HDRS
"multi_device_driver_test.h"
"multi_queue_driver_test.h"
DEPS
::cts_test_base
iree::base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef IREE_HAL_CTS_MULTI_DEVICE_COPY_TEST_H_
#define IREE_HAL_CTS_MULTI_DEVICE_COPY_TEST_H_
#ifndef IREE_HAL_CTS_MULTI_QUEUE_COPY_TEST_H_
#define IREE_HAL_CTS_MULTI_QUEUE_COPY_TEST_H_

#include <cstdint>
#include <vector>
Expand All @@ -27,9 +27,20 @@ constexpr iree_hal_queue_affinity_t kQueue1 = 0x2;

} // namespace

class DeviceGroupCopyTest : public CTSTestBase<> {};

TEST_F(DeviceGroupCopyTest, CopyBetweenDevicesFromQueue0) {
class MultiQueueCopyTest : public CTSTestBase<> {
virtual void SetUp() {
CTSTestBase<>::SetUp();
int64_t concurrency;
IREE_ASSERT_OK(iree_hal_device_query_i64(
device_, IREE_SV("hal.device"), IREE_SV("concurrency"), &concurrency));
if (concurrency < 2) {
GTEST_SKIP() << "Test requires at least two queues";
return;
}
}
};

TEST_F(MultiQueueCopyTest, CopyBetweenDevicesFromQueue0) {
iree_hal_command_buffer_t* command_buffer1 = NULL;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
device_, IREE_HAL_COMMAND_BUFFER_MODE_ONE_SHOT,
Expand Down Expand Up @@ -122,7 +133,7 @@ TEST_F(DeviceGroupCopyTest, CopyBetweenDevicesFromQueue0) {
iree_hal_buffer_release(host_buffer);
}

TEST_F(DeviceGroupCopyTest, CopyBetweenDevicesFromQueue1) {
TEST_F(MultiQueueCopyTest, CopyBetweenDevicesFromQueue1) {
iree_hal_command_buffer_t* command_buffer1 = NULL;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
device_, IREE_HAL_COMMAND_BUFFER_MODE_ONE_SHOT,
Expand Down Expand Up @@ -217,7 +228,7 @@ TEST_F(DeviceGroupCopyTest, CopyBetweenDevicesFromQueue1) {
iree_hal_buffer_release(host_buffer);
}

TEST_F(DeviceGroupCopyTest, CopyBetweenDevicesFromBothQueues) {
TEST_F(MultiQueueCopyTest, CopyBetweenDevicesFromBothQueues) {
iree_hal_command_buffer_t* command_buffer1 = NULL;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
device_, IREE_HAL_COMMAND_BUFFER_MODE_ONE_SHOT,
Expand Down Expand Up @@ -312,7 +323,7 @@ TEST_F(DeviceGroupCopyTest, CopyBetweenDevicesFromBothQueues) {
iree_hal_buffer_release(host_buffer);
}

TEST_F(DeviceGroupCopyTest, CopyBetweenDevicesFromBothQueuesSynchronized) {
TEST_F(MultiQueueCopyTest, CopyBetweenDevicesFromBothQueuesSynchronized) {
iree_hal_command_buffer_t* command_buffer1 = NULL;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
device_, IREE_HAL_COMMAND_BUFFER_MODE_ONE_SHOT,
Expand Down Expand Up @@ -440,7 +451,7 @@ TEST_F(DeviceGroupCopyTest, CopyBetweenDevicesFromBothQueuesSynchronized) {
iree_hal_buffer_release(host_buffer);
}

TEST_F(DeviceGroupCopyTest,
TEST_F(MultiQueueCopyTest,
CopyBetweenDevicesFromBothQueuesSynchronizedReverseSubmit) {
iree_hal_command_buffer_t* command_buffer1 = NULL;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
Expand Down Expand Up @@ -569,7 +580,7 @@ TEST_F(DeviceGroupCopyTest,
iree_hal_buffer_release(host_buffer);
}

TEST_F(DeviceGroupCopyTest, SimultaneousCopyWithTwoDevices) {
TEST_F(MultiQueueCopyTest, SimultaneousCopyWithTwoDevices) {
iree_hal_command_buffer_t* command_buffer1 = NULL;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
device_, IREE_HAL_COMMAND_BUFFER_MODE_ONE_SHOT,
Expand Down Expand Up @@ -721,4 +732,4 @@ TEST_F(DeviceGroupCopyTest, SimultaneousCopyWithTwoDevices) {

} // namespace iree::hal::cts

#endif // IREE_HAL_CTS_MULTI_DEVICE_COPY_TEST_H_
#endif // IREE_HAL_CTS_MULTI_QUEUE_COPY_TEST_H_
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace iree::hal::cts {
using ::testing::ContainerEq;

class DeviceGroupCommandBufferDispatchTest : public CTSTestBase<> {
class MultiQueueCommandBufferDispatchTest : public CTSTestBase<> {
protected:
void PrepareAbsExecutable() {
IREE_ASSERT_OK(iree_hal_executable_cache_create(
Expand All @@ -44,6 +44,17 @@ class DeviceGroupCommandBufferDispatchTest : public CTSTestBase<> {
IREE_ASSERT_OK(loop_status_);
}

virtual void SetUp() {
CTSTestBase<>::SetUp();
int64_t concurrency;
IREE_ASSERT_OK(iree_hal_device_query_i64(
device_, IREE_SV("hal.device"), IREE_SV("concurrency"), &concurrency));
if (concurrency < 2) {
GTEST_SKIP() << "Test requires at least two queues";
return;
}
}

iree_status_t loop_status_ = iree_ok_status();
iree_hal_executable_cache_t* executable_cache_ = NULL;
iree_hal_executable_t* executable_ = NULL;
Expand All @@ -52,7 +63,7 @@ class DeviceGroupCommandBufferDispatchTest : public CTSTestBase<> {
// Dispatches absf(x) on a two subranges (elements 8-9 and 16-17) of a 32
// element input buffer. input_buffer = [-2.5 -2.5 -2.5 -2.5, ...]
// output_buffer = [-9.0 -9.0, -9.0, -9.0, 2.5, 2.5, -9.0, ......, 2.5, 2.5]
TEST_F(DeviceGroupCommandBufferDispatchTest,
TEST_F(MultiQueueCommandBufferDispatchTest,
DispatchSameCommandListInTwoPlaces) {
PrepareAbsExecutable();

Expand Down
2 changes: 0 additions & 2 deletions runtime/src/iree/hal/drivers/cuda/cts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ iree_hal_cts_test_suite(
EXCLUDED_TESTS
# HAL event is unimplemented for now.
"event"
${IREE_MULTI_DEVICE_CTS_TESTS}
LABELS
driver=cuda
requires-gpu-nvidia
Expand All @@ -50,7 +49,6 @@ iree_hal_cts_test_suite(
EXCLUDED_TESTS
# HAL event is unimplemented for now.
"event"
${IREE_MULTI_DEVICE_CTS_TESTS}
LABELS
driver=cuda
requires-gpu-nvidia
Expand Down
7 changes: 7 additions & 0 deletions runtime/src/iree/hal/drivers/cuda/cuda_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,13 @@ static iree_status_t iree_hal_cuda_device_query_i64(
return iree_ok_status();
}

if (iree_string_view_equal(category, IREE_SV("hal.device"))) {
if (iree_string_view_equal(key, IREE_SV("concurrency"))) {
*out_value = 1;
return iree_ok_status();
}
}

if (iree_string_view_equal(category, IREE_SV("cuda.device"))) {
if (iree_string_view_equal(key, IREE_SV("compute_capability_major"))) {
return iree_hal_cuda_device_query_attribute(
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/iree/hal/drivers/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ iree_cc_library(
"hip_driver.c"
"hip_device.h"
"hip_device.c"
"hip_multi_device_command_buffer.h"
"hip_multi_device_command_buffer.c"
"hip_multi_queue_command_buffer.h"
"hip_multi_queue_command_buffer.c"
"memory_pools.c"
"memory_pools.h"
"native_executable.c"
Expand Down
28 changes: 12 additions & 16 deletions runtime/src/iree/hal/drivers/hip/cts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ iree_hal_cts_test_suite(
EXCLUDED_TESTS
# HAL event is unimplemented for now.
"event"
${IREE_MULTI_DEVICE_CTS_TESTS}
LABELS
driver=hip
requires-gpu-amd
Expand Down Expand Up @@ -63,7 +62,6 @@ iree_hal_cts_test_suite(
EXCLUDED_TESTS
# HAL event is unimplemented for now.
"event"
${IREE_MULTI_DEVICE_CTS_TESTS}
LABELS
driver=hip
)
Expand All @@ -72,15 +70,15 @@ iree_hal_cts_test_suite(
DRIVER_NAME
hip
VARIANT_SUFFIX
multi_device_stream
multi_queue_stream
DRIVER_REGISTRATION_HDR
"runtime/src/iree/hal/drivers/hip/registration/driver_module.h"
DRIVER_REGISTRATION_FN
"iree_hal_hip_driver_module_register"
DEVICE_CREATION_HDR
"runtime/src/iree/hal/drivers/hip/cts/multi_device_creation.h"
"runtime/src/iree/hal/drivers/hip/cts/multi_queue_device_creation.h"
DEFAULT_DEVICE_CREATION_FN
"iree_hal_drivers_hip_cts_default_multi_device_create"
"iree_hal_drivers_hip_cts_default_multi_queue_create"
COMPILER_TARGET_BACKEND
"rocm"
EXECUTABLE_FORMAT
Expand All @@ -103,15 +101,15 @@ iree_hal_cts_test_suite(
DRIVER_NAME
hip
VARIANT_SUFFIX
multi_device_graph
multi_queue_graph
DRIVER_REGISTRATION_HDR
"runtime/src/iree/hal/drivers/hip/registration/driver_module.h"
DRIVER_REGISTRATION_FN
"iree_hal_hip_driver_module_register"
DEVICE_CREATION_HDR
"runtime/src/iree/hal/drivers/hip/cts/multi_device_creation.h"
"runtime/src/iree/hal/drivers/hip/cts/multi_queue_device_creation.h"
DEFAULT_DEVICE_CREATION_FN
"iree_hal_drivers_hip_cts_default_multi_device_create"
"iree_hal_drivers_hip_cts_default_multi_queue_create"
COMPILER_TARGET_BACKEND
"rocm"
EXECUTABLE_FORMAT
Expand All @@ -133,15 +131,15 @@ iree_hal_cts_test_suite(
DRIVER_NAME
hip
VARIANT_SUFFIX
multi_device_stream_queue_1
multi_queue_stream_queue_1
DRIVER_REGISTRATION_HDR
"runtime/src/iree/hal/drivers/hip/registration/driver_module.h"
DRIVER_REGISTRATION_FN
"iree_hal_hip_driver_module_register"
DEVICE_CREATION_HDR
"runtime/src/iree/hal/drivers/hip/cts/multi_device_creation.h"
"runtime/src/iree/hal/drivers/hip/cts/multi_queue_device_creation.h"
DEFAULT_DEVICE_CREATION_FN
"iree_hal_drivers_hip_cts_default_multi_device_create"
"iree_hal_drivers_hip_cts_default_multi_queue_create"
COMPILER_TARGET_BACKEND
"rocm"
EXECUTABLE_FORMAT
Expand All @@ -155,7 +153,6 @@ iree_hal_cts_test_suite(
DEPS
iree::hal::drivers::hip::registration
EXCLUDED_TESTS
${IREE_MULTI_DEVICE_CTS_TESTS}
# HAL event is unimplemented for now.
"event"
LABELS
Expand All @@ -167,15 +164,15 @@ iree_hal_cts_test_suite(
DRIVER_NAME
hip
VARIANT_SUFFIX
multi_device_graph_queue_1
multi_queue_graph_queue_1
DRIVER_REGISTRATION_HDR
"runtime/src/iree/hal/drivers/hip/registration/driver_module.h"
DRIVER_REGISTRATION_FN
"iree_hal_hip_driver_module_register"
DEVICE_CREATION_HDR
"runtime/src/iree/hal/drivers/hip/cts/multi_device_creation.h"
"runtime/src/iree/hal/drivers/hip/cts/multi_queue_device_creation.h"
DEFAULT_DEVICE_CREATION_FN
"iree_hal_drivers_hip_cts_default_multi_device_create"
"iree_hal_drivers_hip_cts_default_multi_queue_create"
DEFAULT_SUBMIT_QUEUE_AFFINITY
"(1 << 1)"
COMPILER_TARGET_BACKEND
Expand All @@ -189,7 +186,6 @@ iree_hal_cts_test_suite(
DEPS
iree::hal::drivers::hip::registration
EXCLUDED_TESTS
${IREE_MULTI_DEVICE_CTS_TESTS}
# HAL event is unimplemented for now.
"event"
LABELS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef IREE_HAL_DRIVERS_HIP_REGISTRATION_MULTI_DEVICE_H_
#define IREE_HAL_DRIVERS_HIP_REGISTRATION_MULTI_DEVICE_H_
#ifndef IREE_HAL_DRIVERS_HIP_REGISTRATION_MULTI_QUEUE_H_
#define IREE_HAL_DRIVERS_HIP_REGISTRATION_MULTI_QUEUE_H_

#include <map>

#include "iree/hal/driver.h"
#include "iree/testing/status_matchers.h"

inline iree_status_t iree_hal_drivers_hip_cts_default_multi_device_create(
inline iree_status_t iree_hal_drivers_hip_cts_default_multi_queue_create(
iree_hal_driver_t* driver, iree_allocator_t host_allocator,
iree_hal_device_t** out_device) {
std::multimap<std::string, iree_host_size_t> grouped_devices;
Expand Down Expand Up @@ -68,4 +68,4 @@ inline iree_status_t iree_hal_drivers_hip_cts_default_multi_device_create(
/*params=*/NULL, iree_allocator_system(), out_device);
}

#endif // IREE_HAL_DRIVERS_HIP_REGISTRATION_MULTI_DEVICE_H_
#endif // IREE_HAL_DRIVERS_HIP_REGISTRATION_MULTI_QUEUE_H_
Loading

0 comments on commit f3019a6

Please sign in to comment.