Skip to content
Snippets Groups Projects
Commit e55339d1 authored by Mark Olesen's avatar Mark Olesen
Browse files

BUG: name collision on profiling (issue #440)

parent 6a583851
Branches
Tags
No related merge requests found
......@@ -37,16 +37,21 @@ Foam::profiling* Foam::profiling::pool_(0);
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::profilingInformation* Foam::profiling::find(const string& name)
Foam::profilingInformation* Foam::profiling::find
(
const string& descr,
const label parentId
)
{
StorageContainer::iterator iter = hash_.find(name);
return (iter != hash_.end() ? iter() : 0);
StorageContainer::iterator iter = hash_.find(Key(descr, parentId));
return (iter.found() ? iter() : 0);
}
Foam::profilingInformation* Foam::profiling::store(profilingInformation *info)
{
hash_.insert(info->description(), info);
// Profile information lookup is qualified by parent id
hash_.insert(Key(info->description(), info->parent().id()), info);
return info;
}
......@@ -174,7 +179,7 @@ Foam::profilingInformation* Foam::profiling::New
{
profilingInformation *parent = pool_->stack_.top();
info = pool_->find(descr);
info = pool_->find(descr, parent->id());
if (!info)
{
info = pool_->store(new profilingInformation(descr, parent));
......
......@@ -87,10 +87,35 @@ public:
private:
// Private typedefs
// Private classes, typedefs
typedef profilingSysInfo sysInfo;
typedef HashPtrTable<Information, string> StorageContainer;
//- Profile information lookup is qualified by parent id
typedef Tuple2<string, label> Key;
//- Hashing for information lookup
class HashKey
:
public Hash<Key>
{
public:
HashKey()
{}
//- Hash qualified by the parent id to avoid collisions
unsigned operator()(const Key& key) const
{
return
(
Hash<string>()(key.first())
+ Hash<label>()(key.second())
);
}
};
typedef HashPtrTable<Information, Key, HashKey> StorageContainer;
typedef LIFOStack<Information*> StackContainer;
......@@ -164,8 +189,9 @@ protected:
// Protected Member Functions
//- Find named profiling information element or null on failure
profilingInformation* find(const string& name);
//- Find named profiling information element with specified parent.
// Return nullptr on failure.
profilingInformation* find(const string& descr, const label parentId);
//- Add to hashed storage,
// returns pointer to newly stored element for chaining
......
......@@ -59,7 +59,12 @@ Foam::SolverPerformance<Type> Foam::fvMatrix<Type>::solve
const dictionary& solverControls
)
{
addProfiling(solve, "fvMatrix::solve." + psi_.name());
word regionName;
if (psi_.mesh().name() != polyMesh::defaultRegion)
{
regionName = psi_.mesh().name() + "::";
}
addProfiling(solve, "fvMatrix::solve." + regionName + psi_.name());
if (debug)
{
......
......@@ -60,7 +60,12 @@ Foam::fvMatrix<Foam::scalar>::solver
const dictionary& solverControls
)
{
addProfiling(solve, "fvMatrix::solve." + psi_.name());
word regionName;
if (psi_.mesh().name() != polyMesh::defaultRegion)
{
regionName = psi_.mesh().name() + "::";
}
addProfiling(solve, "fvMatrix::solve." + regionName + psi_.name());
if (debug)
{
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment