I worked on sorting the network (for arrays less than 8) and noticed that all the algorithms focused on its ability to allow parallel operations. Here is one such set for an array of size 5.
#define SWAP(x,y) if (data[y] < data[x]) { int tmp = data[x]; data[x] = data[y]; data[y] = tmp; }
SWAP(1, 2);
SWAP(4, 5);
SWAP(0, 2);
SWAP(3, 5);
SWAP(0, 1);
SWAP(3, 4);
SWAP(2, 5);
SWAP(0, 3);
SWAP(1, 4);
SWAP(2, 4);
SWAP(1, 3);
SWAP(2, 3);
I worked with arrays long int(so each element is 8 bytes in size). So, is there an easy way to parallelize these operations in C? Are there any hardware specific commands that I can use to achieve this (SIMD, ASM (x86), etc.)
source
share