pan/bit: Add helper for generating floating mod tests
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 1 Apr 2020 20:24:15 +0000 (16:24 -0400)
committerMarge Bot <eric+marge@anholt.net>
Sun, 5 Apr 2020 23:26:04 +0000 (23:26 +0000)
We can iterate them, isn't that adorable!

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4458>

src/panfrost/bifrost/test/bi_test_pack.c
src/panfrost/bifrost/test/bit.h

index bd20252c20f2c91af3a7f0079bf3105fd789b3d8..c693f8509f56e0e0e7bf6c337a7e6996786d5661 100644 (file)
@@ -143,5 +143,55 @@ bit_test_single(struct panfrost_device *dev,
         bi_pack(ctx, &prog.compiled);
 
         return bit_vertex(dev, prog, input, 16, NULL, 0,
-                        s.r, 16, BIT_DEBUG_ALL);
+                        s.r, 16, debug);
+}
+
+/* Utilities for generating tests */
+
+static void
+bit_generate_vector(uint32_t *mem)
+{
+        for (unsigned i = 0; i < 4; ++i)
+                mem[i] = rand();
+}
+
+/* Tests all 64 combinations of floating point modifiers for a given
+ * instruction / floating-type / test type */
+
+void
+bit_fmod_helper(struct panfrost_device *dev,
+                enum bi_class c, unsigned size, bool fma,
+                uint32_t *input, enum bit_debug debug)
+{
+        nir_alu_type T = nir_type_float | size;
+
+        bi_instruction ins = {
+                .type = c,
+                .src = {
+                        BIR_INDEX_REGISTER | 0,
+                        BIR_INDEX_REGISTER | 1,
+                },
+                .src_types = { T, T },
+                .dest = BIR_INDEX_REGISTER | 2,
+                .dest_type = T,
+        };
+
+        for (unsigned outmod = 0; outmod < 4; ++outmod) {
+                for (unsigned inmod = 0; inmod < 16; ++inmod) {
+                        ins.outmod = outmod;
+                        ins.src_abs[0] = (inmod & 0x1);
+                        ins.src_abs[1] = (inmod & 0x2);
+                        ins.src_neg[0] = (inmod & 0x4);
+                        ins.src_neg[1] = (inmod & 0x8);
+
+                        if (!bit_test_single(dev, &ins, input, fma, debug)) {
+                                fprintf(stderr, "FAIL: fmod.%s%u.%s%s.%u\n",
+                                                bi_class_name(c),
+                                                size,
+                                                fma ? "fma" : "add",
+                                                outmod ? bi_output_mod_name(outmod) : ".none",
+                                                inmod);
+                        }
+                }
+        }
 }
index a45d18af44b51a0080ee0942d0d4f062a19433a8..5f01b345f0c7f0c96544ebe71083504f77024ea9 100644 (file)
@@ -48,7 +48,7 @@ bool
 bit_vertex(struct panfrost_device *dev, panfrost_program prog,
                 uint32_t *iubo, size_t sz_ubo,
                 uint32_t *iattr, size_t sz_attr,
-                uint32_t *expected, size_t sz_expected, enum bit_debug);
+                uint32_t *expected, size_t sz_expected, enum bit_debug debug);
 
 /* BIT interpreter */
 
@@ -69,11 +69,10 @@ bit_step(struct bit_state *s, bi_instruction *ins, bool FMA);
 
 /* Packing tests */
 
-bool
-bit_test_single(struct panfrost_device *dev,
-                bi_instruction *ins, 
-                uint32_t input[4],
-                bool fma);
+void
+bit_fmod_helper(struct panfrost_device *dev,
+                enum bi_class c, unsigned size, bool fma,
+                uint32_t *input, enum bit_debug debug);
 
 #endif