|
| 1 | +/******************************************************************************* |
| 2 | +// |
| 3 | +// SYCL 2020 Conformance Test Suite |
| 4 | +// |
| 5 | +// Copyright (c) 2025 The Khronos Group Inc. |
| 6 | +// |
| 7 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +// you may not use this file except in compliance with the License. |
| 9 | +// You may obtain a copy of the License at |
| 10 | +// |
| 11 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +// |
| 13 | +// Unless required by applicable law or agreed to in writing, software |
| 14 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +// See the License for the specific language governing permissions and |
| 17 | +// limitations under the License. |
| 18 | +// |
| 19 | +*******************************************************************************/ |
| 20 | + |
| 21 | +#include "../../common/common.h" |
| 22 | +#include <future> |
| 23 | + |
| 24 | +namespace queue_flush::tests { |
| 25 | + |
| 26 | +TEST_CASE( |
| 27 | + "the queue flush extension defines the " |
| 28 | + "SYCL_KHR_QUEUE_FLUSH macro", |
| 29 | + "[khr_queue_flush]") { |
| 30 | +#ifndef SYCL_KHR_QUEUE_FLUSH |
| 31 | + static_assert(false, "SYCL_KHR_QUEUE_FLUSH is not defined"); |
| 32 | +#endif |
| 33 | +} |
| 34 | + |
| 35 | +TEST_CASE("Flush and spin lock event", "[khr_queue_flush]") { |
| 36 | + sycl::queue q; |
| 37 | + auto e = q.single_task([] {}); |
| 38 | + q.khr_flush(); |
| 39 | + while (e.get_info<sycl::info::event::command_execution_status>() != |
| 40 | + sycl::info::event_command_status::complete) { |
| 41 | + }; |
| 42 | +} |
| 43 | + |
| 44 | +TEST_CASE("Flush and host task", "[khr_queue_flush]") { |
| 45 | + sycl::queue q; |
| 46 | + std::promise<void> promise; |
| 47 | + |
| 48 | + q.submit([&](sycl::handler& cgh) { |
| 49 | + cgh.host_task([&] { promise.get_future().wait(); }); |
| 50 | + }); |
| 51 | + q.khr_flush(); |
| 52 | + promise.set_value(); |
| 53 | + q.wait(); |
| 54 | +} |
| 55 | + |
| 56 | +} // namespace queue_flush::tests |
0 commit comments