• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- MPITypes.h - Functionality to model MPI concepts --------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// This file provides definitions to model concepts of MPI. The mpi::Request
12 /// class defines a wrapper class, in order to make MPI requests trackable for
13 /// path-sensitive analysis.
14 ///
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_MPICHECKER_MPITYPES_H
18 #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_MPICHECKER_MPITYPES_H
19 
20 #include "MPIFunctionClassifier.h"
21 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
22 #include "llvm/ADT/SmallSet.h"
23 
24 namespace clang {
25 namespace ento {
26 namespace mpi {
27 
28 class Request {
29 public:
30   enum State : unsigned char { Nonblocking, Wait };
31 
Request(State S)32   Request(State S) : CurrentState{S} {}
33 
Profile(llvm::FoldingSetNodeID & Id)34   void Profile(llvm::FoldingSetNodeID &Id) const {
35     Id.AddInteger(CurrentState);
36   }
37 
38   bool operator==(const Request &ToCompare) const {
39     return CurrentState == ToCompare.CurrentState;
40   }
41 
42   const State CurrentState;
43 };
44 
45 // The RequestMap stores MPI requests which are identified by their memory
46 // region. Requests are used in MPI to complete nonblocking operations with wait
47 // operations. A custom map implementation is used, in order to make it
48 // available in an arbitrary amount of translation units.
49 struct RequestMap {};
50 typedef llvm::ImmutableMap<const clang::ento::MemRegion *,
51                            clang::ento::mpi::Request>
52     RequestMapImpl;
53 
54 } // end of namespace: mpi
55 
56 
57 template <>
58 struct ProgramStateTrait<mpi::RequestMap>
59     : public ProgramStatePartialTrait<mpi::RequestMapImpl> {
60   static void *GDMIndex() {
61     static int index = 0;
62     return &index;
63   }
64 };
65 
66 } // end of namespace: ento
67 } // end of namespace: clang
68 #endif
69