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)
position = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
int nb = 8;
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, nb, nb, 1);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 0.0f);
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, nb, nb, nb);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
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
}
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);
}
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);
}
......
......@@ -98,9 +98,13 @@ protected:
static std::map<std::string, RegisteredBaseAttribute*>* m_attributes_registry_map;
static int m_nbInstances;
// TODO RELEASE MEMORY
static std::vector< std::vector<Dart>* > s_vdartsBuffers[NB_ORBITS];
static std::vector< std::vector<unsigned int>* > s_vintsBuffers[NB_ORBITS];
// buffer for less memory allocation
static std::vector< std::vector<Dart>* >* s_vdartsBuffers;
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
......@@ -130,9 +134,6 @@ protected:
std::multimap<AttributeMultiVectorGen*, AttributeHandlerGen*> attributeHandlers ; // TODO think of MT (AttributeHandler creation & release are not thread safe!)
std::mutex attributeHandlersMutex;
// table of instancied maps for Dart/CellMarker release
static std::vector<GenericMap*> s_instances;
public:
static const unsigned int UNKNOWN_ATTRIB = AttributeContainer::UNKNOWN ;
......@@ -142,9 +143,11 @@ public:
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)
return true;
}
return false;
}
......
......@@ -41,16 +41,18 @@ namespace Parallel
int NumberOfThreads = getSystemNumberOfCores();
}
std::map<std::string, RegisteredBaseAttribute*>* GenericMap::m_attributes_registry_map = NULL;
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()
{
......@@ -93,23 +95,30 @@ GenericMap::GenericMap()
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)
{
m_attribs[i].setOrbit(i) ;
m_attribs[i].setRegistry(m_attributes_registry_map) ;
}
s_instances->push_back(this);
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_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();
}
......@@ -148,8 +157,10 @@ GenericMap::~GenericMap()
}
// remove instance for table
std::remove (s_instances.begin(), s_instances.end(), this);
// remove instance of table
auto it = std::find(s_instances->begin(), s_instances->end(), this);
*it = s_instances->back();
s_instances->pop_back();
}
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