- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear users,
I wanted to make a comment regarding the floating-point support Altera's OpenCL provides. The compiler provides a complete coverage of floating-point operations, both in single and double precision. The single-precision floating point operations are conformant to the OpenCL 1.0 standard, while the double-precision functions are not at the moment. The compiler supports all vector sizes for these operations. One item worthy of note is that the compiler may infer a double-precision operation where you may have wanted to use a single-precision operation. This happens in accordance to the C99 standard and how arguments are promoted. For example, __kernel void test1(__global float *x, __global float *y) { int i = get_global_id(0); y = pow(x, 5.0); } may have been intended to use a single-precision pow function, since the variable input is of type float. However, the specification of the constant is actually understood to be double-precision, and thus the compiler sees the function call with arguments pow(float, double) and the only legal argument promotion is to pow(double, double). To obtain the desired, and conformant, functionality the kernel should be written as follows: __kernel void test1(__global float *x, __global float *y) { int i = get_global_id(0); y = pow(x, 5.0f); } Now, the second argument is also a single-precision argument and the compiler will correctly invoke the single-precision pow function and produce a conformant result.Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page