Queue class helper functions

Overview

// global functions

DPCTL_API __dpctl_give DPCTLSyclQueueRef
DPCTLQueueMgr_GetCurrentQueue(void);

DPCTL_API size_t
DPCTLQueueMgr_GetQueueStackSize(void);

DPCTL_API bool
DPCTLQueueMgr_GlobalQueueIsCurrent(void);

DPCTL_API bool
DPCTLQueueMgr_IsCurrentQueue(__dpctl_keep const DPCTLSyclQueueRef QRef);

DPCTL_API void
DPCTLQueueMgr_PopQueue(void);

DPCTL_API void
DPCTLQueueMgr_PushQueue(__dpctl_keep const DPCTLSyclQueueRef QRef);

DPCTL_API void
DPCTLQueueMgr_SetGlobalQueue(__dpctl_keep const DPCTLSyclQueueRef QRef);

Detailed Documentation

Global Functions

DPCTL_API __dpctl_give DPCTLSyclQueueRef
DPCTLQueueMgr_GetCurrentQueue(void)

Get the current sycl::queue for the thread of execution.

Dpctl lets an application access a “current queue” as soon as the application loads dpctl. The initial current queue also termed the global queue is a queue created using SYCL’s default_selector. The current queue is set per thread and can be changed for a specific execution scope using the PushQueue and PopQueue functions in this module. The global queue can also be changed by using SetGlobalQueue.

The DPCTLQueueMgr_GetCurrentQueue function returns the current queue in the current scope from where the function was called.

Returns:

An opaque DPCTLSyclQueueRef pointer wrapping a sycl::queue*.

DPCTL_API size_t
DPCTLQueueMgr_GetQueueStackSize(void)

A helper function meant for unit testing. Returns the current number of queues pushed to the queue manager’s internal stack of sycl::queue objects.

Returns:

The current size of the queue manager’s stack of queues.

DPCTL_API bool
DPCTLQueueMgr_GlobalQueueIsCurrent(void)

Returns true if the global queue set for the queue manager is also the current queue.

The default current queue provided by the queue manager is termed as the global queue. If DPCTLQueueMgr_PushQueue is used to make another queue the current queue, then the global queue no longer remains the current queue till all pushed queues are popped using DPCTLQueueMgr_PopQueue. The DPCTLQueueMgr_GlobalQueueIsCurrent checks if the global queue is also the current queue, i.e., no queues have been pushed and are yet to be popped.

Returns:

True if the global queue is the current queue, else false.

DPCTL_API bool
DPCTLQueueMgr_IsCurrentQueue(__dpctl_keep const DPCTLSyclQueueRef QRef)

Check if the queue argument is also the current queue.

Parameters:

QRef

An opaque pointer to a sycl::queue.

Returns:

True if QRef argument is the the current queue, else False.

DPCTL_API void
DPCTLQueueMgr_PopQueue(void)

Pops the top of stack sycl::queue object from the queue manager’s * internal stack of queues and makes the next queue in the stack the current queue.

DPCTLPopSyclQueue removes the top of stack queue and changes the current queue. If no queue was previously pushed, then a DPCTLQueueMgr_PopQueue call is a no-op.

DPCTL_API void
DPCTLQueueMgr_PushQueue(__dpctl_keep const DPCTLSyclQueueRef QRef)

Pushes the passed in sycl::queue object to the queue manager’s internal stack of queues and makes the queue the current queue.

The queue manager maintains a thread-local stack of sycl::queue objects. The DPCTLQueueMgr_PushQueue() function pushes to the stack and sets the passed in DPCTLSyclQueueRef object as the current queue. The current queue is the queue returned by the DPCTLQueueMgr_GetCurrentQueue() function.

Parameters:

QRef

An opaque reference to a sycl::queue.

DPCTL_API void
DPCTLQueueMgr_SetGlobalQueue(__dpctl_keep const DPCTLSyclQueueRef QRef)

Resets the global queue using the passed in DPCTLSyclQueueRef the previous global queue is deleted.

Parameters:

QRef

An opaque reference to a sycl::device.