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