Home | History | Annotate | Download | only in MPI-Checker
      1 //===-- MPIFunctionClassifier.h - classifies MPI functions ----*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 ///
     10 /// \file
     11 /// This file defines functionality to identify and classify MPI functions.
     12 ///
     13 //===----------------------------------------------------------------------===//
     14 
     15 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_MPICHECKER_MPIFUNCTIONCLASSIFIER_H
     16 #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_MPICHECKER_MPIFUNCTIONCLASSIFIER_H
     17 
     18 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
     19 
     20 namespace clang {
     21 namespace ento {
     22 namespace mpi {
     23 
     24 class MPIFunctionClassifier {
     25 public:
     26   MPIFunctionClassifier(ASTContext &ASTCtx) { identifierInit(ASTCtx); }
     27 
     28   // general identifiers
     29   bool isMPIType(const IdentifierInfo *const IdentInfo) const;
     30   bool isNonBlockingType(const IdentifierInfo *const IdentInfo) const;
     31 
     32   // point-to-point identifiers
     33   bool isPointToPointType(const IdentifierInfo *const IdentInfo) const;
     34 
     35   // collective identifiers
     36   bool isCollectiveType(const IdentifierInfo *const IdentInfo) const;
     37   bool isCollToColl(const IdentifierInfo *const IdentInfo) const;
     38   bool isScatterType(const IdentifierInfo *const IdentInfo) const;
     39   bool isGatherType(const IdentifierInfo *const IdentInfo) const;
     40   bool isAllgatherType(const IdentifierInfo *const IdentInfo) const;
     41   bool isAlltoallType(const IdentifierInfo *const IdentInfo) const;
     42   bool isReduceType(const IdentifierInfo *const IdentInfo) const;
     43   bool isBcastType(const IdentifierInfo *const IdentInfo) const;
     44 
     45   // additional identifiers
     46   bool isMPI_Wait(const IdentifierInfo *const IdentInfo) const;
     47   bool isMPI_Waitall(const IdentifierInfo *const IdentInfo) const;
     48   bool isWaitType(const IdentifierInfo *const IdentInfo) const;
     49 
     50 private:
     51   // Initializes function identifiers, to recognize them during analysis.
     52   void identifierInit(ASTContext &ASTCtx);
     53   void initPointToPointIdentifiers(ASTContext &ASTCtx);
     54   void initCollectiveIdentifiers(ASTContext &ASTCtx);
     55   void initAdditionalIdentifiers(ASTContext &ASTCtx);
     56 
     57   // The containers are used, to enable classification of MPI-functions during
     58   // analysis.
     59   llvm::SmallVector<IdentifierInfo *, 12> MPINonBlockingTypes;
     60 
     61   llvm::SmallVector<IdentifierInfo *, 10> MPIPointToPointTypes;
     62   llvm::SmallVector<IdentifierInfo *, 16> MPICollectiveTypes;
     63 
     64   llvm::SmallVector<IdentifierInfo *, 4> MPIPointToCollTypes;
     65   llvm::SmallVector<IdentifierInfo *, 4> MPICollToPointTypes;
     66   llvm::SmallVector<IdentifierInfo *, 6> MPICollToCollTypes;
     67 
     68   llvm::SmallVector<IdentifierInfo *, 32> MPIType;
     69 
     70   // point-to-point functions
     71   IdentifierInfo *IdentInfo_MPI_Send = nullptr, *IdentInfo_MPI_Isend = nullptr,
     72       *IdentInfo_MPI_Ssend = nullptr, *IdentInfo_MPI_Issend = nullptr,
     73       *IdentInfo_MPI_Bsend = nullptr, *IdentInfo_MPI_Ibsend = nullptr,
     74       *IdentInfo_MPI_Rsend = nullptr, *IdentInfo_MPI_Irsend = nullptr,
     75       *IdentInfo_MPI_Recv = nullptr, *IdentInfo_MPI_Irecv = nullptr;
     76 
     77   // collective functions
     78   IdentifierInfo *IdentInfo_MPI_Scatter = nullptr,
     79       *IdentInfo_MPI_Iscatter = nullptr, *IdentInfo_MPI_Gather = nullptr,
     80       *IdentInfo_MPI_Igather = nullptr, *IdentInfo_MPI_Allgather = nullptr,
     81       *IdentInfo_MPI_Iallgather = nullptr, *IdentInfo_MPI_Bcast = nullptr,
     82       *IdentInfo_MPI_Ibcast = nullptr, *IdentInfo_MPI_Reduce = nullptr,
     83       *IdentInfo_MPI_Ireduce = nullptr, *IdentInfo_MPI_Allreduce = nullptr,
     84       *IdentInfo_MPI_Iallreduce = nullptr, *IdentInfo_MPI_Alltoall = nullptr,
     85       *IdentInfo_MPI_Ialltoall = nullptr, *IdentInfo_MPI_Barrier = nullptr;
     86 
     87   // additional functions
     88   IdentifierInfo *IdentInfo_MPI_Comm_rank = nullptr,
     89       *IdentInfo_MPI_Comm_size = nullptr, *IdentInfo_MPI_Wait = nullptr,
     90       *IdentInfo_MPI_Waitall = nullptr;
     91 };
     92 
     93 } // end of namespace: mpi
     94 } // end of namespace: ento
     95 } // end of namespace: clang
     96 
     97 #endif
     98