66template <
typename TData>
class BlockOperator;
73template <
typename ExecSpace,
typename TData,
bool APPEND,
typename Enable>
79template <
typename TData>
87template <
typename TData>
134 template <
template <
typename>
typename TOperator>
135 static std::shared_ptr<TOperator<TData>>
Create(
136 const unsigned int block_idx,
139 const std::string &execStr)
141 std::string requestedKey = TOperator<TData>::name + execStr;
148 std::stringstream msg;
149 msg <<
"No such operator: " << requestedKey << std::endl;
154 return std::static_pointer_cast<TOperator<TData>>(
190 template <
typename ExecSpace,
typename TDataZ,
bool APPEND,
typename Enable>
220 template <
typename MemSpace>
222 const unsigned int streamID = 0)
224 if constexpr (std::is_same_v<MemSpace, NektarSpaces::HostSpace>)
229 else if constexpr (std::is_same_v<MemSpace, NektarSpaces::DeviceSpace>)
249 TData *hostptr =
nullptr;
252 memset(hostptr, 0,
sizeof(TData) * size);
262 memset(hostptr, 0,
sizeof(TData) * size);
277 const unsigned int streamID)
281 TData *deviceptr =
nullptr;
282 deviceMalloc(&deviceptr,
sizeof(TData) * size, streamID);
291 deviceMalloc(&deviceptr,
sizeof(TData) * size, streamID);
298 static inline std::unordered_map<unsigned int, TData *>
m_deviceWsp;
302 static inline std::unordered_map<unsigned int, TData *>
m_hostWsp;
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
bool ModuleExists(tKey idKey)
Checks if a particular module is available.
tBasePtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
void PrintAvailableClasses(std::ostream &pOut=std::cout)
Prints the available classes to stdout.
Common base class of the block-operator family interfaces: holds the block index, representative expa...
static std::shared_ptr< TOperator< TData > > Create(const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse, const std::string &execStr)
Create a concrete block-operator instance through the block-operator factory.
static std::unordered_map< unsigned int, TData * > m_deviceWsp
Device scratch buffer for each stream, keyed by stream ID.
static void SetDeviceWorkSpace(const size_t size, const unsigned int streamID)
Ensure the device scratch buffer for streamID exists and holds at least size elements,...
static std::unordered_map< unsigned int, size_t > m_hostWspSize
Element capacity of the buffer in m_hostWsp for each stream.
unsigned int m_block_idx
Index of the block within the expansion list's Collections.
static TData * GetStaticWorkSpace(const size_t size, const unsigned int streamID=0)
Return a per-stream scratch buffer in MemSpace, sized to hold at least size elements of TData,...
static std::unordered_map< unsigned int, TData * > m_hostWsp
Host scratch buffer for each stream, keyed by stream ID.
static void SetHostWorkSpace(const size_t size, const unsigned int streamID)
Ensure the host scratch buffer for streamID exists and holds at least size elements,...
BlockOperator(const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse)
Construct the interface part of a concrete block operator; called by the factory-registered creator f...
virtual ~BlockOperator()=default
LocalRegions::ExpansionSharedPtr m_exp
Representative expansion of the block (its first element).
LibUtilities::NekDataWarehouseSharedPtr m_dataWarehouse
Data warehouse shared with the other operators on the expansion list.
static std::unordered_map< unsigned int, size_t > m_deviceWspSize
Element capacity of the buffer in m_deviceWsp for each stream.
The advection along the homogeneous direction, w du/dz.
std::shared_ptr< NekDataWarehouse > NekDataWarehouseSharedPtr
std::shared_ptr< Expansion > ExpansionSharedPtr
BlockOperatorFactory< TData > & GetBlockOperatorFactory()
Return the process-wide singleton BlockOperatorFactory<TData>, constructing it on first use.
static constexpr size_t host_memory_alignment
void deviceFree(TData *src, const size_t size, const unsigned int streamID, const MemAllocType memAllocType=eHostPageable)
void hostFree(TData *src, const size_t alignment)
void deviceMalloc(TData **src, const size_t size, const unsigned int streamID, const MemAllocType memAllocType=eHostPageable)
void hostMalloc(TData **src, const size_t size, const size_t alignment)