Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 7. Using Automatic Parallelizati... > An Example of Parallelization

An Example of Parallelization

As an example of automatic parallelization and parallelization using OpenMP, we will consider a short code that determines whether each point in a matrix is in or out of the Mandelbrot set. Listing 7.63 shows the code.

Listing 7.63. Code to Determine Whether a Point Is in the Mandelbrot Set

int inSet( double ix, double iy )
{
  int    iterations = 0;
  double x = ix, y = iy;
  double x2 = x*x, y2 = y*y;
  while ( (x2 + y2 < 4) && (iterations < 1000) )  /* Line 9 */
  {
    y = 2*x*y + iy;
    x = x2 – y2 + ix;
    x2= x*x;
    y2= y*y;

    iterations++;
  }
  return iterations;
}


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint