[llvm-dev] Automatic Insertion of OpenACC/OpenMP directives

Fernando Magno Quintao Pereira via llvm-dev llvm-dev at lists.llvm.org
Sat Dec 31 08:33:33 PST 2016


Dear LLVMers,

    we have released a tool that uses LLVM to insert OpenACC or OpenMP
4.0 directives in programs. You can use the tool online here:
http://cuda.dcc.ufmg.br/dawn/. Our tool, dawn-cc, analyzes the LLVM IR
to infer the sizes of memory chunks, and to find dependences within
loops. After that, we use debug information to translate the low-level
information back into annotations that we insert into C/C++ programs.
For instance, if we take a program like this one below:

void saxpy(float a, float *x, float *y, int n) {
  for (int i = 0; i < n; ++i)
    y[i] = a*x[i] + y[i];
}

Then dawn-cc produces the code below:

void saxpy(float a, float *x, float *y, int n) {
  long long int AI1[6];
  AI1[0] = n - 1;
  AI1[1] = 4 * AI1[0];
  AI1[2] = AI1[1] + 4;
  AI1[3] = AI1[2] / 4;
  AI1[4] = (AI1[3] > 0);
  AI1[5] = (AI1[4] ? AI1[3] : 0);
  #pragma acc data pcopy(x[0:AI1[5]],y[0:AI1[5]])
  #pragma acc kernels
  for (int i = 0; i < n; ++i)
    y[i] = a * x[i] + y[i];
}

I was wondering if we could add a link to dawn-cc in the LLVM's
project page (http://llvm.org/ProjectsWithLLVM/). There are a number
of papers that describe what dawn-cc does. The main publication is
this paper:

* Automatic Insertion of Copy Annotation in Data-Parallel Programs -
SBAC-PAD 2016

The array size inference analysis comes from this work:

* Runtime Pointer Disambiguation - OOPSLA 2015

The source code of dawn-cc, including all the static analyses, is available at:

* https://github.com/gleisonsdm/DawnCC-Compiler

And, as I've mentioned, you can try it through an online interface:

* cuda.dcc.ufmg.br/dawn

Feel free to report bugs, or send us questions.

Fernando


More information about the llvm-dev mailing list