mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
planner: remove Bühlmann factor cache
The Bühlmann factors were cached in a thread-safe hashmap. It seemed somewhat dubious that entering a critical section and doing a hash-lookup would be significantly faster than a simple exp() call. Indeed, in a very cache friendly test (16 entries, tight loop) calling the factor() function 32 000 000 times from a different translation units we get: - with cache: 604 ms - without cache: 266 ms Therefore, remove the cache. Given that 32 000 000 calls take only 266 ms, it appears not sensible to try to optimize this function anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f37f428762
commit
123937901f
3 changed files with 6 additions and 47 deletions
|
|
@ -1601,31 +1601,6 @@ char *intdup(int index)
|
|||
return strdup(tmpbuf);
|
||||
}
|
||||
|
||||
QHash<int, double> factor_cache;
|
||||
|
||||
QReadWriteLock factorCacheLock;
|
||||
extern "C" double cache_value(int tissue, int timestep, enum inertgas inertgas)
|
||||
{
|
||||
double value;
|
||||
int key = (timestep << 5) + (tissue << 1);
|
||||
if (inertgas == HE)
|
||||
++key;
|
||||
factorCacheLock.lockForRead();
|
||||
value = factor_cache.value(key);
|
||||
factorCacheLock.unlock();
|
||||
return value;
|
||||
}
|
||||
|
||||
extern "C" void cache_insert(int tissue, int timestep, enum inertgas inertgas, double value)
|
||||
{
|
||||
int key = (timestep << 5) + (tissue << 1);
|
||||
if (inertgas == HE)
|
||||
++key;
|
||||
factorCacheLock.lockForWrite();
|
||||
factor_cache.insert(key, value);
|
||||
factorCacheLock.unlock();
|
||||
}
|
||||
|
||||
extern "C" void print_qt_versions()
|
||||
{
|
||||
printf("%s\n", qPrintable(QStringLiteral("built with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion())));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue