MetaFork Logo A Compilation Framework for Concurrency Platforms

Sources for Download

Installation Guide

Click on “” to show the content for each version, and click on “” to hide.

MetaFork version 0.1

Tech reports on fork-join concurrency model

- Specification
- Experimentation
- Manual

Requirements

- Linux systems, i.e. Ubuntu, using bash.
- Lex and Yacc.
- GCC version 4.8.* or later to support CilkPlus, OpenMP.

Installation notes

- This version of MetaFork compilation framework is developed based on a hand-written parser.
- The installation procedure is listed below:
  1. Locate the downloaded package: metafork_distrib_0_1.tgz
  2. tar zxvf metafork_distrib_0_1.tgz
  3. cd metafork/
  4. make translators
  Note that make check can be used to verify that the Metafork translators work correctly with the examples.
- Makefile under the metafork/ folder contains other targets, in particular for testing the translators.

Shell configuration (with bash)

- The following environment variables and directory pathes must be added in order to compile and run the MetaFork framework.
export PATH=<yourpath>/src/bin:$PATH
- Replace <yourpath> by the path where the metafork/ folder is.
- Run source ~/.bashrc once it is done.

MetaFork version 0.0

Tech reports on fork-join concurrency model

- Specification
- Experi mentation
- Manual

Requirements

- Linux systems, i.e. Ubuntu, using bash.
- Lex and Yacc.
- GCC version 4.8.* or later to support CilkPlus, OpenMP.

Installation notes

- This version of MetaFork compilation framework is developed based on a hand-written parser.
- The installation procedure is listed below:
  1. Locate the downloaded package: metafork_distrib_0_0.tgz
  2. tar zxvf metafork_distrib_0_0.tgz
  3. cd metafork/
  4. make translators
  Note that make check can be used to verify that the Metafork translators work correctly with the examples.
- Makefile under the metafork/ folder contains other targets, in particular for testing the translators.

Shell configuration (with bash)

- The following environment variables and directory pathes must be added in order to compile and run the MetaFork framework.
export PATH=<yourpath>/src/bin:$PATH
- Replace <yourpath> by the path where the metafork/ folder is.
- Run source ~/.bashrc once it is done.

MetaFork version 1.0

Requirements

- Linux systems, i.e. Ubuntu, using bash.
- Clang 3.6.* or later.
- GCC version 4.8.* or later to support CilkPlus, OpenMP and LLVM.

Installation notes

- This new version of MetaFork compilation framework is developed based on LLVM/Clang. Building LLVM/Clang is part of building MetaFork.
- The installation procedure is listed below:
  1. Locate the downloaded package: MetaFork_version_1.0.tar
  2. tar xvf MetaFork_version_1.0.tar
  3. cd MetaFork_version_1.0/
  4. cd build/
  5. cmake -G “Unix Makefiles” ..
  6. make
- Building LLVM/Clang may require to update or install several libraries on your linux system.

Shell configuration (with bash)

- The following environment variables and directory pathes must be added in order to compile and run the MetaFork framework.
export PATH=<yourpath>/MetaFork_version_1.0/build/bin:$PATH
export C_INCLUDE_PATH=<yourpath>/MetaFork_version_1.0/tools/clang/include/clang/AST/:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=<yourpath>/MetaFork_version_1.0/tools/clang/include/clang/AST/:$CPLUS_INCLUDE_PATH
- Replace <yourpath> by the path where the MetaFork_version_1.0/ folder is.
- Run source ~/.bashrc once it is done.

Using the MetaFork translators

- Each translator follows the same synopsis:
<translator> <sourcefile> -- <flag> <headerfile_path>
- Some explanations:
  1. All the contents after “--” will be passed to the frontend of LLVM/Clang.
  2. <flag> is used to activate the keywords specific to the source language; it (in different languages) can be -fcilkplus, -fmetafork or -fopenmp=libiomp5.
  3. Since we are doing source-to-source compilation, the user should specify the path of her/his header-files. This could be done using the flag -I to include the directory containing those header-files.
- For example, if you want to translate an OpenMP file “test.cpp” to CilkPlus code, the steps should be:
openmptometa test.cpp -- -fopenmp=libiomp5 -I<your_headerfile_path>
metatocilk test.cpp -- -fmetafork -I<your_headerfile_path>
- If you want to translate an CilkPlus file “test.cpp” to OpenMP code, the steps should be:
cilktometa test.cpp -- -fcilkplus -I<your_headerfile_path>
metatoopenmp test.cpp -- -fmetafork -I<your_headerfile_path>

MetaFork version 2.0

