Assignment 5: Mandelbrot

I suppose everybody needs to implement Mandelbrot sometime... so, here we are.

Here's a very simple version of the well-known Mandelbrot computation: mandel.c. Your task is simply to make it somewhat faster by using either OpenMP or OpenACC.

If you are a graduate student, you will be expected to produce two versions: one using OpenMP and the other using OpenACC. You also must give a very brief (~5 minute) talk in the final exam timeslot describing how those versions worked and tradeoffs between them. Undergraduates just pick one and don't have to give a talk.

The program takes a first command line argument which must be a P6-format PPM image file. That file is mapped and overwritten by the color Madelbrot image. A 3840x2160 image generated by the program from man.ppm is:

Optionally, it takes four more arguments that are the coordinates to render for the Mandelbrot.

What To Do

The parallelism should come in parallelizing the loop:

for (y=0; y<tall; ++y) { ... }

However, you could instead parallelize the x loop. It's your choice.

As a reference for how to compile using OpenACC, here's a simple OpenACC version of our little pi benchmark:

#include <stdio.h>

#define N 2000000000

#define vl 1024

int main(void) {

  double pi = 0.0f;
  long long i;

#pragma acc parallel vector_length(vl) 
#pragma acc loop reduction(+:pi)
  for (i=0; i<N; i++) {
    double t= (double)((i+0.5)/N);
    pi +=4.0/(1.0+t*t);
  }
#pragma acc end parallel

  printf("pi=%11.10f\n",pi/N);

  return 0;

}

Compiling that with OpenACC looks like:

gcc pi.c -fopenacc -foffload=nvptx-none -O3 -foffload="-03" -o pi

Incidentally, that will generate a warning message saying it's ignoring the 1024 vector length and using 32 instead... but that should be harmless. If it causes problems, alternatively, just say:

gcc pi.c -fopenacc -O3 -o pi

Either way, the speedup for the pi computation is about 20X. Compiled without the OpenACC directive, it takes 24.2s to run, while it takes just 1.2s using OpenACC (about half of which is the set-up time to ship things to/from the GPU).

Due Dates

The recommended due date for this assignment is before class, Friday, December 13, 2019. This submission window will close when final exam timeslot begins on Monday, December 16, 2019.

Submission Procedure

For each project, you will be submitting a tarball (i.e., a file with the name ending in .tar or .tgz) that contains all things relevant to your work on the project. Minimally, each project tarball includes the source code for the project and a semi-formal "implementors notes" document as a PDF named notes.pdf (this is following the same guidelines used for CPE480). Your implementors notes for this project must explain why you decided to implement this using OpenMP or OpenACC and not the other choice. For this particular project, I would expect a source file still named mandel.c and that you would submit a tarball including the source, Implementor's Nots, and a makefile.

Submit your tarball below. The file can be either an ordinary .tar file created using tar cvf file.tar yourprojectfiles or a compressed .tgz file file created using tar zcvf file.tgz yourprojectfiles. Be careful about using * as a shorthand in listing yourprojectfiles on the command line, because if the output tar file is listed in the expansion, the result can be an infinite file (which is not ok).

Your account is
Your password is

Your section is EE599-002 (undergrad) EE699-002 (grad)


EE599/699 GPU & Multi-Core Computing