Skip to content

Commit

Permalink
[SYCL][Graph] Implement queue state query
Browse files Browse the repository at this point in the history
Implements query for queue state from #162

Adds symbol for queue query entry-point and update test to use test-e2e.

Closes #93
  • Loading branch information
EwanC authored May 16, 2023
1 parent cdfd8b6 commit 516eb33
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions sycl/include/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
/// \return SYCL device this queue was constructed with.
device get_device() const;

/// \return State the queue is currently in.
ext::oneapi::experimental::queue_state ext_oneapi_get_state() const;

/// \return true if this queue is a SYCL host queue.
__SYCL2020_DEPRECATED(
"is_host() is deprecated as the host device is no longer supported.")
Expand Down
6 changes: 6 additions & 0 deletions sycl/source/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ context queue::get_context() const { return impl->get_context(); }

device queue::get_device() const { return impl->get_device(); }

ext::oneapi::experimental::queue_state queue::ext_oneapi_get_state() const {
return impl->getCommandGraph()
? ext::oneapi::experimental::queue_state::recording
: ext::oneapi::experimental::queue_state::executing;
}

bool queue::is_host() const {
bool IsHost = impl->is_host();
assert(!IsHost && "queue::is_host should not be called in implementation.");
Expand Down
9 changes: 3 additions & 6 deletions sycl/test-e2e/Graph/queue_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out

// Expected fail as this query isn't implemented yet
// XFAIL: *

// Tests the return values from queue graph functions which change the
// internal queue state.

Expand All @@ -13,16 +10,16 @@
int main() {
queue Queue;

exp_ext::queue_state State = Queue.get_info<info::queue::state>();
exp_ext::queue_state State = Queue.ext_oneapi_get_state();
assert(State == exp_ext::queue_state::executing);

exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()};
Graph.begin_recording(Queue);
State = Queue.get_info<info::queue::state>();
State = Queue.ext_oneapi_get_state();
assert(State == exp_ext::queue_state::recording);

Graph.end_recording();
State = Queue.get_info<info::queue::state>();
State = Queue.ext_oneapi_get_state();
assert(State == exp_ext::queue_state::executing);

return 0;
Expand Down
1 change: 1 addition & 0 deletions sycl/test/abi/sycl_symbols_linux.dump
Original file line number Diff line number Diff line change
Expand Up @@ -4130,6 +4130,7 @@ _ZNK4sycl3_V15queue12has_propertyINS0_8property5queue16enable_profilingEEEbv
_ZNK4sycl3_V15queue12has_propertyINS0_8property5queue4cuda18use_default_streamEEEbv
_ZNK4sycl3_V15queue12has_propertyINS0_8property5queue8in_orderEEEbv
_ZNK4sycl3_V15queue16ext_oneapi_emptyEv
_ZNK4sycl3_V15queue20ext_oneapi_get_stateEv
_ZNK4sycl3_V15queue28ext_codeplay_supports_fusionEv
_ZNK4sycl3_V15queue3getEv
_ZNK4sycl3_V15queue7is_hostEv
Expand Down

0 comments on commit 516eb33

Please sign in to comment.