GithubHelp home page GithubHelp logo

harite / mpi-checker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 0ax1/mpi-checker

0.0 3.0 0.0 1.77 MB

A static analysis checker for MPI code written in C using Clang's Static Analyzer.

Python 2.15% Shell 5.42% C++ 75.33% C 16.90% CMake 0.19%

mpi-checker's Introduction

MPI-Checker

A static analysis checker for MPI code written in C using Clang's Static Analyzer.


MPI-Checker is currently in the process of being merged into Clang.

Integrated checks

AST-Checks

  • unmatched point-to-point call: Point-to-point calls without a matching partner.
  • unreachable call: Unreachable calls caused by deadlocks from blocking calls.
  • type mismatch: Buffer type and specified MPI type do not match.
  • incorrect buffer referencing: B-type is incorrectly referenced when passed to an MPI function.
  • invalid argument type: Non integer type used where only integer types are allowed.
  • collective call in rank branch: Collective call inside a rank branch.

Path-Sensitive-Checks

  • double nonblocking: Double request usage of nonblocking calls without intermediate wait.
  • double wait : Double wait on the same request without intermediate nonblocking call.
  • missing wait: Nonblocking call without matching wait.
  • unmatched wait: Waiting for a request that was never used by a nonblocking call.

Point-to-Point Schema Validation

If only additions for an argument are used, operands are accepted as a match if they appear as a permutation. Else if subtractions are used, operands have to be in the same order. To match point to point calls, the checker has to make some assumptions how arguments are specified. To match variables across cases and functions, the same variable name has to be used. For the rank argument, the checker expects the last operator to be "inverse" and the last operand to be equal. If none except the last operator are additions also rank operands (excluding the last) are matched if they appear as a permutation:
MPI_Isend(&buf, 1, MPI_INT, f() + N + 3 + rank + 1, 0, MPI_COMM_WORLD, &sendReq1);
MPI_Irecv(&buf, 1, MPI_INT, N + f() + 3 + rank - 1, 0, MPI_COMM_WORLD, &recvReq1);

Rank Variables

Rank variables are identified as such if they get passed to MPI_Comm_rank. Different rank variables can be used within translation unit. They can be a common integer variable or used as a member in a struct. Rank variables are not detected if initialized in another translation unit, than the one they are used in.

int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

if (rank == 0) {...}
else if (rank == 1) {...}

Prerequisites

Current versions of: your default compiler, zsh, svn, git, cmake, ninja, sed (install gnu-sed with brew if you're on osx)

Installation

Download [fullSetup.sh] (https://raw.githubusercontent.com/0ax1/MPI-Checker/master/setup/fullSetup.sh), make it executable with chmod +x and run it to setup LLVM 3.7 with Clang and MPI-Checker. This will download, config and build all components in ./llvm37.

In "one line": wget https://raw.githubusercontent.com/0ax1/MPI-Checker/master/setup/fullSetup.sh && chmod +x fullSetup.sh && ./fullSetup.sh && rm fullSetup.sh

If you want libcxx or the compiler-rt to be included you can comment them in, removing # from # svn co (libcxx|compiler-rt) in fullSetup.sh.

If you have the LLVM 3.7 source already, cd to the top of the repository, execute [addMPI-Checker.sh] (https://raw.githubusercontent.com/0ax1/MPI-Checker/master/setup/addMPI-Checker.sh) and then rerun your build system manually.

Finally add these locations to your search path:
llvm37/build/release/bin
llvm37/repo/tools/clang/tools/scan-build
llvm37/repo/tools/clang/tools/scan-view

Update

To update MPI-Checker call git pull in llvm37/repo/tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker. Then run ninja && ninja ClangUnitTests in llvm37/build/release.

Examples

Have a look at the examples folder.

Tests

See the tests folder.

Limitations

  • MPI related logic must be enclosed within the scope of a translation unit. This stems from the general limitation of Clang's Static Analyzer to analyze one translation unit in isolation.
  • Unreachable calls can only be detected if caused by blocking MPI calls. The reason for this is that point-to-point schema validation is currently achieved by non path-sensitive (ast) analysis while request var usage must be checked with path-sensitive analysis. So deadlocks caused by waits can not be detected.
  • There can't be any assumptions made at compile time about MPI_Waitany and MPI_Waitsome, since their effect depends on what is done at runtime. Because of that, they are not taken into account.
  • The analysis is limited to C. Analyzing C++ code is currently not supported.

mpi-checker's People

Watchers

harite avatar James Cloos avatar  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.