forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaspects.cpp
More file actions
93 lines (87 loc) · 3.09 KB
/
aspects.cpp
File metadata and controls
93 lines (87 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: env SYCL_DEVICE_FILTER=%sycl_be %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
<< " 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 if (plt.has(aspect::custom)) {
std::cout << "Platform #" << pltIdx
<< " type: Custom 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::atomic64)) {
std::cout << " atomic64" << 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;
}
if (plt.has(aspect::usm_device_allocations)) {
std::cout << " USM allocations" << std::endl;
}
if (plt.has(aspect::usm_host_allocations)) {
std::cout << " USM host allocations" << std::endl;
}
if (plt.has(aspect::usm_shared_allocations)) {
std::cout << " USM shared allocations" << std::endl;
}
if (plt.has(aspect::usm_restricted_shared_allocations)) {
std::cout << " USM restricted shared allocations" << std::endl;
}
if (plt.has(aspect::usm_system_allocator)) {
std::cout << " USM system allocator" << std::endl;
}
}
std::cout << "Passed." << std::endl;
return 0;
}