OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1663 Discussions

Should I use float3 or float array?

zhaopeng
Beginner
234 Views
Hello,
Three-components vector type is often used in engineering like velocity. Although built-in float3 is very convenient, it uses float4 for memory alignment which means memory waste. And the plain float array doesn't have this problem but the codes become a little more complex. What's the best practice for 3 components vector?
Thanks!
ZHAO Peng
0 Kudos
1 Reply
Raghupathi_M_Intel
234 Views
The answer depends on the device you are running. Typically vector data types are mapped to the underlying SIMDhardware. So using vector data types is much faster than using scalars. But some devices may only have scalar hardware so there is no performance benefit in using vector types. If the wasted memory is not that critical (its only small anyway), its better to use vector types.

Thanks,
Raghu
Reply