internship - final presentation (26-08-2015)
TRANSCRIPT
Goal
● C++ w/ OpenMP -> Clang’s AST + (Data Structure)
○ (Data Structure) -> TGFF
○ (Data Structure) -> DOT
○ (Data Structure) -> DARTS
Goal
● C++ w/ OpenMP -> Clang’s AST + (Data Structure)
○ (Data Structure) -> TGFF
○ (Data Structure) -> DOT
○ (Data Structure) -> DARTS
(Data Structure)
● LinkedList of Tasks
○ Task -> Task -> … -> Task -> null
● 3 Types of Tasks
○ CallTask, StmtGroupTask, ParallelTask
StmtGroupTask & ParallelTask
● StmtGroupTask
○ Group of non-parallel, non-OpenMP Stmts
● ParallelTask
○ Group of regular or OMP-directive parallel Stmts
C++ w/ OpenMP -> Clang’s AST
void f(int n) {
int a = 1; int b = 2;
# pragma omp parallel
{
int c = 3; int d = 4;
# pragma omp for
for(int i = 0; i < n; i++)
{ int e = 5; int f = 6; int g = 7; }
// implicit barrier
int h = 8;
# pragma omp single
{ int i = 9; }
// implicit barrier
int j = 10;
# pragma omp single
{ int k = 11; }
}
// combined implicit barrier
int l = 12;
}
● Interface for traversing clang’s AST
RecursiveASTVisitor
Class Hierarchy
bool TheVisitor::TraverseDecl(clang::Decl *d) { if(!d) return true; else if(!isa<clang::FunctionDecl>(d)) return true;
// create the function start CallTask clang::FunctionDecl *f = llvm::cast <clang::FunctionDecl>(d); this->task = new CallTask(f, true);
// traverse children nodes RecursiveASTVisitor::TraverseDecl(d); // move to next sibling // or back go back to parent
// create the function end CallTask Task *tmp = new CallTask(f, false); this->task->setChild(tmp); this->task = nullptr; // good practice return true; }
Goal
● C++ w/ OpenMP -> Clang’s AST + (Data Structure)
○ (Data Structure) -> TGFF
○ (Data Structure) -> DOT
○ (Data Structure) -> DARTS
Goal
● C++ w/ OpenMP -> Clang’s AST + (Data Structure)
○ (Data Structure) -> TGFF
○ (Data Structure) -> DOT
○ (Data Structure) -> DARTS
(Data Structure) -> TGFF
● List of Tasks
○ ParallelTask is broken down into N StmtGroupTasks
(for N number of threads)
● List of Arcs
○ Synonymous with dependencies
(Data Structure) -> DARTS
● Modular1. Derived Codelet classes for each unique Task2. A Single ThreadedProcedure for the entire Task
Graph3. Definition of each derived codelet class’s fire
method4. main entry function
Script to Execute Tool#!/bin/sh
CLANGBUILD=~/Documents/clang-llvm/buildOMP=~/Documents/omp-darts-compiler/ompdarts-sean/taskgraph/functions/hello.cppDARTSDIR=~/CAPSL/DARTSAPP=TaskGraphTP
rm $DARTSDIR/apps/$APP/$APP.cpp
# run tool# Options:# numthreads (default is 2)# tgff# dot# darts# Examples:# $BUILD/bin/ompdarts-taskgraph-generator $PROGRAM -numthreads=5 -tgff -dot -darts -- -Xclang -fopenmp# $BUILD/bin/ompdarts-taskgraph-generator $PROGRAM -- -Xclang -fopenmp
$CLANGBUILD/bin/ompdarts-taskgraph-generator $OMP -numthreads=2 -darts -- -Xclang -fopenmp >> $DARTSDIR/apps/$APP/$APP.cpp
TMP=$PWDcd $DARTSDIR/buildmake$DARTSDIR/build/apps/$APP/$APPcd $TMP
DARTS ExampleTaskGraphTP()Fired codelet startFired codelet sg0Fired codelet call0Fired codelet sg1_t0Fired codelet sg1_t1Fired codelet for0_t0Fired codelet for0_t1Fired codelet barrier0Fired codelet sg2_t0Fired codelet sg2_t1Fired codelet single0_t0Skipped codelet single0_t1Fired codelet barrier1Fired codelet single1_t0Skipped codelet single1_t1Fired codelet barrier2Fired codelet sg3Fired codelet endTotal Time Taken: 0.00969014 sec
void f(int n) {
int a = 1; int b = 2;
# pragma omp parallel
{
int c = 3; int d = 4;
# pragma omp for
for(int i = 0; i < n; i++)
{ int e = 5; int f = 6; int g = 7; }
// implicit barrier
int h = 8; int i = 9;
# pragma omp single
{ int j = 10; int k = 11; }
// implicit barrier
# pragma omp single
{ int l = 12; }
}
// combined implicit barrier of OMPSingle and OMPParallel
int m = 13;
}