2727#include < Math/SMatrix.h>
2828#include < random>
2929
30- using MatSym3DGPU = o2::math_utils::SMatrixGPU<float , 3 , 3 , o2::math_utils::MatRepSymGPU<float , 3 >>;
31- using MatSym3D = ROOT::Math::SMatrix<float , 3 , 3 , ROOT::Math::MatRepSym<float , 3 >>;
32- using Mat3DGPU = o2::math_utils::SMatrixGPU<float , 3 , 3 , o2::math_utils::MatRepStdGPU<float , 3 , 3 >>;
33- using Mat3D = ROOT::Math::SMatrix<float , 3 , 3 , ROOT::Math::MatRepStd<float , 3 , 3 >>;
30+ using MatSym3DGPU = o2::math_utils::SMatrixGPU<double , 3 , 3 , o2::math_utils::MatRepSymGPU<double , 3 >>;
31+ using MatSym3D = ROOT::Math::SMatrix<double , 3 , 3 , ROOT::Math::MatRepSym<double , 3 >>;
32+ using Mat3DGPU = o2::math_utils::SMatrixGPU<double , 3 , 3 , o2::math_utils::MatRepStdGPU<double , 3 , 3 >>;
33+ using Mat3D = ROOT::Math::SMatrix<double , 3 , 3 , ROOT::Math::MatRepStd<double , 3 , 3 >>;
34+
35+ static constexpr double tolerance = 1e-8 ;
3436
3537#define GPU_CHECK (call ) \
3638 do { \
@@ -130,7 +132,7 @@ GPUg() void copyMatrixKernelArray(
130132
131133// Function to compare two matrices element-wise with a specified tolerance
132134template <typename MatrixType>
133- void compareMatricesElementWise (const MatrixType& mat1, const MatrixType& mat2, float tolerance)
135+ void compareMatricesElementWise (const MatrixType& mat1, const MatrixType& mat2, double tolerance)
134136{
135137 auto tol = boost::test_tools::tolerance (tolerance);
136138
@@ -228,7 +230,7 @@ struct GPUSMatrixImplFixtureSolo {
228230 {
229231 std::random_device rd;
230232 std::mt19937 gen (rd ());
231- std::uniform_real_distribution<float > dis (1.0 , 10.0 );
233+ std::uniform_real_distribution<double > dis (1.0 , 10.0 );
232234
233235 // Initialize host matrices with random values
234236 for (int i = 0 ; i < 3 ; ++i) {
@@ -255,7 +257,6 @@ struct GPUSMatrixImplFixtureSolo {
255257
256258BOOST_FIXTURE_TEST_CASE (MatrixInversion, GPUSMatrixImplFixtureSolo)
257259{
258- float tolerance = 0 .00001f ;
259260 const int nBlocks{1 }, nThreads{1 };
260261 GPUBenchmark benchmark (" Single symmetric matrix inversion (" + std::to_string (nBlocks) + " blocks, " + std::to_string (nThreads) + " threads)" );
261262 benchmark.start ();
@@ -290,7 +291,7 @@ BOOST_FIXTURE_TEST_CASE(MatrixInversion, GPUSMatrixImplFixtureSolo)
290291 identity (2 , 2 ) = 1 ;
291292 auto operation = SMatrix_h * SMatrix_original_h;
292293 Mat3D result;
293- ROOT::Math::Assign<float , 3 , 3 , decltype (operation), ROOT::Math::MatRepStd<float , 3 , 3 >, ROOT::Math::MatRepStd<float , 3 , 3 >>::Evaluate (result, operation);
294+ ROOT::Math::Assign<double , 3 , 3 , decltype (operation), ROOT::Math::MatRepStd<double , 3 , 3 >, ROOT::Math::MatRepStd<double , 3 , 3 >>::Evaluate (result, operation);
294295 compareMatricesElementWise (result, identity, tolerance);
295296}
296297
@@ -307,7 +308,7 @@ struct GPUSMatrixImplFixtureDuo {
307308 {
308309 std::random_device rd;
309310 std::mt19937 gen (rd ());
310- std::uniform_real_distribution<float > dis (1.0 , 10.0 );
311+ std::uniform_real_distribution<double > dis (1.0 , 10.0 );
311312
312313 // Initialize host matrices with random values
313314 for (int i = 0 ; i < 3 ; ++i) {
@@ -384,7 +385,7 @@ struct GPUSmatrixImplFixtureSoloArray {
384385 {
385386 std::random_device rd;
386387 std::mt19937 gen (rd ());
387- std::uniform_real_distribution<float > dis (1.0 , 10.0 );
388+ std::uniform_real_distribution<double > dis (1.0 , 10.0 );
388389
389390 // Initialize host matrices with random values
390391 for (size_t iMatrix{0 }; iMatrix < D; ++iMatrix) {
@@ -414,9 +415,7 @@ struct GPUSmatrixImplFixtureSoloArray {
414415
415416BOOST_FIXTURE_TEST_CASE (MatrixInversionArray, GPUSmatrixImplFixtureSoloArray<1'000'000 >)
416417{
417- float tolerance = 0 .00001f ;
418418 const int nBlocks{20 }, nThreads{512 };
419-
420419 GPUBenchmark benchmark (" Array of 1'000'000 symmetric matrices inversion (" + std::to_string (nBlocks) + " blocks, " + std::to_string (nThreads) + " threads)" );
421420 benchmark.start ();
422421 gpu::invertMatrixKernelArray<MatSym3DGPU><<<nBlocks, nThreads>>> (static_cast <MatSym3DGPU*>(SMatrixSymArray_d.get ()), 1'000'000 );
0 commit comments