MicroGPU 1.0
Simple functional model of a GPU for educational purposes
Loading...
Searching...
No Matches
warp.hh
Go to the documentation of this file.
1#ifndef SRC_WARP_WARP_HH_
2#define SRC_WARP_WARP_HH_
3
4#include<iostream>
5#include<string>
6#include<vector>
7#include<array>
8#include<bitset>
9#include "../thread/thread.hh"
10
11// Define the number of threads in a warp
12#define WARP_THREAD_COUNT 32
13
14// Type alias for the active mask of threads in a warp
15using ActiveMask = std::bitset<WARP_THREAD_COUNT>;
16
17
26
30 int dest;
31 int src1;
32 int src2;
33
34 Instruction(InstructionType t, int d, int s1, int s2)
35 : type(t), dest(d), src1(s1), src2(s2) {}
36 Instruction() : type(ADD), dest(0), src1(0), src2(0) {}
37
38};
39
40// Reconvergence point structure
42 int pc;
44
45 reconvergencePoint(int pc_, const ActiveMask& mask_)
46 : pc(pc_), mask(mask_) {}
48};
49
50// Warp state enumeration
56
65
66// Type alias for a group of threads in a warp
67using ThreadGroup = std::array<Thread, WARP_THREAD_COUNT>;
68
77class Warp {
78 int id;
79 int pc; // All threads in the warp share the same program counter
83 std::vector<reconvergencePoint> reconvergenceStack;
86
87 public:
88 Warp();
90
91 // Getter and Setter methods
92 int getId() const;
93 int getPc() const;
94 void setPc(int pc_);
95 void setCurrentInstruction(const Instruction& instr);
99 void setActiveMask(const ActiveMask& mask) { activeMask = mask; }
100 std :: string getPipelineStageString() const;
101 const ActiveMask& getActiveMask() const;
102 WarpState getState() const { return state; }
103
104};
105
106
107#endif // SRC_WARP_WARP_HH_
Represents a GPU warpThe Warp class encapsulates the state and behavior of a GPU warp,...
Definition warp.hh:77
int getId() const
Definition warp.cc:14
void setPc(int pc_)
Definition warp.cc:22
Warp()
Definition warp.cc:3
int id
Definition warp.hh:78
int pc
Definition warp.hh:79
ThreadGroup threads
Definition warp.hh:80
PipelineStage getPipelineStage() const
Definition warp.hh:97
void setActiveMask(const ActiveMask &mask)
Definition warp.hh:99
const ActiveMask & getActiveMask() const
Definition warp.cc:26
std::vector< reconvergencePoint > reconvergenceStack
Definition warp.hh:83
int getPc() const
Definition warp.cc:18
void setPipelineStage(PipelineStage stage)
Definition warp.hh:98
PipelineStage pipelineStage
Definition warp.hh:85
std::string getPipelineStageString() const
Definition warp.cc:38
ActiveMask activeMask
Definition warp.hh:81
void setCurrentInstruction(const Instruction &instr)
Definition warp.cc:30
Instruction currentInstruction
Definition warp.hh:82
Instruction getCurrentInstruction() const
Definition warp.cc:34
WarpState getState() const
Definition warp.hh:102
WarpState state
Definition warp.hh:84
Instruction structure.
Definition warp.hh:28
int dest
Definition warp.hh:30
int src2
Definition warp.hh:32
int src1
Definition warp.hh:31
InstructionType type
Definition warp.hh:29
Instruction()
Definition warp.hh:36
Instruction(InstructionType t, int d, int s1, int s2)
Definition warp.hh:34
Definition warp.hh:41
int pc
Definition warp.hh:42
reconvergencePoint()
Definition warp.hh:47
ActiveMask mask
Definition warp.hh:43
reconvergencePoint(int pc_, const ActiveMask &mask_)
Definition warp.hh:45
std::array< Thread, WARP_THREAD_COUNT > ThreadGroup
Definition warp.hh:67
InstructionType
Instruction types enumeration.
Definition warp.hh:19
@ SUB
Definition warp.hh:21
@ LOAD
Definition warp.hh:22
@ ADD
Definition warp.hh:20
@ BRANCH
Definition warp.hh:24
@ STORE
Definition warp.hh:23
PipelineStage
Definition warp.hh:57
@ STAGE_1
Definition warp.hh:60
@ STAGE_3
Definition warp.hh:62
@ DONE
Definition warp.hh:63
@ STAGE_2
Definition warp.hh:61
@ NOT_STARTED
Definition warp.hh:58
@ STAGE_0
Definition warp.hh:59
WarpState
Definition warp.hh:51
@ RUNNING
Definition warp.hh:53
@ READY
Definition warp.hh:52
@ STALLED
Definition warp.hh:54
std::bitset< WARP_THREAD_COUNT > ActiveMask
Definition warp.hh:15