Requirements

- Linux systems, i.e. Ubuntu, using bash.
- Clang 3.6.*
- GCC version 4.8.* or later to support CilkPlus, OpenMP and LLVM.

Installation of Clang/LLVM

- The installation procedure is listed below:
  1. Downloaded package: http://llvm.org/releases/download.html
  2. download "Clang for Ubuntu 14.04 (.sig)
  3. tar xvf clang+llvm-3.6.2-x86_64-linux-gnu-ubuntu-14.04.tar.xz

Environment configuration of Clang/LLVM (with bash)

export CLANG_ROOT=<yourpath>
export PATH=$CLANG_ROOT/bin:$PATH
export LD_LIBRARY_PATH=$CLANG_ROOT/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=$CLANG_ROOT/lib:$LIBRARY_PATH
export C_INCLUDE_PATH=$CLANG_ROOT/include/:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$CLANG_ROOT/include/:$CPLUS_INCLUDE_PATH
- Replace <yourpath> by the path where the clang+llvm-3.6.2-x86_64-linux-gnu-ubuntu-14.04/ folder is.
- Run source ~/.bashrc once it is done.

Installation of MetaFork

- This new version of MetaFork compilation framework is developed based on LLVM/Clang.
- The installation procedure is listed below:
  1. Downloaded package: MetaFork_version_2.0.tar.gz
  2. tar xvf MetaFork_version_2.0.tar.gz
  3. cd distrib/
  4. make
  5. make install
  6. set "Environment configuration of MetaFork (with bash)"
  7. make obj (correctness check)

Environment configuration of MetaFork (with bash)

- The following environment variables and directory pathes must be added in order to compile and run the MetaFork framework.
export PATH=<yourpath>/install/bin:$PATH
export C_INCLUDE_PATH=<yourpath>/install/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=<yourpath>/install/include:$CPLUS_INCLUDE_PATH
- Replace <yourpath> by the path where the distrib folder is.
- Run source ~/.bashrc once it is done.

Using the MetaFork translators

- Each translator follows the same synopsis:
<translator> <sourcefile> -- <flag> <headerfile_path>
- Some explanations:
  1. All the contents after “--” will be passed to the frontend of LLVM/Clang.
  2. Since we are doing source-to-source compilation, the user should specify the path of her/his header-files. This could be done using the flag -I to include the directory containing those header-files. Also users could specify the output file name after “ -o ”flag.
- For example, if you want to translate an OpenMP file “test.cpp” to CilkPlus code, the steps should be:
openmptometa test.cpp -o output1.cpp -- -Xclang -fopenmp=libiomp5 -I<your_headerfile_path>
metatocilk output1.cpp -o output2.cpp -- -include PragmaMetatoCilk.h -I<your_headerfile_path>
- If you want to translate an CilkPlus file “test.cpp” to OpenMP code, the steps should be:
cilktometa test.cpp -o output1.cpp -- -include PragmaCilk.h -I<your_headerfile_path>
metatoopenmp output1.cpp -o output2.cpp -- -include PragmaMetatoOpenMP.h -I<your_headerfile_path>

MetaFork-to-CUDA code generator

Requirements

- Linux systems, i.e. Ubuntu, using bash.
- automake, autoconf, libtool
- Clang 3.6.*
- GMP

Installation

  • Download package: metafork-ppcg.tar
  • tar xvf metafork-ppcg.tar
  • cd metafork-ppcg
  • ./autogen.sh
  • ./configure CXXFLAGS='-fno-rtti' --enable-metafork
  • ./options
  • make by default, using global memory
    make mem=mlocal using shared memory

Environment configuration

In .bashrc file, add the following lines:
  • export METAFORKPPCG_ROOT=/your/metafork-ppcg/path
  • export PATH=$METAFORKPPCG_ROOT/.libs:$PATH
  • export LIBRARY_PATH=$METAFORKPPCG_ROOT/isl/.libs/:$LIBRARY_PATH
  • export LD_LIBRARY_PATH=$METAFORKPPCG_ROOT/isl/.libs/:$LD_LIBRARY_PATH
  • export LIBRARY_PATH=$METAFORKPPCG_ROOT/pet/.libs/:$LIBRARY_PATH
  • export LD_LIBRARY_PATH=$METAFORKPPCG_ROOT/pet/.libs/:$LD_LIBRARY_PATH
  • export CPLUS_INCLUDE_PATH=$METAFORKPPCG_ROOT/pet/include/:$CPLUS_INCLUDE_PATH
  • export C_INCLUDE_PATH=$METAFORKPPCG_ROOT/pet/include/:$C_INCLUDE_PATH
