This codeblock
try
{
for(int i=0;i<N;i++)
{
std::shared_ptr<std::random_device> tmp=std::shared_ptr<std::random_device>(new std::random_device);
rdThread.push_back(tmp);
rngThread.push_back(std::mt19937((*rdThread[rdThread.size()-1])()));
distThread.push_back(std::uniform_real_distribution<T>(0,1));
}
}
catch(std::exception & ex)
{
std::cout<<ex.what()<<std::endl;
}
produces an exception when N is 2000 or similar high value. Error message of runtime exception is:
random_device::random_device(const std::string&)
Segmentation fault (core dumped)
I can't find if error is about some std::string that random_device uses or gcc's internal limit on this number generator. But push_back into vector seems to be using it somehow.
Is it possible that a compiler may not support a few thousands of random number generators?
rdThread
is random_device vector.
rngThread
is vector of mt19937.
distThread
is a vector of uniform real distributions.
All are working fine for less than 2000 items and I don't know what this error message is saying. Its about copy constructor I guess but I don't use any string to construct anything for it.
- g++ (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1
- C++1y dialect is on
- Optimization O3 is on
Aucun commentaire:
Enregistrer un commentaire