• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4package gen_tasks_logic
5
6import (
7	"fmt"
8	"sort"
9
10	"go.skia.org/infra/task_scheduler/go/specs"
11)
12
13// nanobenchFlags generates flags to Nanobench based on the given task properties.
14func (b *taskBuilder) nanobenchFlags(doUpload bool) {
15	args := []string{
16		"nanobench",
17		"--pre_log",
18	}
19
20	if b.gpu() {
21		args = append(args, "--gpuStatsDump", "true")
22	}
23
24	args = append(args, "--scales", "1.0", "1.1")
25
26	configs := []string{}
27	if b.cpu() {
28		args = append(args, "--nogpu")
29		configs = append(configs, "8888", "nonrendering")
30
31		if b.extraConfig("BonusConfigs") {
32			configs = []string{
33				"f16",
34				"srgb-rgba",
35				"srgb-f16",
36				"narrow-rgba",
37				"narrow-f16",
38			}
39		}
40
41		if b.model("Nexus7") {
42			args = append(args, "--purgeBetweenBenches") // Debugging skia:8929
43		}
44
45	} else if b.gpu() {
46		args = append(args, "--nocpu")
47
48		glPrefix := "gl"
49		sampleCount := 8
50		if b.os("Android", "iOS") {
51			sampleCount = 4
52			// The NVIDIA_Shield has a regular OpenGL implementation. We bench that
53			// instead of ES.
54			if !b.model("NVIDIA_Shield") {
55				glPrefix = "gles"
56			}
57			// iOS crashes with MSAA (skia:6399)
58			// Nexus7 (Tegra3) does not support MSAA.
59			// MSAA is disabled on Pixel3a (https://b.corp.google.com/issues/143074513).
60			// MSAA is disabled on Pixel5 (https://skbug.com/11152).
61			if b.os("iOS") || b.model("Nexus7", "Pixel3a", "Pixel5") {
62				sampleCount = 0
63			}
64		} else if b.matchGpu("AppleM1") {
65			sampleCount = 4
66		} else if b.matchGpu("Intel") {
67			// MSAA doesn't work well on Intel GPUs chromium:527565, chromium:983926
68			sampleCount = 0
69		} else if b.os("ChromeOS") {
70			glPrefix = "gles"
71		}
72
73		configs = append(configs, glPrefix, "srgb-"+glPrefix)
74
75		if b.os("Ubuntu18") && b.noExtraConfig() {
76			configs = append(configs, glPrefix+"reducedshaders")
77		}
78		// narrow-gl/gles tests the case of color converting *all* content
79		// It hangs on the AndroidOne (Mali400)  skia:10669
80		if !b.gpu("Mali400MP2") {
81			configs = append(configs, "narrow-"+glPrefix)
82		}
83
84		// skia:10644 The fake ES2 config is used to compare highest available ES version to
85		// when we're limited to ES2. We could consider adding a MSAA fake config as well.
86		if b.os("Android") && glPrefix == "gles" {
87			// These only support ES2. No point in running twice.
88			if !b.gpu("Mali400MP2", "Tegra3") {
89				configs = append(configs, "glesfakev2")
90			}
91		}
92
93		if sampleCount > 0 {
94			configs = append(configs, fmt.Sprintf("%smsaa%d", glPrefix, sampleCount))
95			if b.gpu("QuadroP400", "MaliG77", "AppleM1") {
96				configs = append(configs, fmt.Sprintf("%sdmsaa", glPrefix))
97			}
98		}
99
100		// We want to test both the OpenGL config and the GLES config on Linux Intel:
101		// GL is used by Chrome, GLES is used by ChromeOS.
102		if b.matchGpu("Intel") && b.isLinux() {
103			configs = append(configs, "gles", "srgb-gles")
104		}
105
106		if b.extraConfig("CommandBuffer") {
107			configs = []string{"cmdbuffer_es2"}
108			if !b.matchGpu("Intel") {
109				configs = append(configs, "cmdbuffer_es2_dmsaa")
110			}
111		}
112
113		if b.extraConfig("Vulkan") {
114			configs = []string{"vk"}
115			if b.os("Android") {
116				// skbug.com/9274
117				if !b.model("Pixel2XL") {
118					configs = append(configs, "vkmsaa4")
119				}
120			} else {
121				// MSAA doesn't work well on Intel GPUs chromium:527565, chromium:983926, skia:9023
122				if !b.matchGpu("Intel") {
123					configs = append(configs, "vkmsaa8")
124				}
125			}
126			if b.gpu("QuadroP400", "MaliG77") {
127				configs = append(configs, "vkdmsaa")
128			}
129		}
130		if b.extraConfig("Metal") {
131			configs = []string{"mtl"}
132			if b.os("iOS") {
133				configs = append(configs, "mtlmsaa4")
134			} else {
135				configs = append(configs, "mtlmsaa8")
136			}
137			if b.model("iPhone11") {
138				configs = append(configs, "mtlreducedshaders")
139			}
140		}
141
142		if b.extraConfig("ANGLE") {
143			// Test only ANGLE configs.
144			configs = []string{"angle_d3d11_es2", "angle_d3d11_es3"}
145			if sampleCount > 0 {
146				configs = append(configs, fmt.Sprintf("angle_d3d11_es2_msaa%d", sampleCount))
147				configs = append(configs, fmt.Sprintf("angle_d3d11_es3_msaa%d", sampleCount))
148			}
149			if b.gpu("QuadroP400") {
150				// See skia:7823 and chromium:693090.
151				configs = append(configs, "angle_gl_es2")
152				configs = append(configs, "angle_gl_es3")
153				if sampleCount > 0 {
154					configs = append(configs, fmt.Sprintf("angle_gl_es2_msaa%d", sampleCount))
155					configs = append(configs, fmt.Sprintf("angle_gl_es3_msaa%d", sampleCount))
156				}
157			}
158		}
159		if b.os("ChromeOS") {
160			// Just run GLES for now - maybe add gles_msaa4 in the future
161			configs = []string{"gles"}
162		}
163		if b.extraConfig("SwiftShader") {
164			configs = []string{"gles", "glesdmsaa"}
165		}
166	}
167
168	args = append(args, "--config")
169	args = append(args, configs...)
170
171	// Use 4 internal msaa samples on mobile and AppleM1, otherwise 8.
172	args = append(args, "--internalSamples")
173	if b.os("Android") || b.os("iOS") || b.matchGpu("AppleM1") {
174		args = append(args, "4")
175	} else {
176		args = append(args, "8")
177	}
178
179	// By default, we test with GPU threading enabled, unless specifically
180	// disabled.
181	if b.extraConfig("NoGPUThreads") {
182		args = append(args, "--gpuThreads", "0")
183	}
184
185	if b.debug() || b.extraConfig("ASAN") || b.extraConfig("Valgrind") {
186		args = append(args, "--loops", "1")
187		args = append(args, "--samples", "1")
188		// Ensure that the bot framework does not think we have timed out.
189		args = append(args, "--keepAlive", "true")
190	}
191
192	// Some people don't like verbose output.
193	verbose := false
194
195	match := []string{}
196	if b.os("Android") {
197		// Segfaults when run as GPU bench. Very large texture?
198		match = append(match, "~blurroundrect")
199		match = append(match, "~patch_grid") // skia:2847
200		match = append(match, "~desk_carsvg")
201	}
202	if b.matchModel("Nexus5") {
203		match = append(match, "~keymobi_shop_mobileweb_ebay_com.skp") // skia:5178
204	}
205	if b.os("iOS") {
206		match = append(match, "~blurroundrect")
207		match = append(match, "~patch_grid") // skia:2847
208		match = append(match, "~desk_carsvg")
209		match = append(match, "~keymobi")
210		match = append(match, "~path_hairline")
211		match = append(match, "~GLInstancedArraysBench") // skia:4714
212	}
213	if b.os("iOS") && b.extraConfig("Metal") {
214		// skia:9799
215		match = append(match, "~compositing_images_tile_size")
216	}
217	if b.matchGpu("Intel") && b.isLinux() && !b.extraConfig("Vulkan") {
218		// TODO(dogben): Track down what's causing bots to die.
219		verbose = true
220	}
221	if b.gpu("IntelHD405") && b.isLinux() && b.extraConfig("Vulkan") {
222		// skia:7322
223		match = append(match, "~desk_carsvg.skp_1")
224		match = append(match, "~desk_googlehome.skp")
225		match = append(match, "~desk_tiger8svg.skp_1")
226		match = append(match, "~desk_wowwiki.skp")
227		match = append(match, "~desk_ynevsvg.skp_1.1")
228		match = append(match, "~desk_nostroke_tiger8svg.skp")
229		match = append(match, "~keymobi_booking_com.skp_1")
230		match = append(match, "~keymobi_cnn_article.skp_1")
231		match = append(match, "~keymobi_forecast_io.skp_1")
232		match = append(match, "~keymobi_sfgate.skp_1")
233		match = append(match, "~keymobi_techcrunch_com.skp_1.1")
234		match = append(match, "~keymobi_techcrunch.skp_1.1")
235		match = append(match, "~svgparse_Seal_of_California.svg_1.1")
236		match = append(match, "~svgparse_NewYork-StateSeal.svg_1.1")
237		match = append(match, "~svgparse_Vermont_state_seal.svg_1")
238		match = append(match, "~tabl_gamedeksiam.skp_1.1")
239		match = append(match, "~tabl_pravda.skp_1")
240		match = append(match, "~top25desk_ebay_com.skp_1.1")
241		match = append(match, "~top25desk_ebay.skp_1.1")
242	}
243	if b.extraConfig("Vulkan") && b.gpu("GTX660") {
244		// skia:8523 skia:9271
245		match = append(match, "~compositing_images")
246	}
247	if b.model("MacBook10.1") && b.extraConfig("CommandBuffer") {
248		match = append(match, "~^desk_micrographygirlsvg.skp_1.1$")
249	}
250	if b.extraConfig("ASAN") && b.cpu() {
251		// floor2int_undef benches undefined behavior, so ASAN correctly complains.
252		match = append(match, "~^floor2int_undef$")
253	}
254	if b.model("AcerChromebook13_CB5_311") && b.gpu() {
255		// skia:7551
256		match = append(match, "~^shapes_rrect_inner_rrect_50_500x500$")
257	}
258	if b.model("Pixel3a") {
259		// skia:9413
260		match = append(match, "~^path_text$")
261		match = append(match, "~^path_text_clipped_uncached$")
262	}
263	if b.model("Pixel3") && b.extraConfig("Vulkan") {
264		// skia:9972
265		match = append(match, "~^path_text_clipped_uncached$")
266	}
267
268	if b.model("Wembley") {
269		// These tests spin forever on the Wembley.
270		match = append(match, "~^create_backend_texture")
271		match = append(match, "~^draw_coverage")
272		match = append(match, "~^compositing_images")
273	}
274
275	if b.model(DONT_REDUCE_OPS_TASK_SPLITTING_MODELS...) {
276		args = append(args, "--dontReduceOpsTaskSplitting", "true")
277	}
278	if b.model("NUC7i5BNK") {
279		args = append(args, "--gpuResourceCacheLimit", "16777216")
280	}
281
282	if b.extraConfig("DMSAAStats") {
283		// Render tiled, single-frame skps with an extremely tall canvas that hopefully allows for
284		// us to tile most or all of the content.
285		args = append(args,
286			"--sourceType", "skp", "--clip", "0,0,1600,16384", "--GPUbenchTileW", "1600",
287			"--GPUbenchTileH", "512", "--samples", "1", "--loops", "1", "--config", "gldmsaa",
288			"--dmsaaStatsDump")
289		// Don't collect stats on the skps generated from vector content. We want these to actually
290		// trigger dmsaa.
291		match = append(match, "~svg", "~chalkboard", "~motionmark")
292	}
293
294	// We do not need or want to benchmark the decodes of incomplete images.
295	// In fact, in nanobench we assert that the full image decode succeeds.
296	match = append(match, "~inc0.gif")
297	match = append(match, "~inc1.gif")
298	match = append(match, "~incInterlaced.gif")
299	match = append(match, "~inc0.jpg")
300	match = append(match, "~incGray.jpg")
301	match = append(match, "~inc0.wbmp")
302	match = append(match, "~inc1.wbmp")
303	match = append(match, "~inc0.webp")
304	match = append(match, "~inc1.webp")
305	match = append(match, "~inc0.ico")
306	match = append(match, "~inc1.ico")
307	match = append(match, "~inc0.png")
308	match = append(match, "~inc1.png")
309	match = append(match, "~inc2.png")
310	match = append(match, "~inc12.png")
311	match = append(match, "~inc13.png")
312	match = append(match, "~inc14.png")
313	match = append(match, "~inc0.webp")
314	match = append(match, "~inc1.webp")
315
316	if len(match) > 0 {
317		args = append(args, "--match")
318		args = append(args, match...)
319	}
320
321	if verbose {
322		args = append(args, "--verbose")
323	}
324
325	// Add properties indicating which assets the task should use.
326	b.recipeProp("do_upload", fmt.Sprintf("%t", doUpload))
327	if !b.gpu() {
328		b.asset("skimage")
329		b.recipeProp("images", "true")
330	}
331	b.recipeProp("resources", "true")
332	if !b.os("iOS") {
333		b.asset("skp")
334		b.recipeProp("skps", "true")
335	}
336	if !b.extraConfig("Valgrind") {
337		b.asset("svg")
338		b.recipeProp("svgs", "true")
339	}
340	if b.cpu() && b.os("Android") {
341		// TODO(borenet): Where do these come from?
342		b.recipeProp("textTraces", "true")
343	}
344
345	// These properties are plumbed through nanobench and into Perf results.
346	nanoProps := map[string]string{
347		"gitHash":          specs.PLACEHOLDER_REVISION,
348		"issue":            specs.PLACEHOLDER_ISSUE,
349		"patchset":         specs.PLACEHOLDER_PATCHSET,
350		"patch_storage":    specs.PLACEHOLDER_PATCH_STORAGE,
351		"swarming_bot_id":  "${SWARMING_BOT_ID}",
352		"swarming_task_id": "${SWARMING_TASK_ID}",
353	}
354
355	if doUpload {
356		keysExclude := map[string]bool{
357			"configuration": true,
358			"role":          true,
359			"test_filter":   true,
360		}
361		keys := make([]string, 0, len(b.parts))
362		for k := range b.parts {
363			keys = append(keys, k)
364		}
365		sort.Strings(keys)
366		args = append(args, "--key")
367		for _, k := range keys {
368			if !keysExclude[k] {
369				args = append(args, k, b.parts[k])
370			}
371		}
372	}
373
374	// Finalize the nanobench flags and properties.
375	b.recipeProp("nanobench_flags", marshalJson(args))
376	b.recipeProp("nanobench_properties", marshalJson(nanoProps))
377}
378