diff options
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); |