@@ -44,27 +44,16 @@ void updateStats(sycl::queue myQueue, sycl::buffer<Actor> actorBuf,
44
44
45
45
auto forceSumReduction =
46
46
sycl::reduction (forceSumBuf, cgh, sycl::plus<float >());
47
-
48
- cgh.parallel_for (sycl::range<1 >{actorAcc.size ()}, forceSumReduction,
49
- [=](sycl::id<1 > index, auto &sum) {
50
- if (!actorAcc[index].getAtDestination ()) {
51
- sum += actorAcc[index].getForce ();
52
- }
53
- });
54
- });
55
- myQueue.throw_asynchronous ();
56
-
57
- myQueue.submit ([&](sycl::handler &cgh) {
58
- auto actorAcc = actorBuf.get_access <sycl::access::mode::read>(cgh);
59
-
47
+
60
48
auto activeActorsReduction =
61
49
sycl::reduction (activeActorsBuf, cgh, sycl::plus<int >());
62
50
63
- cgh.parallel_for (sycl::range<1 >{actorAcc.size ()},
64
- activeActorsReduction,
65
- [=](sycl::id<1 > index, auto &sum) {
66
- if (!actorAcc[index].getAtDestination ()) {
67
- sum += 1 ;
51
+ int globalSize = (std::floor (actorAcc.size ()/16 ) + 1 ) * 16 ;
52
+ cgh.parallel_for (sycl::nd_range<1 >{globalSize, 16 }, forceSumReduction, activeActorsReduction,
53
+ [=](sycl::nd_item<1 > index, auto &forceSum, auto & actorSum) {
54
+ if (!actorAcc[index.get_global_id ()].getAtDestination ()) {
55
+ forceSum += actorAcc[index.get_global_id ()].getForce ();
56
+ actorSum += 1 ;
68
57
}
69
58
});
70
59
});
0 commit comments