summaryrefslogtreecommitdiff
path: root/kernels/compiler_pipe_builtin.cl
blob: 4e8dcc429f6bd107312c7a4ea9fb361534be3411 (plain)
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
106
107
108
109
110
111
112
113
114
115
116
117
typedef struct{
  int a;
  int b;
}mystruct;

__kernel void compiler_pipe_convenience_write_int(write_only pipe int p, __global int *src)
{
    int gid = get_global_id(0);
    write_pipe(p, &src[gid]);
}
__kernel void compiler_pipe_convenience_read_int(read_only pipe int p, __global int *dst)
{
    int gid = get_global_id(0);
    read_pipe(p, &dst[gid]);
}
__kernel void compiler_pipe_convenience_write_mystruct(write_only pipe mystruct p, __global mystruct *src)
{
    int gid = get_global_id(0);
    write_pipe(p, &src[gid]);
}
__kernel void compiler_pipe_convenience_read_mystruct(read_only pipe mystruct p, __global mystruct *dst)
{
    int gid = get_global_id(0);
    read_pipe(p, &dst[gid]);
}

__kernel void compiler_pipe_reserve_write_int(write_only pipe int p, __global int *src)
{
    int gid = get_global_id(0);
    reserve_id_t res_id = reserve_write_pipe(p, 1);
    if(is_valid_reserve_id(res_id))
    {
      write_pipe(p, res_id, 0, &src[gid]);
      commit_write_pipe(p, res_id);
    }
}
__kernel void compiler_pipe_reserve_read_int(read_only pipe int p, __global int *dst)
{
    int gid = get_global_id(0);
    reserve_id_t res_id = reserve_read_pipe(p, 1);
    if(is_valid_reserve_id(res_id))
    {
      read_pipe(p, res_id, 0, &dst[gid]);
      commit_read_pipe(p, res_id);
    }
}
__kernel void compiler_pipe_reserve_write_mystruct(write_only pipe mystruct p, __global mystruct *src)
{
    int gid = get_global_id(0);
    reserve_id_t res_id = reserve_write_pipe(p, 1);
    if(is_valid_reserve_id(res_id))
    {
      write_pipe(p, res_id, 0, &src[gid]);
      commit_write_pipe(p, res_id);
    }
}
__kernel void compiler_pipe_reserve_read_mystruct(read_only pipe mystruct p, __global mystruct *dst)
{
    int gid = get_global_id(0);
    reserve_id_t res_id = reserve_read_pipe(p, 1);
    if(is_valid_reserve_id(res_id))
    {
      read_pipe(p, res_id, 0, &dst[gid]);
      commit_read_pipe(p, res_id);
    }
}

__kernel void compiler_pipe_workgroup_write_int(write_only pipe int p, __global int *src)
{
    int gid = get_global_id(0);
    reserve_id_t res_id = work_group_reserve_write_pipe(p, get_local_size(0));
    if(is_valid_reserve_id(res_id))
    {
      write_pipe(p, res_id, get_local_id(0), &src[gid]);
      work_group_commit_write_pipe(p, res_id);
    }
}
__kernel void compiler_pipe_workgroup_read_int(read_only pipe int p, __global int *dst)
{
    int gid = get_global_id(0);
    reserve_id_t res_id = work_group_reserve_read_pipe(p, get_local_size(0));
    if(is_valid_reserve_id(res_id))
    {
      read_pipe(p, res_id, get_local_id(0), &dst[gid]);
      work_group_commit_read_pipe(p, res_id);
    }
}
__kernel void compiler_pipe_workgroup_write_mystruct(write_only pipe mystruct p, __global mystruct *src)
{
    int gid = get_global_id(0);
    reserve_id_t res_id = work_group_reserve_write_pipe(p, get_local_size(0));
    if(is_valid_reserve_id(res_id))
    {
      write_pipe(p, res_id, get_local_id(0), &src[gid]);
      work_group_commit_write_pipe(p, res_id);
    }
}
__kernel void compiler_pipe_workgroup_read_mystruct(read_only pipe mystruct p, __global mystruct *dst)
{
    int gid = get_global_id(0);
    reserve_id_t res_id = work_group_reserve_read_pipe(p, get_local_size(0));
    if(is_valid_reserve_id(res_id))
    {
      read_pipe(p, res_id, get_local_id(0), &dst[gid]);
      work_group_commit_read_pipe(p, res_id);
    }
}

__kernel void compiler_pipe_query(write_only pipe int p, __global uint *src)
{
    int gid = get_global_id(0);
    write_pipe(p,&gid);
    if(gid == 0) {
      src[0] = get_pipe_num_packets(p);
      src[1] = get_pipe_max_packets(p);
    }
}