I have a small physically based renderer where one of the most important task is to generate canonical random numbers. I used have my self-customized random number generator class and it used to give me some bizarre artifacts.
Once i get to know that C++ also started to support the fast radom number generator engine i wanted to give it a try. Unfortunately i am getting the core dumped segmentation fault.
I need to generate random integer numbers and generate the canonical random numbers. I am doing it as follows:
I managed to recreate the segmentation fault. The coding style i followed is mentioned in your previous post. The GDB output is:
[code]
creating image (1024x1024)
creating camera
preparing scene...
BVH construction done in 0.03 seconds
creating ray tracer
Path tracing...
[New Thread 0x7ffff2ae1700 (LWP 5586)]
[New Thread 0x7ffff22e0700 (LWP 5587)]
[New Thread 0x7ffff1adf700 (LWP 5588)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff2ae1700 (LWP 5586)]
0x00007ffff78112f5 in __sincosf (x=0.851227164, sinx=0x7ffff22e20fc, cosx=0x7ffff22e20f8) at ../sysdeps/ieee754/flt-32/s_sincosf.c:52
52 ../sysdeps/ieee754/flt-32/s_sincosf.c: No such file or directory.
Off-hand it seems that the thread 5586 is writing to objects that belong to thread 5587 when they happen to be inaccessible. I'd start by examining your synchronization logic.
void PathTracer::computeImage()
{
std::cout << "Path tracing..." << std::endl;
//map the samples to hemisphere with
//cosine weighted density function
//mSampler->mapSamplesToHemisphere(1);
Timer timer;
Color c;
//get the width and height of the image
int width = mImage->getWidth();
int height = mImage->getHeight();
// Loop over all pixels in the image
#pragma omp parallel for schedule(dynamic,1), private(c)
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
// Raytrace the pixel at (x,y).
c = tracePixel(x,y);
// Store the result in the image.
mImage->setPixel(x,y,c);
}
#pragma omp critical
// Print progress approximately every 5%.
if ((y+1) % (height/20) == 0 || (y+1) == height)
std::cout << (100*(y+1)/height) << "% done" << std::endl;
}
std::cout << "Done in " << timer.stop() << " seconds" << std::endl;
}