From aef8efe25cea0776f78c7a17fad6e6a441ee332c Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Fri, 2 Mar 2018 16:29:29 -0500 Subject: [PATCH] step-37: print vectorization info --- examples/step-37/doc/intro.dox | 3 ++- examples/step-37/doc/results.dox | 4 ++++ examples/step-37/step-37.cc | 13 ++++++++++++ include/deal.II/base/utilities.h | 34 ++++++++++++++++++++++++++++++++ source/base/utilities.cc | 18 +++++++++++++++++ 5 files changed, 71 insertions(+), 1 deletion(-) diff --git a/examples/step-37/doc/intro.dox b/examples/step-37/doc/intro.dox index ff0cde0b77..6541e07af5 100644 --- a/examples/step-37/doc/intro.dox +++ b/examples/step-37/doc/intro.dox @@ -514,7 +514,8 @@ FEEvaluation for your computer, you should compile deal.II with the so-called enabled by setting the variable CMAKE_CXX_FLAGS to "-march=native" in the cmake build settings (on the command line, specify -DCMAKE_CXX_FLAGS="-march=native", see the deal.II README for -more information). Similar options exist for other compilers. +more information). Similar options exist for other compilers. We output +the current vectorization length in the run() function of this example.

Running multigrid on large-scale parallel computers

diff --git a/examples/step-37/doc/results.dox b/examples/step-37/doc/results.dox index 262eaebd77..b1049dbaab 100644 --- a/examples/step-37/doc/results.dox +++ b/examples/step-37/doc/results.dox @@ -13,6 +13,7 @@ Of more interest is to evaluate some aspects of the multigrid solver. When we run this program in 2D for quadratic ($Q_2$) elements, we get the following output (when run on one core in release mode): @code +Vectorization over 2 doubles = 128 bits (SSE2), VECTORIZATION_LEVEL=1 Cycle 0 Number of degrees of freedom: 81 Total setup time (wall) 0.00159788s @@ -67,6 +68,7 @@ use uniform mesh refinement, we get eight times as many elements and approximately eight times as many degrees of freedom with each cycle: @code +Vectorization over 2 doubles = 128 bits (SSE2), VECTORIZATION_LEVEL=1 Cycle 0 Number of degrees of freedom: 125 Total setup time (wall) 0.00231099s @@ -105,6 +107,7 @@ degree_finite_element=4; at the top of the program, we get the following program output: @code +Vectorization over 2 doubles = 128 bits (SSE2), VECTORIZATION_LEVEL=1 Cycle 0 Number of degrees of freedom: 729 Total setup time (wall) 0.00633097s @@ -157,6 +160,7 @@ Finally, let us look at the timings with degree 8, which corresponds to another round of mesh refinement in the lower order methods: @code +Vectorization over 2 doubles = 128 bits (SSE2), VECTORIZATION_LEVEL=1 Cycle 0 Number of degrees of freedom: 4913 Total setup time (wall) 0.0842004s diff --git a/examples/step-37/step-37.cc b/examples/step-37/step-37.cc index 23d44253d1..5d1e111129 100644 --- a/examples/step-37/step-37.cc +++ b/examples/step-37/step-37.cc @@ -1159,9 +1159,22 @@ namespace Step37 // The function that runs the program is very similar to the one in // step-16. We do few refinement steps in 3D compared to 2D, but that's // it. + // + // Before we run the program, we output some information about the detected + // vectorization level as discussed in the introduction. template void LaplaceProblem::run () { + { + const unsigned int n_vect_doubles = VectorizedArray::n_array_elements; + const unsigned int n_vect_bits = 8*sizeof(double)*n_vect_doubles; + + pcout << "Vectorization over " << n_vect_doubles + << " doubles = " << n_vect_bits << " bits (" + << Utilities::System::get_current_vectorization_level() + << "), VECTORIZATION_LEVEL=" << DEAL_II_COMPILER_VECTORIZATION_LEVEL << std::endl; + } + for (unsigned int cycle=0; cycle<9-dim; ++cycle) { pcout << "Cycle " << cycle << std::endl; diff --git a/include/deal.II/base/utilities.h b/include/deal.II/base/utilities.h index d973a91810..ad70c706ac 100644 --- a/include/deal.II/base/utilities.h +++ b/include/deal.II/base/utilities.h @@ -621,6 +621,40 @@ namespace Utilities */ double get_cpu_load (); + /** + * Return the current level of vectorization as described by DEAL_II_COMPILER_VECTORIZATION_LEVEL + * in vectorization.h as a string. The list of possible return values is: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
VECTORIZATION_LEVELReturn ValueWidth in bits
0disabled64
1SSE2128
2AVX256
3AVX512512
+ */ + const std::string get_current_vectorization_level(); + /** * Structure that hold information about memory usage in kB. Used by * get_memory_stats(). See man 5 proc entry /status for details. diff --git a/source/base/utilities.cc b/source/base/utilities.cc index a192cfc3ab..ada51d6cfd 100644 --- a/source/base/utilities.cc +++ b/source/base/utilities.cc @@ -631,6 +631,24 @@ namespace Utilities #endif + const std::string + get_current_vectorization_level() + { + switch (DEAL_II_COMPILER_VECTORIZATION_LEVEL) + { + case 0: + return "disabled"; + case 1: + return "SSE2"; + case 2: + return "AVX"; + case 3: + return "AVX512"; + default: + AssertThrow(false, ExcInternalError("Invalid DEAL_II_COMPILER_VECTORIZATION_LEVEL.")); + return "ERROR"; + } + } void get_memory_stats (MemoryStats &stats) -- 2.39.5