meric issueshttps://code.it4i.cz/vys0053/meric/-/issues2023-06-21T17:25:14+02:00https://code.it4i.cz/vys0053/meric/-/issues/84activate tuning for dynamic tuning despite static is default2023-06-21T17:25:14+02:00Ondrej Vysockyactivate tuning for dynamic tuning despite static is default- investigate opts file and identify tuned parameters
- the static configuration is not set at environment initialization, but at the `*_static` region start- investigate opts file and identify tuned parameters
- the static configuration is not set at environment initialization, but at the `*_static` region startOndrej VysockyOndrej Vysockyhttps://code.it4i.cz/vys0053/meric/-/issues/69Threads and processes pinning2020-03-24T16:43:06+01:00Ondrej VysockyThreads and processes pinningProvide possibility to set affinity by MERIC.
* https://kb.hlrs.de/platforms/index.php/Thread_And_Memory_Pinning
* https://linux.die.net/man/3/numa
* https://github.com/numactl/numactl
```
$ lscpu -e
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ...Provide possibility to set affinity by MERIC.
* https://kb.hlrs.de/platforms/index.php/Thread_And_Memory_Pinning
* https://linux.die.net/man/3/numa
* https://github.com/numactl/numactl
```
$ lscpu -e
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE MAXMHZ MINMHZ
0 0 0 0 0:0:0:0 yes 3300.0000 1200.0000
1 0 0 1 1:1:1:0 yes 3300.0000 1200.0000
2 0 0 2 2:2:2:0 yes 3300.0000 1200.0000
3 0 0 3 3:3:3:0 yes 3300.0000 1200.0000
4 0 0 4 4:4:4:0 yes 3300.0000 1200.0000
5 0 0 5 5:5:5:0 yes 3300.0000 1200.0000
6 0 0 6 6:6:6:0 yes 3300.0000 1200.0000
7 0 0 7 7:7:7:0 yes 3300.0000 1200.0000
8 0 0 8 8:8:8:0 yes 3300.0000 1200.0000
9 0 0 9 9:9:9:0 yes 3300.0000 1200.0000
10 0 0 10 10:10:10:0 yes 3300.0000 1200.0000
11 0 0 11 11:11:11:0 yes 3300.0000 1200.0000
12 1 1 12 12:12:12:1 yes 3300.0000 1200.0000
13 1 1 13 13:13:13:1 yes 3300.0000 1200.0000
14 1 1 14 14:14:14:1 yes 3300.0000 1200.0000
15 1 1 15 15:15:15:1 yes 3300.0000 1200.0000
16 1 1 16 16:16:16:1 yes 3300.0000 1200.0000
17 1 1 17 17:17:17:1 yes 3300.0000 1200.0000
18 1 1 18 18:18:18:1 yes 3300.0000 1200.0000
19 1 1 19 19:19:19:1 yes 3300.0000 1200.0000
20 1 1 20 20:20:20:1 yes 3300.0000 1200.0000
21 1 1 21 21:21:21:1 yes 3300.0000 1200.0000
22 1 1 22 22:22:22:1 yes 3300.0000 1200.0000
23 1 1 23 23:23:23:1 yes 3300.0000 1200.0000
24 0 0 0 0:0:0:0 yes 3300.0000 1200.0000
25 0 0 1 1:1:1:0 yes 3300.0000 1200.0000
26 0 0 2 2:2:2:0 yes 3300.0000 1200.0000
27 0 0 3 3:3:3:0 yes 3300.0000 1200.0000
28 0 0 4 4:4:4:0 yes 3300.0000 1200.0000
29 0 0 5 5:5:5:0 yes 3300.0000 1200.0000
30 0 0 6 6:6:6:0 yes 3300.0000 1200.0000
31 0 0 7 7:7:7:0 yes 3300.0000 1200.0000
32 0 0 8 8:8:8:0 yes 3300.0000 1200.0000
33 0 0 9 9:9:9:0 yes 3300.0000 1200.0000
34 0 0 10 10:10:10:0 yes 3300.0000 1200.0000
35 0 0 11 11:11:11:0 yes 3300.0000 1200.0000
36 1 1 12 12:12:12:1 yes 3300.0000 1200.0000
37 1 1 13 13:13:13:1 yes 3300.0000 1200.0000
38 1 1 14 14:14:14:1 yes 3300.0000 1200.0000
39 1 1 15 15:15:15:1 yes 3300.0000 1200.0000
40 1 1 16 16:16:16:1 yes 3300.0000 1200.0000
41 1 1 17 17:17:17:1 yes 3300.0000 1200.0000
42 1 1 18 18:18:18:1 yes 3300.0000 1200.0000
43 1 1 19 19:19:19:1 yes 3300.0000 1200.0000
44 1 1 20 20:20:20:1 yes 3300.0000 1200.0000
45 1 1 21 21:21:21:1 yes 3300.0000 1200.0000
46 1 1 22 22:22:22:1 yes 3300.0000 1200.0000
47 1 1 23 23:23:23:1 yes 3300.0000 1200.0000
```Ondrej VysockyOndrej Vysockyhttps://code.it4i.cz/vys0053/meric/-/issues/55Binary instrumentation2023-06-15T10:34:50+02:00Ondrej VysockyBinary instrumentation# TODOs
* [x] A main region must be inserted otherwise it may happen that we will not have data for the whole (missing static tuning)
* [x] MPI_Init_thread
* [ ] MPI Fortran
# Tools overview
http://deniable.org/reversing/binary-ins...# TODOs
* [x] A main region must be inserted otherwise it may happen that we will not have data for the whole (missing static tuning)
* [x] MPI_Init_thread
* [ ] MPI Fortran
# Tools overview
http://deniable.org/reversing/binary-instrumentation
http://2011.zeronights.org/files/dmitriyd1g1evdokimov-dbiintro-111202045015-phpapp01.pdf
# DBI [Pin tool](https://software.intel.com/en-us/articles/pin-a-binary-instrumentation-tool-downloads)
* easy to instrument all the functions and then filter them in JIT mode
* probed mode can catch function start but for stop Pin requires function's prototype
* Linux Pin tools cannot use the pthreads
* `TODO test` - application must be compiled with `-g` flag
# DBI [Valgrind](http://valgrind.org/)
* massive overhead
# DBI [DynamoRIO](http://www.dynamorio.org/)
* massive overhead and memory consumption for all functions profiling
* Linux DynamoRIO tools cannot use the pthreads
* If an executable is built with the -rdynamic flag to gcc, its global symbols will be present in .dynsym and dr_get_proc_address() will locate them. Otherwise, the drsyms Extension (see Symbol Access Library) must be used to locate the symbols. drsyms searches the debug symbol table (.symtab) in addition to .dynsym.
# DBI [Frida](https://www.frida.re/)
* almost no documentation for C API
* hard to compile from source files
# DBI+SBI [DinInst](https://dyninst.org/)
* used by Score-P
## Instalation ##
* requires `zlib` and `Boost`, from Dyninst-10.0.0 also `m4`
* the Dyninst compilation can download the Boost and compile the necessary parts, but it does not work very well
```
# boost minimum required installation
./bootstrap.sh --with-libraries=date_time,system,thread
./b2
#Zlib
export ZLIB_ROOT=/PATH/TO/ZLIB
export LD_LIBRARY_PATH=$ZLIB_ROOT/build:$LD_LIBRARY_PATH
export LIBRARY_PATH=$ZLIB_ROOT/build:$LIBRARY_PATH
#zlib.h : zconf.h
export CPATH=$ZLIB_ROOT:$ZLIB_ROOT/build:$CPATH
#Boost
export BOOST_ROOT=/PATH/TO/BOOST
export LD_LIBRARY_PATH=$BOOST_ROOT/stage/lib/:$LD_LIBRARY_PATH
export CPATH=$BOOST_ROOT:$CPATH
```
* install Dyninst
```
mkdir build
cd build
cmake ..
# in case of missing paths to Boost
vim ../cmake/packages.cmake
# set(PATH_BOOST /PATH/TO/BOOST/)
# set(Boost_INCLUDE_DIR /PATH/TO/BOOST/)
# set(Boost_LIBRARY_DIR /PATH/TO/BOOST/stage/lib)
make
make install
export DINST_HOME=/PATH/TO/DYNINST/DIRECTORY
export DYNINSTAPI_RT_LIB=$DINST_HOME/build/dyninstAPI_RT/libdyninstAPI_RT.so
export LD_LIBRARY_PATH+=:$DINST_HOME/build/dyninstAPI_RT/
```
## Intro ##
* [Dyninst overview](http://www.umiacs.umd.edu/mc2symposium/slides/securityTutorialDyninst.pdf)
* [DyninstAPI Programmer's Guide](https://dyninst.org/sites/default/files/manuals/dyninst/dyninstAPI.pdf):
```
The DyninstAPI library provides an interface for instrumenting and working with binaries and processes.
The user writes a mutator, which uses the DyninstAPI library to operate on the application.
The process that contains the mutator and DyninstAPI library is known as the mutator process.
The mutator process operates on other processes or on-disk binaries, which are known as mutatees.
The two primary abstractions in the API are points and snippets.
A point is a location in a program where instrumentation can be inserted.
A snippet is a representation of some executable code to be inserted into a program at a point.
```Ondrej VysockyOndrej Vysockyhttps://code.it4i.cz/vys0053/meric/-/issues/53Powercap2023-06-02T10:17:41+02:00Ondrej VysockyPowercap### RAPL (Intel)
* [x] msr-safe
* [ ] x86_adapt
* [ ] PAPI
* [x] geopm
https://onlinelibrary.wiley.com/doi/pdf/10.1002/cpe.4485
Additionally,the Linux kernel has begun to expose RAPL-based power management via the sysfs powercap in...### RAPL (Intel)
* [x] msr-safe
* [ ] x86_adapt
* [ ] PAPI
* [x] geopm
https://onlinelibrary.wiley.com/doi/pdf/10.1002/cpe.4485
Additionally,the Linux kernel has begun to expose RAPL-based power management via the sysfs powercap interface,which provides simpler and safer access to the low-level power controls.The Linux perf command-line interface has begun exposing and managing some of the hardware counters,but the power management is still handled by accessing the sysfs powercap filesystem.
### OPAL (IBM)new versionOndrej VysockyOndrej Vysockyhttps://code.it4i.cz/vys0053/meric/-/issues/51Meric_AddCounter(CounterValue, CounterName);2018-02-15T09:16:13+01:00Ondrej VysockyMeric_AddCounter(CounterValue, CounterName);In some cases the application provides some counters measurement, that we want to visualize int he final measurement report. In this case we should use this function to add a counter name and value to the region we are currently running.In some cases the application provides some counters measurement, that we want to visualize int he final measurement report. In this case we should use this function to add a counter name and value to the region we are currently running.new versionOndrej VysockyOndrej Vysockyhttps://code.it4i.cz/vys0053/meric/-/issues/49optional barriers turn off2022-01-04T12:48:14+01:00Ondrej Vysockyoptional barriers turn offScore-P doesn't use barriers in its instrumentation. In case of automatic instrumentation it would result in extremely high overhead. It means that it is not possible to measure the resources consumption precisely. On the other hand in c...Score-P doesn't use barriers in its instrumentation. In case of automatic instrumentation it would result in extremely high overhead. It means that it is not possible to measure the resources consumption precisely. On the other hand in case of some application (eg. master-slave algorithms) it is necessary not to use barriers.
For MERIC it is possible to turn off OpenMP barriers easily (probably). Removing MPI barriers would require more drastic code changes.new versionOndrej VysockyOndrej Vysocky