Skip to content

Commit a270103

Browse files
committed
Compute activeActors as int
1 parent 0bd7e69 commit a270103

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

external/Stats.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ void updateStats(sycl::queue myQueue, sycl::buffer<Actor> actorBuf,
99
float forceSum = 0;
1010
auto forceSumBuf = sycl::buffer<float>(&forceSum, 1);
1111

12-
float activeActors = 0;
13-
auto activeActorsBuf = sycl::buffer<float>(&activeActors, 1);
12+
int activeActors = 0;
13+
auto activeActorsBuf = sycl::buffer<int>(&activeActors, 1);
1414

1515
// Calculate average force applied to actors this iteration
1616
myQueue
@@ -37,23 +37,23 @@ void updateStats(sycl::queue myQueue, sycl::buffer<Actor> actorBuf,
3737
actorBuf.get_access<sycl::access::mode::read>(cgh);
3838

3939
auto activeActorsReduction =
40-
sycl::reduction(activeActorsBuf, cgh, sycl::plus<float>());
40+
sycl::reduction(activeActorsBuf, cgh, sycl::plus<int>());
4141

4242
cgh.parallel_for(sycl::range<1>{actorAcc.size()},
4343
activeActorsReduction,
4444
[=](sycl::id<1> index, auto &sum) {
4545
if (!actorAcc[index].getAtDestination()) {
46-
sum += 1.0f;
46+
sum += 1;
4747
}
4848
});
4949
});
5050
myQueue.throw_asynchronous();
5151

5252
sycl::host_accessor<float, 1, sycl::access::mode::read> forceSumHostAcc(
5353
forceSumBuf);
54-
sycl::host_accessor<float, 1, sycl::access::mode::read>
54+
sycl::host_accessor<int, 1, sycl::access::mode::read>
5555
activeActorsHostAcc(activeActorsBuf);
56-
averageForces.push_back(forceSumHostAcc[0] / activeActorsHostAcc[0]);
56+
averageForces.push_back(forceSumHostAcc[0] / float(activeActorsHostAcc[0]));
5757

5858
// Find actors which have reached their destination and record how long
5959
// it took them

0 commit comments

Comments
 (0)