This repository was archived by the owner on Mar 28, 2023. It is now read-only.
forked from llvm/llvm-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 130
[SYCL] Test for device.has(aspect::atomic64) #946
Merged
AlexeySachkov
merged 6 commits into
intel:intel
from
denis-kabanov:test_for_atomic64_check
Sep 6, 2022
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c1784a2
[SYCL] Test for device.has(aspect::atomic64)
denis-kabanov 9bd460b
Use backend macros
denis-kabanov 1f07deb
Split test cpp file
denis-kabanov d82e377
Add missing Dev initialization
denis-kabanov 31c133e
Merge branch 'intel' into test_for_atomic64_check
AlexeySachkov 559b928
Make sure that the test is not optimized out completely
AlexeySachkov 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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib | ||
// %level_zero_options RUN: %CPU_RUN_PLACEHOLDER %t.out RUN: | ||
// %GPU_RUN_PLACEHOLDER %t.out RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
|
||
// REQUIRES: (opencl && opencl_icd) || (level_zero && level_zero_dev_kit) || hip | ||
AlexeySachkov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// XFAIL: hip | ||
// Expected failure because hip does not have atomic64 check implementation | ||
|
||
#include <CL/cl.h> | ||
#include <CL/sycl.hpp> | ||
#include <level_zero/ze_api.h> | ||
|
||
using namespace sycl; | ||
|
||
int main() { | ||
queue Queue; | ||
device Dev = Queue.get_device(); | ||
bool Result; | ||
switch (Dev.get_backend()) { | ||
case backend::opencl: { | ||
// Get size for string of extensions | ||
size_t ExtSize; | ||
clGetDeviceInfo(get_native<backend::opencl>(Dev), CL_DEVICE_EXTENSIONS, 0, | ||
nullptr, &ExtSize); | ||
std::string ExtStr(ExtSize, '\0'); | ||
|
||
// Collect device extensions into string ExtStr | ||
clGetDeviceInfo(get_native<backend::opencl>(Dev), CL_DEVICE_EXTENSIONS, | ||
ExtSize, &ExtStr.front(), nullptr); | ||
|
||
// Check that ExtStr has two extensions related to atomic64 support | ||
if (ExtStr.find("cl_khr_int64_base_atomics") == std::string::npos || | ||
ExtStr.find("cl_khr_int64_extended_atomics") == std::string::npos) | ||
Result = false; | ||
else | ||
Result = true; | ||
assert(Dev.has(aspect::atomic64) == Result && | ||
"The Result value differs from the implemented atomic64 check on " | ||
"the OpenCL backend."); | ||
break; | ||
} | ||
case backend::ext_oneapi_level_zero: { | ||
ze_device_module_properties_t Properties; | ||
zeDeviceGetModuleProperties(get_native<backend::ext_oneapi_level_zero>(Dev), | ||
&Properties); | ||
if (Properties.flags & ZE_DEVICE_MODULE_FLAG_INT64_ATOMICS) | ||
Result = true; | ||
else | ||
Result = false; | ||
assert(Dev.has(aspect::atomic64) == Result && | ||
"The Result value differs from the implemented atomic64 check on " | ||
"the L0 backend."); | ||
} | ||
case backend::ext_oneapi_hip: { | ||
Dev.has(aspect::atomic64); | ||
break; | ||
} | ||
default: | ||
assert(false && "Used unexpected backend."); | ||
} | ||
return 0; | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.