aboutsummaryrefslogtreecommitdiffhomepage
path: root/demos
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-07-01 14:12:32 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-07-01 14:12:32 +0000
commita356ebd47de5b7120567f2785d27b9f43a774322 (patch)
treec2c2bed9cdbe49522ae304775cd2bdb30d7db59d /demos
parent56d03f181e69588313cf32a4d5c7bab94e3e2cdf (diff)
interleaved rendering balances the load better
Diffstat (limited to 'demos')
-rw-r--r--demos/mandelbrot/mandelbrot.cpp9
-rw-r--r--demos/mandelbrot/mandelbrot.h1
2 files changed, 4 insertions, 6 deletions
diff --git a/demos/mandelbrot/mandelbrot.cpp b/demos/mandelbrot/mandelbrot.cpp
index d73a9eb0b..df892b9d1 100644
--- a/demos/mandelbrot/mandelbrot.cpp
+++ b/demos/mandelbrot/mandelbrot.cpp
@@ -29,13 +29,13 @@ template<typename Real> void MandelbrotThread::render(int img_width, int img_hei
unsigned char *const buffer = widget->buffer;
const double xradius = widget->xradius;
const double yradius = xradius * img_height / img_width;
+ const int threadcount = widget->threadcount;
typedef Eigen::Matrix<Real, 2, 1> Vector2;
Vector2 start(widget->center.x() - widget->xradius, widget->center.y() - yradius);
Vector2 step(2*widget->xradius/img_width, 2*yradius/img_height);
total_iter = 0;
- int slice_height = img_height / widget->threadcount;
- for(int y = id * slice_height; y < (id+1) * slice_height; y++)
+ for(int y = id; y < img_height; y += threadcount)
{
int pix = y * img_width;
@@ -78,7 +78,6 @@ template<typename Real> void MandelbrotThread::render(int img_width, int img_hei
// compute pixel colors
for(int i = 0; i < packetSize; i++)
{
-
buffer[4*(pix+i)] = 255*pix_iter[i]/max_iter;
buffer[4*(pix+i)+1] = 0;
buffer[4*(pix+i)+2] = 0;
@@ -135,8 +134,8 @@ void MandelbrotWidget::paintEvent(QPaintEvent *)
? int(Eigen::ei_packet_traits<float>::size)
: int(Eigen::ei_packet_traits<double>::size);
setWindowTitle(QString("resolution ")+QString::number(xradius*2/width(), 'e', 2)
- +QString(", up to %1 iterations").arg(threads[0]->max_iter)
- +(threads[0]->single_precision ? QString(", single ") : QString(", double "))
+ +QString(", %1 iterations per pixel, ").arg(threads[0]->max_iter)
+ +(threads[0]->single_precision ? QString("single ") : QString("double "))
+QString("precision, ")
+(packetSize==1 ? QString("no vectorization")
: QString("vectorized (%1 per packet)").arg(packetSize)));
diff --git a/demos/mandelbrot/mandelbrot.h b/demos/mandelbrot/mandelbrot.h
index 1468bdca9..c8fad5505 100644
--- a/demos/mandelbrot/mandelbrot.h
+++ b/demos/mandelbrot/mandelbrot.h
@@ -41,7 +41,6 @@ class MandelbrotWidget : public QWidget
void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
- template<typename Real> int render(int max_iter, int resx, int resy);
public:
MandelbrotWidget() : QWidget(), center(0,0), xradius(2),