brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.4 KiB · 093ac36 Raw
142 lines · cpp
1#include "OmptAssertEvent.h"2#include "OmptAsserter.h"3#include "OmptTester.h"4#include <omp-tools.h>5 6#include "gtest/gtest.h"7 8using OS = omptest::ObserveState;9using OAE = omptest::OmptAssertEvent;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, flags40 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_other60 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 anything124  auto BRDflt =125      OAE::BufferRecord("dflt", "", OS::Always, ompt_callback_target_submit);126 127  // Minimum time set, no max time128  auto BRMinSet = OAE::BufferRecord("minset", "", OS::Always,129                                    ompt_callback_target_submit, 10);130 131  // Minimum time and maximum time set132  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 definition141OMPTEST_TESTSUITE_MAIN()142