1 //===--------- statequeue.h - NVPTX OpenMP GPU State Queue ------- CUDA -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file contains a queue to hand out OpenMP state objects to teams of
10 // one or more kernels.
13 // Thomas R.W. Scogland and Wu-chun Feng. 2015.
14 // Design and Evaluation of Scalable Concurrent Queues for Many-Core
15 // Architectures. International Conference on Performance Engineering.
17 //===----------------------------------------------------------------------===//
19 #ifndef __STATE_QUEUE_H
20 #define __STATE_QUEUE_H
24 #include "target_impl.h"
26 template <typename ElementType
, uint32_t SIZE
> class omptarget_nvptx_Queue
{
28 ElementType elements
[SIZE
];
29 volatile ElementType
*elementQueue
[SIZE
];
30 volatile uint32_t head
;
31 volatile uint32_t ids
[SIZE
];
32 volatile uint32_t tail
;
34 static const uint32_t MAX_ID
= (1u << 31) / SIZE
/ 2;
35 INLINE
uint32_t ENQUEUE_TICKET();
36 INLINE
uint32_t DEQUEUE_TICKET();
37 INLINE
static uint32_t ID(uint32_t ticket
);
38 INLINE
bool IsServing(uint32_t slot
, uint32_t id
);
39 INLINE
void PushElement(uint32_t slot
, ElementType
*element
);
40 INLINE ElementType
*PopElement(uint32_t slot
);
41 INLINE
void DoneServing(uint32_t slot
, uint32_t id
);
44 INLINE
omptarget_nvptx_Queue() {}
45 INLINE
void Enqueue(ElementType
*element
);
46 INLINE ElementType
*Dequeue();
49 #include "state-queuei.h"