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