Skip to content

harite/MPI-Checker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 75.4%
  • C 16.9%
  • Shell 5.4%
  • Python 2.1%
  • CMake 0.2%