University of Duisburg-Essen, House of Energy Markets and Finance
2024-07-11
$$ %mathbb alphabet
%mathcal alphabet
%boldsymbols
%greeks
% Transpose like you want to have it % %%\newcommand{}[1]{#1’
%general short cuts$$
I searched for a benchmarking tool for my (R)cpp code
I found RcppClock
RcppClock was slow, so I started working on it
But why is it so cool?
It’s simple:
Using std::map
to match .tick()
and .tock()
calls is efficient:
std::map<std::string, tp> tickmap;
// Start timer: write name + time into tickmap
void tick(std::string name)
{
tickmap.insert(std::pair<std::string, tp>(name, sc::high_resolution_clock::now()));
}
// Stop timer: write duration into timers, save key
void tock(std::string name)
{
timers.push_back(
sc::duration_cast<sc::nanoseconds>(
sc::high_resolution_clock::now() - tickmap[name]
).count()
);
keys.push_back(name);
}
At this stage, RcppTimer can’t handle OpenMP parralelism as it can’t distinguish between threads.
Simple solution: Add Threadnumber to the Key of the tickmap
.
At this stage, RcppTimer can’t handle OpenMP parralelism as it can’t distinguish between threads.
Simple solution: Add Threadnumber to the Key of the tickmap
.
Parallelism can cause memory access problems
But we can “lock” objects in OMP threads before accessing them
Parallelism can cause memory access problems
But we can “lock” objects in OMP threads before accessing them
Simple
Powerful
useR! 2024