-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the Stack class used in Parser to its own header so that it can be used by others. The Stack class has a fixed maximum size. This is useful for traversing a tree on GPU, because recursive function does not work well in device code.
- Loading branch information
1 parent
87de52e
commit 2db1344
Showing
5 changed files
with
27 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef AMREX_STACK_H_ | ||
#define AMREX_STACK_H_ | ||
|
||
namespace amrex { | ||
|
||
template <int T, int N> | ||
struct Stack | ||
{ | ||
T m_data[N]; | ||
int m_size = 0; | ||
constexpr void push (T v) { m_data[m_size++] = v; } | ||
constexpr void pop () { --m_size; } | ||
[[nodiscard]] constexpr T const& top () const { return m_data[m_size-1]; } | ||
[[nodiscard]] constexpr T & top () { return m_data[m_size-1]; } | ||
[[nodiscard]] constexpr T operator[] (int i) const { return m_data[i]; } | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters