Clang Project

clang_source_code/include/clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h
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_LIB_STATICANALYZER_CHECKERS_MPICHECKER_MPIFUNCTIONCLASSIFIER_H
15#define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_MPICHECKER_MPIFUNCTIONCLASSIFIER_H
16
17#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
18
19namespace clang {
20namespace ento {
21namespace mpi {
22
23class MPIFunctionClassifier {
24public:
25  MPIFunctionClassifier(ASTContext &ASTCtx) { identifierInit(ASTCtx); }
26
27  // general identifiers
28  bool isMPIType(const IdentifierInfo *const IdentInfoconst;
29  bool isNonBlockingType(const IdentifierInfo *const IdentInfoconst;
30
31  // point-to-point identifiers
32  bool isPointToPointType(const IdentifierInfo *const IdentInfoconst;
33
34  // collective identifiers
35  bool isCollectiveType(const IdentifierInfo *const IdentInfoconst;
36  bool isCollToColl(const IdentifierInfo *const IdentInfoconst;
37  bool isScatterType(const IdentifierInfo *const IdentInfoconst;
38  bool isGatherType(const IdentifierInfo *const IdentInfoconst;
39  bool isAllgatherType(const IdentifierInfo *const IdentInfoconst;
40  bool isAlltoallType(const IdentifierInfo *const IdentInfoconst;
41  bool isReduceType(const IdentifierInfo *const IdentInfoconst;
42  bool isBcastType(const IdentifierInfo *const IdentInfoconst;
43
44  // additional identifiers
45  bool isMPI_Wait(const IdentifierInfo *const IdentInfoconst;
46  bool isMPI_Waitall(const IdentifierInfo *const IdentInfoconst;
47  bool isWaitType(const IdentifierInfo *const IdentInfoconst;
48
49private:
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 *, 12MPINonBlockingTypes;
59
60  llvm::SmallVector<IdentifierInfo *, 10MPIPointToPointTypes;
61  llvm::SmallVector<IdentifierInfo *, 16MPICollectiveTypes;
62
63  llvm::SmallVector<IdentifierInfo *, 4MPIPointToCollTypes;
64  llvm::SmallVector<IdentifierInfo *, 4MPICollToPointTypes;
65  llvm::SmallVector<IdentifierInfo *, 6MPICollToCollTypes;
66
67  llvm::SmallVector<IdentifierInfo *, 32MPIType;
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
clang::ento::mpi::MPIFunctionClassifier::isMPIType
clang::ento::mpi::MPIFunctionClassifier::isNonBlockingType
clang::ento::mpi::MPIFunctionClassifier::isPointToPointType
clang::ento::mpi::MPIFunctionClassifier::isCollectiveType
clang::ento::mpi::MPIFunctionClassifier::isCollToColl
clang::ento::mpi::MPIFunctionClassifier::isScatterType
clang::ento::mpi::MPIFunctionClassifier::isGatherType
clang::ento::mpi::MPIFunctionClassifier::isAllgatherType
clang::ento::mpi::MPIFunctionClassifier::isAlltoallType
clang::ento::mpi::MPIFunctionClassifier::isReduceType
clang::ento::mpi::MPIFunctionClassifier::isBcastType
clang::ento::mpi::MPIFunctionClassifier::isMPI_Wait
clang::ento::mpi::MPIFunctionClassifier::isMPI_Waitall
clang::ento::mpi::MPIFunctionClassifier::isWaitType
clang::ento::mpi::MPIFunctionClassifier::identifierInit
clang::ento::mpi::MPIFunctionClassifier::initPointToPointIdentifiers
clang::ento::mpi::MPIFunctionClassifier::initCollectiveIdentifiers
clang::ento::mpi::MPIFunctionClassifier::initAdditionalIdentifiers
clang::ento::mpi::MPIFunctionClassifier::MPINonBlockingTypes
clang::ento::mpi::MPIFunctionClassifier::MPIPointToPointTypes
clang::ento::mpi::MPIFunctionClassifier::MPICollectiveTypes
clang::ento::mpi::MPIFunctionClassifier::MPIPointToCollTypes
clang::ento::mpi::MPIFunctionClassifier::MPICollToPointTypes
clang::ento::mpi::MPIFunctionClassifier::MPICollToCollTypes
clang::ento::mpi::MPIFunctionClassifier::MPIType
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Send
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Isend
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Ssend
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Issend
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Bsend
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Ibsend
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Rsend
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Irsend
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Recv
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Irecv
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Scatter
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Iscatter
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Gather
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Igather
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Allgather
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Iallgather
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Bcast
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Ibcast
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Reduce
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Ireduce
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Allreduce
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Iallreduce
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Alltoall
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Ialltoall
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Barrier
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Comm_rank
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Comm_size
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Wait
clang::ento::mpi::MPIFunctionClassifier::IdentInfo_MPI_Waitall