]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make CUDA tests more robust 7367/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 21 Oct 2018 13:26:43 +0000 (15:26 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 21 Oct 2018 15:33:50 +0000 (17:33 +0200)
tests/cuda/precondition_01.cu
tests/cuda/precondition_01.output
tests/cuda/precondition_02.cu
tests/cuda/precondition_02.output

index b238ad379a74e5a6ffbf9c737318ea502f5a5fa2..9de6715e61fe230c2e9f0c64851dbc3988bb9b15 100644 (file)
@@ -42,7 +42,6 @@ test(Utilities::CUDA::Handle &cuda_handle)
   structure.compress();
   A.reinit(structure);
   testproblem.five_point(A);
-  A.print(std::cout);
 
   // Solve on the device
   CUDAWrappers::SparseMatrix<Number>          A_dev(cuda_handle, A);
@@ -52,7 +51,8 @@ test(Utilities::CUDA::Handle &cuda_handle)
   for (unsigned int i = 0; i < size; ++i)
     rw_vector[i] = static_cast<Number>(i);
   rhs_dev.import(rw_vector, VectorOperation::insert);
-  SolverControl                                         control(100, 1.e-10);
+  const Number  tolerance = 1000. * std::numeric_limits<Number>::epsilon();
+  SolverControl control(100, tolerance);
   SolverCG<LinearAlgebra::CUDAWrappers::Vector<Number>> cg_dev(control);
 
   CUDAWrappers::PreconditionIC<Number> prec_ic(cuda_handle);
@@ -61,19 +61,23 @@ test(Utilities::CUDA::Handle &cuda_handle)
   cg_dev.solve(A_dev, sol_dev, rhs_dev, prec_ic);
 
   // Check the result
-  rw_vector.import(sol_dev, VectorOperation::insert);
-  for (unsigned int i = 0; i < size; ++i)
-    deallog << rw_vector[i] << std::endl;
+  LinearAlgebra::CUDAWrappers::Vector<Number> residual(size);
+  A_dev.residual(residual, sol_dev, rhs_dev);
+  Assert(residual.l2_norm() < 20 * tolerance, ExcInternalError());
+  deallog << "OK" << std::endl;
 }
 
 int
 main()
 {
   initlog();
+  deallog << std::setprecision(10);
   deallog.depth_console(0);
 
   Utilities::CUDA::Handle cuda_handle;
+  deallog << "Testing float" << std::endl;
   test<float>(cuda_handle);
+  deallog << "Testing double" << std::endl;
   test<double>(cuda_handle);
 
   deallog << "OK" << std::endl;
index 0f5ff017381a8c9926e05c4de3fed31848294ebb..27a4138a2b613769cfd1775142a1b7acaf1d50ec 100644 (file)
 
-DEAL:cg::Starting value 416.989
-DEAL:cg::Convergence step 19 value 1.41136e-11
-DEAL::20.9607
-DEAL::38.8073
-DEAL::52.3525
-DEAL::61.2758
-DEAL::65.4369
-DEAL::64.6135
-DEAL::58.3945
-DEAL::46.1455
-DEAL::27.0190
-DEAL::45.0353
-DEAL::80.9161
-DEAL::107.327
-DEAL::124.314
-DEAL::131.858
-DEAL::129.623
-DEAL::116.819
-DEAL::92.1685
-DEAL::53.9305
-DEAL::69.2645
-DEAL::122.495
-DEAL::160.725
-DEAL::184.794
-DEAL::195.060
-DEAL::191.200
-DEAL::172.090
-DEAL::135.779
-DEAL::79.5345
-DEAL::91.5276
-DEAL::160.074
-DEAL::208.285
-DEAL::238.076
-DEAL::250.389
-DEAL::245.025
-DEAL::220.563
-DEAL::174.324
-DEAL::102.428
-DEAL::109.771
-DEAL::189.991
-DEAL::245.262
-DEAL::278.838
-DEAL::292.394
-DEAL::285.950
-DEAL::257.813
-DEAL::204.524
-DEAL::120.855
-DEAL::121.567
-DEAL::207.855
-DEAL::265.937
-DEAL::300.618
-DEAL::314.399
-DEAL::307.567
-DEAL::278.215
-DEAL::222.104
-DEAL::132.468
-DEAL::123.643
-DEAL::207.924
-DEAL::263.011
-DEAL::295.300
-DEAL::308.015
-DEAL::301.706
-DEAL::274.376
-DEAL::221.208
-DEAL::133.913
-DEAL::111.079
-DEAL::182.188
-DEAL::226.884
-DEAL::252.556
-DEAL::262.656
-DEAL::257.865
-DEAL::236.376
-DEAL::193.440
-DEAL::119.974
-DEAL::75.4858
-DEAL::118.864
-DEAL::144.783
-DEAL::159.382
-DEAL::165.189
-DEAL::162.720
-DEAL::150.825
-DEAL::126.202
-DEAL::81.5441
-DEAL:cg::Starting value 416.989
-DEAL:cg::Convergence step 17 value 5.54040e-11
-DEAL::20.9607
-DEAL::38.8073
-DEAL::52.3525
-DEAL::61.2757
-DEAL::65.4369
-DEAL::64.6135
-DEAL::58.3945
-DEAL::46.1455
-DEAL::27.0190
-DEAL::45.0353
-DEAL::80.9161
-DEAL::107.327
-DEAL::124.314
-DEAL::131.858
-DEAL::129.623
-DEAL::116.819
-DEAL::92.1685
-DEAL::53.9305
-DEAL::69.2645
-DEAL::122.495
-DEAL::160.725
-DEAL::184.794
-DEAL::195.060
-DEAL::191.200
-DEAL::172.090
-DEAL::135.779
-DEAL::79.5345
-DEAL::91.5276
-DEAL::160.074
-DEAL::208.285
-DEAL::238.076
-DEAL::250.389
-DEAL::245.025
-DEAL::220.563
-DEAL::174.324
-DEAL::102.428
-DEAL::109.771
-DEAL::189.991
-DEAL::245.262
-DEAL::278.838
-DEAL::292.394
-DEAL::285.950
-DEAL::257.813
-DEAL::204.524
-DEAL::120.855
-DEAL::121.567
-DEAL::207.855
-DEAL::265.937
-DEAL::300.618
-DEAL::314.399
-DEAL::307.567
-DEAL::278.215
-DEAL::222.104
-DEAL::132.468
-DEAL::123.643
-DEAL::207.924
-DEAL::263.011
-DEAL::295.300
-DEAL::308.015
-DEAL::301.706
-DEAL::274.376
-DEAL::221.208
-DEAL::133.913
-DEAL::111.079
-DEAL::182.188
-DEAL::226.884
-DEAL::252.556
-DEAL::262.656
-DEAL::257.865
-DEAL::236.376
-DEAL::193.440
-DEAL::119.974
-DEAL::75.4858
-DEAL::118.864
-DEAL::144.783
-DEAL::159.382
-DEAL::165.189
-DEAL::162.720
-DEAL::150.825
-DEAL::126.202
-DEAL::81.5441
+DEAL::Testing float
+DEAL:cg::Starting value 416.9891968
+DEAL:cg::Convergence step 11 value 3.993874634e-05
+DEAL::OK
+DEAL::Testing double
+DEAL:cg::Starting value 416.9892085
+DEAL:cg::Convergence step 20 value 9.834412497e-14
+DEAL::OK
 DEAL::OK
index 990d4a92b93b747d04c27664a06ad2684f9c4d7b..edfea90e81f54f470efd7633bb84fc0086c2b27a 100644 (file)
@@ -42,7 +42,6 @@ test(Utilities::CUDA::Handle &cuda_handle)
   structure.compress();
   A.reinit(structure);
   testproblem.five_point(A);
-  A.print(std::cout);
 
   // Solve on the device
   CUDAWrappers::SparseMatrix<Number>          A_dev(cuda_handle, A);
@@ -52,7 +51,8 @@ test(Utilities::CUDA::Handle &cuda_handle)
   for (unsigned int i = 0; i < size; ++i)
     rw_vector[i] = static_cast<Number>(i);
   rhs_dev.import(rw_vector, VectorOperation::insert);
-  SolverControl                                         control(100, 1.e-10);
+  const Number  tolerance = 1000. * std::numeric_limits<Number>::epsilon();
+  SolverControl control(100, tolerance);
   SolverCG<LinearAlgebra::CUDAWrappers::Vector<Number>> cg_dev(control);
 
   CUDAWrappers::PreconditionILU<Number> prec_ilu(cuda_handle);
@@ -61,19 +61,23 @@ test(Utilities::CUDA::Handle &cuda_handle)
   cg_dev.solve(A_dev, sol_dev, rhs_dev, prec_ilu);
 
   // Check the result
-  rw_vector.import(sol_dev, VectorOperation::insert);
-  for (unsigned int i = 0; i < size; ++i)
-    deallog << rw_vector[i] << std::endl;
+  LinearAlgebra::CUDAWrappers::Vector<Number> residual(size);
+  A_dev.residual(residual, sol_dev, rhs_dev);
+  Assert(residual.l2_norm() < 20 * tolerance, ExcInternalError());
+  deallog << "OK" << std::endl;
 }
 
 int
 main()
 {
   initlog();
+  deallog << std::setprecision(10);
   deallog.depth_console(0);
 
   Utilities::CUDA::Handle cuda_handle;
+  deallog << "Testing float" << std::endl;
   test<float>(cuda_handle);
+  deallog << "Testing double" << std::endl;
   test<double>(cuda_handle);
 
   deallog << "OK" << std::endl;
index 913218546b8cade10c97428372926abd0ee38389..1c14226e672202bf1d609e404115af6b3a1e9424 100644 (file)
 
-DEAL:cg::Starting value 416.989
-DEAL:cg::Convergence step 19 value 1.40142e-11
-DEAL::20.9607
-DEAL::38.8073
-DEAL::52.3525
-DEAL::61.2758
-DEAL::65.4369
-DEAL::64.6135
-DEAL::58.3945
-DEAL::46.1455
-DEAL::27.0190
-DEAL::45.0353
-DEAL::80.9161
-DEAL::107.327
-DEAL::124.314
-DEAL::131.858
-DEAL::129.623
-DEAL::116.819
-DEAL::92.1685
-DEAL::53.9305
-DEAL::69.2645
-DEAL::122.495
-DEAL::160.725
-DEAL::184.794
-DEAL::195.060
-DEAL::191.200
-DEAL::172.090
-DEAL::135.779
-DEAL::79.5345
-DEAL::91.5276
-DEAL::160.074
-DEAL::208.285
-DEAL::238.076
-DEAL::250.389
-DEAL::245.025
-DEAL::220.563
-DEAL::174.324
-DEAL::102.428
-DEAL::109.771
-DEAL::189.991
-DEAL::245.262
-DEAL::278.838
-DEAL::292.394
-DEAL::285.950
-DEAL::257.813
-DEAL::204.524
-DEAL::120.855
-DEAL::121.567
-DEAL::207.855
-DEAL::265.937
-DEAL::300.618
-DEAL::314.399
-DEAL::307.567
-DEAL::278.215
-DEAL::222.104
-DEAL::132.468
-DEAL::123.643
-DEAL::207.924
-DEAL::263.011
-DEAL::295.300
-DEAL::308.015
-DEAL::301.706
-DEAL::274.376
-DEAL::221.208
-DEAL::133.913
-DEAL::111.079
-DEAL::182.188
-DEAL::226.884
-DEAL::252.556
-DEAL::262.656
-DEAL::257.865
-DEAL::236.376
-DEAL::193.440
-DEAL::119.974
-DEAL::75.4858
-DEAL::118.864
-DEAL::144.783
-DEAL::159.382
-DEAL::165.189
-DEAL::162.720
-DEAL::150.825
-DEAL::126.202
-DEAL::81.5441
-DEAL:cg::Starting value 416.989
-DEAL:cg::Convergence step 17 value 5.54040e-11
-DEAL::20.9607
-DEAL::38.8073
-DEAL::52.3525
-DEAL::61.2757
-DEAL::65.4369
-DEAL::64.6135
-DEAL::58.3945
-DEAL::46.1455
-DEAL::27.0190
-DEAL::45.0353
-DEAL::80.9161
-DEAL::107.327
-DEAL::124.314
-DEAL::131.858
-DEAL::129.623
-DEAL::116.819
-DEAL::92.1685
-DEAL::53.9305
-DEAL::69.2645
-DEAL::122.495
-DEAL::160.725
-DEAL::184.794
-DEAL::195.060
-DEAL::191.200
-DEAL::172.090
-DEAL::135.779
-DEAL::79.5345
-DEAL::91.5276
-DEAL::160.074
-DEAL::208.285
-DEAL::238.076
-DEAL::250.389
-DEAL::245.025
-DEAL::220.563
-DEAL::174.324
-DEAL::102.428
-DEAL::109.771
-DEAL::189.991
-DEAL::245.262
-DEAL::278.838
-DEAL::292.394
-DEAL::285.950
-DEAL::257.813
-DEAL::204.524
-DEAL::120.855
-DEAL::121.567
-DEAL::207.855
-DEAL::265.937
-DEAL::300.618
-DEAL::314.399
-DEAL::307.567
-DEAL::278.215
-DEAL::222.104
-DEAL::132.468
-DEAL::123.643
-DEAL::207.924
-DEAL::263.011
-DEAL::295.300
-DEAL::308.015
-DEAL::301.706
-DEAL::274.376
-DEAL::221.208
-DEAL::133.913
-DEAL::111.079
-DEAL::182.188
-DEAL::226.884
-DEAL::252.556
-DEAL::262.656
-DEAL::257.865
-DEAL::236.376
-DEAL::193.440
-DEAL::119.974
-DEAL::75.4858
-DEAL::118.864
-DEAL::144.783
-DEAL::159.382
-DEAL::165.189
-DEAL::162.720
-DEAL::150.825
-DEAL::126.202
-DEAL::81.5441
+DEAL::Testing float
+DEAL:cg::Starting value 416.9891968
+DEAL:cg::Convergence step 11 value 3.993944847e-05
+DEAL::OK
+DEAL::Testing double
+DEAL:cg::Starting value 416.9892085
+DEAL:cg::Convergence step 20 value 9.834484941e-14
+DEAL::OK
 DEAL::OK

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.