MPIFunctionClassifier.h 4.1 KB

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