Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

2. Usage

Hervé Yviquel edited this page May 20, 2017 · 7 revisions

Describe the application

First, you need to describe your application using the OpenMP accelerator model. As an example, the code below presents a simple program loop describing a matrix multiplication which was annotated with OpenMP directives in order to offload the computation to the cloud. In the OpenMP abstract accelerator model, the target clause defines the portion of the program that will be executed by the target device. The map clause details the mapping of the data between the host and the target device: inputs (A and B) are mapped to the target, and the output (C) is mapped from the target.

int MatMul(float *A, float *B, float *C) {
  #pragma omp target map(to: A[:N*N], B[:N*N]) map(from: C[:N*N]) device(CLOUD)
  #pragma omp parallel for
  for(int i=0; i < N; ++i)
    for (int j = 0; j < N; ++j)
      C[i * N + j] = 0;
      for (int k = 0; k < N; ++k)
        C[i * N + j] += A[i * N + k] * B[k * N + j];
  return 0;
}

The full specifications of OpenMP (including the construct to program accelerators) are available here. Just remember that OmpCloud does not support all constructs as presented by this overview of the supported constructs.

Compile the application

To use our cloud offloading workflow for your own program, you can compile your code by running something like:

clang -fopenmp -omptargets=x86_64-unknown-linux-spark mat-mul.c -o mat-mul

Notice that it requires our custom version of Clang. The instructions to install it are available here.

Instantiate a cluster

If you want to offload the computation to the cloud, you previously need to setup a Spark cluster on a cloud provider. In case you only want to test OmpCloud on your computer, you can download Spark, extract it, and add the bin folder to your PATH.

Configure the OmpCloud runtime

You need to configure the credential to allow your application to offload computation to the newly created cluster. The environment variable $OMPCLOUD_CONF_PATH defines the path of the configuration file to use when offloading the computation. This way, you can easily switch from one configuration to another by changing its value.

export OMPCLOUD_CONF_PATH="path/to/config/file.ini"

The documentation describing the configuration file is available here. Additionally, there is some examples available here.

Run the program

Just run it!

./mat-mul

And you should see some debug message in your console showing the evolution of the execution...