Commit c400df5d authored by Jehferson Mello's avatar Jehferson Mello
Browse files

fixup! Fixed an issue where CPU implementations weren't running properly consecutively

parent 3773d3da
......@@ -279,7 +279,7 @@ RGBA getColour(const Vec4f& steps)
*
******************************************************************************/
Vec4f trace(const Camera& cam, const Screen& s, int x, int y, const estimatorFunction& f)
Vec4f trace(const Camera& cam, const Screen& s, size_t x, size_t y, const estimatorFunction& f)
{
/**
* This function taken from
......@@ -329,7 +329,6 @@ void traceRegion(colourVec& data,
bool FracGen::Generate(int width, int height)
{
static std::atomic<int> h {0};
bool finishedGeneration = false;
int heightStep = bench ? height : 10;
......@@ -367,19 +366,19 @@ bool FracGen::Generate(int width, int height)
// Minor optimization in TBB: Since we can define the range here, we don't need to check bounds in
// traceRegion. This is very similar to how SYCL and OpenCL do things
tbb::blocked_range2d<size_t,size_t> range(h.load(), std::min(h.load()+heightStep, height), 0, width);
tbb::blocked_range2d<size_t,size_t> range(lastHeight, std::min(lastHeight+heightStep, static_cast<size_t>(height)), 0, width);
tbb::parallel_for(range, tbbTrace);
h+= heightStep;
lastHeight+= heightStep;
/*
* TBB doesn't seem to like the way of doing things where I know how
* many tasks there are and am collecting the return from them.
* At least not in the initial tutorials and beginner documentation
*/
if (h >=height)
if (lastHeight >=static_cast<size_t>(height) )
{
h.store(0);
lastHeight = 0;
finishedGeneration = true;
}
......@@ -389,6 +388,7 @@ bool FracGen::Generate(int width, int height)
FracGen::FracGen(bool benching, size_t width, size_t height)
: bench{benching}
, cam{new Camera}
, lastHeight{0}
{
outBuffer = std::make_shared< colourVec >(width*height);
......
......@@ -32,6 +32,8 @@ private:
bool bench;
std::shared_ptr<Camera> cam;
FracPtr outBuffer;
size_t lastHeight;
};
......
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