1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2021 Intel Corporation
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21bf215546Sopenharmony_ci * IN THE SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci#include "brw_private.h"
26bf215546Sopenharmony_ci#include "compiler/shader_info.h"
27bf215546Sopenharmony_ci#include "intel/dev/intel_debug.h"
28bf215546Sopenharmony_ci#include "intel/dev/intel_device_info.h"
29bf215546Sopenharmony_ci#include "util/ralloc.h"
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ci#include <gtest/gtest.h>
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_cienum {
34bf215546Sopenharmony_ci   SIMD8  = 0,
35bf215546Sopenharmony_ci   SIMD16 = 1,
36bf215546Sopenharmony_ci   SIMD32 = 2,
37bf215546Sopenharmony_ci};
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_ciconst bool spilled = true;
40bf215546Sopenharmony_ciconst bool not_spilled = false;
41bf215546Sopenharmony_ci
42bf215546Sopenharmony_ciclass SIMDSelectionTest : public ::testing::Test {
43bf215546Sopenharmony_ciprotected:
44bf215546Sopenharmony_ci   SIMDSelectionTest() : error{NULL, NULL, NULL} {
45bf215546Sopenharmony_ci      mem_ctx = ralloc_context(NULL);
46bf215546Sopenharmony_ci      devinfo = rzalloc(mem_ctx, intel_device_info);
47bf215546Sopenharmony_ci      prog_data = rzalloc(mem_ctx, struct brw_cs_prog_data);
48bf215546Sopenharmony_ci      required_dispatch_width = 0;
49bf215546Sopenharmony_ci   }
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ci   ~SIMDSelectionTest() {
52bf215546Sopenharmony_ci      ralloc_free(mem_ctx);
53bf215546Sopenharmony_ci   };
54bf215546Sopenharmony_ci
55bf215546Sopenharmony_ci   bool should_compile(unsigned simd) {
56bf215546Sopenharmony_ci      return brw_simd_should_compile(mem_ctx, simd, devinfo, prog_data,
57bf215546Sopenharmony_ci                                     required_dispatch_width, &error[simd]);
58bf215546Sopenharmony_ci   }
59bf215546Sopenharmony_ci
60bf215546Sopenharmony_ci   void *mem_ctx;
61bf215546Sopenharmony_ci   intel_device_info *devinfo;
62bf215546Sopenharmony_ci   struct brw_cs_prog_data *prog_data;
63bf215546Sopenharmony_ci   const char *error[3];
64bf215546Sopenharmony_ci   unsigned required_dispatch_width;
65bf215546Sopenharmony_ci};
66bf215546Sopenharmony_ci
67bf215546Sopenharmony_ciclass SIMDSelectionCS : public SIMDSelectionTest {
68bf215546Sopenharmony_ciprotected:
69bf215546Sopenharmony_ci   SIMDSelectionCS() {
70bf215546Sopenharmony_ci      prog_data->base.stage = MESA_SHADER_COMPUTE;
71bf215546Sopenharmony_ci      prog_data->local_size[0] = 32;
72bf215546Sopenharmony_ci      prog_data->local_size[1] = 1;
73bf215546Sopenharmony_ci      prog_data->local_size[2] = 1;
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ci      devinfo->max_cs_workgroup_threads = 64;
76bf215546Sopenharmony_ci   }
77bf215546Sopenharmony_ci};
78bf215546Sopenharmony_ci
79bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, DefaultsToSIMD16)
80bf215546Sopenharmony_ci{
81bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
82bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD8, prog_data, not_spilled);
83bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD16));
84bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD16, prog_data, not_spilled);
85bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD32));
86bf215546Sopenharmony_ci
87bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), SIMD16);
88bf215546Sopenharmony_ci}
89bf215546Sopenharmony_ci
90bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, TooBigFor16)
91bf215546Sopenharmony_ci{
92bf215546Sopenharmony_ci   prog_data->local_size[0] = devinfo->max_cs_workgroup_threads;
93bf215546Sopenharmony_ci   prog_data->local_size[1] = 32;
94bf215546Sopenharmony_ci   prog_data->local_size[2] = 1;
95bf215546Sopenharmony_ci
96bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD8));
97bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD16));
98bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD32));
99bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD32, prog_data, spilled);
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), SIMD32);
102bf215546Sopenharmony_ci}
103bf215546Sopenharmony_ci
104bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, WorkgroupSize1)
105bf215546Sopenharmony_ci{
106bf215546Sopenharmony_ci   prog_data->local_size[0] = 1;
107bf215546Sopenharmony_ci   prog_data->local_size[1] = 1;
108bf215546Sopenharmony_ci   prog_data->local_size[2] = 1;
109bf215546Sopenharmony_ci
110bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
111bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD8, prog_data, not_spilled);
112bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD16));
113bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD32));
114bf215546Sopenharmony_ci
115bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), SIMD8);
116bf215546Sopenharmony_ci}
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, WorkgroupSize8)
119bf215546Sopenharmony_ci{
120bf215546Sopenharmony_ci   prog_data->local_size[0] = 8;
121bf215546Sopenharmony_ci   prog_data->local_size[1] = 1;
122bf215546Sopenharmony_ci   prog_data->local_size[2] = 1;
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
125bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD8, prog_data, not_spilled);
126bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD16));
127bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD32));
128bf215546Sopenharmony_ci
129bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), SIMD8);
130bf215546Sopenharmony_ci}
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, WorkgroupSizeVariable)
133bf215546Sopenharmony_ci{
134bf215546Sopenharmony_ci   prog_data->local_size[0] = 0;
135bf215546Sopenharmony_ci   prog_data->local_size[1] = 0;
136bf215546Sopenharmony_ci   prog_data->local_size[2] = 0;
137bf215546Sopenharmony_ci
138bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
139bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD8, prog_data, not_spilled);
140bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD16));
141bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD16, prog_data, not_spilled);
142bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD32));
143bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD32, prog_data, not_spilled);
144bf215546Sopenharmony_ci
145bf215546Sopenharmony_ci   ASSERT_EQ(prog_data->prog_mask, 1u << SIMD8 | 1u << SIMD16 | 1u << SIMD32);
146bf215546Sopenharmony_ci
147bf215546Sopenharmony_ci   const unsigned wg_8_1_1[] = { 8, 1, 1 };
148bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_8_1_1), SIMD8);
149bf215546Sopenharmony_ci
150bf215546Sopenharmony_ci   const unsigned wg_16_1_1[] = { 16, 1, 1 };
151bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_16_1_1), SIMD16);
152bf215546Sopenharmony_ci
153bf215546Sopenharmony_ci   const unsigned wg_32_1_1[] = { 32, 1, 1 };
154bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_32_1_1), SIMD16);
155bf215546Sopenharmony_ci}
156bf215546Sopenharmony_ci
157bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, WorkgroupSizeVariableSpilled)
158bf215546Sopenharmony_ci{
159bf215546Sopenharmony_ci   prog_data->local_size[0] = 0;
160bf215546Sopenharmony_ci   prog_data->local_size[1] = 0;
161bf215546Sopenharmony_ci   prog_data->local_size[2] = 0;
162bf215546Sopenharmony_ci
163bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
164bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD8, prog_data, spilled);
165bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD16));
166bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD16, prog_data, spilled);
167bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD32));
168bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD32, prog_data, spilled);
169bf215546Sopenharmony_ci
170bf215546Sopenharmony_ci   ASSERT_EQ(prog_data->prog_mask, 1u << SIMD8 | 1u << SIMD16 | 1u << SIMD32);
171bf215546Sopenharmony_ci
172bf215546Sopenharmony_ci   const unsigned wg_8_1_1[] = { 8, 1, 1 };
173bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_8_1_1), SIMD8);
174bf215546Sopenharmony_ci
175bf215546Sopenharmony_ci   const unsigned wg_16_1_1[] = { 16, 1, 1 };
176bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_16_1_1), SIMD8);
177bf215546Sopenharmony_ci
178bf215546Sopenharmony_ci   const unsigned wg_32_1_1[] = { 32, 1, 1 };
179bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_32_1_1), SIMD8);
180bf215546Sopenharmony_ci}
181bf215546Sopenharmony_ci
182bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, WorkgroupSizeVariableNoSIMD8)
183bf215546Sopenharmony_ci{
184bf215546Sopenharmony_ci   prog_data->local_size[0] = 0;
185bf215546Sopenharmony_ci   prog_data->local_size[1] = 0;
186bf215546Sopenharmony_ci   prog_data->local_size[2] = 0;
187bf215546Sopenharmony_ci
188bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
189bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD16));
190bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD16, prog_data, not_spilled);
191bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD32));
192bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD32, prog_data, not_spilled);
193bf215546Sopenharmony_ci
194bf215546Sopenharmony_ci   ASSERT_EQ(prog_data->prog_mask, 1u << SIMD16 | 1u << SIMD32);
195bf215546Sopenharmony_ci
196bf215546Sopenharmony_ci   const unsigned wg_8_1_1[] = { 8, 1, 1 };
197bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_8_1_1), SIMD16);
198bf215546Sopenharmony_ci
199bf215546Sopenharmony_ci   const unsigned wg_16_1_1[] = { 16, 1, 1 };
200bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_16_1_1), SIMD16);
201bf215546Sopenharmony_ci
202bf215546Sopenharmony_ci   const unsigned wg_32_1_1[] = { 32, 1, 1 };
203bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_32_1_1), SIMD16);
204bf215546Sopenharmony_ci}
205bf215546Sopenharmony_ci
206bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, WorkgroupSizeVariableNoSIMD16)
207bf215546Sopenharmony_ci{
208bf215546Sopenharmony_ci   prog_data->local_size[0] = 0;
209bf215546Sopenharmony_ci   prog_data->local_size[1] = 0;
210bf215546Sopenharmony_ci   prog_data->local_size[2] = 0;
211bf215546Sopenharmony_ci
212bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
213bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD8, prog_data, not_spilled);
214bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD16));
215bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD32));
216bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD32, prog_data, not_spilled);
217bf215546Sopenharmony_ci
218bf215546Sopenharmony_ci   ASSERT_EQ(prog_data->prog_mask, 1u << SIMD8 | 1u << SIMD32);
219bf215546Sopenharmony_ci
220bf215546Sopenharmony_ci   const unsigned wg_8_1_1[] = { 8, 1, 1 };
221bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_8_1_1), SIMD8);
222bf215546Sopenharmony_ci
223bf215546Sopenharmony_ci   const unsigned wg_16_1_1[] = { 16, 1, 1 };
224bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_16_1_1), SIMD8);
225bf215546Sopenharmony_ci
226bf215546Sopenharmony_ci   const unsigned wg_32_1_1[] = { 32, 1, 1 };
227bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_32_1_1), SIMD8);
228bf215546Sopenharmony_ci}
229bf215546Sopenharmony_ci
230bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, WorkgroupSizeVariableNoSIMD8NoSIMD16)
231bf215546Sopenharmony_ci{
232bf215546Sopenharmony_ci   prog_data->local_size[0] = 0;
233bf215546Sopenharmony_ci   prog_data->local_size[1] = 0;
234bf215546Sopenharmony_ci   prog_data->local_size[2] = 0;
235bf215546Sopenharmony_ci
236bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
237bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD16));
238bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD32));
239bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD32, prog_data, not_spilled);
240bf215546Sopenharmony_ci
241bf215546Sopenharmony_ci   ASSERT_EQ(prog_data->prog_mask, 1u << SIMD32);
242bf215546Sopenharmony_ci
243bf215546Sopenharmony_ci   const unsigned wg_8_1_1[] = { 8, 1, 1 };
244bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_8_1_1), SIMD32);
245bf215546Sopenharmony_ci
246bf215546Sopenharmony_ci   const unsigned wg_16_1_1[] = { 16, 1, 1 };
247bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_16_1_1), SIMD32);
248bf215546Sopenharmony_ci
249bf215546Sopenharmony_ci   const unsigned wg_32_1_1[] = { 32, 1, 1 };
250bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select_for_workgroup_size(devinfo, prog_data, wg_32_1_1), SIMD32);
251bf215546Sopenharmony_ci}
252bf215546Sopenharmony_ci
253bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, SpillAtSIMD8)
254bf215546Sopenharmony_ci{
255bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
256bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD8, prog_data, spilled);
257bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD16));
258bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD32));
259bf215546Sopenharmony_ci
260bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), SIMD8);
261bf215546Sopenharmony_ci}
262bf215546Sopenharmony_ci
263bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, SpillAtSIMD16)
264bf215546Sopenharmony_ci{
265bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
266bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD8, prog_data, not_spilled);
267bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD16));
268bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD16, prog_data, spilled);
269bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD32));
270bf215546Sopenharmony_ci
271bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), SIMD8);
272bf215546Sopenharmony_ci}
273bf215546Sopenharmony_ci
274bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, EnvironmentVariable32)
275bf215546Sopenharmony_ci{
276bf215546Sopenharmony_ci   intel_debug |= DEBUG_DO32;
277bf215546Sopenharmony_ci
278bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
279bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD8, prog_data, not_spilled);
280bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD16));
281bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD16, prog_data, not_spilled);
282bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD32));
283bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD32, prog_data, not_spilled);
284bf215546Sopenharmony_ci
285bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), SIMD32);
286bf215546Sopenharmony_ci}
287bf215546Sopenharmony_ci
288bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, EnvironmentVariable32ButSpills)
289bf215546Sopenharmony_ci{
290bf215546Sopenharmony_ci   intel_debug |= DEBUG_DO32;
291bf215546Sopenharmony_ci
292bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
293bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD8, prog_data, not_spilled);
294bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD16));
295bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD16, prog_data, not_spilled);
296bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD32));
297bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD32, prog_data, spilled);
298bf215546Sopenharmony_ci
299bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), SIMD16);
300bf215546Sopenharmony_ci}
301bf215546Sopenharmony_ci
302bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, Require8)
303bf215546Sopenharmony_ci{
304bf215546Sopenharmony_ci   required_dispatch_width = 8;
305bf215546Sopenharmony_ci
306bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
307bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD8, prog_data, not_spilled);
308bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD16));
309bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD32));
310bf215546Sopenharmony_ci
311bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), SIMD8);
312bf215546Sopenharmony_ci}
313bf215546Sopenharmony_ci
314bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, Require8ErrorWhenNotCompile)
315bf215546Sopenharmony_ci{
316bf215546Sopenharmony_ci   required_dispatch_width = 8;
317bf215546Sopenharmony_ci
318bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD8));
319bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD16));
320bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD32));
321bf215546Sopenharmony_ci
322bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), -1);
323bf215546Sopenharmony_ci}
324bf215546Sopenharmony_ci
325bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, Require16)
326bf215546Sopenharmony_ci{
327bf215546Sopenharmony_ci   required_dispatch_width = 16;
328bf215546Sopenharmony_ci
329bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD8));
330bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD16));
331bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD16, prog_data, not_spilled);
332bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD32));
333bf215546Sopenharmony_ci
334bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), SIMD16);
335bf215546Sopenharmony_ci}
336bf215546Sopenharmony_ci
337bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, Require16ErrorWhenNotCompile)
338bf215546Sopenharmony_ci{
339bf215546Sopenharmony_ci   required_dispatch_width = 16;
340bf215546Sopenharmony_ci
341bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD8));
342bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD16));
343bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD32));
344bf215546Sopenharmony_ci
345bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), -1);
346bf215546Sopenharmony_ci}
347bf215546Sopenharmony_ci
348bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, Require32)
349bf215546Sopenharmony_ci{
350bf215546Sopenharmony_ci   required_dispatch_width = 32;
351bf215546Sopenharmony_ci
352bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD8));
353bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD16));
354bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD32));
355bf215546Sopenharmony_ci   brw_simd_mark_compiled(SIMD32, prog_data, not_spilled);
356bf215546Sopenharmony_ci
357bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), SIMD32);
358bf215546Sopenharmony_ci}
359bf215546Sopenharmony_ci
360bf215546Sopenharmony_ciTEST_F(SIMDSelectionCS, Require32ErrorWhenNotCompile)
361bf215546Sopenharmony_ci{
362bf215546Sopenharmony_ci   required_dispatch_width = 32;
363bf215546Sopenharmony_ci
364bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD8));
365bf215546Sopenharmony_ci   ASSERT_FALSE(should_compile(SIMD16));
366bf215546Sopenharmony_ci   ASSERT_TRUE(should_compile(SIMD32));
367bf215546Sopenharmony_ci
368bf215546Sopenharmony_ci   ASSERT_EQ(brw_simd_select(prog_data), -1);
369bf215546Sopenharmony_ci}
370