takahiroharada / oclradixsort Goto Github PK
View Code? Open in Web Editor NEWFrom book "Heterogeneous Computing with OpenCL"
From book "Heterogeneous Computing with OpenCL"
Hi, @takahiroharada for this part of code,
void sort4Bits1(u32 sortData[4], int startBit, int lIdx, __local u32* ldsSortData)
{
for(uint ibit=0; ibit<BITS_PER_PASS; ibit+=2)
{
uint4 b = make_uint4((sortData[0]>>(startBit+ibit)) & 0x3,
(sortData[1]>>(startBit+ibit)) & 0x3,
(sortData[2]>>(startBit+ibit)) & 0x3,
(sortData[3]>>(startBit+ibit)) & 0x3);
u32 key4;
u32 sKeyPacked[4] = { 0, 0, 0, 0 };
{
sKeyPacked[0] |= 1<<(8*b.x);
sKeyPacked[1] |= 1<<(8*b.y);
sKeyPacked[2] |= 1<<(8*b.z);
sKeyPacked[3] |= 1<<(8*b.w);
key4 = sKeyPacked[0] + sKeyPacked[1] + sKeyPacked[2] + sKeyPacked[3];
}
u32 rankPacked;
u32 sumPacked;
{
rankPacked = localPrefixSum( key4, lIdx, &sumPacked, ldsSortData, WG_SIZE );
}
GROUP_LDS_BARRIER;
u32 newOffset[4] = { 0,0,0,0 };
{
u32 sumScanned = bit8Scan( sumPacked );
If b.x, b.y, b.z, b.w is the same for whole workgroup(which has 64 threads), for example is b.x = b.y = b.z = b.w = 0 for each thread, then key4 = 4; after this into the localPrefixSum function, which will get the result sumPacked = 256, will overflow when the result only contains 8 bits. bit8Scan function will get wrong result, is there some method to solve this potential issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.