Skip to content
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
61 changes: 61 additions & 0 deletions sycl/test-e2e/Clock/clock.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// REQUIRES-INTEL-DRIVER: cpu: 2026
// REQUIRES: aspect-usm_shared_allocations
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

// UNSUPPORTED: spirv-backend
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/20146
// UNSUPPORTED: target-native_cpu
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/20142

#include <sycl/detail/core.hpp>
#include <sycl/ext/oneapi/experimental/clock.hpp>
#include <sycl/usm.hpp>

namespace syclex = sycl::ext::oneapi::experimental;

template <syclex::clock_scope scope> void test(sycl::queue &q) {
auto *data = sycl::malloc_shared<uint64_t>(3, q);

q.parallel_for(2, [=](sycl::id<1> idx) {
if (idx == 0) {
data[0] = syclex::clock<scope>();
int sum = 0;
for (int i = 0; i < 1e6; ++i)
sum += i;
data[1] = syclex::clock<scope>();
sum = 0;
for (int i = 0; i < 1e6; ++i)
sum += i;
data[2] = syclex::clock<scope>();
}
}).wait();

assert(data[1] > data[0]);
assert(data[2] > data[1]);
sycl::free(data, q);
}

template <syclex::clock_scope scope>
void test_if_supported(sycl::queue &q, sycl::aspect asp) {
auto dev = q.get_device();
if (dev.has(asp))
test<scope>(q);
else
try {
test<scope>(q);
} catch (sycl::exception &e) {
assert(e.code() == sycl::errc::kernel_not_supported && "Unexpected errc");
}
}

int main() {
sycl::queue q;
test_if_supported<syclex::clock_scope::sub_group>(
q, sycl::aspect::ext_oneapi_clock_sub_group);
test_if_supported<syclex::clock_scope::work_group>(
q, sycl::aspect::ext_oneapi_clock_work_group);
test_if_supported<syclex::clock_scope::device>(
q, sycl::aspect::ext_oneapi_clock_device);
return 0;
}
43 changes: 43 additions & 0 deletions sycl/test-e2e/Clock/test-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
:sectnums:
:xrefstyle: short

# Test plan for sycl_ext_oneapi_clock

This is a test plan for the APIs described in
https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/proposed/sycl_ext_oneapi_clock.asciidoc[sycl_ext_oneapi_clock].

## Testing scope

### Device coverage

All of the tests described below are performed only on the default device that
is selected on the CTS command line.

## Tests

### New aspects

The extension introduces the following aspects:

* `ext_oneapi_clock_sub_group`,
* `ext_oneapi_clock_work_group`,
* `ext_oneapi_clock_device`

Check if these aspects are defined by the implementation.

### New function

The extension introduces the following function:

* `uint64_t clock<clock_scope scope>()`

Check if the function:

* can be successfully called from a kernel,
* accepts all possible values of `clock_scope` enum,
* returns different values when called multiple times and these values are
increasing (keep in mind an overflow).

When possible, check if the implementation throws an exception with the
`errc::kernel_not_supported` error code when the kernel is submitted to a queue,
but a device doesn't have a corresponding aspect.
49 changes: 0 additions & 49 deletions sycl/test-e2e/Experimental/clock.cpp

This file was deleted.

Loading