14#ifndef OPENMP_TOOLS_OMPTEST_INCLUDE_OMPTASSERTER_H
15#define OPENMP_TOOLS_OMPTEST_INCLUDE_OMPTASSERTER_H
30class OmptEventGroupInterface;
63 std::set<omptest::internal::EventTy> SuppressedEvents{
125 std::shared_ptr<logging::Logger>
getLog()
const {
return Log; }
149 std::shared_ptr<logging::Logger>
Log{
nullptr};
163 static std::mutex StaticMemberAccessMutex;
166 static std::weak_ptr<OmptEventGroupInterface> EventGroupInterfaceInstance;
169 static std::weak_ptr<logging::Logger> LoggingInstance;
213 std::vector<omptest::OmptAssertEvent>
Events{};
234 std::vector<omptest::OmptAssertEvent>
Events{};
241 : OutStream(OutStream) {}
248 std::ostream &OutStream;
283 mutable std::mutex GroupMutex;
284 std::map<std::string, omptest::AssertEventGroup> ActiveEventGroups{};
285 std::map<std::string, omptest::AssertEventGroup> DeprecatedEventGroups{};
286 std::set<std::string> EncounteredSyncPoints{};
Provides ompTest-tailored logging, with log-levels and formatting/coloring.
Contains assertion event constructors, for generally all observable events.
Base class for asserting on OMPT events.
virtual omptest::AssertState checkState()
Determine and return the asserter's state.
std::shared_ptr< OmptEventGroupInterface > EventGroups
Pointer to the OmptEventGroupInterface.
AssertMode OperationMode
Operation mode during assertion / notification.
std::mutex AssertMutex
Mutex to avoid data races w.r.t. event notifications and/or insertions.
AssertMode getOperationMode()
Get the asserter's current operationmode: e.g.: Strict or Relaxed.
int getNotificationCount()
Get the total number of received, effective notifications.
omptest::AssertState getState()
Return the asserter's current state.
int NumNotifications
The total number of effective notifications.
virtual ~OmptAsserter()=default
void notify(omptest::OmptAssertEvent &&AE) override
Called from the CallbackHandler with a corresponding AssertEvent to which callback was handled.
virtual void insert(omptest::OmptAssertEvent &&AE)
Add an event to the asserter's internal data structure.
virtual void notifyImpl(omptest::OmptAssertEvent &&AE)=0
Implemented in subclasses to implement what should actually be done with the notification.
int NumSuccessfulAsserts
The number of successful assertion checks.
std::shared_ptr< OmptEventGroupInterface > getEventGroups() const
Accessor for the event group interface.
virtual size_t getRemainingEventCount()=0
Get the number of currently remaining events, with: ObserveState::Always.
void setOperationMode(AssertMode Mode)
Set the asserter's mode of operation w.r.t. assertion.
int getSuccessfulAssertionCount()
Get the total number of successful assertion checks.
bool verifyEventGroups(const omptest::OmptAssertEvent &ExpectedEvent, const omptest::OmptAssertEvent &ObservedEvent)
Check the observed events' group association.
std::shared_ptr< logging::Logger > getLog() const
Accessor for the event group interface.
std::shared_ptr< logging::Logger > Log
Pointer to the logging instance.
omptest::AssertState State
The asserter's current state.
This class provides the members and methods to manage event groups and SyncPoints in conjunction with...
bool checkActiveEventGroups(const std::string &GroupName, omptest::AssertEventGroup Group)
Check if given group is currently part of the active event groups.
OmptEventGroupInterface & operator=(const OmptEventGroupInterface &)=delete
OmptEventGroupInterface(const OmptEventGroupInterface &)=delete
Non-copyable and non-movable.
bool checkDeprecatedEventGroups(const std::string &GroupName, omptest::AssertEventGroup Group)
Check if given group is currently part of the deprecated event groups.
OmptEventGroupInterface & operator=(OmptEventGroupInterface &&)=delete
bool addActiveEventGroup(const std::string &GroupName, omptest::AssertEventGroup Group)
Add given group to the set of active event groups.
OmptEventGroupInterface()=default
OmptEventGroupInterface(OmptEventGroupInterface &&)=delete
~OmptEventGroupInterface()=default
bool deprecateActiveEventGroup(const std::string &GroupName)
Move given group from the set of active event groups to the set of previously active event groups.
Class that reports the occurred events.
OmptEventReporter(std::ostream &OutStream=std::cout)
void notify(omptest::OmptAssertEvent &&AE) override
Called from the CallbackHandler with a corresponding AssertEvent to which callback was handled.
General base class for the subscriber/notification pattern in OmptCallbackHandler.
virtual ~OmptListener()=default
void suppressEvent(omptest::internal::EventTy EvTy)
Add the given event type to the set of suppressed events.
bool isSuppressedEventType(omptest::internal::EventTy EvTy)
Check if the given event type is from the set of suppressed event types.
void permitEvent(omptest::internal::EventTy EvTy)
Remove the given event type to the set of suppressed events.
virtual void notify(omptest::OmptAssertEvent &&AE)=0
Called for each registered OMPT event of the OmptCallbackHandler.
void setActive(bool Enabled)
Control whether this asserter should be considered 'active'.
bool isActive()
Check if this asserter is considered 'active'.
Class that can assert in a sequenced fashion, i.e., events have to occur in the order they were regis...
size_t getRemainingEventCount() override
Get the number of currently remaining events, with: ObserveState::Always.
bool consumeSuspend()
Notification helper function, implementing Suspend logic.
bool consumeRegularEvent(const omptest::OmptAssertEvent &AE)
Notification helper function, implementing regular event notification logic.
void insert(omptest::OmptAssertEvent &&AE) override
Add the event to the in-sequence set of events that the asserter should check for.
bool consumeSyncPoint(const omptest::OmptAssertEvent &AE)
Notification helper function, implementing SyncPoint logic.
virtual void notifyImpl(omptest::OmptAssertEvent &&AE) override
Implements the asserter's actual logic.
omptest::AssertState checkState() override
Determine and return the asserter's state.
size_t NextEvent
Index of the next, expected event.
bool checkExcessNotify(const omptest::OmptAssertEvent &AE)
Notification helper function, implementing excess event notification logic.
std::vector< omptest::OmptAssertEvent > Events
EventTy
Enum values are used for comparison of observed and asserted events List is based on OpenMP 5....
POD type, which holds the target region id, corresponding to an event group.
Assertion event struct, provides statically callable CTORs.
Class that asserts with set semantics, i.e., unordered.
virtual void notifyImpl(omptest::OmptAssertEvent &&AE) override
Implements the asserter's logic.
size_t getRemainingEventCount() override
Get the number of currently remaining events, with: ObserveState::Always.
void insert(omptest::OmptAssertEvent &&AE) override
Add the event to the set of events that the asserter should check for.
omptest::AssertState checkState() override
Determine and return the asserter's state.
std::vector< omptest::OmptAssertEvent > Events
For now use vector (but do set semantics)