LLVM OpenMP 22.0.0git
main-test.cpp
Go to the documentation of this file.
1#include "OmptAssertEvent.h"
2#include "OmptAsserter.h"
3#include "OmptTester.h"
4#include <omp-tools.h>
5
6#include "gtest/gtest.h"
7
10
11TEST(CompareOperatorTests, ThreadBeginIdentity) {
12 auto TBInitial =
13 OAE::ThreadBegin("dflt", "", OS::Always, ompt_thread_initial);
14 auto TBWorker = OAE::ThreadBegin("dflt", "", OS::Always, ompt_thread_worker);
15 auto TBOther = OAE::ThreadBegin("dflt", "", OS::Always, ompt_thread_other);
16 auto TBUnknown =
17 OAE::ThreadBegin("dflt", "", OS::Always, ompt_thread_unknown);
18
19 ASSERT_EQ(TBInitial, TBInitial);
20 ASSERT_EQ(TBWorker, TBWorker);
21 ASSERT_EQ(TBOther, TBOther);
22 ASSERT_EQ(TBUnknown, TBUnknown);
23}
24
25TEST(CompareOperatorTests, ThreadEndIdentity) {
26 auto TE = OAE::ThreadEnd("dflt", "", OS::Always);
27
28 ASSERT_EQ(TE, TE);
29}
30
31TEST(CompareOperatorTests, ParallelBeginIdentity) {
32 auto PBNumT = OAE::ParallelBegin("thrdenable", "", OS::Always, 3);
33
34 ASSERT_EQ(PBNumT, PBNumT);
35}
36
37TEST(CompareOperatorTests, ParallelEndIdentity) {
38 auto PEDflt = OAE::ParallelEnd("dflt", "", OS::Always);
39 // TODO: Add cases with parallel data set, task data set, flags
40
41 ASSERT_EQ(PEDflt, PEDflt);
42}
43
44TEST(CompareOperatorTests, WorkIdentity) {
45 auto WDLoopBgn =
46 OAE::Work("loopbgn", "", OS::Always, ompt_work_loop, ompt_scope_begin);
47 auto WDLoopEnd =
48 OAE::Work("loopend", "", OS::Always, ompt_work_loop, ompt_scope_end);
49
50 ASSERT_EQ(WDLoopBgn, WDLoopBgn);
51 ASSERT_EQ(WDLoopEnd, WDLoopEnd);
52
53 auto WDSectionsBgn = OAE::Work("sectionsbgn", "", OS::Always,
54 ompt_work_sections, ompt_scope_begin);
55 auto WDSectionsEnd = OAE::Work("sectionsend", "", OS::Always,
56 ompt_work_sections, ompt_scope_end);
57
58 // TODO: singleexecutor, single_other, workshare, distribute, taskloop, scope,
59 // loop_static, loop_dynamic, loop_guided, loop_other
60
61 ASSERT_EQ(WDSectionsBgn, WDSectionsBgn);
62 ASSERT_EQ(WDSectionsEnd, WDSectionsEnd);
63}
64
65TEST(CompareOperatorTests, DispatchIdentity) {
66 auto DIDflt = OAE::Dispatch("dflt", "", OS::Always);
67
68 ASSERT_EQ(DIDflt, DIDflt);
69}
70
71TEST(CompareOperatorTests, TaskCreateIdentity) {
72 auto TCDflt = OAE::TaskCreate("dflt", "", OS::Always);
73
74 ASSERT_EQ(TCDflt, TCDflt);
75}
76
77TEST(CompareOperatorTests, TaskScheduleIdentity) {
78 auto TS = OAE::TaskSchedule("dflt", "", OS::Always);
79
80 ASSERT_EQ(TS, TS);
81}
82
83TEST(CompareOperatorTests, ImplicitTaskIdentity) {
84 auto ITDfltBgn =
85 OAE::ImplicitTask("dfltbgn", "", OS::Always, ompt_scope_begin);
86 auto ITDfltEnd = OAE::ImplicitTask("dfltend", "", OS::Always, ompt_scope_end);
87
88 ASSERT_EQ(ITDfltBgn, ITDfltBgn);
89 ASSERT_EQ(ITDfltEnd, ITDfltEnd);
90}
91
92TEST(CompareOperatorTests, SyncRegionIdentity) {
93 auto SRDfltBgn =
94 OAE::SyncRegion("srdfltbgn", "", OS::Always,
95 ompt_sync_region_barrier_explicit, ompt_scope_begin);
96 auto SRDfltEnd =
97 OAE::SyncRegion("srdfltend", "", OS::Always,
98 ompt_sync_region_barrier_explicit, ompt_scope_end);
99
100 ASSERT_EQ(SRDfltBgn, SRDfltBgn);
101 ASSERT_EQ(SRDfltEnd, SRDfltEnd);
102}
103
104TEST(CompareOperatorTests, TargetIdentity) {
105 auto TargetDfltBgn =
106 OAE::Target("dfltbgn", "", OS::Always, ompt_target, ompt_scope_begin);
107 auto TargetDfltEnd =
108 OAE::Target("dfltend", "", OS::Always, ompt_target, ompt_scope_end);
109
110 ASSERT_EQ(TargetDfltBgn, TargetDfltBgn);
111 ASSERT_EQ(TargetDfltEnd, TargetDfltEnd);
112
113 auto TargetDevBgn = OAE::Target("tgtdevbgn", "", OS::Always, ompt_target,
114 ompt_scope_begin, 1);
115 auto TargetDevEnd =
116 OAE::Target("tgtdevend", "", OS::Always, ompt_target, ompt_scope_end, 1);
117
118 ASSERT_EQ(TargetDevBgn, TargetDevBgn);
119 ASSERT_EQ(TargetDevEnd, TargetDevEnd);
120}
121
122TEST(CompareOperatorTests, BufferRecordIdentity) {
123 // Default, no time limit or anything
124 auto BRDflt =
125 OAE::BufferRecord("dflt", "", OS::Always, ompt_callback_target_submit);
126
127 // Minimum time set, no max time
128 auto BRMinSet = OAE::BufferRecord("minset", "", OS::Always,
129 ompt_callback_target_submit, 10);
130
131 // Minimum time and maximum time set
132 auto BRMinMaxSet = OAE::BufferRecord("minmaxset", "", OS::Always,
133 ompt_callback_target_submit, {10, 100});
134
135 ASSERT_EQ(BRDflt, BRDflt);
136 ASSERT_EQ(BRMinSet, BRMinSet);
137 ASSERT_EQ(BRMinMaxSet, BRMinMaxSet);
138}
139
140// Add main definition
Contains assertion event constructors, for generally all observable events.
Contains all asserter-related class declarations and important enums.
#define TEST(test_suite_name, test_name)
This file represents the main header file for usage of the ompTest library.
#define OMPTEST_TESTSUITE_MAIN()
Definition OmptTester.h:52
omptest::OmptAssertEvent OAE
omptest::ObserveState OS
Assertion event struct, provides statically callable CTORs.
static OmptAssertEvent SyncRegion(const std::string &Name, const std::string &Group, const ObserveState &Expected, ompt_sync_region_t Kind, ompt_scope_endpoint_t Endpoint, ompt_data_t *ParallelData=expectedDefault(ompt_data_t *), ompt_data_t *TaskData=expectedDefault(ompt_data_t *), const void *CodeptrRA=expectedDefault(const void *))
static OmptAssertEvent BufferRecord(const std::string &Name, const std::string &Group, const ObserveState &Expected, ompt_record_ompt_t *Record)
static OmptAssertEvent Dispatch(const std::string &Name, const std::string &Group, const ObserveState &Expected, ompt_data_t *ParallelData=expectedDefault(ompt_data_t *), ompt_data_t *TaskData=expectedDefault(ompt_data_t *), ompt_dispatch_t Kind=expectedDefault(ompt_dispatch_t), ompt_data_t Instance=expectedDefault(ompt_data_t))
static OmptAssertEvent TaskSchedule(const std::string &Name, const std::string &Group, const ObserveState &Expected)
static OmptAssertEvent ParallelEnd(const std::string &Name, const std::string &Group, const ObserveState &Expected, ompt_data_t *ParallelData=expectedDefault(ompt_data_t *), ompt_data_t *EncounteringTaskData=expectedDefault(ompt_data_t *), int Flags=expectedDefault(int), const void *CodeptrRA=expectedDefault(const void *))
static OmptAssertEvent Work(const std::string &Name, const std::string &Group, const ObserveState &Expected, ompt_work_t WorkType, ompt_scope_endpoint_t Endpoint, ompt_data_t *ParallelData=expectedDefault(ompt_data_t *), ompt_data_t *TaskData=expectedDefault(ompt_data_t *), uint64_t Count=expectedDefault(uint64_t), const void *CodeptrRA=expectedDefault(const void *))
static OmptAssertEvent ThreadEnd(const std::string &Name, const std::string &Group, const ObserveState &Expected)
static OmptAssertEvent ParallelBegin(const std::string &Name, const std::string &Group, const ObserveState &Expected, int NumThreads)
static OmptAssertEvent TaskCreate(const std::string &Name, const std::string &Group, const ObserveState &Expected, ompt_data_t *EncounteringTaskData=expectedDefault(ompt_data_t *), const ompt_frame_t *EncounteringTaskFrame=expectedDefault(ompt_frame_t *), ompt_data_t *NewTaskData=expectedDefault(ompt_data_t *), int Flags=expectedDefault(int), int HasDependences=expectedDefault(int), const void *CodeptrRA=expectedDefault(const void *))
static OmptAssertEvent ThreadBegin(const std::string &Name, const std::string &Group, const ObserveState &Expected, ompt_thread_t ThreadType)
static OmptAssertEvent ImplicitTask(const std::string &Name, const std::string &Group, const ObserveState &Expected, ompt_scope_endpoint_t Endpoint, ompt_data_t *ParallelData=expectedDefault(ompt_data_t *), ompt_data_t *TaskData=expectedDefault(ompt_data_t *), unsigned int ActualParallelism=expectedDefault(unsigned int), unsigned int Index=expectedDefault(unsigned int), int Flags=expectedDefault(int))
static OmptAssertEvent Target(const std::string &Name, const std::string &Group, const ObserveState &Expected, ompt_target_t Kind, ompt_scope_endpoint_t Endpoint, int DeviceNum=expectedDefault(int), ompt_data_t *TaskData=expectedDefault(ompt_data_t *), ompt_id_t TargetId=expectedDefault(ompt_id_t), const void *CodeptrRA=expectedDefault(void *))