Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:37:06

0001 //===-- MPIFunctionClassifier.h - classifies MPI functions ----*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 ///
0009 /// \file
0010 /// This file defines functionality to identify and classify MPI functions.
0011 ///
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CLANG_STATICANALYZER_CHECKERS_MPIFUNCTIONCLASSIFIER_H
0015 #define LLVM_CLANG_STATICANALYZER_CHECKERS_MPIFUNCTIONCLASSIFIER_H
0016 
0017 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
0018 
0019 namespace clang {
0020 namespace ento {
0021 namespace mpi {
0022 
0023 class MPIFunctionClassifier {
0024 public:
0025   MPIFunctionClassifier(ASTContext &ASTCtx) { identifierInit(ASTCtx); }
0026 
0027   // general identifiers
0028   bool isMPIType(const IdentifierInfo *const IdentInfo) const;
0029   bool isNonBlockingType(const IdentifierInfo *const IdentInfo) const;
0030 
0031   // point-to-point identifiers
0032   bool isPointToPointType(const IdentifierInfo *const IdentInfo) const;
0033 
0034   // collective identifiers
0035   bool isCollectiveType(const IdentifierInfo *const IdentInfo) const;
0036   bool isCollToColl(const IdentifierInfo *const IdentInfo) const;
0037   bool isScatterType(const IdentifierInfo *const IdentInfo) const;
0038   bool isGatherType(const IdentifierInfo *const IdentInfo) const;
0039   bool isAllgatherType(const IdentifierInfo *const IdentInfo) const;
0040   bool isAlltoallType(const IdentifierInfo *const IdentInfo) const;
0041   bool isReduceType(const IdentifierInfo *const IdentInfo) const;
0042   bool isBcastType(const IdentifierInfo *const IdentInfo) const;
0043 
0044   // additional identifiers
0045   bool isMPI_Wait(const IdentifierInfo *const IdentInfo) const;
0046   bool isMPI_Waitall(const IdentifierInfo *const IdentInfo) const;
0047   bool isWaitType(const IdentifierInfo *const IdentInfo) const;
0048 
0049 private:
0050   // Initializes function identifiers, to recognize them during analysis.
0051   void identifierInit(ASTContext &ASTCtx);
0052   void initPointToPointIdentifiers(ASTContext &ASTCtx);
0053   void initCollectiveIdentifiers(ASTContext &ASTCtx);
0054   void initAdditionalIdentifiers(ASTContext &ASTCtx);
0055 
0056   // The containers are used, to enable classification of MPI-functions during
0057   // analysis.
0058   llvm::SmallVector<IdentifierInfo *, 12> MPINonBlockingTypes;
0059 
0060   llvm::SmallVector<IdentifierInfo *, 10> MPIPointToPointTypes;
0061   llvm::SmallVector<IdentifierInfo *, 16> MPICollectiveTypes;
0062 
0063   llvm::SmallVector<IdentifierInfo *, 4> MPIPointToCollTypes;
0064   llvm::SmallVector<IdentifierInfo *, 4> MPICollToPointTypes;
0065   llvm::SmallVector<IdentifierInfo *, 6> MPICollToCollTypes;
0066 
0067   llvm::SmallVector<IdentifierInfo *, 32> MPIType;
0068 
0069   // point-to-point functions
0070   IdentifierInfo *IdentInfo_MPI_Send = nullptr, *IdentInfo_MPI_Isend = nullptr,
0071       *IdentInfo_MPI_Ssend = nullptr, *IdentInfo_MPI_Issend = nullptr,
0072       *IdentInfo_MPI_Bsend = nullptr, *IdentInfo_MPI_Ibsend = nullptr,
0073       *IdentInfo_MPI_Rsend = nullptr, *IdentInfo_MPI_Irsend = nullptr,
0074       *IdentInfo_MPI_Recv = nullptr, *IdentInfo_MPI_Irecv = nullptr;
0075 
0076   // collective functions
0077   IdentifierInfo *IdentInfo_MPI_Scatter = nullptr,
0078       *IdentInfo_MPI_Iscatter = nullptr, *IdentInfo_MPI_Gather = nullptr,
0079       *IdentInfo_MPI_Igather = nullptr, *IdentInfo_MPI_Allgather = nullptr,
0080       *IdentInfo_MPI_Iallgather = nullptr, *IdentInfo_MPI_Bcast = nullptr,
0081       *IdentInfo_MPI_Ibcast = nullptr, *IdentInfo_MPI_Reduce = nullptr,
0082       *IdentInfo_MPI_Ireduce = nullptr, *IdentInfo_MPI_Allreduce = nullptr,
0083       *IdentInfo_MPI_Iallreduce = nullptr, *IdentInfo_MPI_Alltoall = nullptr,
0084       *IdentInfo_MPI_Ialltoall = nullptr, *IdentInfo_MPI_Barrier = nullptr;
0085 
0086   // additional functions
0087   IdentifierInfo *IdentInfo_MPI_Comm_rank = nullptr,
0088       *IdentInfo_MPI_Comm_size = nullptr, *IdentInfo_MPI_Wait = nullptr,
0089       *IdentInfo_MPI_Waitall = nullptr;
0090 };
0091 
0092 } // end of namespace: mpi
0093 } // end of namespace: ento
0094 } // end of namespace: clang
0095 
0096 #endif