Skip to content

Commit 3d86bcb

Browse files
committed
Naming conventions
1 parent 9312dc8 commit 3d86bcb

File tree

6 files changed

+54
-56
lines changed

6 files changed

+54
-56
lines changed

external/Actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Actor::checkAtDestination(sycl::float4 destination,
9191
// Destinations are defined as rectangular regions
9292
if (pos[0] >= destination[0] && pos[0] <= destination[2] &&
9393
pos[1] >= destination[1] && pos[1] <= destination[3]) {
94-
if (destinationIndex >= PATHALLOCATIONSIZE - 1 ||
94+
if (destinationIndex >= PATH_ALLOCATION_SIZE - 1 ||
9595
destinationIndex >= pathSize - 1) {
9696
this->setAtDestination(true);
9797
} else {

external/ParseInputFile.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ void validateParameters(rapidjson::Document &jsonDoc) {
7676
}
7777

7878
void parseInputFile(std::string filename, std::vector<Actor> &actors,
79-
Room &room, std::vector<Path> &paths, int &WIDTH,
80-
int &HEIGHT, int &SCALE, int &DELAY,
81-
std::array<int, 3> &BGCOLOR, std::array<int, 3> &WALLCOLOR,
82-
bool &HEATMAPENABLED) {
79+
Room &room, std::vector<Path> &paths, int &width,
80+
int &height, int &scale, int &delay,
81+
std::array<int, 3> &bgColor, std::array<int, 3> &wallColor,
82+
bool &heatmapEnabled) {
8383
std::ifstream jsonFile(filename);
8484
if (!jsonFile.is_open()) {
8585
throw JSONException("Error opening file " + filename);
@@ -95,16 +95,16 @@ void parseInputFile(std::string filename, std::vector<Actor> &actors,
9595

9696
// Config
9797
auto &config = jsonDoc["config"];
98-
WIDTH = config["width"].GetInt();
99-
HEIGHT = config["height"].GetInt();
100-
SCALE = config["scale"].GetInt();
101-
DELAY = config["delay"].GetInt();
102-
WALLCOLOR = {config["wallColor"][0].GetInt(),
98+
width = config["width"].GetInt();
99+
height = config["height"].GetInt();
100+
scale = config["scale"].GetInt();
101+
delay = config["delay"].GetInt();
102+
wallColor = {config["wallColor"][0].GetInt(),
103103
config["wallColor"][1].GetInt(),
104104
config["wallColor"][2].GetInt()};
105-
BGCOLOR = {config["bgColor"][0].GetInt(), config["bgColor"][1].GetInt(),
105+
bgColor = {config["bgColor"][0].GetInt(), config["bgColor"][1].GetInt(),
106106
config["bgColor"][2].GetInt()};
107-
HEATMAPENABLED = config["heatmapEnabled"].GetBool();
107+
heatmapEnabled = config["heatmapEnabled"].GetBool();
108108

109109
// Room
110110
auto jsonWalls = jsonDoc["room"]["walls"].GetArray();
@@ -120,8 +120,8 @@ void parseInputFile(std::string filename, std::vector<Actor> &actors,
120120
for (auto &p : jsonPaths) {
121121
int id = p["id"].GetInt();
122122
auto jsonCheckpoints = p["checkpoints"].GetArray();
123-
std::array<sycl::float4, PATHALLOCATIONSIZE> checkpoints;
124-
if (jsonCheckpoints.Size() > PATHALLOCATIONSIZE) {
123+
std::array<sycl::float4, PATH_ALLOCATION_SIZE> checkpoints;
124+
if (jsonCheckpoints.Size() > PATH_ALLOCATION_SIZE) {
125125
throw JSONException(
126126
"Path Size exceeds amount allocated in memory\nEither reduce "
127127
"path size or increase PATHALLOCATIONSIZE in 'Path.hpp'");

external/ParseInputFile.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ class JSONException : public std::runtime_error {
4747
void validateParameters(rapidjson::Document &jsonDoc);
4848

4949
void parseInputFile(std::string filename, std::vector<Actor> &actors,
50-
Room &room, std::vector<Path> &paths, int &WIDTH,
51-
int &HEIGHT, int &SCALE, int &DELAY,
52-
std::array<int, 3> &BGCOLOR, std::array<int, 3> &WALLCOLOR,
53-
bool &HEATMAPENABLED);
50+
Room &room, std::vector<Path> &paths, int &width,
51+
int &height, int &scale, int &delay,
52+
std::array<int, 3> &bgColor, std::array<int, 3> &wallColor,
53+
bool &heatmapEnabled);
5454

5555
#endif

external/Path.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727

2828
Path::Path(
2929
int pId,
30-
std::array<sycl::float4, PATHALLOCATIONSIZE> pCheckpoints,
30+
std::array<sycl::float4, PATH_ALLOCATION_SIZE> pCheckpoints,
3131
int pPathSize)
3232
: id(pId), checkpoints(pCheckpoints), pathSize(pPathSize) {}
3333

3434
SYCL_EXTERNAL int Path::getId() const { return id; }
3535

36-
SYCL_EXTERNAL std::array<sycl::float4, PATHALLOCATIONSIZE>
36+
SYCL_EXTERNAL std::array<sycl::float4, PATH_ALLOCATION_SIZE>
3737
Path::getCheckpoints() const {
3838
return checkpoints;
3939
}
@@ -43,7 +43,7 @@ SYCL_EXTERNAL int Path::getPathSize() const { return pathSize; }
4343
void Path::setId(int newId) { id = newId; }
4444

4545
void Path::setCheckpoints(
46-
std::array<sycl::float4, PATHALLOCATIONSIZE>
46+
std::array<sycl::float4, PATH_ALLOCATION_SIZE>
4747
newCheckpoints) {
4848
checkpoints = newCheckpoints;
4949
}

external/Path.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,28 @@
3333
// Constant denoting the size of the array used to store paths
3434
// SYCL kernels can't use dynamic vectors, so paths are stored in
3535
// a fixed-size array, so the path size can't exceed this constant
36-
const int PATHALLOCATIONSIZE = 10;
36+
const int PATH_ALLOCATION_SIZE = 10;
3737

3838
class Path {
3939
private:
40-
std::array<sycl::float4, PATHALLOCATIONSIZE> checkpoints;
40+
std::array<sycl::float4, PATH_ALLOCATION_SIZE> checkpoints;
4141
int id;
4242
int pathSize;
4343

4444
public:
4545
Path(int pId,
46-
std::array<sycl::float4, PATHALLOCATIONSIZE>
46+
std::array<sycl::float4, PATH_ALLOCATION_SIZE>
4747
pCheckpoints,
4848
int pPathSize);
4949

5050
SYCL_EXTERNAL int getId() const;
51-
SYCL_EXTERNAL std::array<sycl::float4, PATHALLOCATIONSIZE>
51+
SYCL_EXTERNAL std::array<sycl::float4, PATH_ALLOCATION_SIZE>
5252
getCheckpoints() const;
5353
SYCL_EXTERNAL int getPathSize() const;
5454

5555
void setId(int newId);
5656
void
57-
setCheckpoints(std::array<sycl::float4, PATHALLOCATIONSIZE>
57+
setCheckpoints(std::array<sycl::float4, PATH_ALLOCATION_SIZE>
5858
newCheckpoints);
5959
};
6060

src/main.cpp

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,15 @@
4545
#include "Stats.hpp"
4646
#endif
4747

48-
uint GLOBALSEED;
49-
50-
void init(int &WIDTH, int &HEIGHT, int &SCALE, int &DELAY,
51-
std::array<int, 3> &BGCOLOR, std::array<int, 3> &WALLCOLOR,
52-
bool &HEATMAPENABLED, std::vector<Actor> &actors, Room &room,
48+
void init(int &width, int &height, int &scale, int &delay,
49+
std::array<int, 3> &bgColor, std::array<int, 3> &wallColor,
50+
bool &heatmapEnabled, std::vector<Actor> &actors, Room &room,
5351
std::vector<Path> &paths, int argc, char **argv) {
5452
// Read from input file path JSON
5553
if (argc == 2) {
5654
std::string inputPath = argv[1];
57-
parseInputFile(inputPath, actors, room, paths, WIDTH, HEIGHT, SCALE,
58-
DELAY, BGCOLOR, WALLCOLOR, HEATMAPENABLED);
55+
parseInputFile(inputPath, actors, room, paths, width, height, scale,
56+
delay, bgColor, wallColor, heatmapEnabled);
5957
} else if (argc < 2) {
6058
throw std::invalid_argument(
6159
"Input configuration file must be supplied");
@@ -73,12 +71,12 @@ void init(int &WIDTH, int &HEIGHT, int &SCALE, int &DELAY,
7371
}
7472

7573
#ifndef PROFILING_MODE
76-
void initSDL(int WIDTH, int HEIGHT, int SCALE, SDL_Window *&win,
74+
void initSDL(int width, int height, int scale, SDL_Window *&win,
7775
SDL_Renderer *&render) {
7876
SDL_Init(SDL_INIT_VIDEO);
7977
win = SDL_CreateWindow("SYCL Crowd Simulation", SDL_WINDOWPOS_UNDEFINED,
80-
SDL_WINDOWPOS_UNDEFINED, WIDTH * SCALE,
81-
HEIGHT * SCALE, SDL_WINDOW_SHOWN);
78+
SDL_WINDOWPOS_UNDEFINED, width * scale,
79+
height * scale, SDL_WINDOW_SHOWN);
8280
render = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED);
8381
}
8482

@@ -96,29 +94,29 @@ void drawCircle(SDL_Renderer *&render, SDL_Point center, int radius,
9694
}
9795
}
9896

99-
void draw(int SCALE, std::array<int, 3> BGCOLOR, std::array<int, 3> WALLCOLOR,
97+
void draw(int scale, std::array<int, 3> bgColor, std::array<int, 3> wallColor,
10098
SDL_Renderer *&render,
10199
sycl::host_accessor<Actor, 1, sycl::access::mode::read> actors,
102100
Room room) {
103-
SDL_SetRenderDrawColor(render, BGCOLOR[0], BGCOLOR[1], BGCOLOR[2], 255);
101+
SDL_SetRenderDrawColor(render, bgColor[0], bgColor[1], bgColor[2], 255);
104102
SDL_RenderClear(render);
105103

106104
for (int i = 0; i < actors.size(); i++) {
107105
auto actor = actors[i];
108-
SDL_Point pos = {int(actor.getPos()[0] * SCALE),
109-
int(actor.getPos()[1] * SCALE)};
106+
SDL_Point pos = {int(actor.getPos()[0] * scale),
107+
int(actor.getPos()[1] * scale)};
110108
SDL_Color actorColor = {Uint8(actor.getColor()[0]),
111109
Uint8(actor.getColor()[1]),
112110
Uint8(actor.getColor()[2]), 255};
113-
drawCircle(render, pos, actor.getRadius() * SCALE, actorColor);
111+
drawCircle(render, pos, actor.getRadius() * scale, actorColor);
114112
}
115113

116-
SDL_SetRenderDrawColor(render, WALLCOLOR[0], WALLCOLOR[1], WALLCOLOR[2],
114+
SDL_SetRenderDrawColor(render, wallColor[0], wallColor[1], wallColor[2],
117115
255);
118116
auto walls = room.getWalls();
119117
for (auto wall : walls) {
120-
SDL_RenderDrawLine(render, wall[0][0] * SCALE, wall[0][1] * SCALE,
121-
wall[1][0] * SCALE, wall[1][1] * SCALE);
118+
SDL_RenderDrawLine(render, wall[0][0] * scale, wall[0][1] * scale,
119+
wall[1][0] * scale, wall[1][1] * scale);
122120
}
123121

124122
SDL_RenderPresent(render);
@@ -183,14 +181,14 @@ void updateBBox(sycl::queue &myQueue, sycl::buffer<Actor> &actorBuf) {
183181
}
184182

185183
int main(int argc, char *argv[]) {
186-
int WIDTH; // metres
187-
int HEIGHT; // metres
188-
int SCALE;
189-
int DELAY;
190-
bool HEATMAPENABLED;
184+
int width; // metres
185+
int height; // metres
186+
int scale;
187+
int delay;
188+
bool heatmapEnabled;
191189

192-
std::array<int, 3> BGCOLOR;
193-
std::array<int, 3> WALLCOLOR;
190+
std::array<int, 3> bgColor;
191+
std::array<int, 3> wallColor;
194192

195193
std::vector<Actor> actors;
196194
Room room = Room({});
@@ -204,13 +202,13 @@ int main(int argc, char *argv[]) {
204202

205203
sycl::queue myQueue{sycl::gpu_selector(), asyncHandler};
206204

207-
init(WIDTH, HEIGHT, SCALE, DELAY, BGCOLOR, WALLCOLOR, HEATMAPENABLED,
205+
init(width, height, scale, delay, bgColor, wallColor, heatmapEnabled,
208206
actors, room, paths, argc, argv);
209207

210208
#ifndef PROFILING_MODE
211209
SDL_Window *win;
212210
SDL_Renderer *render;
213-
initSDL(WIDTH, HEIGHT, SCALE, win, render);
211+
initSDL(width, height, scale, win, render);
214212
#endif
215213

216214
// Buffer creation
@@ -221,7 +219,7 @@ int main(int argc, char *argv[]) {
221219
wallsBuf.set_final_data(nullptr);
222220
auto pathsBuf = sycl::buffer<Path>(paths.data(), paths.size());
223221
pathsBuf.set_final_data(nullptr);
224-
auto heatmapEnableBuf = sycl::buffer<bool>(&HEATMAPENABLED, 1);
222+
auto heatmapEnableBuf = sycl::buffer<bool>(&heatmapEnabled, 1);
225223

226224
int delayCounter = 0;
227225
int updateBBoxCounter = 0;
@@ -260,7 +258,7 @@ int main(int argc, char *argv[]) {
260258
#endif
261259

262260
if (!isPause) {
263-
if (delayCounter >= DELAY) {
261+
if (delayCounter >= delay) {
264262
delayCounter = 0;
265263

266264
#ifdef STATS
@@ -294,7 +292,7 @@ int main(int argc, char *argv[]) {
294292
actorHostAcc(actorBuf);
295293

296294
#ifndef PROFILING_MODE
297-
draw(SCALE, BGCOLOR, WALLCOLOR, render, actorHostAcc, room);
295+
draw(scale, bgColor, wallColor, render, actorHostAcc, room);
298296
#endif
299297

300298
updateBBoxCounter--;

0 commit comments

Comments
 (0)