This patch ties in the array split, merge, and interleave code.
shader-db changes in the TGSI code are:
original code | array-merge | change
mean max | mean max | best mean % worst
-----------------------------------------------------------
arrays 0.05 2 | 0.00 0 | -2 -100 0
total temps 5.05 21 | 4.92 20 | -15 -2.59 1
instr 55.33 988 | 55.20 988 | -15 -0.24 0
Evaluation:
Run shader-db in single thread mode (otherwise the output is
not ordered and the best and worst column don't make sense) to
get results pre-stats.txt and post-stats.txt. Then using
python pandas:
import pandas as pd
old_stats = pd.read_csv('pre-stats.txt')
new_stats = pd.read_csv('post-stats.txt')
omean = old_stats.mean()
omax = old_stats.max()
nmean = new_stats.mean()
nmax = new_stats.max()
delta = new_stats - old_stats
pd.concat([omean, omax, nmean, nmax, delta.min(),
delta.mean()/old_stats.mean()*100, delta.max()],
axis=1, keys=['mean', 'max', 'mean', 'max', 'best',
'avg change %', 'worst'])
v4: - Correct typo and add bugs that are fixed by this series.
- Update stats and describe stats evaluation
Bugzilla:
https://bugs.freedesktop.org/show_bug.cgi?id=105371
https://bugs.freedesktop.org/show_bug.cgi?id=100200
Signed-off-by: Gert Wollny <gw.fossdev@gmail.com>
Acked-by: Dave Airlie <airlied@redhat.com>
void
glsl_to_tgsi_visitor::merge_registers(void)
{
+ struct array_live_range *arr_live_ranges = NULL;
+
struct register_live_range *reg_live_ranges =
rzalloc_array(mem_ctx, struct register_live_range, this->next_temp);
+ if (this->next_array > 0) {
+ arr_live_ranges = new array_live_range[this->next_array];
+ for (unsigned i = 0; i < this->next_array; ++i)
+ arr_live_ranges[i] = array_live_range(i+1, this->array_sizes[i+1]);
+ }
+
+
if (get_temp_registers_required_live_ranges(reg_live_ranges, &this->instructions,
- this->next_temp, reg_live_ranges)) {
+ this->next_temp, reg_live_ranges,
+ this->next_array, arr_live_ranges)) {
struct rename_reg_pair *renames =
rzalloc_array(reg_live_ranges, struct rename_reg_pair, this->next_temp);
get_temp_registers_remapping(reg_live_ranges, this->next_temp,
reg_live_ranges, renames);
rename_temp_registers(renames);
- ralloc_free(renames);
+
+ this->next_array = merge_arrays(this->next_array, this->array_sizes,
+ &this->instructions, arr_live_ranges);
+
+ if (arr_live_ranges)
+ delete[] arr_live_ranges;
}
ralloc_free(reg_live_ranges);
}
const array_remapping& rhs);
private:
+
+ void interleave(int trgt_access_mask, int src_access_mask);
+
unsigned target_id;
int8_t read_swizzle_map[4];
};
unsigned *array_sizes,
exec_list *instructions,
struct array_live_range *arr_live_ranges);
-#endif
\ No newline at end of file
+#endif
*/
bool
get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions,
- int ntemps, struct register_live_range *register_live_ranges)
+ int ntemps, struct register_live_range *register_live_ranges,
+ int narrays, struct array_live_range *array_live_ranges)
{
int line = 0;
int loop_id = 1;
bool is_at_end = false;
int n_scopes = 1;
- /* Placeholder to make the tests pass */
- int narrays = 2;
- struct array_live_range array_live_ranges[3];
-
/* Count scopes to allocate the needed space without the need for
* re-allocation
*/
#ifndef MESA_GLSL_TO_TGSI_TEMPRENAME_H
#define MESA_GLSL_TO_TGSI_TEMPRENAME_H
-#include "st_glsl_to_tgsi_private.h"
+#include "st_glsl_to_tgsi_array_merge.h"
/** Storage to record the required live range of a temporary register
* begin == end == -1 indicates that the register can be reused without
* point to allocated memory that can hold ntemps register_live_range
* structures. On output the live ranges contains the live ranges for
* the registers with the exception of TEMP[0]
+ * @param[in] narrays number of array sreserved for this shader
+ * @param[in,out] arr_live_ranges memory location to store the estimated required
+ * live ranges for each array. The parameter must point to allocated memory
+ * that can hold narrays array_live_range structures. On output the live
+ * ranges contains the live ranges for the registers with the exception of
+ * ARRAY[0].
* @returns: true if the lifetimes were estimated, false if not (i.e. if a
* subroutine was called).
*/
bool
get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions,
- int ntemps, struct register_live_range *register_live_ranges);
+ int ntemps, struct register_live_range *register_live_ranges,
+ int narrays, array_live_range *array_live_ranges);
/** Estimate the merge remapping of the registers.
* @param[in] mem_ctx a memory context that can be used with the ralloc_*
{
FakeShader shader(code);
lifetime_result result(shader.get_num_temps());
-
+ vector <array_live_range> arr(10);
success =
get_temp_registers_required_live_ranges(mem_ctx, shader.get_program(mem_ctx),
- shader.get_num_temps(),
- &result[0]);
+ shader.get_num_temps(),
+ &result[0], 9, &arr[0]);
return result;
}
{
FakeShader shader(code);
lifetime_result result(shader.get_num_temps());
-
+ vector <array_live_range> arr(10);
bool success =
get_temp_registers_required_live_ranges(mem_ctx, shader.get_program(mem_ctx),
shader.get_num_temps(),
- &result[0]);
+ &result[0], 9, &arr[0]);
ASSERT_TRUE(success);
ASSERT_EQ(result.size(), e.size());
check(result, e);
{
FakeShader shader(code);
std::vector<register_live_range> lt(shader.get_num_temps());
-
+ vector <array_live_range> arr(10);
get_temp_registers_required_live_ranges(mem_ctx, shader.get_program(mem_ctx),
- shader.get_num_temps(), <[0]);
+ shader.get_num_temps(), <[0],
+ 9, &arr[0]);
this->run(lt, expect);
}