Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

[SYCL] Test for get_backend() methods #162

Merged
merged 6 commits into from
Mar 23, 2021
Merged
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
37 changes: 34 additions & 3 deletions SYCL/Basic/get_backend.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %t.out
//
//==----------------- get_backend.cpp ------------------------==//
Expand Down Expand Up @@ -26,12 +26,43 @@ bool check(backend be) {
return false;
}

inline void return_fail() {
std::cout << "Failed" << std::endl;
exit(1);
}

int main() {
for (const auto &plt : platform::get_platforms()) {
if (!plt.is_host()) {
if (check(plt.get_backend()) == false) {
std::cout << "Failed" << std::endl;
return 1;
return_fail();
}

context c(plt);
if (c.get_backend() != plt.get_backend()) {
return_fail();
}

program prog(c);
if (prog.get_backend() != plt.get_backend()) {
return_fail();
}

default_selector sel;
queue q(c, sel);
if (q.get_backend() != plt.get_backend()) {
return_fail();
}

auto device = q.get_device();
if (device.get_backend() != plt.get_backend()) {
return_fail();
}

unsigned char *HostAlloc = (unsigned char *)malloc_host(1, c);
auto e = q.memset(HostAlloc, 42, 1);
if (e.get_backend() != plt.get_backend()) {
return_fail();
}
}
}
Expand Down