File: fmod-float-varying-1.ispc

package info (click to toggle)
ispc 1.28.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 97,620 kB
  • sloc: cpp: 77,067; python: 8,303; yacc: 3,337; lex: 1,126; ansic: 631; sh: 475; makefile: 17
file content (35 lines) | stat: -rw-r--r-- 1,243 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "test_static.isph"

task void f_f(uniform float RET[], uniform float aFOO[]) {
    RET[programIndex] = 0;

    // Case 1: x and y are generic positive values
    float x = aFOO[programCount / 2];
    float y = 0.8;
    float testVal = fmod(x, y);
    float baseRes = x - trunc(x / y) * y;
    RET[programIndex] += ((abs(baseRes - testVal) < 1e-6) || abs((baseRes-testVal)/baseRes) < 1e-5) ? 0 : 1;

    // Case 2: x is negative, y is positive
    x = -aFOO[programCount / 2];
    y = 0.8;
    testVal = fmod(x, y);
    baseRes = x - trunc(x / y) * y;
    RET[programIndex] += ((abs(baseRes - testVal) < 1e-6) || abs((baseRes-testVal)/baseRes) < 1e-5) ? 0 : 1;

    // Case 3: x is positive, y is negative
    x = aFOO[programCount / 2];
    y = -0.8;
    testVal = fmod(x, y);
    baseRes = x - trunc(x / y) * y;
    RET[programIndex] += ((abs(baseRes - testVal) < 1e-6) || abs((baseRes-testVal)/baseRes) < 1e-5) ? 0 : 1;

    // Case 4: x and y are negative
    x = -aFOO[programCount / 2];
    y = -0.8;
    testVal = fmod(x, y);
    baseRes = x - trunc(x / y) * y;
    RET[programIndex] += ((abs(baseRes - testVal) < 1e-6) || abs((baseRes-testVal)/baseRes) < 1e-5) ? 0 : 1;
}

task void result(uniform float RET[]) { RET[0] = 0; }