Coder Social home page Coder Social logo

ouankou / accparser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from passlab/accparser

0.0 0.0 0.0 1.92 MB

accparser: a standalone OpenACC parser based on ANTLR 4.

License: Other

Shell 0.07% C++ 73.08% C 2.98% ANTLR 19.98% Makefile 1.17% CMake 2.71%

accparser's Introduction

accparser

accparser (ACCP): a standalone OpenACC parser based on ANTLR 4. It supports both C and Fortran. The generated OpenACC AST can be converted to OpenMP AST. The OpenMP AST is represented by OpenMPIR from ompparser.

Prerequisite

accparser requires ANTLR 4 and its C++ runtime, which are available on Ubuntu 20.04 or later. For other systems, they may need to be manually built.

sudo apt update
sudo apt install -y \
    antlr4 \
    libantlr4-runtime-dev \
    build-essential \
    g++ \
    cmake

clang/clang++ and gcc/g++ are both fine.

Build

mkdir build
cd build
cmake ..
make

It will produce a library libaccparser.so and an executable acc_demo.out

Optionally, we can also enable the OpenMP translator.

git submodule update --init
mkdir build
cd build
cmake -DUSE_OMPPARSER=true -DCMAKE_INSTALL_PREFIX=../accparser-install ..
make install

Run

Given a test file foo.txt with the following content to try accparser.

Input:

#pragma acc parallel private(a, b, c)
./acc_demo.out ./foo.txt

The output includes the OpenACC source code, recognized tokens, parse tree, and the OpenACC code unparsed from the generated OpenACC IR.

Output:

======================================
Line: 1
GIVEN INPUT: #pragma acc parallel private(a, b, c)
======================================
TOKEN : TOKEN_STRING
ACC : "acc"
PARALLEL : "parallel"
PRIVATE : "private"
LEFT_PAREN : "("
EXPR : "a"
EXPR : "b"
EXPR : "c"
RIGHT_PAREN : ")"
EOF : "<EOF>"
======================================
PARSE TREE:
(accparallelprivate(abc)<EOF> acc 
        (parallelprivate(abc) 
            (parallelprivate(abc) parallel 
                (private(abc) 
                    (private(abc) 
                        (private(abc) private ( 
                            (abc 
                                (a a) 
                                (b b) 
                                (c c)) )))))) <EOF>)
======================================
GENERATED OUTPUT: #pragma acc parallel private (a, b, c)
======================================

At each line of the parse tree section, the output follows the format (root child_1 child_2 ... child_n). For example, the first line shows that the root is accparallelprivate(abc). Its children include acc and parallelprivate(abc). The latter has its own children that are listed at other lines.

accparser's People

Contributors

ouankou avatar xinyaoyi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.