Test of a single stream, where data dependencies fully determine the execution order.
| 67 | // Test of a single stream, where data dependencies fully determine the |
| 68 | // execution order. |
| 69 | TEST_F(GpuHloScheduleTest, SequentialMatMul) { |
| 70 | HloComputation::Builder builder("entry_computation"); |
| 71 | HloInstruction* x = builder.AddInstruction(HloInstruction::CreateParameter( |
| 72 | /*parameter_number=*/0, f32_2x2_, /*name=*/"x")); |
| 73 | HloInstruction* y = builder.AddInstruction(HloInstruction::CreateParameter( |
| 74 | /*parameter_number=*/1, f32_2x2_, /*name=*/"y")); |
| 75 | HloInstruction* z = builder.AddInstruction(HloInstruction::CreateParameter( |
| 76 | /*parameter_number=*/2, f32_2x2_, /*name=*/"z")); |
| 77 | HloInstruction* dot1 = |
| 78 | builder.AddInstruction(CreateCanonicalDot(f32_2x2_, x, y)); |
| 79 | HloInstruction* dot2 = |
| 80 | builder.AddInstruction(CreateCanonicalDot(f32_2x2_, dot1, z)); |
| 81 | |
| 82 | auto module = CreateNewVerifiedModule(); |
| 83 | module->AddEntryComputation(builder.Build(dot2)); |
| 84 | |
| 85 | std::unique_ptr<StreamAssignment> streams = AssignStreams(*module); |
| 86 | EXPECT_EQ(streams->StreamNumberForHlo(*dot1), |
| 87 | streams->StreamNumberForHlo(*dot2)); |
| 88 | |
| 89 | auto schedule = BuildGpuHloSchedule(*module, *streams); |
| 90 | // Remove parameters, which are unordered. |
| 91 | EXPECT_EQ(RemoveHlo(schedule->ThunkLaunchOrder(), {x, y, z}), |
| 92 | HloVec({dot1, dot2})); |
| 93 | |
| 94 | // Parameters x,y,z are mutually unordered, while dot1 and dot2 are |
| 95 | // transitively ordered by operands. |
| 96 | auto order = schedule->ConsumeHloOrdering(); |
| 97 | EXPECT_TRUE(order->ExecutesBefore(x, dot1)); |
| 98 | EXPECT_TRUE(order->ExecutesBefore(x, dot2)); |
| 99 | EXPECT_TRUE(order->ExecutesBefore(y, dot1)); |
| 100 | EXPECT_TRUE(order->ExecutesBefore(y, dot2)); |
| 101 | EXPECT_TRUE(order->ExecutesBefore(z, dot2)); |
| 102 | EXPECT_TRUE(order->ExecutesBefore(dot1, dot2)); |
| 103 | |
| 104 | EXPECT_FALSE(order->ExecutesBefore(x, x)); |
| 105 | EXPECT_FALSE(order->ExecutesBefore(x, y)); |
| 106 | EXPECT_FALSE(order->ExecutesBefore(x, z)); |
| 107 | EXPECT_FALSE(order->ExecutesBefore(y, x)); |
| 108 | EXPECT_FALSE(order->ExecutesBefore(y, y)); |
| 109 | EXPECT_FALSE(order->ExecutesBefore(y, z)); |
| 110 | EXPECT_FALSE(order->ExecutesBefore(z, x)); |
| 111 | EXPECT_FALSE(order->ExecutesBefore(z, y)); |
| 112 | EXPECT_FALSE(order->ExecutesBefore(z, z)); |
| 113 | EXPECT_FALSE(order->ExecutesBefore(z, dot1)); |
| 114 | EXPECT_FALSE(order->ExecutesBefore(dot1, x)); |
| 115 | EXPECT_FALSE(order->ExecutesBefore(dot1, y)); |
| 116 | EXPECT_FALSE(order->ExecutesBefore(dot1, z)); |
| 117 | EXPECT_FALSE(order->ExecutesBefore(dot1, dot1)); |
| 118 | EXPECT_FALSE(order->ExecutesBefore(dot2, x)); |
| 119 | EXPECT_FALSE(order->ExecutesBefore(dot2, y)); |
| 120 | EXPECT_FALSE(order->ExecutesBefore(dot2, z)); |
| 121 | EXPECT_FALSE(order->ExecutesBefore(dot2, dot1)); |
| 122 | EXPECT_FALSE(order->ExecutesBefore(dot2, dot2)); |
| 123 | } |
| 124 | |
| 125 | // Test of a single stream, where data dependencies do not fully determine the |
| 126 | // execution order, but the stream assignment does. |
nothing calls this directly
no test coverage detected