1// Copyright 2023 Google LLC 2// 3// Use of this source code is governed by a BSD-style license that can be 4// found in the LICENSE file. 5 6package device_specific_configs 7 8import ( 9 "fmt" 10 "sort" 11) 12 13// Config represents a Bazel config that communicates information about the device under test. 14// 15// This struct is used to generate file //bazel/devicesrc. 16// 17// Configurations of this kind should not be used to set build time settings, such as the target 18// Bazel platform (e.g. Linux, Android), optimization level (e.g. Debug, Release) or local vs. RBE. 19// For that kind of information, please pass a second --config flag using one of the configurations 20// defined in //bazel/buildrc. 21type Config struct { 22 // Name of the config (the <foo> that gets passed to Bazel via --config=<foo>). 23 Name string 24 25 // Any device-specific key/value pairs to include in Gold and Perf traces produced by GM and 26 // benchmark tests, except for keys "cpu_or_gpu" and "cpu_or_gpu_value". See fields CPU and GPU. 27 Keys map[string]string 28 29 // CPU is the name of the CPU on this device. 30 // 31 // When a GM or benchmark test case is executed, the corresponding test runner will set the 32 // "cpu_or_gpu_value" key of the resulting Gold or Perf trace with the contents of this field 33 // if the test case is CPU-bound, in which case it will also set the "cpu_or_gpu" key to "CPU". 34 CPU string 35 36 // GPU is the name of the GPU on this device. 37 // 38 // This field is the GPU analogous of the CPU field; see its documentation for details. 39 GPU string 40 41 // SwarmingDimensions are the Swarming dimensions that a CI task must exhibit in order to get 42 // scheduled to run on a machine that corresponds with the device under test indicated by the 43 // Bazel config. 44 SwarmingDimensions map[string]string 45} 46 47// Model returns the "model" key in the Keys dictionary. 48func (d Config) Model() string { 49 model, ok := d.Keys["model"] 50 if !ok { 51 // Should never happen. We have a unit test that ensures all configs have this key. 52 panic(fmt.Sprintf("config %q does not contain key \"model\"", d.Name)) 53 } 54 return model 55} 56 57// TestRunnerArgs returns the command-line arguments that should be passed to the Bazel test 58// target. 59func (d Config) TestRunnerArgs() []string { 60 args := []string{ 61 // Pass the name of the Bazel configuration as an argument. Android tests use this to infer the 62 // model of the device under test. Specifically, adb_test_runner.go will take device-specific 63 // setup and teardown steps based on the model. C++ tests running on the same machine as Bazel 64 // will ignore this flag. 65 "--device-specific-bazel-config", 66 d.Name, 67 } 68 69 // Sort keys for determinism. 70 var keys []string 71 for key := range d.Keys { 72 keys = append(keys, key) 73 } 74 sort.Strings(keys) 75 76 // Add key/value pairs. 77 args = append(args, "--key") 78 for _, key := range keys { 79 args = append(args, key, d.Keys[key]) 80 } 81 82 if d.CPU != "" { 83 args = append(args, "--cpuName", d.CPU) 84 } 85 86 if d.GPU != "" { 87 args = append(args, "--gpuName", d.GPU) 88 } 89 90 return args 91} 92 93// Configs contains all known device-specific Bazel configs. 94// 95// The contents of this map are used to generate file //bazel/devicesrc. 96// 97// TODO(lovisolo): Populate field SwarmingDimensions for all configs. 98var Configs = map[string]Config{ 99 "AlphaR2": { 100 Name: "AlphaR2", 101 Keys: map[string]string{ 102 "arch": "x86_64", 103 "model": "AlphaR2", 104 "os": "Win10", 105 }, 106 GPU: "RadeonR9M470X", 107 }, 108 "AndroidOne": { 109 Name: "AndroidOne", 110 Keys: map[string]string{ 111 "arch": "arm", 112 "model": "AndroidOne", 113 "os": "Android", 114 }, 115 GPU: "Mali400MP2", 116 }, 117 "GCE_Debian10_AVX2": { 118 Name: "GCE_Debian10_AVX2", 119 Keys: map[string]string{ 120 "arch": "x86_64", 121 "model": "GCE", 122 "os": "Debian10", 123 }, 124 CPU: "AVX2", 125 GPU: "SwiftShader", 126 }, 127 "GCE_Debian10_AVX512": { 128 Name: "GCE_Debian10_AVX512", 129 Keys: map[string]string{ 130 "arch": "x86_64", 131 "model": "GCE", 132 "os": "Debian10", 133 }, 134 CPU: "AVX512", 135 GPU: "SwiftShader", 136 }, 137 "GCE_Debian10_Rome": { 138 Name: "GCE_Debian10_Rome", 139 Keys: map[string]string{ 140 "arch": "x86_64", 141 "model": "GCE", 142 "os": "Debian10", 143 }, 144 CPU: "Rome", 145 GPU: "SwiftShader", 146 }, 147 "GCE_Win2019_AVX2": { 148 Name: "GCE_Win2019_AVX2", 149 Keys: map[string]string{ 150 "arch": "x86_64", 151 "model": "GCE", 152 "os": "Win2019", 153 }, 154 CPU: "AVX2", 155 GPU: "SwiftShader", 156 }, 157 "GCE_Win2019_AVX512": { 158 Name: "GCE_Win2019_AVX512", 159 Keys: map[string]string{ 160 "arch": "x86_64", 161 "model": "GCE", 162 "os": "Win2019", 163 }, 164 CPU: "AVX512", 165 GPU: "SwiftShader", 166 }, 167 "GCE_Win2019_Rome": { 168 Name: "GCE_Win2019_Rome", 169 Keys: map[string]string{ 170 "arch": "x86_64", 171 "model": "GCE", 172 "os": "Win2019", 173 }, 174 CPU: "Rome", 175 GPU: "SwiftShader", 176 }, 177 "GCE_x86_Debian10_AVX2": { 178 Name: "GCE_x86_Debian10_AVX2", 179 Keys: map[string]string{ 180 "arch": "x86", 181 "model": "GCE", 182 "os": "Debian10", 183 }, 184 CPU: "AVX2", 185 GPU: "SwiftShader", 186 }, 187 "GCE_x86_Debian10_AVX512": { 188 Name: "GCE_x86_Debian10_AVX512", 189 Keys: map[string]string{ 190 "arch": "x86", 191 "model": "GCE", 192 "os": "Debian10", 193 }, 194 CPU: "AVX512", 195 GPU: "SwiftShader", 196 }, 197 "GCE_x86_Debian10_Rome": { 198 Name: "GCE_x86_Debian10_Rome", 199 Keys: map[string]string{ 200 "arch": "x86", 201 "model": "GCE", 202 "os": "Debian10", 203 }, 204 CPU: "Rome", 205 GPU: "SwiftShader", 206 }, 207 "GCE_x86_Win2019_AVX2": { 208 Name: "GCE_x86_Win2019_AVX2", 209 Keys: map[string]string{ 210 "arch": "x86", 211 "model": "GCE", 212 "os": "Win2019", 213 }, 214 CPU: "AVX2", 215 GPU: "SwiftShader", 216 }, 217 "GCE_x86_Win2019_AVX512": { 218 Name: "GCE_x86_Win2019_AVX512", 219 Keys: map[string]string{ 220 "arch": "x86", 221 "model": "GCE", 222 "os": "Win2019", 223 }, 224 CPU: "AVX512", 225 GPU: "SwiftShader", 226 }, 227 "GCE_x86_Win2019_Rome": { 228 Name: "GCE_x86_Win2019_Rome", 229 Keys: map[string]string{ 230 "arch": "x86", 231 "model": "GCE", 232 "os": "Win2019", 233 }, 234 CPU: "Rome", 235 GPU: "SwiftShader", 236 }, 237 "GalaxyS20": { 238 Name: "GalaxyS20", 239 Keys: map[string]string{ 240 "arch": "arm64", 241 "model": "GalaxyS20", 242 "os": "Android", 243 }, 244 GPU: "MaliG77", 245 }, 246 "GalaxyS7_G930FD": { 247 Name: "GalaxyS7_G930FD", 248 Keys: map[string]string{ 249 "arch": "arm64", 250 "model": "GalaxyS7_G930FD", 251 "os": "Android", 252 }, 253 GPU: "MaliT880", 254 }, 255 "Golo_wasm_Ubuntu18": { 256 Name: "Golo_wasm_Ubuntu18", 257 Keys: map[string]string{ 258 "arch": "wasm", 259 "model": "Golo", 260 "os": "Ubuntu18", 261 }, 262 GPU: "QuadroP400", 263 }, 264 "Golo_wasm_Win10": { 265 Name: "Golo_wasm_Win10", 266 Keys: map[string]string{ 267 "arch": "wasm", 268 "model": "Golo", 269 "os": "Win10", 270 }, 271 GPU: "QuadroP400", 272 }, 273 "Golo_x86_64_Ubuntu18": { 274 Name: "Golo_x86_64_Ubuntu18", 275 Keys: map[string]string{ 276 "arch": "x86_64", 277 "model": "Golo", 278 "os": "Ubuntu18", 279 }, 280 GPU: "QuadroP400", 281 }, 282 "Golo_x86_64_Win10": { 283 Name: "Golo_x86_64_Win10", 284 Keys: map[string]string{ 285 "arch": "x86_64", 286 "model": "Golo", 287 "os": "Win10", 288 }, 289 GPU: "QuadroP400", 290 }, 291 "JioNext": { 292 Name: "JioNext", 293 Keys: map[string]string{ 294 "arch": "arm", 295 "model": "JioNext", 296 "os": "Android", 297 }, 298 CPU: "SnapdragonQM215", 299 GPU: "Adreno308", 300 }, 301 "Kevin": { 302 Name: "Kevin", 303 Keys: map[string]string{ 304 "arch": "arm", 305 "model": "Kevin", 306 "os": "ChromeOS", 307 }, 308 GPU: "MaliT860", 309 }, 310 "MacBook10.1": { 311 Name: "MacBook10.1", 312 Keys: map[string]string{ 313 "arch": "x86_64", 314 "model": "MacBook10.1", 315 "os": "Mac10.13", 316 }, 317 GPU: "IntelHD615", 318 }, 319 "MacBookAir7.2": { 320 Name: "MacBookAir7.2", 321 Keys: map[string]string{ 322 "arch": "x86_64", 323 "model": "MacBookAir7.2", 324 "os": "Mac10.15.1", 325 }, 326 GPU: "IntelHD6000", 327 }, 328 "MacBookPro11.5_Mac10.13": { 329 Name: "MacBookPro11.5_Mac10.13", 330 Keys: map[string]string{ 331 "arch": "x86_64", 332 "model": "MacBookPro11.5", 333 "os": "Mac10.13", 334 }, 335 CPU: "AVX2", 336 GPU: "RadeonHD8870M", 337 }, 338 "MacBookPro11.5_Mac10.15.7": { 339 Name: "MacBookPro11.5_Mac10.15.7", 340 Keys: map[string]string{ 341 "arch": "x86_64", 342 "model": "MacBookPro11.5", 343 "os": "Mac10.15.7", 344 }, 345 CPU: "AVX2", 346 GPU: "RadeonHD8870M", 347 }, 348 "MacBookPro16.2": { 349 Name: "MacBookPro16.2", 350 Keys: map[string]string{ 351 "arch": "x86_64", 352 "model": "MacBookPro16.2", 353 "os": "Mac12", 354 }, 355 CPU: "AppleIntel", 356 GPU: "IntelIrisPlus", 357 }, 358 "MacMini7.1_Mac10.13": { 359 Name: "MacMini7.1_Mac10.13", 360 Keys: map[string]string{ 361 "arch": "x86_64", 362 "model": "MacMini7.1", 363 "os": "Mac10.13", 364 }, 365 CPU: "AVX2", 366 GPU: "IntelIris5100", 367 }, 368 "MacMini7.1_Mac10.14": { 369 Name: "MacMini7.1_Mac10.14", 370 Keys: map[string]string{ 371 "arch": "x86_64", 372 "model": "MacMini7.1", 373 "os": "Mac10.14", 374 }, 375 CPU: "AVX2", 376 GPU: "IntelIris5100", 377 }, 378 "MacMini7.1_Mac10.15.7": { 379 Name: "MacMini7.1_Mac10.15.7", 380 Keys: map[string]string{ 381 "arch": "x86_64", 382 "model": "MacMini7.1", 383 "os": "Mac10.15.7", 384 }, 385 CPU: "AVX2", 386 GPU: "IntelIris5100", 387 }, 388 "MacMini9.1_Mac11": { 389 Name: "MacMini9.1_Mac11", 390 Keys: map[string]string{ 391 "arch": "arm64", 392 "model": "MacMini9.1", 393 "os": "Mac11", 394 }, 395 CPU: "AppleM1", 396 GPU: "AppleM1", 397 }, 398 "MacMini9.1_Mac12": { 399 Name: "MacMini9.1_Mac12", 400 Keys: map[string]string{ 401 "arch": "arm64", 402 "model": "MacMini9.1", 403 "os": "Mac12", 404 }, 405 CPU: "AppleM1", 406 GPU: "AppleM1", 407 }, 408 "MacMini9.1_Mac13": { 409 Name: "MacMini9.1_Mac13", 410 Keys: map[string]string{ 411 "arch": "arm64", 412 "model": "MacMini9.1", 413 "os": "Mac13", 414 }, 415 CPU: "AppleM1", 416 GPU: "AppleM1", 417 }, 418 "NUC11TZi5_Debian11": { 419 Name: "NUC11TZi5_Debian11", 420 Keys: map[string]string{ 421 "arch": "x86_64", 422 "model": "NUC11TZi5", 423 "os": "Debian11", 424 }, 425 CPU: "AVX2", 426 GPU: "IntelIrisXe", 427 }, 428 "NUC11TZi5_Win10": { 429 Name: "NUC11TZi5_Win10", 430 Keys: map[string]string{ 431 "arch": "x86_64", 432 "model": "NUC11TZi5", 433 "os": "Win10", 434 }, 435 CPU: "AVX2", 436 GPU: "IntelIrisXe", 437 }, 438 "NUC5PPYH": { 439 Name: "NUC5PPYH", 440 Keys: map[string]string{ 441 "arch": "x86_64", 442 "model": "NUC5PPYH", 443 "os": "Debian10", 444 }, 445 GPU: "IntelHD405", 446 }, 447 "NUC5i7RYH": { 448 Name: "NUC5i7RYH", 449 Keys: map[string]string{ 450 "arch": "x86_64", 451 "model": "NUC5i7RYH", 452 "os": "Win10", 453 }, 454 CPU: "AVX2", 455 GPU: "IntelIris6100", 456 }, 457 "NUC6i5SYK": { 458 Name: "NUC6i5SYK", 459 Keys: map[string]string{ 460 "arch": "x86_64", 461 "model": "NUC6i5SYK", 462 "os": "Win10", 463 }, 464 GPU: "IntelIris540", 465 }, 466 "NUC8i5BEK": { 467 Name: "NUC8i5BEK", 468 Keys: map[string]string{ 469 "arch": "x86_64", 470 "model": "NUC8i5BEK", 471 "os": "Win10", 472 }, 473 GPU: "IntelIris655", 474 }, 475 "NUC9i7QN_Debian11": { 476 Name: "NUC9i7QN_Debian11", 477 Keys: map[string]string{ 478 "arch": "x86_64", 479 "model": "NUC9i7QN", 480 "os": "Debian11", 481 }, 482 CPU: "AVX2", 483 GPU: "RTX3060", 484 // Based on 485 // https://skia.googlesource.com/skia/+/5606ef899116266132253e979a793fea97f12604/infra/bots/gen_tasks_logic/gen_tasks_logic.go#952. 486 SwarmingDimensions: map[string]string{ 487 "os": "Debian-11.5", 488 "cpu": "x86-64-i7-9750H", 489 }, 490 }, 491 "NUC9i7QN_Win10": { 492 Name: "NUC9i7QN_Win10", 493 Keys: map[string]string{ 494 "arch": "x86_64", 495 "model": "NUC9i7QN", 496 "os": "Win10", 497 }, 498 CPU: "AVX2", 499 GPU: "RTX3060", 500 }, 501 "NUCD34010WYKH": { 502 Name: "NUCD34010WYKH", 503 Keys: map[string]string{ 504 "arch": "x86_64", 505 "model": "NUCD34010WYKH", 506 "os": "Win10", 507 }, 508 GPU: "IntelHD4400", 509 }, 510 "NUCDE3815TYKHE": { 511 Name: "NUCDE3815TYKHE", 512 Keys: map[string]string{ 513 "arch": "x86_64", 514 "model": "NUCDE3815TYKHE", 515 "os": "Debian10", 516 }, 517 GPU: "IntelBayTrail", 518 }, 519 "Nexus7": { 520 Name: "Nexus7", 521 Keys: map[string]string{ 522 "arch": "arm", 523 "model": "Nexus7", 524 "os": "Android", 525 }, 526 GPU: "Tegra3", 527 }, 528 "P30": { 529 Name: "P30", 530 Keys: map[string]string{ 531 "arch": "arm64", 532 "model": "P30", 533 "os": "Android", 534 }, 535 GPU: "MaliG76", 536 }, 537 "Pixel4": { 538 Name: "Pixel4", 539 Keys: map[string]string{ 540 "arch": "arm64", 541 "model": "Pixel4", 542 "os": "Android", 543 }, 544 CPU: "Snapdragon855", 545 GPU: "Adreno640", 546 }, 547 "Pixel4XL": { 548 Name: "Pixel4XL", 549 Keys: map[string]string{ 550 "arch": "arm64", 551 "model": "Pixel4XL", 552 "os": "Android", 553 }, 554 GPU: "Adreno640", 555 }, 556 "Pixel5": { 557 Name: "Pixel5", 558 Keys: map[string]string{ 559 "arch": "arm64", 560 "model": "Pixel5", 561 "os": "Android", 562 }, 563 GPU: "Adreno620", 564 // Based on 565 // https://skia.googlesource.com/skia/+/f8daeeb7f092abe1674bc2303c0781f9fb1756ab/infra/bots/gen_tasks_logic/gen_tasks_logic.go#836. 566 SwarmingDimensions: map[string]string{ 567 "os": "Android", 568 "device_type": "redfin", 569 "device_os": "RD1A.200810.022.A4", 570 }, 571 }, 572 "Pixel5_Android12": { 573 Name: "Pixel5_Android12", 574 Keys: map[string]string{ 575 "arch": "arm64", 576 "model": "Pixel5", 577 "os": "Android12", 578 }, 579 GPU: "Adreno620", 580 // Based on 581 // https://skia.googlesource.com/skia/+/f8daeeb7f092abe1674bc2303c0781f9fb1756ab/infra/bots/gen_tasks_logic/gen_tasks_logic.go#910. 582 SwarmingDimensions: map[string]string{ 583 "os": "Android", 584 "device_type": "redfin", 585 "device_os": "SP2A.220305.012", 586 }, 587 }, 588 "Pixel6": { 589 Name: "Pixel6", 590 Keys: map[string]string{ 591 "arch": "arm64", 592 "model": "Pixel6", 593 "os": "Android", 594 }, 595 GPU: "MaliG78", 596 }, 597 "Pixel7": { 598 Name: "Pixel7", 599 Keys: map[string]string{ 600 "arch": "arm64", 601 "model": "Pixel7", 602 "os": "Android", 603 }, 604 GPU: "MaliG710", 605 }, 606 "RUBYR5_Debian11": { 607 Name: "RUBYR5_Debian11", 608 Keys: map[string]string{ 609 "arch": "x86_64", 610 "model": "RUBYR5", 611 "os": "Debian11", 612 }, 613 GPU: "RadeonVega6", 614 }, 615 "RUBYR5_Win10": { 616 Name: "RUBYR5_Win10", 617 Keys: map[string]string{ 618 "arch": "x86_64", 619 "model": "RUBYR5", 620 "os": "Win10", 621 }, 622 GPU: "RadeonVega6", 623 }, 624 "Sparky360": { 625 Name: "Sparky360", 626 Keys: map[string]string{ 627 "arch": "x86_64", 628 "model": "Sparky360", 629 "os": "ChromeOS", 630 }, 631 GPU: "IntelUHDGraphics605", 632 }, 633 "Spin513": { 634 Name: "Spin513", 635 Keys: map[string]string{ 636 "arch": "arm", 637 "model": "Spin513", 638 "os": "ChromeOS", 639 }, 640 GPU: "Adreno618", 641 }, 642 "Spin514": { 643 Name: "Spin514", 644 Keys: map[string]string{ 645 "arch": "x86_64", 646 "model": "Spin514", 647 "os": "ChromeOS", 648 }, 649 GPU: "RadeonVega3", 650 }, 651 "VMware7.1_Mac10.13": { 652 Name: "VMware7.1_Mac10.13", 653 Keys: map[string]string{ 654 "arch": "x86_64", 655 "model": "VMware7.1", 656 "os": "Mac10.13", 657 }, 658 CPU: "AVX", 659 }, 660 "VMware7.1_Mac10.14": { 661 Name: "VMware7.1_Mac10.14", 662 Keys: map[string]string{ 663 "arch": "x86_64", 664 "model": "VMware7.1", 665 "os": "Mac10.14", 666 }, 667 CPU: "AVX", 668 }, 669 "VMware7.1_Mac10.15.7": { 670 Name: "VMware7.1_Mac10.15.7", 671 Keys: map[string]string{ 672 "arch": "x86_64", 673 "model": "VMware7.1", 674 "os": "Mac10.15.7", 675 }, 676 CPU: "AVX", 677 }, 678 "Wembley": { 679 Name: "Wembley", 680 Keys: map[string]string{ 681 "arch": "arm", 682 "model": "Wembley", 683 "os": "Android", 684 }, 685 GPU: "PowerVRGE8320", 686 }, 687 "iPadPro": { 688 Name: "iPadPro", 689 Keys: map[string]string{ 690 "arch": "arm64", 691 "model": "iPadPro", 692 "os": "iOS", 693 }, 694 GPU: "PowerVRGT7800", 695 }, 696 "iPhone7": { 697 Name: "iPhone7", 698 Keys: map[string]string{ 699 "arch": "arm64", 700 "model": "iPhone7", 701 "os": "iOS", 702 }, 703 GPU: "PowerVRGT7600", 704 }, 705 "iPhone8": { 706 Name: "iPhone8", 707 Keys: map[string]string{ 708 "arch": "arm64", 709 "model": "iPhone8", 710 "os": "iOS", 711 }, 712 GPU: "AppleA11", 713 }, 714} 715