@@ -75,48 +75,43 @@ extern "C" {
75
75
// /
76
76
struct SharedMemorySmartStackTy {
77
77
// / Initialize the stack. Must be called by all threads.
78
- static void init (bool IsSPMD);
78
+ void init (bool IsSPMD);
79
79
80
80
// / Allocate \p Bytes on the stack for the encountering thread. Each thread
81
81
// / can call this function.
82
- static void *push (uint64_t Bytes);
82
+ void *push (uint64_t Bytes);
83
83
84
84
// / Deallocate the last allocation made by the encountering thread and pointed
85
85
// / to by \p Ptr from the stack. Each thread can call this function.
86
- static void pop (void *Ptr, uint64_t Bytes);
86
+ void pop (void *Ptr, uint64_t Bytes);
87
87
88
88
private:
89
89
// / Compute the size of the storage space reserved for a thread.
90
- static uint32_t computeThreadStorageTotal () {
90
+ uint32_t computeThreadStorageTotal () {
91
91
uint32_t NumLanesInBlock = mapping::getNumberOfThreadsInBlock ();
92
92
return utils::alignDown ((state::SharedScratchpadSize / NumLanesInBlock),
93
93
allocator::ALIGNMENT);
94
94
}
95
95
96
96
// / Return the top address of the warp data stack, that is the first address
97
97
// / this warp will allocate memory at next.
98
- static void *getThreadDataTop (uint32_t TId) {
99
- return ( void *) &Data[computeThreadStorageTotal () * TId + Usage[TId]];
98
+ void *getThreadDataTop (uint32_t TId) {
99
+ return &Data[computeThreadStorageTotal () * TId + Usage[TId]];
100
100
}
101
101
102
102
// / The actual storage, shared among all warps.
103
-
104
- [[gnu::aligned(allocator::ALIGNMENT)]] [[clang::loader_uninitialized]]
105
- static Local<unsigned char > Data[state::SharedScratchpadSize];
106
- [[gnu::aligned(allocator::ALIGNMENT)]] [[clang::loader_uninitialized]]
107
- static Local<unsigned char > Usage[mapping::MaxThreadsPerTeam];
103
+ [[gnu::aligned(
104
+ allocator::ALIGNMENT)]] unsigned char Data[state::SharedScratchpadSize];
105
+ [[gnu::aligned(
106
+ allocator::ALIGNMENT)]] unsigned char Usage[mapping::MaxThreadsPerTeam];
108
107
};
109
108
110
- Local<unsigned char >
111
- SharedMemorySmartStackTy::Data[state::SharedScratchpadSize];
112
- Local<unsigned char >
113
- SharedMemorySmartStackTy::Usage[mapping::MaxThreadsPerTeam];
114
-
115
109
static_assert (state::SharedScratchpadSize / mapping::MaxThreadsPerTeam <= 256 ,
116
110
" Shared scratchpad of this size not supported yet." );
117
111
118
- // / The single shared memory scratchpad.
119
- using SharedMemorySmartStack = SharedMemorySmartStackTy;
112
+ // / The allocation of a single shared memory scratchpad.
113
+ [[clang::loader_uninitialized]] static Local<SharedMemorySmartStackTy>
114
+ SharedMemorySmartStack;
120
115
121
116
void SharedMemorySmartStackTy::init (bool IsSPMD) {
122
117
Usage[mapping::getThreadIdInBlock ()] = 0 ;
@@ -168,11 +163,11 @@ void SharedMemorySmartStackTy::pop(void *Ptr, uint64_t Bytes) {
168
163
void *memory::getDynamicBuffer () { return DynamicSharedBuffer; }
169
164
170
165
void *memory::allocShared (uint64_t Bytes, const char *Reason) {
171
- return SharedMemorySmartStack:: push (Bytes);
166
+ return SharedMemorySmartStack. push (Bytes);
172
167
}
173
168
174
169
void memory::freeShared (void *Ptr, uint64_t Bytes, const char *Reason) {
175
- SharedMemorySmartStack:: pop (Ptr, Bytes);
170
+ SharedMemorySmartStack. pop (Ptr, Bytes);
176
171
}
177
172
178
173
void *memory::allocGlobal (uint64_t Bytes, const char *Reason) {
@@ -252,7 +247,7 @@ int returnValIfLevelIsActive(int Level, int Val, int DefaultVal,
252
247
253
248
void state::init (bool IsSPMD, KernelEnvironmentTy &KernelEnvironment,
254
249
KernelLaunchEnvironmentTy &KernelLaunchEnvironment) {
255
- SharedMemorySmartStack:: init (IsSPMD);
250
+ SharedMemorySmartStack. init (IsSPMD);
256
251
if (mapping::isInitialThreadInLevel0 (IsSPMD)) {
257
252
TeamState.init (IsSPMD);
258
253
ThreadStates = nullptr ;
0 commit comments