clang 10.0.0git

MPIFunctionClassifier.h
Go to the documentation of this file.
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
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
ento
clang::ento::mpi::MPIFunctionClassifier
Definition: MPIFunctionClassifier.h:23
clang::ento::mpi::MPIFunctionClassifier::isCollectiveType
bool isCollectiveType(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:219
clang::ento::mpi::MPIFunctionClassifier::isAlltoallType
bool isAlltoallType(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:249
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:57
clang::ento::mpi::MPIFunctionClassifier::isAllgatherType
bool isAllgatherType(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:243
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:168
clang::ento::mpi::MPIFunctionClassifier::isNonBlockingType
bool isNonBlockingType(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:207
clang::ento::mpi::MPIFunctionClassifier::isBcastType
bool isBcastType(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:255
clang::ento::mpi::MPIFunctionClassifier::isMPI_Waitall
bool isMPI_Waitall(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:272
clang::ento::mpi::MPIFunctionClassifier::isMPI_Wait
bool isMPI_Wait(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:268
clang::ento::mpi::MPIFunctionClassifier::isScatterType
bool isScatterType(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:229
clang::ento::mpi::MPIFunctionClassifier::isReduceType
bool isReduceType(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:259
clang::ento::mpi::MPIFunctionClassifier::isWaitType
bool isWaitType(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:277
llvm::SmallVector
Definition: LLVM.h:35
clang::ento::mpi::MPIFunctionClassifier::MPIFunctionClassifier
MPIFunctionClassifier(ASTContext &ASTCtx)
Definition: MPIFunctionClassifier.h:25
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::ento::mpi::MPIFunctionClassifier::isPointToPointType
bool isPointToPointType(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:213
clang::ento::mpi::MPIFunctionClassifier::isGatherType
bool isGatherType(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:235
clang::ento::mpi::MPIFunctionClassifier::isCollToColl
bool isCollToColl(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:224
clang::ento::mpi::MPIFunctionClassifier::isMPIType
bool isMPIType(const IdentifierInfo *const IdentInfo) const
Definition: MPIFunctionClassifier.cpp:203
CheckerContext.h