Sort a float array into non-decreasing order on the GPU with a bitonic network. is a power of two and the whole array fits in one block (n <= 1024).
A bitonic sorter is a fixed comparison network: at stage and distance , thread compares with and swaps so that each length- block becomes bitonic and then monotonic. Direction inside a block is set by whether bit of is clear (ascending) or set (descending), until the last stage which is entirely ascending.
Complete:
__global__ kernel that sorts in shared memory with the bitonic network.void solve(const float* input, float* output, int n) where both pointers are host pointers of length n. Allocate, copy in, launch one block, copy out, and free.Constraints: is a power of two, 1 <= n <= 1024. Do not write a main() in your solution.