Skip to content

Commit 9312dc8

Browse files
committed
Replace nested data struct with sycl::float4 for checkpoints
1 parent d7fa29b commit 9312dc8

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

external/Actor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ SYCL_EXTERNAL void Actor::setSeed(uint newSeed) { seed = newSeed; }
8686
SYCL_EXTERNAL void Actor::setForce(float newForce) { force = newForce; }
8787

8888
SYCL_EXTERNAL void
89-
Actor::checkAtDestination(std::array<sycl::float2, 2> destination,
89+
Actor::checkAtDestination(sycl::float4 destination,
9090
int pathSize) {
9191
// Destinations are defined as rectangular regions
92-
if (pos[0] >= destination[0][0] && pos[0] <= destination[1][0] &&
93-
pos[1] >= destination[0][1] && pos[1] <= destination[1][1]) {
92+
if (pos[0] >= destination[0] && pos[0] <= destination[2] &&
93+
pos[1] >= destination[1] && pos[1] <= destination[3]) {
9494
if (destinationIndex >= PATHALLOCATIONSIZE - 1 ||
9595
destinationIndex >= pathSize - 1) {
9696
this->setAtDestination(true);

external/Actor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Actor {
7777
SYCL_EXTERNAL void setForce(float newForce);
7878

7979
SYCL_EXTERNAL void
80-
checkAtDestination(std::array<sycl::float2, 2> destination, int pathSize);
80+
checkAtDestination(sycl::float4 destination, int pathSize);
8181
};
8282

8383
#endif

external/DifferentialEq.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ SYCL_EXTERNAL void differentialEq(
3939
// Calculate personal impulse
4040
float mi = currentActor->getMass();
4141
float v0i = currentActor->getDesiredSpeed();
42-
std::array<sycl::float2, 2> destination =
42+
sycl::float4 destination =
4343
paths[currentActor->getPathId()]
4444
.getCheckpoints()[currentActor->getDestinationIndex()];
4545

4646
// Find direction vector to nearest point in destination region
4747
std::pair<float, sycl::float2> minRegionDistance;
4848
std::array<sycl::float2, 4> destinationRect = {
49-
destination[0],
50-
{destination[1][0], destination[0][1]},
51-
destination[1],
52-
{destination[0][0], destination[1][1]}};
49+
sycl::float2{destination[0], destination[1]},
50+
sycl::float2{destination[2], destination[1]},
51+
sycl::float2{destination[2], destination[3]},
52+
sycl::float2{destination[0], destination[3]}};
5353
for (int x = 0; x < 4; x++) {
5454
int endIndex = x == 3 ? 0 : x + 1;
5555
auto dniw =

external/ParseInputFile.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,18 @@ 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<std::array<sycl::float2, 2>, PATHALLOCATIONSIZE> checkpoints;
123+
std::array<sycl::float4, PATHALLOCATIONSIZE> checkpoints;
124124
if (jsonCheckpoints.Size() > PATHALLOCATIONSIZE) {
125125
throw JSONException(
126126
"Path Size exceeds amount allocated in memory\nEither reduce "
127127
"path size or increase PATHALLOCATIONSIZE in 'Path.hpp'");
128128
}
129129
for (int i = 0; i < jsonCheckpoints.Size(); i++) {
130-
std::array<sycl::float2, 2> region;
131-
region[0] = sycl::float2({jsonCheckpoints[i][0][0].GetFloat(),
132-
jsonCheckpoints[i][0][1].GetFloat()});
133-
region[1] = sycl::float2({jsonCheckpoints[i][1][0].GetFloat(),
134-
jsonCheckpoints[i][1][1].GetFloat()});
130+
sycl::float4 region;
131+
region = sycl::float4({jsonCheckpoints[i][0][0].GetFloat(),
132+
jsonCheckpoints[i][0][1].GetFloat(),
133+
jsonCheckpoints[i][1][0].GetFloat(),
134+
jsonCheckpoints[i][1][1].GetFloat()});
135135
checkpoints[i] = region;
136136
}
137137
int pathSize = jsonCheckpoints.Size();

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<std::array<sycl::float2, 2>, PATHALLOCATIONSIZE> pCheckpoints,
30+
std::array<sycl::float4, PATHALLOCATIONSIZE> 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<std::array<sycl::float2, 2>, PATHALLOCATIONSIZE>
36+
SYCL_EXTERNAL std::array<sycl::float4, PATHALLOCATIONSIZE>
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<std::array<sycl::float2, 2>, PATHALLOCATIONSIZE>
46+
std::array<sycl::float4, PATHALLOCATIONSIZE>
4747
newCheckpoints) {
4848
checkpoints = newCheckpoints;
4949
}

external/Path.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,24 @@ const int PATHALLOCATIONSIZE = 10;
3737

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

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

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

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

0 commit comments

Comments
 (0)