TIMPI
Loading...
Searching...
No Matches
Functions | Variables
message_tag_unit.C File Reference

Go to the source code of this file.

Functions

void testGetUniqueTagAuto ()
 
void testGetUniqueTagManual ()
 
void testGetUniqueTagOverlap ()
 
int main (int argc, const char *const *argv)
 

Variables

CommunicatorTestCommWorld
 

Function Documentation

◆ main()

int main ( int  argc,
const char *const *  argv 
)

Definition at line 104 of file message_tag_unit.C.

105{
107 TestCommWorld = &init.comm();
108
112
113 return 0;
114}
The TIMPIInit class, when constructed, initializes any dependent libraries (e.g.
Definition timpi_init.h:58
Communicator * TestCommWorld
void testGetUniqueTagManual()
void testGetUniqueTagAuto()
void testGetUniqueTagOverlap()
Tnew cast_int(Told oldvar)

References TIMPI::cast_int(), TestCommWorld, testGetUniqueTagAuto(), testGetUniqueTagManual(), and testGetUniqueTagOverlap().

◆ testGetUniqueTagAuto()

void testGetUniqueTagAuto ( )

Definition at line 13 of file message_tag_unit.C.

14 {
15 // We need to duplicate the communicator first, because the
16 // original might already have tags used by other unit tests
17
19
21
22 const int n_vals = 5;
23 const int n_vals_in_scope = 3;
24 std::vector<int> vals(n_vals);
25
26 {
27 std::vector<TIMPI::MessageTag> tags(n_vals_in_scope);
28 for (int i=0; i != n_vals_in_scope; ++i)
29 {
30 tags[i] = newcomm.get_unique_tag();
31 vals[i] = tags[i].value();
32 for (int j=0; j != i; ++j)
33 {
35 }
36 }
37 }
38
39 // Even after we go out of scope those values should be used up
40 for (int i=n_vals_in_scope; i != n_vals; ++i)
41 {
42 TIMPI::MessageTag another_tag = newcomm.get_unique_tag();
44 for (int j=0; j != i; ++j)
45 {
47 }
48 }
49 }
Encapsulates the MPI_Comm object.
void duplicate(const Communicator &comm)
Encapsulates the MPI tag integers.
Definition message_tag.h:47
int value() const
Definition message_tag.h:92

References TIMPI::cast_int(), TIMPI::Communicator::duplicate(), TestCommWorld, and TIMPI::MessageTag::value().

Referenced by main().

◆ testGetUniqueTagManual()

void testGetUniqueTagManual ( )

Definition at line 53 of file message_tag_unit.C.

54 {
55 // Here we'll use the standard communicator, because even if it
56 // used these tags in other contexts it should have freed them for
57 // reuse later.
58
59 const int requests[] = {2, 4, 6, 8, 8, 6, 8, 123, 3141, 3142};
60
61 for (const int i : requests)
62 {
65 TIMPI_UNIT_ASSERT(i == manual_tag.value());
66
68 TIMPI_UNIT_ASSERT(i == tag_copy.value());
69
71 TIMPI_UNIT_ASSERT(i == tag_move.value());
72
75 }
76 }
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
Get a tag that is unique to this Communicator.

References TIMPI::cast_int(), TIMPI::Communicator::get_unique_tag(), and TestCommWorld.

Referenced by main().

◆ testGetUniqueTagOverlap()

void testGetUniqueTagOverlap ( )

Definition at line 79 of file message_tag_unit.C.

80 {
81 // Try to request the same tag twice, make sure we don't get it
82 // the second time.
83
84 const int requests[] = {2, 4, 6, 8, 8, 6, 8, 123, 3141, 3142};
85
86 for (const int i : requests)
87 {
90 TIMPI_UNIT_ASSERT(i == manual_tag.value());
91
95
97 TIMPI_UNIT_ASSERT(i == tag_copy.value());
98
100 TIMPI_UNIT_ASSERT(i == tag_move.value());
101 }
102 }

References TIMPI::cast_int(), TIMPI::Communicator::get_unique_tag(), and TestCommWorld.

Referenced by main().

Variable Documentation

◆ TestCommWorld

Communicator* TestCommWorld