- Replace /your/metafork-ppcg/path by the path where the metafork-ppcg folder is.
- Run source ~/.bashrc once it is done.

Specifications

It appears you don't have a PDF plugin for this browser. No biggie... you can click here to download the PDF file.

An example: 1D Jacobi

C code:
for (int t = 0; t < T; ++t) {
    for (int i = 0; i < N-2; ++i)
        b[i+1] = (a[i] + a[i+1] + a[i+2]) / 3;
    for (int i = 0; i < N-2; ++i)
        a[i+1] = b[i+1];
}
MetaFork code:
// N is the input array size, which is 2^k+2, k is a positive integer
// B is the number of threads per thread-block
int ub_v = (N - 2) / B;

meta_schedule {
    for (int t = 0; t < T; ++t) {
        meta_for (int v = 0; v < ub_v; v++)
            meta_for (int u = 0; u < B; u++) {
                int p = v * B + u;
                b[p+1] = (a[p] + a[p+1] + a[p+2]) / 3;
            }

        meta_for (int v = 0; v < ub_v; v++)
            meta_for (int u = 0; u < B; u++) {
                int w = v * B + u;
                a[w+1] = b[w+1];
            }
    }
}
Generated CUDA kernel code using global memory:
__global__ void kernel0(int *a, int *b, int N, int T, int ub_v, 
                                                 int B, int c0) {
    int b0 = blockIdx.x;
    int t0 = threadIdx.x;
    int private_p;

    #define floord(n,d) (((n)<0) ? -((-(n)+(d)-1)/(d)) : (n)/(d))
    for (int c1 = b0; c1 < ub_v; c1 += 32768) {
        private_p = (((c1) * (B)) + (t0));
        b[private_p + 1] = (((a[private_p] + a[private_p + 1]) 
                          + a[private_p + 2]) / 3);
        __syncthreads();
    }
}

__global__ void kernel1(int *a, int *b, int N, int T, int ub_v, 
                                                 int B, int c0) {
    int b0 = blockIdx.x;
    int t0 = threadIdx.x;
    int private_w;

    #define floord(n,d) (((n)<0) ? -((-(n)+(d)-1)/(d)) : (n)/(d))
    for (int c1 = b0; c1 < ub_v; c1 += 32768) {
        private_w = (((c1) * (B)) + (t0));
        a[private_w + 1] = b[private_w + 1];
        __syncthreads();
    }
}
- jacobi.c
- jacobi_host.cu
- jacobi_kernel.cu
- jacobi_kernel.hu
- Makefile
Generated CUDA kernel code using shared memory:
__global__ void kernel0(int *a, int *b, int N, int T, int ub_v, int B, int c0) {
    int b0 = blockIdx.x;
    int t0 = threadIdx.x;
    int private_p;
    __shared__ int shared_a[BLOCK_0+2];

    #define floord(n,d) (((n)<0) ? -((-(n)+(d)-1)/(d)) : (n)/(d))
    #define min(x,y)    ((x) < (y) ? (x) : (y))
    for (int c1 = b0; c1 < ub_v; c1 += 32768) {
        for (int c2 = t0; c2 <= min(B + 1, N - B * c1 - 1); c2 += B)
            shared_a[c2] = a[B * c1 + c2];
        __syncthreads();
        private_p = (((c1) * (B)) + (t0));
        b[private_p + 1] = (((shared_a[private_p - B * c1] + shared_a[private_p - B * c1 + 1]) 
                          + shared_a[private_p - B * c1 + 2]) / 3);
        __syncthreads();
    }
}

__global__ void kernel1(int *a, int *b, int N, int T, int ub_v, int B, int c0) {
    int b0 = blockIdx.x;
    int t0 = threadIdx.x;
    int private_w;
    __shared__ int shared_b[BLOCK_0];

    #define floord(n,d) (((n)<0) ? -((-(n)+(d)-1)/(d)) : (n)/(d))
    for (int c1 = b0; c1 < ub_v; c1 += 32768) {
        if (N >= t0 + B * c1 + 2)
            shared_b[t0] = b[t0 + B * c1 + 1];
        __syncthreads();
        private_w = (((c1) * (B)) + (t0));
        a[private_w + 1] = shared_b[private_w - B * c1];
        __syncthreads();
    }
}
- jacobi.c
- jacobi_host.cu
- jacobi_kernel.cu
- jacobi_kernel.hu
- Makefile

ORCCA Lab, Department of Computer Science, The University of Western Ontario, London, Ontario, Canada N6A 5B7