Commit 545fc7b2 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜 Committed by Marge Bot
Browse files

pan/bit: Add special unit test


Signed-off-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <mesa/mesa!4470>
parent 8e50d449
......@@ -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) {
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
}
}
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment