lima/gpir: fix compile fail when two slot node
authorQiang Yu <yuq825@gmail.com>
Thu, 11 Apr 2019 07:42:59 +0000 (15:42 +0800)
committerQiang Yu <yuq825@gmail.com>
Sun, 14 Apr 2019 04:10:23 +0000 (12:10 +0800)
Come from glmark2-es2 jellyfish test.

Fixes: 92d7ca4b1cd "gallium: add lima driver"
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
src/gallium/drivers/lima/ir/gp/gpir.h
src/gallium/drivers/lima/ir/gp/instr.c
src/gallium/drivers/lima/ir/gp/scheduler.c

index 47e4422cd830e741b4af7c1f0619d0a9ecceb2fb..43d2adf23664069ad962e9132397ea649cd31ef0 100644 (file)
@@ -377,6 +377,11 @@ bool gpir_instr_try_insert_node(gpir_instr *instr, gpir_node *node);
 void gpir_instr_remove_node(gpir_instr *instr, gpir_node *node);
 void gpir_instr_print_prog(gpir_compiler *comp);
 
+static inline bool gpir_instr_alu_slot_is_full(gpir_instr *instr)
+{
+   return instr->alu_num_slot_free <= instr->alu_num_slot_needed_by_store;
+}
+
 bool gpir_codegen_acc_same_op(gpir_op op1, gpir_op op2);
 
 bool gpir_pre_rsched_lower_prog(gpir_compiler *comp);
index 847369906086c191b17e27cb61c868a9ae9f61bd..0ff7e7eabc24786dae00ec66ef1c5cfbfed77c13 100644 (file)
@@ -273,7 +273,7 @@ static bool gpir_instr_insert_store_check(gpir_instr *instr, gpir_node *node)
     * already in this instr's alu slot, so instr must have some free
     * alu slot to insert this node's child
     */
-   if (instr->alu_num_slot_free <= instr->alu_num_slot_needed_by_store)
+   if (gpir_instr_alu_slot_is_full(instr))
       return false;
 
    instr->alu_num_slot_needed_by_store++;
index 8dbec242a7a0031556afe2770e229504ce5970de..3d7e640ada26d939c43ec875426827b8eca5c45f 100644 (file)
@@ -464,16 +464,33 @@ static gpir_node *gpir_sched_instr_pass(gpir_instr *instr,
 
    /* schedule node used by previous instr when count > 5 */
    int count = 0;
+   gpir_node *two_slot_node = NULL;
    list_for_each_entry(gpir_node, node, ready_list, list) {
       if (gpir_is_input_node(node)) {
          int min = gpir_get_min_scheduled_succ(node);
          assert(min >= instr->index - 1);
-         if (min == instr->index - 1)
-            count += gpir_op_infos[node->op].may_consume_two_slots ? 2 : 1;
+         if (min == instr->index - 1) {
+            if (gpir_op_infos[node->op].may_consume_two_slots) {
+               two_slot_node = node;
+               count += 2;
+            }
+            else
+               count++;
+         }
       }
    }
 
    if (count > 5) {
+      /* When no slot avaible, must schedule a move for two slot node
+       * to reduce the count. This results from the dummy_m/f method.
+       */
+      if (gpir_instr_alu_slot_is_full(instr)) {
+         assert(two_slot_node);
+         gpir_debug("instr is full, schedule move node for two slot node %d\n",
+                    two_slot_node->index);
+         return gpir_sched_node(instr, two_slot_node);
+      }
+
       /* schedule fully ready node first */
       list_for_each_entry(gpir_node, node, ready_list, list) {
          if (gpir_is_input_node(node)) {