Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openmp/tools/omptest/include/InternalEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ struct BufferRecordDeallocation : public EventBase<BufferRecordDeallocation> {
// take precedence over the following default equality operator definition.
bool operator==(const ParallelBegin &, const ParallelBegin &);
bool operator==(const Work &, const Work &);
bool operator==(const Dispatch &, const Dispatch &);
bool operator==(const ImplicitTask &, const ImplicitTask &);
bool operator==(const SyncRegion &, const SyncRegion &);
bool operator==(const Target &, const Target &);
Expand Down
5 changes: 5 additions & 0 deletions openmp/tools/omptest/src/InternalEventOperators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ bool operator==(const Work &Expected, const Work &Observed) {
isSameTaskData && isSameCount;
}

bool operator==(const Dispatch &Expected, const Dispatch &Observed) {
bool isSameKind = (Expected.Kind == Observed.Kind);
return isSameKind;
}

bool operator==(const ImplicitTask &Expected, const ImplicitTask &Observed) {
bool isSameEndpoint = (Expected.Endpoint == Observed.Endpoint);
bool isSameActualParallelism =
Expand Down
65 changes: 65 additions & 0 deletions openmp/tools/omptest/test/unittests/internal-event-eq-test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include "InternalEvent.h"
#include <omp-tools.h>
#include <sstream>

#include "gtest/gtest.h"

using namespace omptest;

TEST(InternalEvent_equality_ops, Dispatch_identity) {
ompt_data_t DI{.value = 31};
internal::Dispatch D{/*ParallelData=*/(ompt_data_t *)0x11,
/*TaskData=*/(ompt_data_t *)0x22,
/*Kind=*/ompt_dispatch_t::ompt_dispatch_iteration,
/*Instance=*/DI};

EXPECT_EQ(D == D, true);
}

TEST(InternalEvent_equality_ops, Dispatch_same) {
ompt_data_t DI{.ptr = (void *)0x33};
internal::Dispatch D1{/*ParallelData=*/(ompt_data_t *)0x11,
/*TaskData=*/(ompt_data_t *)0x22,
/*Kind=*/ompt_dispatch_t::ompt_dispatch_section,
/*Instance=*/DI};

internal::Dispatch D2{/*ParallelData=*/(ompt_data_t *)0x11,
/*TaskData=*/(ompt_data_t *)0x22,
/*Kind=*/ompt_dispatch_t::ompt_dispatch_section,
/*Instance=*/DI};

EXPECT_EQ(D1 == D2, true);
}

TEST(InternalEvent_equality_ops, Dispatch_different_kind) {
ompt_data_t DI{.ptr = (void *)0x33};
internal::Dispatch D1{/*ParallelData=*/(ompt_data_t *)0x11,
/*TaskData=*/(ompt_data_t *)0x22,
/*Kind=*/ompt_dispatch_t::ompt_dispatch_section,
/*Instance=*/DI};

internal::Dispatch D2{/*ParallelData=*/(ompt_data_t *)0x11,
/*TaskData=*/(ompt_data_t *)0x22,
/*Kind=*/ompt_dispatch_t::ompt_dispatch_iteration,
/*Instance=*/DI};

// Demonstrate that 'Kind' is the only relevant field for equality.
EXPECT_EQ(D1 == D2, false);
}

TEST(InternalEvent_equality_ops, Dispatch_same_kind_different_other) {
ompt_data_t DI1{.ptr = (void *)0x33};
internal::Dispatch D1{/*ParallelData=*/(ompt_data_t *)0x11,
/*TaskData=*/(ompt_data_t *)0x22,
/*Kind=*/ompt_dispatch_t::ompt_dispatch_section,
/*Instance=*/DI1};

ompt_data_t DI2{.ptr = (void *)0x66};
internal::Dispatch D2{/*ParallelData=*/(ompt_data_t *)0x44,
/*TaskData=*/(ompt_data_t *)0x55,
/*Kind=*/ompt_dispatch_t::ompt_dispatch_section,
/*Instance=*/DI2};

// Demonstrate that 'Kind' is the only relevant field for equality.
EXPECT_EQ(D1 == D2, true);
}
Loading