mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-11 01:46:14 +00:00
lib: extract drmtest_permute_array
Lots of tests need to create havoc to LRUs in the kernel or otherwise need to shuffle things around a bit. So make a small array permutation function available. Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
1a9fa8fd12
commit
fbfe374b28
@ -332,6 +332,22 @@ void drmtest_stop_signal_helper(void)
|
|||||||
signal_helper = -1;
|
signal_helper = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* other helpers */
|
||||||
|
void drmtest_permute_array(void *array, unsigned size,
|
||||||
|
void (*exchange_func)(void *array,
|
||||||
|
unsigned i,
|
||||||
|
unsigned j))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = size - 1; i > 1; i--) {
|
||||||
|
/* yes, not perfectly uniform, who cares */
|
||||||
|
long l = random() % (i +1);
|
||||||
|
if (i != l)
|
||||||
|
exchange_func(array, i, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* mappable aperture trasher helper */
|
/* mappable aperture trasher helper */
|
||||||
drm_intel_bo **trash_bos;
|
drm_intel_bo **trash_bos;
|
||||||
int num_trash_bos;
|
int num_trash_bos;
|
||||||
|
@ -55,6 +55,10 @@ uint64_t gem_mappable_aperture_size(void);
|
|||||||
/* generally useful helpers */
|
/* generally useful helpers */
|
||||||
void drmtest_fork_signal_helper(void);
|
void drmtest_fork_signal_helper(void);
|
||||||
void drmtest_stop_signal_helper(void);
|
void drmtest_stop_signal_helper(void);
|
||||||
|
void drmtest_permute_array(void *array, unsigned size,
|
||||||
|
void (*exchange_func)(void *array,
|
||||||
|
unsigned i,
|
||||||
|
unsigned j));
|
||||||
|
|
||||||
/* helpers based upon the libdrm buffer manager */
|
/* helpers based upon the libdrm buffer manager */
|
||||||
void drmtest_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
|
void drmtest_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
|
||||||
|
@ -492,19 +492,6 @@ static void init_buffer(struct scratch_buf *buf, unsigned size)
|
|||||||
buf->num_tiles = options.tiles_per_buf;
|
buf->num_tiles = options.tiles_per_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void permute_array(void *array, unsigned size,
|
|
||||||
void (*exchange_func)(void *array, unsigned i, unsigned j))
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = size - 1; i > 1; i--) {
|
|
||||||
/* yes, not perfectly uniform, who cares */
|
|
||||||
long l = random() % (i +1);
|
|
||||||
if (i != l)
|
|
||||||
exchange_func(array, i, l);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void exchange_buf(void *array, unsigned i, unsigned j)
|
static void exchange_buf(void *array, unsigned i, unsigned j)
|
||||||
{
|
{
|
||||||
struct scratch_buf *buf_arr, tmp;
|
struct scratch_buf *buf_arr, tmp;
|
||||||
@ -521,7 +508,7 @@ static void init_set(unsigned set)
|
|||||||
long int r;
|
long int r;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
permute_array(buffers[set], num_buffers, exchange_buf);
|
drmtest_permute_array(buffers[set], num_buffers, exchange_buf);
|
||||||
|
|
||||||
if (current_set == 1 && options.gpu_busy_load == 0) {
|
if (current_set == 1 && options.gpu_busy_load == 0) {
|
||||||
gpu_busy_load++;
|
gpu_busy_load++;
|
||||||
@ -924,7 +911,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
for (j = 0; j < num_total_tiles; j++)
|
for (j = 0; j < num_total_tiles; j++)
|
||||||
current_permutation[j] = j;
|
current_permutation[j] = j;
|
||||||
permute_array(current_permutation, num_total_tiles, exchange_uint);
|
drmtest_permute_array(current_permutation, num_total_tiles, exchange_uint);
|
||||||
|
|
||||||
copy_tiles(current_permutation);
|
copy_tiles(current_permutation);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user