Skip to content

Commit a2a5752

Browse files
[SYCL][E2E] Add PerformanceTests/aspect_queries.cpp (#18686)
1 parent 5778810 commit a2a5752

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// RUN: %{build} -O3 -DSYCL_DISABLE_IMAGE_ASPECT_WARNING=1 -o %t.out
2+
// RUN: %{run} %t.out
3+
4+
#include <chrono>
5+
#include <sycl/detail/core.hpp>
6+
7+
struct SimpleTimer {
8+
using clock = std::chrono::high_resolution_clock;
9+
SimpleTimer() : start(clock::now()) {}
10+
~SimpleTimer() {
11+
auto d = std::chrono::duration_cast<std::chrono::nanoseconds>(clock::now() -
12+
start)
13+
.count();
14+
std::cout << d << "ns" << " ";
15+
}
16+
17+
std::chrono::time_point<clock> start;
18+
};
19+
20+
int main() {
21+
sycl::device d;
22+
23+
#define ASPECT(A) \
24+
{ \
25+
std::cout << "aspect::" << #A << ": "; \
26+
for (int i = 0; i < 10; ++i) { \
27+
SimpleTimer t; \
28+
(void)d.has(sycl::aspect::A); \
29+
} \
30+
std::cout << std::endl; \
31+
}
32+
33+
#define __SYCL_ASPECT(A, ID) ASPECT(A)
34+
#define __SYCL_ASPECT_DEPRECATED(ASPECT, ID, MSG) __SYCL_ASPECT(ASPECT, ID)
35+
#include <sycl/info/aspects.def>
36+
#include <sycl/info/aspects_deprecated.def>
37+
#undef __SYCL_ASPECT_DEPRECATED
38+
#undef __SYCL_ASPECT
39+
}

0 commit comments

Comments
 (0)