Commit 0572f00e authored by Sylvain Thery's avatar Sylvain Thery

remove bug of static declaration

parent 22d81ee3
...@@ -439,8 +439,8 @@ int main(int argc, char **argv) ...@@ -439,8 +439,8 @@ int main(int argc, char **argv)
position = myMap.addAttribute<VEC3, VERTEX, MAP>("position"); position = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
int nb = 8; int nb = 8;
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, nb, nb, 1); Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, nb, nb, nb);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 0.0f); cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
for (unsigned int i = position.begin(); i != position.end(); position.next(i)) for (unsigned int i = position.begin(); i != position.end(); position.next(i))
{ {
......
...@@ -361,13 +361,13 @@ inline void ImplicitHierarchicalMap3::foreach_dart_of_volume(Dart d, FUNC& f, un ...@@ -361,13 +361,13 @@ inline void ImplicitHierarchicalMap3::foreach_dart_of_volume(Dart d, FUNC& f, un
} }
template <typename FUNC> template <typename FUNC>
inline void ImplicitHierarchicalMap3::foreach_dart_of_vertex1(Dart d, FUNC& f, unsigned int thread) const inline void ImplicitHierarchicalMap3::foreach_dart_of_vertex1(Dart d, FUNC& f, unsigned int /*thread*/) const
{ {
f(d); f(d);
} }
template <typename FUNC> template <typename FUNC>
inline void ImplicitHierarchicalMap3::foreach_dart_of_edge1(Dart d, FUNC& f, unsigned int thread) const inline void ImplicitHierarchicalMap3::foreach_dart_of_edge1(Dart d, FUNC& f, unsigned int /*thread*/) const
{ {
f(d); f(d);
} }
......
...@@ -98,9 +98,13 @@ protected: ...@@ -98,9 +98,13 @@ protected:
static std::map<std::string, RegisteredBaseAttribute*>* m_attributes_registry_map; static std::map<std::string, RegisteredBaseAttribute*>* m_attributes_registry_map;
static int m_nbInstances; static int m_nbInstances;
// TODO RELEASE MEMORY // buffer for less memory allocation
static std::vector< std::vector<Dart>* > s_vdartsBuffers[NB_ORBITS]; static std::vector< std::vector<Dart>* >* s_vdartsBuffers;
static std::vector< std::vector<unsigned int>* > s_vintsBuffers[NB_ORBITS]; static std::vector< std::vector<unsigned int>* >* s_vintsBuffers;
// table of instancied maps for Dart/CellMarker release
static std::vector<GenericMap*>* s_instances;
/** /**
* Direct access to the Dart attributes that store the orbits embeddings * Direct access to the Dart attributes that store the orbits embeddings
...@@ -130,9 +134,6 @@ protected: ...@@ -130,9 +134,6 @@ protected:
std::multimap<AttributeMultiVectorGen*, AttributeHandlerGen*> attributeHandlers ; // TODO think of MT (AttributeHandler creation & release are not thread safe!) std::multimap<AttributeMultiVectorGen*, AttributeHandlerGen*> attributeHandlers ; // TODO think of MT (AttributeHandler creation & release are not thread safe!)
std::mutex attributeHandlersMutex; std::mutex attributeHandlersMutex;
// table of instancied maps for Dart/CellMarker release
static std::vector<GenericMap*> s_instances;
public: public:
static const unsigned int UNKNOWN_ATTRIB = AttributeContainer::UNKNOWN ; static const unsigned int UNKNOWN_ATTRIB = AttributeContainer::UNKNOWN ;
...@@ -142,9 +143,11 @@ public: ...@@ -142,9 +143,11 @@ public:
static inline bool alive(GenericMap* map) static inline bool alive(GenericMap* map)
{ {
for (auto it=s_instances.begin(); it != s_instances.end(); ++it) for (auto it=s_instances->begin(); it != s_instances->end(); ++it)
{
if (*it == map) if (*it == map)
return true; return true;
}
return false; return false;
} }
......
...@@ -41,16 +41,18 @@ namespace Parallel ...@@ -41,16 +41,18 @@ namespace Parallel
int NumberOfThreads = getSystemNumberOfCores(); int NumberOfThreads = getSystemNumberOfCores();
} }
std::map<std::string, RegisteredBaseAttribute*>* GenericMap::m_attributes_registry_map = NULL; std::map<std::string, RegisteredBaseAttribute*>* GenericMap::m_attributes_registry_map = NULL;
int GenericMap::m_nbInstances = 0; int GenericMap::m_nbInstances = 0;
std::vector< std::vector<Dart>* >* GenericMap::s_vdartsBuffers = NULL;
std::vector< std::vector<unsigned int>* >* GenericMap::s_vintsBuffers = NULL;
std::vector< std::vector<Dart>* > GenericMap::s_vdartsBuffers[NB_ORBITS]; std::vector<GenericMap*>* GenericMap::s_instances=NULL;
std::vector< std::vector<unsigned int>* > GenericMap::s_vintsBuffers[NB_ORBITS];
// table of instancied maps for Dart/CellMarker release
std::vector<GenericMap*> GenericMap::s_instances;
GenericMap::GenericMap() GenericMap::GenericMap()
{ {
...@@ -93,23 +95,30 @@ GenericMap::GenericMap() ...@@ -93,23 +95,30 @@ GenericMap::GenericMap()
m_nbInstances++; m_nbInstances++;
s_instances.push_back(this); if (s_instances==NULL)
s_instances= new std::vector<GenericMap*>;
for(unsigned int i = 0; i < NB_ORBITS; ++i) s_instances->push_back(this);
{
m_attribs[i].setOrbit(i) ;
m_attribs[i].setRegistry(m_attributes_registry_map) ;
}
for(unsigned int i = 0; i < NB_THREAD; ++i) if (s_vdartsBuffers == NULL)
{ {
if (s_vdartsBuffers[i].capacity()<8) s_vdartsBuffers = new std::vector< std::vector<Dart>* >[NB_THREAD];
s_vintsBuffers = new std::vector< std::vector<unsigned int>* >[NB_THREAD];
for(unsigned int i = 0; i < NB_THREAD; ++i)
{ {
s_vdartsBuffers[i].reserve(8); s_vdartsBuffers[i].reserve(8);
s_vintsBuffers[i].reserve(8); s_vintsBuffers[i].reserve(8);
// prealloc ? // prealloc ?
} }
} }
for(unsigned int i = 0; i < NB_ORBITS; ++i)
{
m_attribs[i].setOrbit(i) ;
m_attribs[i].setRegistry(m_attributes_registry_map) ;
}
init(); init();
} }
...@@ -148,8 +157,10 @@ GenericMap::~GenericMap() ...@@ -148,8 +157,10 @@ GenericMap::~GenericMap()
} }
// remove instance for table // remove instance of table
std::remove (s_instances.begin(), s_instances.end(), this); auto it = std::find(s_instances->begin(), s_instances->end(), this);
*it = s_instances->back();
s_instances->pop_back();
} }
void GenericMap::init() void GenericMap::init()
......
Markdown is supported
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