Commit 99e90b4e authored by mark's avatar mark
Browse files

BUG: name collision on profiling (issue #440)

parent ceb076db
...@@ -37,16 +37,21 @@ Foam::profiling* Foam::profiling::pool_(0); ...@@ -37,16 +37,21 @@ Foam::profiling* Foam::profiling::pool_(0);
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * 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); StorageContainer::iterator iter = hash_.find(Key(descr, parentId));
return (iter != hash_.end() ? iter() : 0); return (iter.found() ? iter() : 0);
} }
Foam::profilingInformation* Foam::profiling::store(profilingInformation *info) 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; return info;
} }
...@@ -174,7 +179,7 @@ Foam::profilingInformation* Foam::profiling::New ...@@ -174,7 +179,7 @@ Foam::profilingInformation* Foam::profiling::New
{ {
profilingInformation *parent = pool_->stack_.top(); profilingInformation *parent = pool_->stack_.top();
info = pool_->find(descr); info = pool_->find(descr, parent->id());
if (!info) if (!info)
{ {
info = pool_->store(new profilingInformation(descr, parent)); info = pool_->store(new profilingInformation(descr, parent));
......
...@@ -87,10 +87,35 @@ public: ...@@ -87,10 +87,35 @@ public:
private: private:
// Private typedefs // Private classes, typedefs
typedef profilingSysInfo sysInfo; 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; typedef LIFOStack<Information*> StackContainer;
...@@ -164,8 +189,9 @@ protected: ...@@ -164,8 +189,9 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Find named profiling information element or null on failure //- Find named profiling information element with specified parent.
profilingInformation* find(const string& name); // Return nullptr on failure.
profilingInformation* find(const string& descr, const label parentId);
//- Add to hashed storage, //- Add to hashed storage,
// returns pointer to newly stored element for chaining // returns pointer to newly stored element for chaining
......
...@@ -59,7 +59,12 @@ Foam::SolverPerformance<Type> Foam::fvMatrix<Type>::solve ...@@ -59,7 +59,12 @@ Foam::SolverPerformance<Type> Foam::fvMatrix<Type>::solve
const dictionary& solverControls 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) if (debug)
{ {
......
...@@ -60,7 +60,12 @@ Foam::fvMatrix<Foam::scalar>::solver ...@@ -60,7 +60,12 @@ Foam::fvMatrix<Foam::scalar>::solver
const dictionary& solverControls 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) if (debug)
{ {
......
Supports Markdown
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