Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Blame | Last modification | View Log | Download | RSS feed

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