| 1604 | |
| 1605 | template <typename LhsScalar, typename RhsScalar, typename SpecType> |
| 1606 | void TestSet<LhsScalar, RhsScalar, SpecType>::MakePrepackedMatrices() { |
| 1607 | RUY_CHECK(life_stage == LifeStage::kHasResultPaths); |
| 1608 | |
| 1609 | // Prepacked matrices are Path-dependent, so create them for each test result. |
| 1610 | for (auto& result : results) { |
| 1611 | // If this result uses an external path, then skip this entirely. |
| 1612 | if (result->path == Path::kNone) { |
| 1613 | continue; |
| 1614 | } |
| 1615 | // Pre-packing doesn't make sense for Path::kReference. |
| 1616 | // TODO(silvasean): Make Path::kReference an ExternalPath? |
| 1617 | if (result->path == Path::kReference) { |
| 1618 | continue; |
| 1619 | } |
| 1620 | |
| 1621 | // Determine whether we should create/use prepacked matrices. |
| 1622 | if (benchmark) { |
| 1623 | // For benchmarking, do as requested. |
| 1624 | result->use_prepacked_lhs = benchmark_prepack_lhs; |
| 1625 | result->use_prepacked_rhs = benchmark_prepack_rhs; |
| 1626 | } else { |
| 1627 | // When testing, randomly pre-pack sometimes. But don't do it too often. |
| 1628 | result->use_prepacked_lhs = (global_random_engine()() & 7) == 0; |
| 1629 | result->use_prepacked_rhs = (global_random_engine()() & 7) == 0; |
| 1630 | } |
| 1631 | |
| 1632 | // Create the pre-packed matrices. |
| 1633 | PrepackedMatrix* prepacked_lhs_ptr = |
| 1634 | result->use_prepacked_lhs ? &result->prepacked_lhs : nullptr; |
| 1635 | PrepackedMatrix* prepacked_rhs_ptr = |
| 1636 | result->use_prepacked_rhs ? &result->prepacked_rhs : nullptr; |
| 1637 | auto alloc_fn = [&result](std::size_t num_bytes) { |
| 1638 | return result->allocator.AllocateBytes(num_bytes); |
| 1639 | }; |
| 1640 | // Use a dst with a null data pointer to check that the pre-packing |
| 1641 | // invocation doesn't write into it. |
| 1642 | Matrix<DstScalar> null_data_dst = result->storage_matrix.matrix; |
| 1643 | null_data_dst.data = nullptr; |
| 1644 | GlobalContext().SetRuntimeEnabledPaths(result->path); |
| 1645 | PrePackForMul<kAllPaths>(lhs.matrix, rhs.matrix, spec, &GlobalContext(), |
| 1646 | &null_data_dst, prepacked_lhs_ptr, |
| 1647 | prepacked_rhs_ptr, alloc_fn); |
| 1648 | RUY_CHECK(GlobalContext().last_taken_path == result->path); |
| 1649 | } |
| 1650 | |
| 1651 | life_stage = LifeStage::kHasPrepackedMatrices; |
| 1652 | } |
| 1653 | |
| 1654 | template <typename LhsScalar, typename RhsScalar, typename SpecType> |
| 1655 | void TestSet<LhsScalar, RhsScalar, SpecType>::MakeResultPaths() { |
nothing calls this directly
no test coverage detected