Debian Codegraph @

src/panfrost/compiler/bifrost/valhall/va_perf.c

raw
1
2 /*
3 * Copyright (C) 2021 Collabora Ltd.
4 * SPDX-License-Identifier: MIT
5 */
6
7 #include "bi_builder.h"
8 #include "va_compiler.h"
9 #include "valhall.h"
10
11 void
12 va_count_instr_stats(bi_instr *I, struct va_stats *stats)
13 {
14 /* Adjusted for 64-bit arithmetic */
15 unsigned words = bi_count_write_registers(I, 0);
16
17 bi_foreach_dest(I, d) {
18 if (I->dest[d].type == BI_INDEX_REGISTER)
19 stats->reg_mask |= (uint64_t)bi_writemask(I, d) << I->dest[d].value;
20 }
21 bi_foreach_src(I, s) {
22 if (I->src[s].type == BI_INDEX_REGISTER) {
23 unsigned pos = I->src[s].offset + I->src[s].value;
24 unsigned count = bi_count_read_registers(I, s);
25 stats->reg_mask |= ((uint64_t)BITFIELD_MASK(count)) << pos;
26 }
27 if (I->src[s].type == BI_INDEX_FAU) {
28 bi_index index = I->src[s];
29 unsigned val = index.value;
30 if (val >= BIR_FAU_UNIFORM) {
31 val = val & ~BIR_FAU_UNIFORM;
32 if (val < BIR_FAU_UNIFORM) {
33 stats->nr_fau_uniforms = MAX2(stats->nr_fau_uniforms, val+1);
34 }
35 }
36 }
37 }
38 switch (valhall_opcodes[I->op].unit) {
39 /* Arithmetic is 2x slower for 64-bit than 32-bit */
40 case VA_UNIT_FMA:
41 stats->fma += words;
42 return;
43
44 case VA_UNIT_CVT:
45 stats->cvt += words;
46 return;
47
48 case VA_UNIT_SFU:
49 stats->sfu += words;
50 return;
51
52 /* Varying is scaled by 16-bit components interpolated */
53 case VA_UNIT_V:
54 stats->v +=
55 (I->vecsize + 1) * (bi_is_regfmt_16(I->register_format) ? 1 : 2);
56 return;
57
58 /* We just count load/store and texturing for now */
59 case VA_UNIT_LS:
60 stats->ls++;
61 return;
62
63 case VA_UNIT_T:
64 stats->t++;
65 return;
66
67 /* Fused varying+texture loads 2 FP32 components of varying for texture
68 * coordinates and then textures */
69 case VA_UNIT_VT:
70 stats->ls += (2 * 2);
71 stats->t++;
72 return;
73
74 /* Nothing to do here */
75 case VA_UNIT_NONE:
76 return;
77 }
78
79 UNREACHABLE("Invalid unit");
80 }