diff options
author | Jason Ekstrand <[email protected]> | 2015-09-15 17:57:40 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-09-17 17:44:20 -0700 |
commit | 15624fcf55bff9d16f3eaa461e4a3010bbe0e4ba (patch) | |
tree | 4c8f9dcd747c42fa4cd82b8decf3aa584110f07a /src/vulkan/tests | |
parent | 55daed947d3a0a7802733443a5f922dcc28a5770 (diff) |
anv/tests: Refactor the block_pool_no_free test
This simply breaks the monotonicity check out into its own function
Diffstat (limited to 'src/vulkan/tests')
-rw-r--r-- | src/vulkan/tests/block_pool_no_free.c | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/src/vulkan/tests/block_pool_no_free.c b/src/vulkan/tests/block_pool_no_free.c index d40504c4a87..71eb90103ef 100644 --- a/src/vulkan/tests/block_pool_no_free.c +++ b/src/vulkan/tests/block_pool_no_free.c @@ -46,23 +46,8 @@ static void *alloc_blocks(void *_job) return NULL; } -static void run_test() +static void validate_monotonic(uint32_t **blocks) { - struct anv_device device; - struct anv_block_pool pool; - - pthread_mutex_init(&device.mutex, NULL); - anv_block_pool_init(&pool, &device, 16); - - for (unsigned i = 0; i < NUM_THREADS; i++) { - jobs[i].pool = &pool; - jobs[i].id = i; - pthread_create(&jobs[i].thread, NULL, alloc_blocks, &jobs[i]); - } - - for (unsigned i = 0; i < NUM_THREADS; i++) - pthread_join(jobs[i].thread, NULL); - /* A list of indices, one per thread */ unsigned next[NUM_THREADS]; memset(next, 0, sizeof(next)); @@ -76,8 +61,8 @@ static void run_test() if (next[i] >= BLOCKS_PER_THREAD) continue; - if (thread_max < jobs[i].blocks[next[i]]) { - thread_max = jobs[i].blocks[next[i]]; + if (thread_max < blocks[i][next[i]]) { + thread_max = blocks[i][next[i]]; max_thread_idx = i; } } @@ -89,11 +74,35 @@ static void run_test() break; /* That next element had better be higher than the previous highest */ - assert(jobs[max_thread_idx].blocks[next[max_thread_idx]] > highest); + assert(blocks[max_thread_idx][next[max_thread_idx]] > highest); - highest = jobs[max_thread_idx].blocks[next[max_thread_idx]]; + highest = blocks[max_thread_idx][next[max_thread_idx]]; next[max_thread_idx]++; } +} + +static void run_test() +{ + struct anv_device device; + struct anv_block_pool pool; + + pthread_mutex_init(&device.mutex, NULL); + anv_block_pool_init(&pool, &device, 16); + + for (unsigned i = 0; i < NUM_THREADS; i++) { + jobs[i].pool = &pool; + jobs[i].id = i; + pthread_create(&jobs[i].thread, NULL, alloc_blocks, &jobs[i]); + } + + for (unsigned i = 0; i < NUM_THREADS; i++) + pthread_join(jobs[i].thread, NULL); + + uint32_t *block_ptrs[NUM_THREADS]; + for (unsigned i = 0; i < NUM_THREADS; i++) + block_ptrs[i] = jobs[i].blocks; + + validate_monotonic(block_ptrs); anv_block_pool_finish(&pool); pthread_mutex_destroy(&device.mutex); |