Skip to content

Commit 451b70e

Browse files
mdessoledevajithvs
authored andcommitted
[genvectorx] Offload testLorentzVector to device
1 parent 9966609 commit 451b70e

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

tutorials/math/mathcoreGenVectorSYCL.C

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
/// \author Devajith Valaparambil Sreeramaswamy (CERN)
1919

2020
#define ROOT_MATH_ARCH MathSYCL
21+
#define ROOT_MATH_SYCL
2122

2223
#include "MathX/Vector3D.h"
2324
#include "MathX/Point3D.h"
@@ -220,16 +221,31 @@ int testLorentzVector()
220221
<< " Lorentz Vector Tests"
221222
<< "\n************************************************************************\n";
222223

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

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

234250
return ok;
235251
}

0 commit comments

Comments
 (0)