MicroGPU 1.0
Simple functional model of a GPU for educational purposes
Loading...
Searching...
No Matches
computeUnit.hh
Go to the documentation of this file.
1#ifndef COMPUTEUNIT_HH
2#define COMPUTEUNIT_HH
3
4#include<iostream>
5#include<string>
6#include<vector>
7#include<array>
8#include<bitset>
9#include<cassert>
10#include<algorithm>
11#include "../warp/warp.hh"
12
18
38 std::vector<Warp> warps;
39
40 // Each compute unit has its own ID
41 int smId;
42
43 // Current warp ID being executed
45
46 // Current cycle
48
49 // State of the compute unit
51
52 public:
54
55 // Setter methods
56 void setState(SMState newState);
57 void setCurrentWarpId(int warpId);
58 void setWarp(const Warp &warp);
59 void setSmId(int id) { smId = id; }
60
61 // Increment cycle count for the compute unit
63
65 void execute();
66
67 // Getter methods
68 int getCurrentWarpId();
69 SMState getState() const;
70 int getWarpCollectionSize() const;
71 int getCurrentCycle() const { return currentCycle; }
72 int getSmId() const { return smId; }
73
74 // Print method for debugging
75 void printId() const { std::cout << "(ComputeUnit) ComputeUnit ID: " << smId << std::endl; }
76
79
80};
81
82#endif // COMPUTEUNIT_HH
Represents a GPU compute unitThe ComputeUnit class encapsulates the state and behavior of a GPU compu...
Definition computeUnit.hh:37
void calculateNextWarpId()
Method to calculate the next warp ID to execute based on round-robin scheduling.
Definition computeUnit.cc:61
void incrementCycle()
Definition computeUnit.hh:62
SMState state
Definition computeUnit.hh:50
int getWarpCollectionSize() const
Definition computeUnit.cc:20
void setState(SMState newState)
Definition computeUnit.cc:3
void execute()
Execute the current warp and advance its pipeline stage. Called once per cycle.
Definition computeUnit.cc:24
void setCurrentWarpId(int warpId)
Definition computeUnit.cc:7
void printId() const
Definition computeUnit.hh:75
int getCurrentWarpId()
Definition computeUnit.cc:13
SMState getState() const
Definition computeUnit.cc:16
void setSmId(int id)
Definition computeUnit.hh:59
std::vector< Warp > warps
Definition computeUnit.hh:38
int getCurrentCycle() const
Definition computeUnit.hh:71
void setWarp(const Warp &warp)
Definition computeUnit.cc:10
int smId
Definition computeUnit.hh:41
int getSmId() const
Definition computeUnit.hh:72
ComputeUnit()
Definition computeUnit.hh:53
size_t currentWarpId
Definition computeUnit.hh:44
int currentCycle
Definition computeUnit.hh:47
Represents a GPU warpThe Warp class encapsulates the state and behavior of a GPU warp,...
Definition warp.hh:77
SMState
Definition computeUnit.hh:13
@ ERROR
Definition computeUnit.hh:16
@ BUSY
Definition computeUnit.hh:15
@ IDLE
Definition computeUnit.hh:14