From: Alyssa Rosenzweig Date: Mon, 6 Apr 2020 13:51:56 +0000 (-0400) Subject: pan/bit: Add special unit test X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=545fc7b26aeef90f5c03d2a900a8e038011758d3;p=mesa.git pan/bit: Add special unit test Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/bifrost/bi_print.c b/src/panfrost/bifrost/bi_print.c index 70c8c9a88de..0b3af8a00c9 100644 --- a/src/panfrost/bifrost/bi_print.c +++ b/src/panfrost/bifrost/bi_print.c @@ -251,7 +251,7 @@ bi_bitwise_op_name(enum bi_bitwise_op op) } } -static const char * +const char * bi_special_op_name(enum bi_special_op op) { switch (op) { diff --git a/src/panfrost/bifrost/bi_print.h b/src/panfrost/bifrost/bi_print.h index 13ac48bd46f..07632c9ab54 100644 --- a/src/panfrost/bifrost/bi_print.h +++ b/src/panfrost/bifrost/bi_print.h @@ -40,6 +40,7 @@ const char * bi_interp_mode_name(enum bifrost_interp_mode mode); const char * bi_ldst_type_name(enum bifrost_ldst_type type); const char * bi_class_name(enum bi_class cl); const char * bi_cond_name(enum bi_cond cond); +const char * bi_special_op_name(enum bi_special_op op); void bi_print_instruction(bi_instruction *ins, FILE *fp); void bi_print_bundle(bi_bundle *bundle, FILE *fp); diff --git a/src/panfrost/bifrost/cmdline.c b/src/panfrost/bifrost/cmdline.c index e640a898f76..095437b89fd 100644 --- a/src/panfrost/bifrost/cmdline.c +++ b/src/panfrost/bifrost/cmdline.c @@ -131,6 +131,7 @@ tests(void) bit_fmod(dev, BIT_DEBUG_FAIL); bit_fma(dev, BIT_DEBUG_FAIL); bit_csel(dev, BIT_DEBUG_FAIL); + bit_special(dev, BIT_DEBUG_FAIL); } static void diff --git a/src/panfrost/bifrost/test/bi_test_pack.c b/src/panfrost/bifrost/test/bi_test_pack.c index 498502731c3..34e2a5cc29f 100644 --- a/src/panfrost/bifrost/test/bi_test_pack.c +++ b/src/panfrost/bifrost/test/bi_test_pack.c @@ -259,6 +259,25 @@ bit_csel_helper(struct panfrost_device *dev, } } +static void +bit_special_helper(struct panfrost_device *dev, + unsigned size, uint32_t *input, enum bit_debug debug) +{ + bi_instruction ins = bit_ins(BI_SPECIAL, 1, nir_type_float, size); + + for (enum bi_special_op op = BI_SPECIAL_FRCP; op <= BI_SPECIAL_FRSQ; ++op) { + for (unsigned c = 0; c < ((size == 16) ? 2 : 1); ++c) { + ins.op.special = op; + ins.swizzle[0][0] = c; + + if (!bit_test_single(dev, &ins, input, false, debug)) { + fprintf(stderr, "FAIL: special%u.%s\n", + size, bi_special_op_name(op)); + } + } + } +} + void bit_fmod(struct panfrost_device *dev, enum bit_debug debug) { @@ -320,3 +339,18 @@ bit_csel(struct panfrost_device *dev, enum bit_debug debug) bit_csel_helper(dev, sz, input, debug); } } + +void +bit_special(struct panfrost_device *dev, enum bit_debug debug) +{ + float input32[4] = { 0.9 }; + uint32_t input16[4] = { _mesa_float_to_half(input32[0]) | (_mesa_float_to_half(0.2) << 16) }; + + for (unsigned sz = 16; sz <= 32; sz *= 2) { + uint32_t *input = + (sz == 16) ? input16 : + (uint32_t *) input32; + + bit_special_helper(dev, sz, input, debug); + } +} diff --git a/src/panfrost/bifrost/test/bit.h b/src/panfrost/bifrost/test/bit.h index 78d80aa80b1..c4c72ed2405 100644 --- a/src/panfrost/bifrost/test/bit.h +++ b/src/panfrost/bifrost/test/bit.h @@ -72,6 +72,7 @@ bit_step(struct bit_state *s, bi_instruction *ins, bool FMA); void bit_fmod(struct panfrost_device *dev, enum bit_debug debug); void bit_fma(struct panfrost_device *dev, enum bit_debug debug); void bit_csel(struct panfrost_device *dev, enum bit_debug debug); +void bit_special(struct panfrost_device *dev, enum bit_debug debug); #endif