File: test_length_distance.cl

package info (click to toggle)
pocl 7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 29,768 kB
  • sloc: lisp: 151,669; ansic: 135,425; cpp: 65,801; python: 1,846; sh: 1,084; ruby: 255; pascal: 231; tcl: 180; makefile: 174; asm: 81; java: 72; xml: 49
file content (68 lines) | stat: -rw-r--r-- 2,230 bytes parent folder | download | duplicates (7)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
kernel 
void test_length_distance() {
  volatile float a = 18446744073709551616.0f; /* 2^64 */
  volatile float e = 1.0f;
  volatile float l = length(a);
  if (l != 18446744073709551616.0f) {
    printf("length(float) failed.\n");
  }
  volatile float d = distance(a, e);
  if (d != 18446744073709551616.0f) {
    printf("distance(float,float) failed.\n");
  }
  volatile float n = normalize(a);
  if (n != 1.0f) {
    printf("normalize(float) failed.\n");
  }

  volatile float2 a2 = (float2)(18446744073709551616.0f,
                                18446744073709551616.0f); /* 2^64 */
  volatile float2 e2 = (float2)(1.0f, 1.0f);
  volatile float l2 = length(a2);
  if (l2 != 2.6087635e19f) {
    printf("length(float2) failed.\n");
  }
  volatile float d2 = distance(a2, e2);
  if (d2 != 2.6087635e19f) {
    printf("distance(float2,float2) failed.\n");
  }
  volatile float2 n2 = normalize(a2);
  if (any(n2 != (float2)(0.70710677f, 0.70710677f))) {
    printf("normalize(float2) failed.\n");
  }

  volatile float3 a3 = (float3)(18446744073709551616.0f,
                                18446744073709551616.0f,
                                18446744073709551616.0f); /* 2^64 */
  volatile float3 e3 = (float3)(1.0f, 1.0f, 1.0f);
  float l3 = length(a3);
  if (l3 != 3.1950697e19f) {
    printf("length(float3) failed.\n");
  }
  float d3 = distance(a3, e3);
  if (d3 != 3.1950697e19f) {
    printf("distance(float3,float3) failed.\n");
  }
  float3 n3 = normalize(a3);
  if (any(n3 != (float3)(0.57735026f, 0.57735026f, 0.57735026f))) {
    printf("normalize(float3) failed.\n");
  }

  volatile float4 a4 = (float4)(18446744073709551616.0f,
                                18446744073709551616.0f,
                                18446744073709551616.0f,
                                18446744073709551616.0f); /* 2^64 */
  volatile float4 e4 = (float4)(1.0f, 1.0f, 1.0f, 1.0f);
  float l4 = length(a4);
  if (l4 != 3.689349e19f) {
    printf("length(float4) failed.\n");
  }
  float d4 = distance(a4, e4);
  if (d4 != 3.689349e19f) {
    printf("distance(float4,float4) failed.\n");
  }
  float4 n4 = normalize(a4);
  if (any(n4 != (float4)(0.5f, 0.5f, 0.5f, 0.5f))) {
    printf("normalize(float4) failed.\n");
  }
}