3
3
4
4
void updateStats (sycl::queue myQueue, sycl::buffer<Actor> actorBuf,
5
5
std::vector<float > &averageForces,
6
- std::vector<int > &destinationTimes,
7
- std::chrono::high_resolution_clock::time_point startPoint) {
6
+ std::vector<std::array< int , 2 > > &destinationTimes,
7
+ std::chrono::high_resolution_clock::time_point startPoint, int timestep ) {
8
8
try {
9
9
float forceSum = 0 ;
10
10
auto forceSumBuf = sycl::buffer<float >(&forceSum, 1 );
@@ -58,7 +58,8 @@ void updateStats(sycl::queue myQueue, sycl::buffer<Actor> actorBuf,
58
58
// Find actors which have reached their destination and record how long
59
59
// it took them
60
60
auto destinationTimesBuf =
61
- sycl::buffer<int >(destinationTimes.data (), destinationTimes.size ());
61
+ sycl::buffer<std::array<int , 2 >>(destinationTimes.data (), destinationTimes.size ());
62
+ auto timestepBuf = sycl::buffer<int >(×tep, 1 );
62
63
63
64
myQueue
64
65
.submit ([&](sycl::handler &cgh) {
@@ -67,6 +68,7 @@ void updateStats(sycl::queue myQueue, sycl::buffer<Actor> actorBuf,
67
68
auto destinationTimesAcc =
68
69
destinationTimesBuf
69
70
.get_access <sycl::access::mode::read_write>(cgh);
71
+ auto timestepAcc = timestepBuf.get_access <sycl::access::mode::read>(cgh);
70
72
71
73
auto end = std::chrono::high_resolution_clock::now ();
72
74
auto duration =
@@ -77,8 +79,8 @@ void updateStats(sycl::queue myQueue, sycl::buffer<Actor> actorBuf,
77
79
cgh.parallel_for (sycl::range<1 >{destinationTimesAcc.size ()},
78
80
[=](sycl::id<1 > index) {
79
81
if (actorAcc[index].getAtDestination () &&
80
- destinationTimesAcc[index] == 0 ) {
81
- destinationTimesAcc[index] = duration;
82
+ destinationTimesAcc[index][ 0 ] == 0 ) {
83
+ destinationTimesAcc[index] = { int ( duration), timestepAcc[ 0 ]} ;
82
84
}
83
85
});
84
86
});
@@ -91,7 +93,7 @@ void updateStats(sycl::queue myQueue, sycl::buffer<Actor> actorBuf,
91
93
}
92
94
93
95
void finalizeStats (sycl::queue myQueue, std::vector<float > averageForces,
94
- std::vector<int > destinationTimes,
96
+ std::vector<std::array< int , 2 > > destinationTimes,
95
97
std::vector<int > kernelDurations, int numActors,
96
98
int totalExecutionTime) {
97
99
try {
@@ -143,17 +145,22 @@ void finalizeStats(sycl::queue myQueue, std::vector<float> averageForces,
143
145
<< std::endl;
144
146
outputFile << std::endl << std::endl;
145
147
146
- outputFile << " Actor ID | Time to Reach Destination (ms)"
148
+ outputFile << " Actor ID | Time to Reach Destination (ms) | Timestep "
147
149
<< std::endl;
148
- outputFile << " -----------------------------------------"
150
+ outputFile << " ---------------------------------------------------- "
149
151
<< std::endl;
150
152
for (int x = 0 ; x < destinationTimes.size (); x++) {
151
153
outputFile << std::setprecision (2 ) << std::fixed;
152
154
outputFile << std::setw (8 ) << x << " |" ;
153
- if (destinationTimes[x] == 0 ) {
154
- outputFile << std::setw (30 ) << " NA" ;
155
+ if (destinationTimes[x][ 0 ] == 0 ) {
156
+ outputFile << std::setw (31 ) << " NA" << " | " ;
155
157
} else {
156
- outputFile << std::setw (30 ) << destinationTimes[x];
158
+ outputFile << std::setw (31 ) << destinationTimes[x][0 ] << " |" ;
159
+ }
160
+ if (destinationTimes[x][1 ] == 0 ) {
161
+ outputFile << std::setw (8 ) << " NA" ;
162
+ } else {
163
+ outputFile << std::setw (8 ) << destinationTimes[x][1 ];
157
164
}
158
165
outputFile << std::endl;
159
166
}
@@ -193,10 +200,10 @@ void finalizeStats(sycl::queue myQueue, std::vector<float> averageForces,
193
200
std::ios::out);
194
201
for (int x = 0 ; x < destinationTimes.size (); x++) {
195
202
outputDestinationTimesCSV << x << " , " ;
196
- if (destinationTimes[x] == 0 ) {
203
+ if (destinationTimes[x][ 0 ] == 0 ) {
197
204
outputDestinationTimesCSV << " -1" << std::endl;
198
205
} else {
199
- outputDestinationTimesCSV << destinationTimes[x]
206
+ outputDestinationTimesCSV << destinationTimes[x][ 0 ]
200
207
<< std::endl;
201
208
}
202
209
}
0 commit comments