MicroGPU 1.0
Simple functional model of a GPU for educational purposes
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Warp Class Reference

Represents a GPU warpThe Warp class encapsulates the state and behavior of a GPU warp, including its ID, program counter, threads, active mask, and current instruction. A warp is a group of threads that execute instructions in lockstep. Each warp has 32 threads in this project. To be added: reconvergence stack to handle divergent control flow. More...

#include <warp.hh>

Collaboration diagram for Warp:
Collaboration graph

Public Member Functions

 Warp ()
 
 Warp (int warpId, const ThreadGroup &threadGroup, WarpState warpState=WarpState::READY, PipelineStage pipelineStage=PipelineStage::NOT_STARTED, bool isBranchDivergent=false)
 
int getId () const
 
int getPc () const
 
void setPc (int pc_)
 
void setCurrentInstruction (const Instruction &instr)
 
Instruction getCurrentInstruction () const
 
PipelineStage getPipelineStage () const
 
void setPipelineStage (PipelineStage stage)
 
void setActiveMask (const ActiveMask &mask)
 
std::string getPipelineStageString () const
 
const ActiveMaskgetActiveMask () const
 
WarpState getState () const
 
bool isDivergent () const
 
void setDivergent ()
 
void execute ()
 
std::string getInstructionTypeString (Instruction inst) const
 
void addReconvergencePoint (int pc, const ActiveMask &mask)
 Add a reconvergence point to the stack.
 
void peekReconvergencePoint () const
 Peek the top reconvergence point on the stack This method is used for debugging purposes to check the current reconvergence points for a warp.
 
void popReconvergencePoint ()
 Pop the top reconvergence point from the stack This method is called when a reconvergence point is reached during execution to restore the active mask and program counter for the warp.
 
size_t getReconvergenceStackSize () const
 
std::bitset< WARP_THREAD_COUNTgetActiveMaskFromReconvergenceStack () const
 Get the active mask from the top reconvergence point on the stack.
 

Private Attributes

int id
 
int pc
 
ThreadGroup threads
 
ActiveMask activeMask
 
Instruction currentInstruction
 
std::vector< reconvergencePointreconvergenceStack
 Reconvergence stack for handling divergent control flow.
 
WarpState state
 
PipelineStage pipelineStage
 
bool isBranchDivergent = false
 

Detailed Description

Represents a GPU warp

The Warp class encapsulates the state and behavior of a GPU warp, including its ID, program counter, threads, active mask, and current instruction. A warp is a group of threads that execute instructions in lockstep. Each warp has 32 threads in this project. To be added: reconvergence stack to handle divergent control flow.

Constructor & Destructor Documentation

◆ Warp() [1/2]

Warp::Warp ( )

◆ Warp() [2/2]

Warp::Warp ( int  warpId,
const ThreadGroup threadGroup,
WarpState  warpState = WarpState::READY,
PipelineStage  pipelineStage = PipelineStage::NOT_STARTED,
bool  isBranchDivergent = false 
)

Member Function Documentation

◆ addReconvergencePoint()

void Warp::addReconvergencePoint ( int  pc,
const ActiveMask mask 
)

Add a reconvergence point to the stack.

Parameters
pcThe program counter value at the reconvergence point
maskThe active mask at the reconvergence point This method is called when a divergent branch is encountered to save the reconvergence point information on the stack.

◆ execute()

void Warp::execute ( )
Here is the call graph for this function:

◆ getActiveMask()

const ActiveMask & Warp::getActiveMask ( ) const

◆ getActiveMaskFromReconvergenceStack()

std::bitset< WARP_THREAD_COUNT > Warp::getActiveMaskFromReconvergenceStack ( ) const

Get the active mask from the top reconvergence point on the stack.

Returns
ActiveMask The active mask from the top reconvergence point

◆ getCurrentInstruction()

Instruction Warp::getCurrentInstruction ( ) const

◆ getId()

int Warp::getId ( ) const

◆ getInstructionTypeString()

std::string Warp::getInstructionTypeString ( Instruction  inst) const

◆ getPc()

int Warp::getPc ( ) const

◆ getPipelineStage()

PipelineStage Warp::getPipelineStage ( ) const
inline

◆ getPipelineStageString()

std::string Warp::getPipelineStageString ( ) const

◆ getReconvergenceStackSize()

size_t Warp::getReconvergenceStackSize ( ) const

◆ getState()

WarpState Warp::getState ( ) const
inline

◆ isDivergent()

bool Warp::isDivergent ( ) const
inline

◆ peekReconvergencePoint()

void Warp::peekReconvergencePoint ( ) const

Peek the top reconvergence point on the stack This method is used for debugging purposes to check the current reconvergence points for a warp.

◆ popReconvergencePoint()

void Warp::popReconvergencePoint ( )

Pop the top reconvergence point from the stack This method is called when a reconvergence point is reached during execution to restore the active mask and program counter for the warp.

◆ setActiveMask()

void Warp::setActiveMask ( const ActiveMask mask)
inline

◆ setCurrentInstruction()

void Warp::setCurrentInstruction ( const Instruction instr)

◆ setDivergent()

void Warp::setDivergent ( )
inline

◆ setPc()

void Warp::setPc ( int  pc_)

◆ setPipelineStage()

void Warp::setPipelineStage ( PipelineStage  stage)
inline

Member Data Documentation

◆ activeMask

ActiveMask Warp::activeMask
private

◆ currentInstruction

Instruction Warp::currentInstruction
private

◆ id

int Warp::id
private

◆ isBranchDivergent

bool Warp::isBranchDivergent = false
private

◆ pc

int Warp::pc
private

◆ pipelineStage

PipelineStage Warp::pipelineStage
private

◆ reconvergenceStack

std::vector<reconvergencePoint> Warp::reconvergenceStack
private

Reconvergence stack for handling divergent control flow.

◆ state

WarpState Warp::state
private

◆ threads

ThreadGroup Warp::threads
private

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