@@ -75,48 +75,43 @@ extern "C" {
7575// /
7676struct SharedMemorySmartStackTy {
7777 // / Initialize the stack. Must be called by all threads.
78- static void init (bool IsSPMD);
78+ void init (bool IsSPMD);
7979
8080 // / Allocate \p Bytes on the stack for the encountering thread. Each thread
8181 // / can call this function.
82- static void *push (uint64_t Bytes);
82+ void *push (uint64_t Bytes);
8383
8484 // / Deallocate the last allocation made by the encountering thread and pointed
8585 // / 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);
8787
8888private:
8989 // / Compute the size of the storage space reserved for a thread.
90- static uint32_t computeThreadStorageTotal () {
90+ uint32_t computeThreadStorageTotal () {
9191 uint32_t NumLanesInBlock = mapping::getNumberOfThreadsInBlock ();
9292 return utils::alignDown ((state::SharedScratchpadSize / NumLanesInBlock),
9393 allocator::ALIGNMENT);
9494 }
9595
9696 // / Return the top address of the warp data stack, that is the first address
9797 // / 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]];
100100 }
101101
102102 // / 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];
108107};
109108
110- Local<unsigned char >
111- SharedMemorySmartStackTy::Data[state::SharedScratchpadSize];
112- Local<unsigned char >
113- SharedMemorySmartStackTy::Usage[mapping::MaxThreadsPerTeam];
114-
115109static_assert (state::SharedScratchpadSize / mapping::MaxThreadsPerTeam <= 256 ,
116110 " Shared scratchpad of this size not supported yet." );
117111
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;
120115
121116void SharedMemorySmartStackTy::init (bool IsSPMD) {
122117 Usage[mapping::getThreadIdInBlock ()] = 0 ;
@@ -168,11 +163,11 @@ void SharedMemorySmartStackTy::pop(void *Ptr, uint64_t Bytes) {
168163void *memory::getDynamicBuffer () { return DynamicSharedBuffer; }
169164
170165void *memory::allocShared (uint64_t Bytes, const char *Reason) {
171- return SharedMemorySmartStack:: push (Bytes);
166+ return SharedMemorySmartStack. push (Bytes);
172167}
173168
174169void memory::freeShared (void *Ptr, uint64_t Bytes, const char *Reason) {
175- SharedMemorySmartStack:: pop (Ptr, Bytes);
170+ SharedMemorySmartStack. pop (Ptr, Bytes);
176171}
177172
178173void *memory::allocGlobal (uint64_t Bytes, const char *Reason) {
@@ -252,7 +247,7 @@ int returnValIfLevelIsActive(int Level, int Val, int DefaultVal,
252247
253248void state::init (bool IsSPMD, KernelEnvironmentTy &KernelEnvironment,
254249 KernelLaunchEnvironmentTy &KernelLaunchEnvironment) {
255- SharedMemorySmartStack:: init (IsSPMD);
250+ SharedMemorySmartStack. init (IsSPMD);
256251 if (mapping::isInitialThreadInLevel0 (IsSPMD)) {
257252 TeamState.init (IsSPMD);
258253 ThreadStates = nullptr ;
0 commit comments