9.5. Data Type Selection Considerations
- Select the most appropriate data type for your application.
For example, do not define your variable as float if the data type short is sufficient.
- Ensure that both sides of an arithmetic expression belong to the same data type.
Consider an example where one side of an arithmetic expression is a floating-point value and the other side is an integer. The mismatched data types cause the Intel® FPGA SDK for OpenCL™ Offline Compiler to create implicit conversion operators, which can become expensive if they are present in large numbers.
- Take advantage of padding if it exists in your data structures.
For example, if you only need float3 data type, which has the same size as float4, you may change the data type to float4 to make use of the extra dimension to carry an unrelated value.
Did you find the information on this page useful?