Nektar++
Loading...
Searching...
No Matches
Functions
ProfilerRiemannOps.cpp File Reference
#include <CompressibleFlowSolverRedesign/RiemannSolvers/Profilers/ProfilerRiemannOps.hpp>
#include <LibUtilities/BasicUtils/StringUtils.hpp>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 main program of the profiler
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

main program of the profiler

Functions:

Benchmark/profile the elemental operators and print out the performance statistics, e.g. elapsed time, throughput, ndofs. Users can customize which operators and data types(float, doubule) to be profiled.

Usage:

  1. Build the Nektar++ project with following configurations to get the profiler executable: NEKTAR_BUILD_DEMOS=ON NEKTAR_ENABLE_DEVICE_SUPPORT=ON You may need other configurations to enable certain features, e.g. CUDA, AVX, MPI, etc.
  2. Prepare a mesh file for the profiling, e.g. mesh.xml. Make sure it has enough elements to get meaningful profiling results. Make sure the file contains correct EXPANSIONS definitions, and defines the conserved variables (rho, rhou, ..., E) with their boundary conditions, as RiemannSolvers/UnitTests/run/square_Euler.xml does.
  3. Run the profiler executable with the mesh file and other parameters. –opExecSpace=Serial specify the execution space. Possible values are: Serial, AVX, and Device –solverinfo Method=HLLC,HLL specify which Riemann solvers to be profiled. Possible values are: Average, LaxFriedrichs, HLL, HLLC, AUSM0, AUSM1, AUSM2, AUSM3, Roe. -P Ntest=100 number of repeated runs for each operator. Usually a operator takes very short time to finish, so we need to repeat it many times to get accurate timing, and also let CPU/GPU running at a stable frequency. -P order=5 the order of the polynomial expansions. If provided, it will override the expansion definition in the mesh file. This gives a convenient way to profile different orders by same mesh file. -verbose print out more information. Not recommended if you launch many processes.
     Examples:
    
     # So far We can only launch one GPU:
         ./ProfilerRiemannOps mesh.xml --opExecSpace=Device --solverinfo
         Method=HLLC -P Ntest=100 -P order=5 -verbose
    
     # To squeeze all the performance of CPU, typically we launch as many
     # processes as the number of cores on a machine:
         mpirun -np 12 ./ProfilerRiemannOps mesh.xml --opExecSpace=Serial
         --solverinfo Method=HLLC -P Ntest=200 -P order=3
    
     # Launch likwid and use 18 processes per socket(CPU package), MEM_DP
     # tells likwid to measure memory and flops performance, This is
     # usually for a roofline analysis:
         likwid-mpirun -nperdomain S:18 -m -g MEM_DP ./ProfilerRiemannOps
         --opExecSpace=Serial --solverinfo Method=HLLC
    
    mesh.xml
  4. likwid is a powerful tool to measure the performance of the CPU/GPI, including memory bandwidth, flops, cache misses and stalls, etc. The profiler already has the likwid API integrated. To use likwid. You need to first ensure likwid is properly installed and then build Nektar with NEKTAR_USE_LIKWID=ON. See likwid documentation for more information.

Definition at line 107 of file ProfilerRiemannOps.cpp.

108{
109#ifdef NEKTAR_USE_MAGMA
110 magma_init();
111#endif
112
115
116 // Initialise a session, graph and explist.
119
120 // Load parameters (from the command lines).
121 int Ntest, order, Ncomp;
122 std::string method;
123 session->LoadParameter("Ntest", Ntest, 100);
124 session->LoadParameter("order", order, 0);
125 session->LoadParameter("Ncomp", Ncomp, 1);
126 session->LoadSolverInfo("Method", method, "");
127
128 // Set the order of the polynomial expansion if provided
129 // we keep the point distribution the same and make
130 // the number of points the same difference from the number
131 // of modes as the original expansion definition.
132 if (order > 0)
133 {
134 graph->SetExpansionInfoToNumModes(order + 1);
135 }
136
137 // Create a ExpList from the graph(mesh).
139 session, graph, "DefaultVar", true, true, Collections::eNoCollection);
140
141 explist->SetDataWarehouse();
142 explist->GetTrace()->SetDataWarehouse();
143
144 // Print GPU properties.
145 if (session->GetComm()->GetRank() == 0 &&
147 {
149 }
150
151 std::vector<std::string> method0;
152
153 if (method.empty())
154 {
155 method0 = {"Average", "LaxFriedrichs", "HLL", "HLLC", "AUSM0",
156 "AUSM1", "AUSM2", "AUSM3", "Roe"};
157 }
158 else
159 {
160 std::vector<std::string> items;
161 StringUtils::Split(items, method, StringUtils::IsAnyOf(","));
162 for (auto &item : items)
163 {
164 StringUtils::Trim(item);
165 if (!item.empty())
166 {
167 method0.push_back(item);
168 }
169 }
170 }
171
172 // You can add/remove the operators to be profiled as you like.
173 // Benchmark-double
174#if defined(NEKTAR_ENABLE_DOUBLE_PRECISION)
175 for (const auto &m : method0)
176 {
177 LaunchProfiler<double>(explist, Ntest, m);
178 }
179#endif
180
181 // Benchmark-float
182#if defined(NEKTAR_ENABLE_SINGLE_PRECISION)
183 // Benchmark-float
184 for (const auto &m : method0)
185 {
186 LaunchProfiler<float>(explist, Ntest, m);
187 }
188
189#endif
190
192
193 session->Finalise();
194
195#ifdef NEKTAR_USE_MAGMA
196 magma_finalize();
197#endif
198}
#define LIKWID_MARKER_THREADINIT
Definition Likwid.hpp:43
#define LIKWID_MARKER_CLOSE
Definition Likwid.hpp:48
#define LIKWID_MARKER_INIT
Definition Likwid.hpp:42
LibUtilities::SessionReaderSharedPtr session
SpatialDomains::MeshGraphSharedPtr graph
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Common base class of the operator family interfaces: holds the expansion list, component names and da...
Definition Operator.hpp:100
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
Predicate matching any of a set of characters.
void Trim(std::string &str)
Container & Split(Container &result, std::string_view input, Pred pred, TokenCompressMode mode=eTokenCompressOff)
Splits input at characters matching pred into result, which is cleared first. An empty input gives a ...
static void PrintDeviceProperties()

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::Collections::eNoCollection, graph, LIKWID_MARKER_CLOSE, LIKWID_MARKER_INIT, LIKWID_MARKER_THREADINIT, Nektar::PrintDeviceProperties(), Nektar::SpatialDomains::MeshGraphIO::Read(), session, Nektar::StringUtils::Split(), and Nektar::StringUtils::Trim().