| 1652 | uint32_t ci, |
| 1653 | uint32_t il, |
| 1654 | int expert, |
| 1655 | float weight) { |
| 1656 | ds4_expert_profile *p = &g_expert_profile; |
| 1657 | const uint32_t cap = p->caps[ci]; |
| 1658 | int *entries = p->cache_entries[ci][il]; |
| 1659 | uint32_t *count = &p->cache_count[ci][il]; |
| 1660 | uint32_t found = UINT32_MAX; |
| 1661 | |
| 1662 | for (uint32_t i = 0; i < *count; i++) { |
| 1663 | if (entries[i] == expert) { |
| 1664 | found = i; |
| 1665 | break; |
| 1666 | } |
| 1667 | } |
| 1668 | |
| 1669 | if (found != UINT32_MAX) { |
| 1670 | p->cache_hits[ci][il]++; |
| 1671 | p->cache_weight_hits[ci][il] += weight; |
| 1672 | for (uint32_t i = found; i > 0; i--) entries[i] = entries[i - 1]; |
| 1673 | entries[0] = expert; |
| 1674 | return; |
| 1675 | } |
| 1676 | |
| 1677 | uint32_t n = *count; |
| 1678 | if (n < cap) { |
| 1679 | (*count)++; |
| 1680 | } else if (n > 0) { |
| 1681 | n = cap - 1; |
| 1682 | } |
| 1683 | for (uint32_t i = n; i > 0; i--) entries[i] = entries[i - 1]; |
| 1684 | entries[0] = expert; |
| 1685 | } |
| 1686 | |
| 1687 | static void ds4_expert_profile_record( |
| 1688 | uint32_t il, |
| 1689 | uint32_t pos, |
| 1690 | const int32_t selected[DS4_MAX_EXPERT_USED], |
| 1691 | const float weights[DS4_MAX_EXPERT_USED], |
| 1692 | bool is_hash) { |
| 1693 | ds4_expert_profile *p = &g_expert_profile; |
| 1694 | if (!p->active || il >= p->n_layer) return; |
| 1695 |
no test coverage detected