MLIR 24.0.0git
mlir::acc::SharedMemoryBudget Class Reference

Tracks aligned byte consumption against a configurable shared memory cap. More...

#include "mlir/Dialect/OpenACC/OpenACCUtilsCG.h"

Public Member Functions

 SharedMemoryBudget (int64_t maxTotalBytes, int64_t initialBytesUsed=0)
bool tryAllocate (int64_t bytes, int64_t alignment=kDefaultAlignmentBytes)
 Reserve bytes, rounding the current offset up to alignment first.
int64_t bytesUsed () const
int64_t maxTotalBytes () const
void setMaxTotalBytes (int64_t maxTotalBytes)

Static Public Member Functions

static int64_t alignOffset (int64_t offset, int64_t alignment=kDefaultAlignmentBytes)
 Round offset up to the next multiple of alignment, which must be a power of two.

Static Public Attributes

static constexpr int64_t kDefaultAlignmentBytes = 16
 Default allocation alignment (bytes).

Detailed Description

Tracks aligned byte consumption against a configurable shared memory cap.

Definition at line 122 of file OpenACCUtilsCG.h.

Constructor & Destructor Documentation

◆ SharedMemoryBudget()

mlir::acc::SharedMemoryBudget::SharedMemoryBudget ( int64_t maxTotalBytes,
int64_t initialBytesUsed = 0 )
inline

Definition at line 127 of file OpenACCUtilsCG.h.

References maxTotalBytes().

Member Function Documentation

◆ alignOffset()

int64_t mlir::acc::SharedMemoryBudget::alignOffset ( int64_t offset,
int64_t alignment = kDefaultAlignmentBytes )
static

Round offset up to the next multiple of alignment, which must be a power of two.

Definition at line 226 of file OpenACCUtilsCG.cpp.

Referenced by mlir::acc::sumExistingSharedMemoryBytes(), and tryAllocate().

◆ bytesUsed()

int64_t mlir::acc::SharedMemoryBudget::bytesUsed ( ) const
inline

Definition at line 134 of file OpenACCUtilsCG.h.

◆ maxTotalBytes()

int64_t mlir::acc::SharedMemoryBudget::maxTotalBytes ( ) const
inline

Definition at line 135 of file OpenACCUtilsCG.h.

Referenced by setMaxTotalBytes(), and SharedMemoryBudget().

◆ setMaxTotalBytes()

void mlir::acc::SharedMemoryBudget::setMaxTotalBytes ( int64_t maxTotalBytes)
inline

Definition at line 136 of file OpenACCUtilsCG.h.

References maxTotalBytes().

◆ tryAllocate()

bool mlir::acc::SharedMemoryBudget::tryAllocate ( int64_t bytes,
int64_t alignment = kDefaultAlignmentBytes )

Reserve bytes, rounding the current offset up to alignment first.

Returns false without mutating state if the reservation would exceed the cap. alignment must be a power of two.

Definition at line 232 of file OpenACCUtilsCG.cpp.

References alignOffset().

Member Data Documentation

◆ kDefaultAlignmentBytes

int64_t mlir::acc::SharedMemoryBudget::kDefaultAlignmentBytes = 16
staticconstexpr

Default allocation alignment (bytes).

Definition at line 125 of file OpenACCUtilsCG.h.


The documentation for this class was generated from the following files: