Skip to content

[SYCL] Fix getting host objects for impl objects #967

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

Merged
merged 1 commit into from
Dec 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sycl/include/CL/sycl/detail/program_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ class program_impl {
}

context get_context() const {
if (is_host())
return context();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return {};

return createSyclObjFromImpl<context>(Context);
}

Expand Down
2 changes: 2 additions & 0 deletions sycl/source/detail/context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ cl_uint context_impl::get_info<info::context::reference_count>() const {
this->getHandleRef());
}
template <> platform context_impl::get_info<info::context::platform>() const {
if (is_host())
return platform();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem

return createSyclObjFromImpl<platform>(MPlatform);
}
template <>
Expand Down
19 changes: 18 additions & 1 deletion sycl/test/basic_tests/info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ int main() {
dev, "Preferred interop user sync");
// TODO test once subdevice creation is enabled
// print_info<info::device::parent_device, device>(dev, "Parent device");
if(!dev.is_host()){
if (!dev.is_host()) {
try {
print_info<info::device::parent_device, device>(dev, "Parent device");
} catch (invalid_object_error e) {
Expand Down Expand Up @@ -343,4 +343,21 @@ int main() {
print_info<info::platform::vendor, string_class>(plt, "Vendor");
print_info<info::platform::extensions, vector_class<string_class>>(
plt, "Extensions");

std::cout << separator << "Queue information\n" << separator;
queue q(selector);
auto qdev = q.get_info<cl::sycl::info::queue::device>();
std::cout << "Device from queue information\n";
print_info<info::device::name, string_class>(qdev, "Name");
auto ctx = q.get_info<cl::sycl::info::queue::context>();

std::cout << separator << "Context information\n" << separator;
std::cout << "Devices from context information\n";
auto cdevs = ctx.get_info<cl::sycl::info::context::devices>();
for (auto cdev : cdevs) {
print_info<info::device::name, string_class>(cdev, "Name");
}
std::cout << separator << "Platform from context information\n" << separator;
auto cplt = ctx.get_info<cl::sycl::info::context::platform>();
print_info<info::platform::name, string_class>(cplt, "Name");
}