MicroGPU 1.0
Simple functional model of a GPU for educational purposes
Loading...
Searching...
No Matches
thread.hh
Go to the documentation of this file.
1#ifndef SRC_THREAD_THREAD_HH_
2#define SRC_THREAD_THREAD_HH_
3
4#include <iostream>
5#include <string>
6#include <vector>
7#include <cassert>
8#include <array>
9
11#define THREAD_REGISTER_COUNT 64
12
13using RegisterFile = std::array<int, THREAD_REGISTER_COUNT>;
14
16 ACTIVE, // Thread is active and can execute instructions
17 INACTIVE // Thread is inactive and should not execute instructions
18};
19
32class Thread {
33
34 int id;
37
38public:
39
40 Thread();
41 Thread(int threadId, ThreadState threadState);
42
43 // Getter methods
44 int getId() const;
45 ThreadState getState() const;
46 int getRegisterValue(int index) const;
47
48 // Setter methods
49 void setId(int threadId);
50 void setState(ThreadState threadState);
51 void setRegisters(const RegisterFile& regs);
52 void setRegisterValue(int index, int value);
53};
54
55
56#endif // SRC_THREAD_THREAD_HH_
Represents a GPU threadThe Thread class encapsulates the state and behavior of a GPU thread,...
Definition thread.hh:32
ThreadState getState() const
Definition thread.cc:19
int getRegisterValue(int index) const
Definition thread.cc:24
int getId() const
Definition thread.cc:15
RegisterFile registers
Definition thread.hh:36
void setId(int threadId)
Definition thread.cc:30
void setState(ThreadState threadState)
Definition thread.cc:34
Thread()
Definition thread.cc:3
ThreadState state
Definition thread.hh:35
void setRegisters(const RegisterFile &regs)
Definition thread.cc:39
int id
Definition thread.hh:34
void setRegisterValue(int index, int value)
Definition thread.cc:43
std::array< int, THREAD_REGISTER_COUNT > RegisterFile
Definition thread.hh:13
ThreadState
Definition thread.hh:15
@ ACTIVE
Definition thread.hh:16
@ INACTIVE
Definition thread.hh:17