Skip to content

Commit ccee59d

Browse files
committed
[genvector] Offload testLorentzVector to device
1 parent 48f5e0d commit ccee59d

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

tutorials/math/mathcoreGenVectorSYCL.C

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,31 @@ int testLorentzVector()
220220
<< " Lorentz Vector Tests"
221221
<< "\n************************************************************************\n";
222222

223-
LorentzVector<PtEtaPhiM4D<float>> v1(1, 2, 3, 4);
224-
LorentzVector<PtEtaPhiM4D<float>> v2(5, 6, 7, 8);
225-
ok += compare(v1.DeltaR(v2), 4.60575f);
226-
// Result cross-validated using:
227-
// TLorentzVector t1, t2;
228-
// t1.SetPtEtaPhiE(1,2,3,4); t2.SetPtEtaPhiE(5,6,7,8);
229-
// t1.DeltaR(t2)
223+
sycl::buffer<int, 1> ok_buf(&ok, sycl::range<1>(1));
224+
sycl::default_selector device_selector;
225+
sycl::queue queue(device_selector);
226+
227+
std::cout << "sycl::queue check - selected device:\n"
228+
<< queue.get_device().get_info<sycl::info::device::name>() << std::endl;
229+
230+
{
231+
queue.submit([&](sycl::handler &cgh) {
232+
auto ok_device = ok_buf.get_access<sycl::access::mode::read_write>(cgh);
233+
cgh.single_task<class testRotations3D>([=]() {
234+
LorentzVector<PtEtaPhiM4D<float>> v1(1, 2, 3, 4);
235+
LorentzVector<PtEtaPhiM4D<float>> v2(5, 6, 7, 8);
236+
ok_device[0] += compare(v1.DeltaR(v2), 4.60575f);
237+
238+
LorentzVector<PtEtaPhiM4D<float>> v = v1 + v2;
239+
ok_device[0] += compare(v.M(), 62.03058f);
240+
});
241+
});
242+
}
230243

231244
if (ok == 0)
232-
std::cout << "\t OK " << std::endl;
245+
std::cout << "\tOK\n";
246+
else
247+
std::cout << "\t FAILED\n";
233248

234249
return ok;
235250
}

0 commit comments

Comments
 (0)