-
Notifications
You must be signed in to change notification settings - Fork 116
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 #2313 from againull/fix_ur_program_get_info
[L0] Fix binary sizes and binaries returned by urProgramGetInfo
- Loading branch information
Showing
5 changed files
with
84 additions
and
31 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
63 changes: 63 additions & 0 deletions
63
test/conformance/program/urMultiDeviceProgramCreateWithIL.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,63 @@ | ||
|
||
// 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 <uur/fixtures.h> | ||
#include <uur/raii.h> | ||
|
||
using urMultiDeviceProgramTest = uur::urMultiDeviceProgramTest; | ||
|
||
// Test binary sizes and binaries obtained from urProgramGetInfo when program is built for a subset of devices in the context. | ||
TEST_F(urMultiDeviceProgramTest, urMultiDeviceProgramGetInfo) { | ||
// Run test only for level zero backend which supports urProgramBuildExp. | ||
ur_platform_backend_t backend; | ||
ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND, | ||
sizeof(backend), &backend, nullptr)); | ||
if (backend != UR_PLATFORM_BACKEND_LEVEL_ZERO) { | ||
GTEST_SKIP(); | ||
} | ||
|
||
std::vector<ur_device_handle_t> associated_devices(devices.size()); | ||
ASSERT_SUCCESS( | ||
urProgramGetInfo(program, UR_PROGRAM_INFO_DEVICES, | ||
associated_devices.size() * sizeof(ur_device_handle_t), | ||
associated_devices.data(), nullptr)); | ||
|
||
// Build program for the first half of devices. | ||
auto subset = std::vector<ur_device_handle_t>( | ||
associated_devices.begin(), | ||
associated_devices.begin() + associated_devices.size() / 2); | ||
ASSERT_SUCCESS( | ||
urProgramBuildExp(program, subset.size(), subset.data(), nullptr)); | ||
|
||
std::vector<size_t> binary_sizes(associated_devices.size()); | ||
ASSERT_SUCCESS(urProgramGetInfo(program, UR_PROGRAM_INFO_BINARY_SIZES, | ||
binary_sizes.size() * sizeof(size_t), | ||
binary_sizes.data(), nullptr)); | ||
|
||
std::vector<std::vector<char>> binaries(associated_devices.size()); | ||
std::vector<char *> pointers(associated_devices.size()); | ||
for (size_t i = 0; i < associated_devices.size() / 2; i++) { | ||
ASSERT_NE(binary_sizes[i], 0); | ||
binaries[i].resize(binary_sizes[i]); | ||
pointers[i] = binaries[i].data(); | ||
} | ||
for (size_t i = associated_devices.size() / 2; | ||
i < associated_devices.size(); i++) { | ||
ASSERT_EQ(binary_sizes[i], 0); | ||
pointers[i] = binaries[i].data(); | ||
} | ||
|
||
ASSERT_SUCCESS(urProgramGetInfo(program, UR_PROGRAM_INFO_BINARIES, | ||
sizeof(uint8_t *) * pointers.size(), | ||
pointers.data(), nullptr)); | ||
for (size_t i = 0; i < associated_devices.size() / 2; i++) { | ||
ASSERT_NE(binaries[i].size(), 0); | ||
} | ||
for (size_t i = associated_devices.size() / 2; | ||
i < associated_devices.size(); i++) { | ||
ASSERT_EQ(binaries[i].size(), 0); | ||
} | ||
} |
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