summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nouveau/nvc0/mme
diff options
context:
space:
mode:
authorRhys Perry <[email protected]>2018-06-27 00:04:41 +0100
committerIlia Mirkin <[email protected]>2019-02-06 19:35:57 -0500
commit5b6f522fc29f4c8bbadd0466b6f61c1876c95807 (patch)
treec96fbad2e2f83bb077b95c2a0618d6da31c06bfd /src/gallium/drivers/nouveau/nvc0/mme
parentcce495572136a606dd2a35e79f45080c3796e2cc (diff)
nvc0: add compute invocation counter
The strategy is to keep a CPU-side counter of the direct invocations, and a GPU-side counter of the indirect invocations, and then add them together for queries. The specific technique is a macro which multiplies a list of integers together and accumulates the product into SCRATCH registers held inside of the context. Another macro will read those values out and add them to the passed-in cpu-side counter to be stored in a query buffer the same way that all the other statistics are stored. Original implementation by Rhys Perry, redone by Ilia Mirkin to use the SCRATCH temporaries. Signed-off-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/gallium/drivers/nouveau/nvc0/mme')
-rw-r--r--src/gallium/drivers/nouveau/nvc0/mme/com9097.mme90
-rw-r--r--src/gallium/drivers/nouveau/nvc0/mme/com9097.mme.h54
2 files changed, 144 insertions, 0 deletions
diff --git a/src/gallium/drivers/nouveau/nvc0/mme/com9097.mme b/src/gallium/drivers/nouveau/nvc0/mme/com9097.mme
index 38c2e868431..d6af8221b65 100644
--- a/src/gallium/drivers/nouveau/nvc0/mme/com9097.mme
+++ b/src/gallium/drivers/nouveau/nvc0/mme/com9097.mme
@@ -580,3 +580,93 @@ crs_loop:
/* Enable */
exit maddr 0x1452 /* CONSERVATIVE_RASTER */
send 0x1
+
+/* NVC0_3D_MACRO_COMPUTE_COUNTER
+ *
+ * This macro takes 6 values, num_groups_* and group_size_*, and adds their
+ * product to the current value
+ *
+ * It's used for keeping track of the number of executed indirect
+ * compute invocations for statistics.
+ *
+ * SCRATCH[4] = current counter [low]
+ * SCRATCH[5] = current counter [high]
+ *
+ * arg = number of parameters to muliply together, ideally 6
+ * parm[0] = num_groups_x
+ * parm[1] = num_groups_y
+ * parm[2] = num_groups_z
+ * parm[3] = group_size_x
+ * parm[4] = group_size_y
+ * parm[5] = group_size_z
+ */
+.section #mme9097_compute_counter
+ mov $r7 $r1
+ mov $r1 1 /* low result */
+ mov $r2 0 /* high result */
+iic_loop_start:
+ parm $r3 /* val, next integer to multiply in */
+ /* multiplication start - look at low bit, add if set, shift right/left */
+ mov $r4 0 /* low temp */
+ mov $r5 0 /* high temp */
+iic_mul_start: /* temp = result * val */
+ braz annul $r3 #iic_mul_done
+iic_mul_body:
+ mov $r6 (extrinsrt 0x0 $r3 0 1 0) /* val & 1 - check low bit */
+ braz $r6 #iic_mul_cont /* bit not set */
+ mov $r3 (extrinsrt 0x0 $r3 1 31 0) /* val >>= 1 - shift right */
+
+ mov $r4 (add $r4 $r1) /* temp += result */
+ mov $r5 (adc $r5 $r2)
+iic_mul_cont:
+ mov $r1 (add $r1 $r1) /* shift left, part 1 (result *= 2) */
+ bra #iic_mul_start
+ mov $r2 (adc $r2 $r2) /* shift left, part 2 */
+iic_mul_done:
+ /* decrease loop counter, keep going if necessary */
+ mov $r7 (add $r7 -1)
+ /* result = temp ( = result * val ) */
+ mov $r1 $r4
+ branz $r7 #iic_loop_start
+ mov $r2 $r5
+
+ /* increment current value by newly-calculated invocation count */
+ read $r3 0xd04 /* SCRATCH[4] */
+ read $r4 0xd05 /* SCRATCH[5] */
+ maddr 0x1d04 /* SCRATCH[4] */
+ exit send (add $r3 $r1)
+ send (adc $r4 $r2)
+
+/* NVC0_3D_MACRO_COMPUTE_COUNTER_TO_QUERY
+ *
+ * This macro writes out the indirect counter plus a direct value to
+ * the given address using QUERY_GET (64-bit value).
+ *
+ * arg = direct counter low
+ * parm[0] = direct counter high
+ * parm[1] = query address high
+ * parm[2] = query address low
+ */
+.section #mme9097_compute_counter_to_query
+ parm $r2 /* counter high */
+ read $r3 0xd04 /* SCRATCH[4] */
+ read $r4 0xd05 /* SCRATCH[5] */
+ mov $r1 (add $r1 $r3)
+ mov $r2 (adc $r2 $r4)
+
+ parm $r3 maddr 0x16c0 /* QUERY_ADDRESS_HIGH */
+ parm $r4 send $r3
+ send $r4 /* r3 = addr high, r4 = addr low */
+ send $r1 /* sum low */
+ mov $r5 0x1000
+ send (extrinsrt 0x0 $r5 0x0 0x10 0x10) /* GET_SHORT */
+
+ /* add 4 to the address */
+ mov $r1 0x4
+ mov $r4 (add $r4 $r1) /* addr low */
+ mov $r3 (adc $r3 0x0) /* addr high */
+ maddr 0x16c0 /* QUERY_ADDRESS_HIGH */
+ send $r3 /* addr high */
+ send $r4 /* addr low */
+ exit send $r2 /* sum high */
+ send (extrinsrt 0x0 $r5 0x0 0x10 0x10) /* GET_SHORT */
diff --git a/src/gallium/drivers/nouveau/nvc0/mme/com9097.mme.h b/src/gallium/drivers/nouveau/nvc0/mme/com9097.mme.h
index 49c08911142..f068367c84e 100644
--- a/src/gallium/drivers/nouveau/nvc0/mme/com9097.mme.h
+++ b/src/gallium/drivers/nouveau/nvc0/mme/com9097.mme.h
@@ -394,3 +394,57 @@ uint32_t mme9097_conservative_raster_state[] = {
0x051480a1,
0x00004041,
};
+
+uint32_t mme9097_compute_counter[] = {
+/* 0x0003: iic_loop_start */
+ 0x00000f11,
+/* 0x0006: iic_mul_start */
+/* 0x0007: iic_mul_body */
+ 0x00004111,
+ 0x00000211,
+/* 0x000c: iic_mul_cont */
+/* 0x000f: iic_mul_done */
+ 0x00000301,
+ 0x00000411,
+ 0x00000511,
+ 0x00025827,
+ 0x0040c612,
+ 0x00013007,
+ 0x07c2c312,
+ 0x00006410,
+ 0x0002ad10,
+ 0x00004910,
+ 0xfffe4007,
+ 0x00029210,
+ 0xffffff11,
+ 0x00002111,
+ 0xfffcb817,
+ 0x00002a11,
+ 0x03410315,
+ 0x03414415,
+ 0x07410021,
+ 0x000058c0,
+ 0x0002a040,
+};
+
+uint32_t mme9097_compute_counter_to_query[] = {
+ 0x00000201,
+ 0x03410315,
+ 0x03414415,
+ 0x0000c910,
+ 0x00031210,
+ 0x05b00351,
+ 0x00001c31,
+ 0x00002041,
+ 0x00000841,
+ 0x04000511,
+ 0x84014042,
+ 0x00010111,
+ 0x00006410,
+ 0x00021b10,
+ 0x05b00021,
+ 0x00001841,
+ 0x00002041,
+ 0x000010c1,
+ 0x84014042,
+};