File: multidim_array_in_struct.cl

package info (click to toggle)
oclgrind 21.10-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,216 kB
  • sloc: cpp: 21,369; ansic: 6,395; lisp: 1,122; python: 124; makefile: 19
file content (40 lines) | stat: -rw-r--r-- 578 bytes parent folder | download | duplicates (4)
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
//
// Issue #64 on GitHub:
// https://github.com/jrprice/Oclgrind/issues/64
//
// Required alignment for multi-dimensional arrays was incorrect.
//

struct S0
{
  uchar a;
  ulong b[2][3][1];
};

kernel void multidim_array_in_struct(global ulong *output)
{
  struct S0 s =
  {
    1UL,
    {
      {
        {1L},
        {1L},
        {1L}
      },
      {
        {1L},
        {1L},
        {1L}
      }
    },
  };

  ulong c = 0UL;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 1; k++)
        c += s.b[i][j][k];

  *output = c;
}