From a356ebd47de5b7120567f2785d27b9f43a774322 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Tue, 1 Jul 2008 14:12:32 +0000 Subject: interleaved rendering balances the load better --- demos/mandelbrot/mandelbrot.cpp | 9 ++++----- demos/mandelbrot/mandelbrot.h | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'demos') 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 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 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 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::size) : int(Eigen::ei_packet_traits::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 int render(int max_iter, int resx, int resy); public: MandelbrotWidget() : QWidget(), center(0,0), xradius(2), -- cgit v1.2.3