-
Notifications
You must be signed in to change notification settings - Fork 201
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
add a unified SVM consistency check test #2174
Open
bashbaug
wants to merge
4
commits into
KhronosGroup:cl_khr_unified_svm
Choose a base branch
from
bashbaug:unified-svm-consistency
base: cl_khr_unified_svm
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 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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,159 @@ | ||
// | ||
// Copyright (c) 2020 The Khronos Group Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#include "common.h" | ||
#include <cinttypes> | ||
|
||
REGISTER_TEST(unified_svm_consistency) | ||
{ | ||
if (!is_extension_available(deviceID, "cl_khr_unified_svm")) | ||
{ | ||
log_info("cl_khr_unified_svm is not supported, skipping test.\n"); | ||
return TEST_SKIPPED_ITSELF; | ||
} | ||
|
||
cl_int err; | ||
|
||
cl_platform_id platformID; | ||
err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), | ||
(void *)(&platformID), nullptr); | ||
test_error(err, "clGetDeviceInfo failed for CL_DEVICE_PLATFORM"); | ||
|
||
cl_uint numDevices = 0; | ||
err = | ||
clGetDeviceIDs(platformID, CL_DEVICE_TYPE_ALL, 0, nullptr, &numDevices); | ||
test_error(err, "clGetDeviceIDs failed to get number of devices"); | ||
|
||
std::vector<cl_device_id> devices(numDevices); | ||
err = clGetDeviceIDs(platformID, CL_DEVICE_TYPE_ALL, numDevices, | ||
devices.data(), nullptr); | ||
test_error(err, "clGetDeviceIDs failed to get device IDs"); | ||
|
||
// For each device in the platform, check that the platform and device | ||
// report the same number of SVM capability combinations. | ||
|
||
size_t platformSize{}; | ||
err = clGetPlatformInfo(platformID, CL_PLATFORM_SVM_TYPE_CAPABILITIES_KHR, | ||
0, nullptr, &platformSize); | ||
test_error(err, | ||
"clGetPlatformInfo failed for " | ||
"CL_PLATFORM_SVM_TYPE_CAPABILITIES_KHR"); | ||
|
||
if (platformSize % sizeof(cl_svm_capabilities_khr) != 0) | ||
{ | ||
test_fail( | ||
"Unexpected platform SVM type capabilities size: %zu bytes.\n", | ||
platformSize); | ||
} | ||
|
||
for (auto device : devices) | ||
{ | ||
size_t deviceSize{}; | ||
err = clGetDeviceInfo(device, CL_DEVICE_SVM_TYPE_CAPABILITIES_KHR, 0, | ||
nullptr, &deviceSize); | ||
test_error( | ||
err, | ||
"clGetDeviceInfo failed for CL_DEVICE_SVM_TYPE_CAPABILITIES_KHR"); | ||
|
||
if (deviceSize % sizeof(cl_svm_capabilities_khr) != 0) | ||
{ | ||
test_fail("Unexpected device SVM type capabilities size: " | ||
"%zu bytes.\n", | ||
deviceSize); | ||
} | ||
if (platformSize != deviceSize) | ||
{ | ||
test_fail("Platform and device report different number of " | ||
"SVM type capability combinations.\n"); | ||
} | ||
} | ||
|
||
// For each SVM capability combination reported by the platform, check that | ||
// the reported platform capabilities at an index are the intersection of | ||
// all non-zero device capabilities at the same index. | ||
|
||
size_t capabilityCount = platformSize / sizeof(cl_svm_capabilities_khr); | ||
|
||
std::vector<cl_svm_capabilities_khr> platformCapabilities(capabilityCount); | ||
err = clGetPlatformInfo(platformID, CL_PLATFORM_SVM_TYPE_CAPABILITIES_KHR, | ||
platformSize, platformCapabilities.data(), nullptr); | ||
test_error(err, | ||
"clGetPlatformInfo failed for " | ||
"CL_PLATFORM_SVM_TYPE_CAPABILITIES_KHR"); | ||
|
||
for (int i = 0; i < capabilityCount; i++) | ||
{ | ||
cl_svm_capabilities_khr check = 0; | ||
for (auto device : devices) | ||
{ | ||
std::vector<cl_svm_capabilities_khr> deviceCapabilities( | ||
capabilityCount); | ||
err = clGetDeviceInfo(device, CL_DEVICE_SVM_TYPE_CAPABILITIES_KHR, | ||
platformSize, deviceCapabilities.data(), | ||
nullptr); | ||
test_error( | ||
err, | ||
"clGetDeviceInfo failed for CL_DEVICE_SVM_CAPABILITIES_KHR"); | ||
|
||
if (deviceCapabilities[i] != 0) | ||
{ | ||
if (check == 0) | ||
{ | ||
check = deviceCapabilities[i]; | ||
} | ||
else | ||
{ | ||
check &= deviceCapabilities[i]; | ||
} | ||
} | ||
} | ||
if (platformCapabilities[i] != check) | ||
{ | ||
test_fail("Platform SVM type capabilities at index %zu: 0x%" PRIx64 | ||
" do not match the intersection of device capabilities " | ||
"0x%" PRIx64 ".\n", | ||
i, platformCapabilities[i], check); | ||
} | ||
} | ||
|
||
// For each SVM capability combination reported by the test device, check | ||
// that the device SVM capabilities are either a super-set of the platform | ||
// SVM capabilities or are zero, indicating that this SVM type is not | ||
// supported. | ||
|
||
std::vector<cl_svm_capabilities_khr> deviceCapabilities(capabilityCount); | ||
err = clGetDeviceInfo(deviceID, CL_DEVICE_SVM_TYPE_CAPABILITIES_KHR, | ||
platformSize, deviceCapabilities.data(), nullptr); | ||
test_error(err, | ||
"clGetDeviceInfo failed for CL_DEVICE_SVM_CAPABILITIES_KHR"); | ||
|
||
for (int i = 0; i < capabilityCount; i++) | ||
{ | ||
bool consistent = (deviceCapabilities[i] & platformCapabilities[i]) | ||
== platformCapabilities[i] | ||
|| deviceCapabilities[i] == 0; | ||
if (!consistent) | ||
{ | ||
test_fail( | ||
"Device SVM type capabilities at index %zu: 0x%" PRIx64 | ||
" are not consistent with platform SVM type capabilities: " | ||
"0x%" PRIx64 ".\n", | ||
i, deviceCapabilities[i], platformCapabilities[i]); | ||
} | ||
} | ||
|
||
return TEST_PASS; | ||
} |
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.
I've not been following the unified svm test plan closely, but is the idea that the extension tests will live in
test_conformance/SVM
rather thantest_conformance/extensions/cl_khr_unified_svm
?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.
Good question. I don't think we've discussed this. I'll create a new test executable if that's what the group prefers, but I think we've generally tried to minimize test executables, so I'm inclined to put the unified SVM tests here unless we have a good reason to do otherwise.
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.
Hmm, I may have found a few good reasons to create a new test executable:
The "SVM" tests run an
InitCL
function to decide whether to run the tests, which currently requires OpenCL 2.0 or newer, and requires that the query forCL_DEVICE_SVM_CAPABILITIES
returns a non-zero value. The first part is debatably OK, though the extension is currently written to support OpenCL 1.2 devices also. The second part is not OK though, because a device can support unified SVM without supporting SVM.The "SVM" tests run with
forceNoContextCreation
set totrue
, which means no context or queue are created. Not the end of the world, but I think the harness context and queue will be sufficient for most of the unified SVM tests, so it'd be nice to keep things simple and use them.