
168 Designing Scientific Applications on GPUs
positive function which is equal to 1 when applied to 0. Thus, if x is greater
than y then expf(x − y − 1) returns a value between 0 and 1. If the result is
rounded to an integer value 0 will be obtained. Now, if x is less than y then
expf(x −y −1) returns a value greater than 1 and since the minimum between
1 and the exponential is get, the returned result would be 1. Such behavior
satisfies exactly our prerequisites. The above if instruction pseudocode is now
equivalent to
int coeff = min(1, expf(RM[1] - MIN - 1));
Best idx = coeff × Current idx + ( 1 - coeff ) × Best idx ;
8.8 Memory access optimization
Memory ...