Mesa (main): pan/bi: Teach meson about scheduler predicate test
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jul 28 22:36:05 UTC 2021
Module: Mesa
Branch: main
Commit: 9bb731012efd1d92cd1ee1fc1e3e53a6efdaf706
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9bb731012efd1d92cd1ee1fc1e3e53a6efdaf706
Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date: Wed Jul 28 12:25:54 2021 -0400
pan/bi: Teach meson about scheduler predicate test
One step of 3 to getting all our tests in meson test.
Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12109>
---
src/panfrost/bifrost/bi_schedule.c | 57 ----------------
src/panfrost/bifrost/cmdline.c | 1 -
src/panfrost/bifrost/compiler.h | 1 -
src/panfrost/bifrost/meson.build | 14 ++++
.../bifrost/test/test-scheduler-predicates.c | 76 ++++++++++++++++++++++
5 files changed, 90 insertions(+), 59 deletions(-)
diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c
index 36653e6fc60..1991205f8db 100644
--- a/src/panfrost/bifrost/bi_schedule.c
+++ b/src/panfrost/bifrost/bi_schedule.c
@@ -1903,60 +1903,3 @@ bi_schedule(bi_context *ctx)
bi_opt_dce_post_ra(ctx);
bi_add_nop_for_atest(ctx);
}
-
-#ifndef NDEBUG
-
-#include "bi_test.h"
-#define TMP() bi_temp(b->shader)
-
-static void
-bi_test_units(bi_builder *b)
-{
- bi_instr *mov = bi_mov_i32_to(b, TMP(), TMP());
- assert(bi_can_fma(mov));
- assert(bi_can_add(mov));
- assert(!bi_must_message(mov));
- assert(bi_reads_zero(mov));
- assert(bi_reads_temps(mov, 0));
- assert(bi_reads_t(mov, 0));
-
- bi_instr *fma = bi_fma_f32_to(b, TMP(), TMP(), TMP(), bi_zero(), BI_ROUND_NONE);
- assert(bi_can_fma(fma));
- assert(!bi_can_add(fma));
- assert(!bi_must_message(fma));
- assert(bi_reads_zero(fma));
- for (unsigned i = 0; i < 3; ++i) {
- assert(bi_reads_temps(fma, i));
- assert(bi_reads_t(fma, i));
- }
-
- bi_instr *load = bi_load_i128_to(b, TMP(), TMP(), TMP(), BI_SEG_UBO);
- assert(!bi_can_fma(load));
- assert(bi_can_add(load));
- assert(bi_must_message(load));
- for (unsigned i = 0; i < 2; ++i) {
- assert(bi_reads_temps(load, i));
- assert(bi_reads_t(load, i));
- }
-
- bi_instr *blend = bi_blend_to(b, TMP(), TMP(), TMP(), TMP(), TMP(), 4);
- assert(!bi_can_fma(load));
- assert(bi_can_add(load));
- assert(bi_must_message(blend));
- for (unsigned i = 0; i < 4; ++i)
- assert(bi_reads_temps(blend, i));
- assert(!bi_reads_t(blend, 0));
- assert(bi_reads_t(blend, 1));
- assert(!bi_reads_t(blend, 2));
- assert(!bi_reads_t(blend, 3));
-}
-
-int bi_test_scheduler(void)
-{
- void *memctx = NULL;
-
- bi_test_units(bit_builder(memctx));
-
- return 0;
-}
-#endif
diff --git a/src/panfrost/bifrost/cmdline.c b/src/panfrost/bifrost/cmdline.c
index e32af874c6c..de51548e472 100644
--- a/src/panfrost/bifrost/cmdline.c
+++ b/src/panfrost/bifrost/cmdline.c
@@ -248,7 +248,6 @@ static int
bi_tests()
{
#ifndef NDEBUG
- bi_test_scheduler();
bi_test_packing();
bi_test_packing_formats();
printf("Pass.\n");
diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h
index b9d9870bb6e..e66e8afe8cc 100644
--- a/src/panfrost/bifrost/compiler.h
+++ b/src/panfrost/bifrost/compiler.h
@@ -908,7 +908,6 @@ uint32_t bi_fold_constant(bi_instr *I, bool *unsupported);
void bi_opt_constant_fold(bi_context *ctx);
/* Test suite */
-int bi_test_scheduler(void);
int bi_test_packing(void);
int bi_test_packing_formats(void);
diff --git a/src/panfrost/bifrost/meson.build b/src/panfrost/bifrost/meson.build
index 277ed1f688f..0bcf9832956 100644
--- a/src/panfrost/bifrost/meson.build
+++ b/src/panfrost/bifrost/meson.build
@@ -142,6 +142,20 @@ libpanfrost_bifrost = static_library(
)
if with_tests
+ test(
+ 'bifrost_scheduler_predicates',
+ executable(
+ 'bifrost_scheduler_predicates_test',
+ files('test/test-scheduler-predicates.c'),
+ c_args : [c_msvc_compat_args, no_override_init_args],
+ gnu_symbol_visibility : 'hidden',
+ include_directories : [inc_include, inc_src, inc_mesa],
+ dependencies: [idep_nir, idep_bi_opcodes_h, idep_bi_builder_h],
+ link_with : [libpanfrost_bifrost],
+ ),
+ suite : ['panfrost'],
+ )
+
test(
'bifrost_constant_fold',
executable(
diff --git a/src/panfrost/bifrost/test/test-scheduler-predicates.c b/src/panfrost/bifrost/test/test-scheduler-predicates.c
new file mode 100644
index 00000000000..95e1598e3e9
--- /dev/null
+++ b/src/panfrost/bifrost/test/test-scheduler-predicates.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2021 Collabora, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "compiler.h"
+#include "bi_test.h"
+#include "bi_builder.h"
+
+#define TMP() bi_temp(b->shader)
+
+int main(int argc, char **argv)
+{
+ unsigned nr_fail = 0, nr_pass = 0;
+ void *ralloc_ctx = ralloc_context(NULL);
+ bi_builder *b = bit_builder(ralloc_ctx);
+
+ bi_instr *mov = bi_mov_i32_to(b, TMP(), TMP());
+ BIT_ASSERT(bi_can_fma(mov));
+ BIT_ASSERT(bi_can_add(mov));
+ BIT_ASSERT(!bi_must_message(mov));
+ BIT_ASSERT(bi_reads_zero(mov));
+ BIT_ASSERT(bi_reads_temps(mov, 0));
+ BIT_ASSERT(bi_reads_t(mov, 0));
+
+ bi_instr *fma = bi_fma_f32_to(b, TMP(), TMP(), TMP(), bi_zero(), BI_ROUND_NONE);
+ BIT_ASSERT(bi_can_fma(fma));
+ BIT_ASSERT(!bi_can_add(fma));
+ BIT_ASSERT(!bi_must_message(fma));
+ BIT_ASSERT(bi_reads_zero(fma));
+ for (unsigned i = 0; i < 3; ++i) {
+ BIT_ASSERT(bi_reads_temps(fma, i));
+ BIT_ASSERT(bi_reads_t(fma, i));
+ }
+
+ bi_instr *load = bi_load_i128_to(b, TMP(), TMP(), TMP(), BI_SEG_UBO);
+ BIT_ASSERT(!bi_can_fma(load));
+ BIT_ASSERT(bi_can_add(load));
+ BIT_ASSERT(bi_must_message(load));
+ for (unsigned i = 0; i < 2; ++i) {
+ BIT_ASSERT(bi_reads_temps(load, i));
+ BIT_ASSERT(bi_reads_t(load, i));
+ }
+
+ bi_instr *blend = bi_blend_to(b, TMP(), TMP(), TMP(), TMP(), TMP(), 4);
+ BIT_ASSERT(!bi_can_fma(load));
+ BIT_ASSERT(bi_can_add(load));
+ BIT_ASSERT(bi_must_message(blend));
+ for (unsigned i = 0; i < 4; ++i)
+ BIT_ASSERT(bi_reads_temps(blend, i));
+ BIT_ASSERT(!bi_reads_t(blend, 0));
+ BIT_ASSERT(bi_reads_t(blend, 1));
+ BIT_ASSERT(!bi_reads_t(blend, 2));
+ BIT_ASSERT(!bi_reads_t(blend, 3));
+
+ ralloc_free(ralloc_ctx);
+ TEST_END(nr_pass, nr_fail);
+}
More information about the mesa-commit
mailing list