From 15310fc70bcaa4c545159ae768b6c5cf13fa262b Mon Sep 17 00:00:00 2001 From: mdessole Date: Fri, 14 Nov 2025 12:18:06 +0100 Subject: [PATCH] [genvectorx] Offload testLorentzVector to device (cherry picked from commit 451b70e02bd64254db897328793161fc09809c9f) --- tutorials/math/mathcoreGenVectorSYCL.C | 32 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/tutorials/math/mathcoreGenVectorSYCL.C b/tutorials/math/mathcoreGenVectorSYCL.C index c1010ef6d55c1..0fb954b3de027 100644 --- a/tutorials/math/mathcoreGenVectorSYCL.C +++ b/tutorials/math/mathcoreGenVectorSYCL.C @@ -18,6 +18,7 @@ /// \author Devajith Valaparambil Sreeramaswamy (CERN) #define ROOT_MATH_ARCH MathSYCL +#define ROOT_MATH_SYCL #include "MathX/Vector3D.h" #include "MathX/Point3D.h" @@ -220,16 +221,31 @@ int testLorentzVector() << " Lorentz Vector Tests" << "\n************************************************************************\n"; - LorentzVector> v1(1, 2, 3, 4); - LorentzVector> v2(5, 6, 7, 8); - ok += compare(v1.DeltaR(v2), 4.60575f); - // Result cross-validated using: - // TLorentzVector t1, t2; - // t1.SetPtEtaPhiE(1,2,3,4); t2.SetPtEtaPhiE(5,6,7,8); - // t1.DeltaR(t2) + sycl::buffer ok_buf(&ok, sycl::range<1>(1)); + sycl::default_selector device_selector; + sycl::queue queue(device_selector); + + std::cout << "sycl::queue check - selected device:\n" + << queue.get_device().get_info() << std::endl; + + { + queue.submit([&](sycl::handler &cgh) { + auto ok_device = ok_buf.get_access(cgh); + cgh.single_task([=]() { + LorentzVector> v1(1, 2, 3, 4); + LorentzVector> v2(5, 6, 7, 8); + ok_device[0] += compare(v1.DeltaR(v2), 4.60575f); + + LorentzVector> v = v1 + v2; + ok_device[0] += compare(v.M(), 62.03058f); + }); + }); + } if (ok == 0) - std::cout << "\t OK " << std::endl; + std::cout << "\tOK\n"; + else + std::cout << "\t FAILED\n"; return ok; }