Download OpenCL™ Optimization Guide
Transcript
optimization_guide … tempSrc.x >>= 8; tempSrc.y >>= 8; … tempSrc.x >>= 8; tempSrc.y >>= 8; … uint a0 = (tempSrc.x & 0xff);// Alpha component of 1st pixel uint a1 = (tempSrc.y & 0xff);// Alpha component of 2nd pixel //any calculations on the individual components … uint4 final = 0; // repack them: final.x = (r0) | ((g0) << 8) | ((b0) << 16) | ((a0) << 16);//first pixel final.y = (r1) | ((g1) << 8) | ((b1) << 16) | ((a1) << 16);//second pixel … dst[offset] = final; } NOTE The global size is 1/4th of the original size in the second example above. If your kernel operates on floating-point data, consider using float4 data type, which gets four times as much data in one load. It also helps to ensure that the kernel has enough work to do, amortizing the work-item scheduling overheads. For the CPU device this optimization is equivalent to explicit (manual) vectorization, see the “Using Vector Data Types” section for more information. Accessing data in greater chunks can improve the Intel® Graphics device data throughput, but it might slightly reduce the CPU device performance as also explained in the “Using Vector Data Types” section. See Also Using Vector Data Types 36