• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2# Copyright 2019 The Amber Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     https://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16SHADER compute my_shader OPENCL-C
17kernel void line(global int* in, global int* out, int slope, int offset) {
18  *out = *in * slope + offset;
19}
20END
21
22BUFFER in_buf DATA_TYPE uint32 DATA 3 END
23BUFFER out_buf1 DATA_TYPE uint32 DATA 0 END
24BUFFER out_buf2 DATA_TYPE uint32 DATA 0 END
25BUFFER out_buf3 DATA_TYPE uint32 DATA 0 END
26BUFFER out_buf4 DATA_TYPE uint32 DATA 0 END
27BUFFER out_buf5 DATA_TYPE uint32 DATA 0 END
28
29PIPELINE compute p1
30  ATTACH my_shader ENTRY_POINT line
31  BIND BUFFER in_buf KERNEL ARG_NAME in
32  BIND BUFFER out_buf1 KERNEL ARG_NAME out
33  SET KERNEL ARG_NAME offset AS uint32 1
34  SET KERNEL ARG_NAME slope AS int32 2
35END
36
37DERIVE_PIPELINE p2 FROM p1
38  BIND BUFFER out_buf2 KERNEL ARG_NAME out
39  COMPILE_OPTIONS my_shader
40    -pod-ubo
41  END
42END
43
44DERIVE_PIPELINE p3 FROM p1
45  BIND BUFFER out_buf3 KERNEL ARG_NAME out
46  COMPILE_OPTIONS my_shader
47    -cluster-pod-kernel-args
48  END
49END
50
51DERIVE_PIPELINE p4 FROM p1
52  BIND BUFFER out_buf4 KERNEL ARG_NAME out
53  SET KERNEL ARG_NAME slope AS int32 3
54  COMPILE_OPTIONS my_shader
55    -cluster-pod-kernel-args
56    -pod-ubo
57  END
58END
59
60DERIVE_PIPELINE p5 FROM p1
61  BIND BUFFER out_buf5 KERNEL ARG_NAME out
62  SET KERNEL ARG_NAME slope AS int32 3
63  COMPILE_OPTIONS my_shader
64    -cluster-pod-kernel-args
65    -pod-pushconstant
66  END
67END
68
69RUN p1 1 1 1
70RUN p2 1 1 1
71RUN p3 1 1 1
72RUN p4 1 1 1
73RUN p5 1 1 1
74
75EXPECT out_buf1 IDX 0 EQ 7
76EXPECT out_buf2 IDX 0 EQ 7
77EXPECT out_buf3 IDX 0 EQ 7
78EXPECT out_buf4 IDX 0 EQ 10
79EXPECT out_buf5 IDX 0 EQ 10
80