-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Added support for aspects and the has() function. #2237
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//==-------------- aspects.hpp - SYCL Aspect Enums ------------*- C++ -*---==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// ===--------------------------------------------------------------------=== // | ||
#pragma once | ||
|
||
#include <CL/sycl/detail/defines.hpp> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
|
||
enum class aspect { | ||
host, | ||
cpu, | ||
gpu, | ||
accelerator, | ||
custom, | ||
fp16, | ||
fp64, | ||
int64_base_atomics, | ||
int64_extended_atomics, | ||
image, | ||
online_compiler, | ||
online_linker, | ||
queue_profiling, | ||
usm_device_allocations, | ||
usm_host_allocations, | ||
usm_shared_allocations, | ||
usm_restricted_shared_allocations, | ||
usm_system_allocator | ||
}; | ||
|
||
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// RUN: %clangxx %s -o %t.out -I %sycl_include -lsycl | ||
// RUN: %t.out | ||
|
||
//==--------------- aspects.cpp - SYCL device test ------------------------==// | ||
// | ||
// Returns the various aspects of a device and platform. | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <CL/sycl.hpp> | ||
#include <iostream> | ||
|
||
using namespace cl::sycl; | ||
|
||
// platform::has() calls device::has() for each device on the platform. | ||
|
||
int main() { | ||
bool failed = false; | ||
int pltIdx = 0; | ||
for (const auto &plt : platform::get_platforms()) { | ||
pltIdx++; | ||
if (plt.has(aspect::host)) { | ||
std::cout << "Platform #" << pltIdx | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently this test only checks that has() method can be called, but it doesn't check its result. Probably it is better to query same info using existing SYCL methods (like get_info) and compare it with the result of has(). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The aspect::has() function calls get_info() to see if the requested aspect is supported. Whether it is right or wrong, has() and get_info() will always agree. |
||
<< " type: host supports:" << std::endl; | ||
} else if (plt.has(aspect::cpu)) { | ||
std::cout << "Platform #" << pltIdx | ||
<< " type: cpu supports:" << std::endl; | ||
} else if (plt.has(aspect::gpu)) { | ||
std::cout << "Platform #" << pltIdx | ||
<< " type: gpu supports:" << std::endl; | ||
} else if (plt.has(aspect::accelerator)) { | ||
std::cout << "Platform #" << pltIdx | ||
<< " type: accelerator supports:" << std::endl; | ||
} else { | ||
failed = true; | ||
std::cout << "Failed: platform #" << pltIdx << " type: unknown" | ||
<< std::endl; | ||
return 1; | ||
} | ||
|
||
if (plt.has(aspect::fp16)) { | ||
std::cout << " fp16" << std::endl; | ||
} | ||
if (plt.has(aspect::fp64)) { | ||
std::cout << " fp64" << std::endl; | ||
} | ||
if (plt.has(aspect::int64_base_atomics)) { | ||
std::cout << " base atomic operations" << std::endl; | ||
} | ||
if (plt.has(aspect::int64_extended_atomics)) { | ||
std::cout << " extended atomic operations" << std::endl; | ||
} | ||
if (plt.has(aspect::image)) { | ||
std::cout << " images" << std::endl; | ||
} | ||
if (plt.has(aspect::online_compiler)) { | ||
std::cout << " online compiler" << std::endl; | ||
} | ||
if (plt.has(aspect::online_linker)) { | ||
std::cout << " online linker" << std::endl; | ||
} | ||
if (plt.has(aspect::queue_profiling)) { | ||
std::cout << " queue profiling" << std::endl; | ||
} | ||
} | ||
std::cout << "Passed." << std::endl; | ||
return 0; | ||
} |
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.
It doesn't look like you've made any changes here and above in this file. Could you please preserve old formatting?
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.
This is not me, it is clang-format. I do not know why it suddenly changed these lines.
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.
it is because clang-format was applied to the whole file. Please apply it only to the changes made in this PR.