File: test_short16.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 (105 lines) | stat: -rw-r--r-- 2,679 bytes parent folder | download | duplicates (8)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// 32-byte vectors have different calling conventions on x86-64
// depending on whether AVX instructions are enabled or not. This is
// not encoded in the target triple. Test here whether the kernel
// library and kernels are built with compatible options.

// The failure mode is that convert_char16(short16) sets the upper 8
// vector elements to zero.

__attribute__((__noinline__))
char my_convert_char(short s)
{
  return convert_char(s);
}

__attribute__((__noinline__))
char2 my_convert_char2(short2 s2)
{
  return convert_char2(s2);
}

__attribute__((__noinline__))
char3 my_convert_char3(short3 s3)
{
  return convert_char3(s3);
}

__attribute__((__noinline__))
char4 my_convert_char4(short4 s4)
{
  return convert_char4(s4);
}

__attribute__((__noinline__))
char8 my_convert_char8(short8 s8)
{
  return convert_char8(s8);
}

__attribute__((__noinline__))
char16 my_convert_char16(short16 s16)
{
  return convert_char16(s16);
}



kernel void test_short16()
{
  short s = (short)(1);
  short2 s2 = (short2)(2);
  short3 s3 = (short3)(3);
  short4 s4 = (short4)(4);
  short8 s8 = (short8)(8);
  short16 s16 = (short16)(16);
  
  char c = my_convert_char(s);
  char2 c2 = my_convert_char2(s2);
  char3 c3 = my_convert_char3(s3);
  char4 c4 = my_convert_char4(s4);
  char8 c8 = my_convert_char8(s8);
  char16 c16 = my_convert_char16(s16);
  
  bool good = true;
  good = good && c == s;
  if (!good) {
    printf("char->short conversion failed\n");
    printf("  c=%d s=%d\n", c, s);
  }
  
  bool good2 = true;
  for (int i=0; i<2; ++i) good2 = good2 && c2[i] == s2[i];
  if (!good2) {
    printf("char2->short2 conversion failed\n");
    for (int i=0; i<2; ++i) printf("  c[%d]=%d s[%d]=%d\n", i, c2[i], i, s2[i]);
  }
  
  bool good3 = true;
  for (int i=0; i<3; ++i) good3 = good3 && c3[i] == s3[i];
  if (!good3) {
    printf("char3->short3 conversion failed\n");
    for (int i=0; i<3; ++i) printf("  c[%d]=%d s[%d]=%d\n", i, c3[i], i, s3[i]);
  }
  
  bool good4 = true;
  for (int i=0; i<4; ++i) good4 = good4 && c4[i] == s4[i];
  if (!good4) {
    printf("char4->short4 conversion failed\n");
    for (int i=0; i<4; ++i) printf("  c[%d]=%d s[%d]=%d\n", i, c4[i], i, s4[i]);
  }
  
  bool good8 = true;
  for (int i=0; i<8; ++i) good8 = good8 && c8[i] == s8[i];
  if (!good8) {
    printf("char8->short8 conversion failed\n");
    for (int i=0; i<8; ++i) printf("  c[%d]=%d s[%d]=%d\n", i, c8[i], i, s8[i]);
  }
  
  bool good16 = true;
  for (int i=0; i<16; ++i) good16 = good16 && c16[i] == s16[i];
  if (!good16) {
    printf("char16->short16 conversion failed\n");
    for (int i=0; i<16; ++i)
      printf("  c[%d]=%d s[%d]=%d\n", i, c16[i], i, s16[i]);
  }
}