func()

in infra/bots/gen_tasks_logic/gen_tasks_logic.go [870:1175]


func (b *taskBuilder) defaultSwarmDimensions() {
	d := map[string]string{
		"pool": b.cfg.Pool,
	}
	if os, ok := b.parts["os"]; ok {
		d["os"], ok = map[string]string{
			"Android":     "Android",
			"Android12":   "Android",
			"ChromeOS":    "ChromeOS",
			"Debian9":     DEFAULT_OS_LINUX_GCE, // Runs in Deb9 Docker.
			"Debian11":    DEBIAN_11_OS,
			"Mac":         DEFAULT_OS_MAC,
			"Mac10.15.1":  "Mac-10.15.1",
			"Mac10.15.7":  "Mac-10.15.7",
			"Mac12":       "Mac-12",
			"Mac13":       "Mac-13",
			"Mac14":       "Mac-14.7", // Builds run on 14.5, tests on 14.7.
			"Mac15":       "Mac-15.3",
			"Mokey":       "Android",
			"MokeyGo32":   "Android",
			"Ubuntu18":    "Ubuntu-18.04",
			"Ubuntu20.04": UBUNTU_20_04_OS,
			"Ubuntu22.04": UBUNTU_22_04_OS,
			"Ubuntu24.04": UBUNTU_24_04_OS,
			"Win":         DEFAULT_OS_WIN_GCE,
			"Win10":       "Windows-10-19045",
			"Win11":       "Windows-11-26100.1742",
			"iOS":         "iOS-13.3.1",
			"iOS18":       "iOS-18.2.1",
		}[os]
		if !ok {
			log.Fatalf("Entry %q not found in OS mapping.", os)
		}
		if (os == "Debian11" || os == "Ubuntu18") && b.extraConfig("Docker") {
			d["os"] = DEFAULT_OS_LINUX_GCE
			d["gce"] = "1"
		}
		if os == "Win11" && b.model("GCE") {
			d["os"] = DEFAULT_OS_WIN_GCE
			d["gce"] = "1"
		}
		if strings.Contains(os, "iOS") {
			d["pool"] = "SkiaIOS"
			if b.model("iPhone11") {
				d["os"] = "iOS-18.4"
			}
		}
		if b.parts["model"] == "iPadPro" {
			d["os"] = "iOS-13.6"
		}
	} else {
		d["os"] = DEFAULT_OS_LINUX_GCE
	}
	if b.role("Test", "Perf") {
		if b.os("Android") {
			// For Android, the device type is a better dimension
			// than CPU or GPU.
			deviceInfo, ok := androidDeviceInfos[b.parts["model"]]
			if !ok {
				log.Fatalf("Entry %q not found in Android mapping.", b.parts["model"])
			}
			d["device_type"] = deviceInfo[0]
			d["device_os"] = deviceInfo[1]
		} else if b.os("Android12") {
			// For Android, the device type is a better dimension
			// than CPU or GPU.
			deviceInfo, ok := map[string][]string{
				"Pixel5": {"redfin", "SP2A.220305.012"},
			}[b.parts["model"]]
			if !ok {
				log.Fatalf("Entry %q not found in Android mapping.", b.parts["model"])
			}
			d["device_type"] = deviceInfo[0]
			d["device_os"] = deviceInfo[1]

			// Tests using Android's HWAddress Sanitizer require an HWASan build of Android.
			// See https://developer.android.com/ndk/guides/hwasan.
			if b.extraConfig("HWASAN") {
				d["android_hwasan_build"] = "1"
			}
		} else if b.os("ChromeOS") {
			deviceOS, ok := map[string]string{
				"Cherry":   "16002.30.0",
				"Guybrush": "16002.27.0",
				"Octopus":  "16002.21.0",
				"Trogdor":  "16002.26.0",
			}[b.parts["model"]]
			if !ok {
				log.Fatalf("Entry %q not found in ChromeOS mapping.", b.parts["model"])
			}
			d["device_os"] = deviceOS
			d["device_type"] = strings.ToLower(b.parts["model"])
		} else if b.matchOs("iOS") {
			device, ok := map[string]string{
				"iPadMini4":   "iPad5,1",
				"iPhone11":    "iPhone12,1",
				"iPhone15Pro": "iPhone16,1",
				"iPhone7":     "iPhone9,1",
				"iPhone8":     "iPhone10,1",
				"iPadPro":     "iPad6,3",
			}[b.parts["model"]]
			if !ok {
				log.Fatalf("Entry %q not found in iOS mapping.", b.parts["model"])
			}
			d["device"] = device
		} else if b.cpu() || b.extraConfig("CanvasKit", "Docker", "SwiftShader") {
			modelMapping, ok := map[string]map[string]map[string]string{
				"AppleM1": {
					"MacMini9.1": {"cpu": "arm64-64-Apple_M1"},
				},
				"AppleM3": {
					"MacBookPro15.3": {"cpu": "arm64-64-Apple_M3"},
				},
				"AppleIntel": {
					"MacBookPro15.1": {"cpu": "x86-64"},
					"MacBookPro16.2": {"cpu": "x86-64"},
				},
				"AVX": {
					"VMware7.1": {"cpu": "x86-64"},
				},
				"AVX2": {
					"GCE":            {"cpu": "x86-64-Haswell_GCE"},
					"Golo":           {"cpu": "x86-64-E3-1230_v5"},
					"MacBookAir7.2":  {"cpu": "x86-64-i5-5350U"},
					"MacBookPro11.5": {"cpu": "x86-64-i7-4870HQ"},
					"MacMini7.1":     {"cpu": "x86-64-i5-4278U"},
					"MacMini8.1":     {"cpu": "x86-64-i7-8700B"},
					"NUC5i7RYH":      {"cpu": "x86-64-i7-5557U"},
					"NUC9i7QN":       {"cpu": "x86-64-i7-9750H"},
					// Unfortunately, these machines don't have a more-specific
					// CPU dimension we can use. However, they do have integrated
					// GPUs whose models differ from our other machines, so we
					// specify the GPU dimension even when running CPU tests.
					"NUC11TZi5": {"cpu": "x86-64", "gpu": "8086:9a49"},
				},
				"AVX512": {
					"GCE":  {"cpu": "x86-64-Skylake_GCE"},
					"Golo": {"cpu": "Intel64_Family_6_Model_85_Stepping_7__GenuineIntel"},
				},
				"Rome": {
					"GCE": {"cpu": "x86-64"},
				},
				"SwiftShader": {
					"GCE": {"cpu": "x86-64-Haswell_GCE"},
				},
			}[b.parts["cpu_or_gpu_value"]]
			if !ok {
				log.Fatalf("Entry %q not found in CPU mapping.", b.parts["cpu_or_gpu_value"])
			}
			dims, ok := modelMapping[b.parts["model"]]
			if !ok {
				log.Fatalf("Entry %q not found in %q model mapping.", b.parts["model"], b.parts["cpu_or_gpu_value"])
			}
			for k, v := range dims {
				d[k] = v
			}
			if b.model("GCE") && b.matchOs("Debian") {
				d["os"] = DEFAULT_OS_LINUX_GCE
			}
			if b.model("GCE") && d["cpu"] == "x86-64-Haswell_GCE" {
				d["machine_type"] = MACHINE_TYPE_MEDIUM
			}
			if b.model("GCE") && b.cpu("Rome") {
				d["machine_type"] = "n2d-standard-16"
			}
		} else {
			// It's a GPU job.
			if b.matchOs("Win") {
				gpu, ok := map[string]string{
					"GTX1660":       "10de:2184-31.0.15.4601",
					"IntelHD4400":   "8086:0a16-10.0.26100.1",
					"IntelIris540":  "8086:1926-26.20.100.7528",
					"IntelIris6100": "8086:162b-20.19.15.5171",
					"IntelIris655":  "8086:3ea5-26.20.100.7463",
					"IntelIrisXe":   "8086:9a49-31.0.101.5333",
					"RadeonHD7770":  "1002:683d-26.20.13031.18002",
					"RadeonR9M470X": "1002:6646-21.19.136.0",
					"QuadroP400":    "10de:1cb3-31.0.15.5222",
					"RadeonVega6":   "1002:1636-31.0.14057.5006",
					"RadeonVega8":   "1002:1638-31.0.21916.2",
					"RTX3060":       "10de:2489-32.0.15.7270",
				}[b.parts["cpu_or_gpu_value"]]
				if !ok {
					log.Fatalf("Entry %q not found in Win GPU mapping.", b.parts["cpu_or_gpu_value"])
				}
				// TODO(borenet): Remove this block once these machines are all
				// migrated.
				if b.os("Win10") && b.parts["cpu_or_gpu_value"] == "RTX3060" {
					gpu = "10de:2489-32.0.15.6094"
				}
				d["gpu"] = gpu
			} else if b.isLinux() {
				gpu, ok := map[string]string{
					// Intel drivers come from CIPD, so no need to specify the version here.
					"IntelHD2000":  "8086:0102",
					"IntelHD405":   "8086:22b1",
					"IntelIris640": "8086:5926-24.2.8",
					"QuadroP400":   "10de:1cb3-510.60.02",
					"RTX3060":      "10de:2489-470.182.03",
					"IntelIrisXe":  "8086:9a49",
					"RadeonVega6":  "1002:1636",
					"RadeonVega8":  "1002:1638-23.2.1",
				}[b.parts["cpu_or_gpu_value"]]
				if !ok {
					log.Fatalf("Entry %q not found in Linux GPU mapping.", b.parts["cpu_or_gpu_value"])
				}
				d["gpu"] = gpu
			} else if b.matchOs("Mac") {
				gpu, ok := map[string]string{
					"AppleM1":             "AppleM1",
					"AppleM3":             "apple:m3",
					"IntelHD6000":         "8086:1626",
					"IntelHD615":          "8086:591e",
					"IntelIris5100":       "8086:0a2e",
					"IntelIrisPlus":       "8086:8a53",
					"IntelUHDGraphics630": "8086:3e9b",
					"RadeonHD8870M":       "1002:6821-4.0.20-3.2.8",
				}[b.parts["cpu_or_gpu_value"]]
				if !ok {
					log.Fatalf("Entry %q not found in Mac GPU mapping.", b.parts["cpu_or_gpu_value"])
				}
				if gpu == "AppleM1" {
					// No GPU dimension yet, but we can constrain by CPU.
					d["cpu"] = "arm64-64-Apple_M1"
				} else {
					d["gpu"] = gpu
				}
				// We have two different types of MacMini7,1 with the same GPU but different CPUs.
				if b.gpu("IntelIris5100") {
					if b.extraConfig("i5") {
						// If we say "i5", run on our MacMini7,1s in the Skolo:
						d["cpu"] = "x86-64-i5-4278U"
					} else {
						// Otherwise, run on Golo machines, just because that's
						// where those jobs have always run. Plus, some of them
						// are Perf jobs, which we want to keep consistent.
						d["cpu"] = "x86-64-i7-4578U"
					}
				}
			} else {
				log.Fatalf("Unknown GPU mapping for OS %q.", b.parts["os"])
			}
		}
		if b.matchOs("Mac") {
			// TODO(borenet): Remove empty and nested entries after all Macs
			// are migrated to the new lab.
			if macModel, ok := map[string]interface{}{
				"MacBookAir7.2":  "",
				"MacBookPro11.5": "MacBookPro11,5",
				"MacBookPro15.1": "MacBookPro15,1",
				"MacBookPro15.3": "Mac15,3",
				"MacBookPro16.2": "",
				"MacMini7.1":     "",
				"MacMini8.1":     "Macmini8,1",
				"MacMini9.1": map[string]string{
					"Mac12": "",
					"Mac13": "",
					"Mac14": "Macmini9,1",
				},
				// TODO(borenet): This is currently resolving to multiple
				// different actual device types.
				"VMware7.1": "",
			}[b.parts["model"]]; ok {
				if macModel != "" {
					macModelDim, ok := macModel.(string)
					if !ok {
						macModelDim = macModel.(map[string]string)[b.parts["os"]]
					}
					if macModelDim != "" {
						d["mac_model"] = macModelDim
					}
				}
			} else {
				log.Fatalf("No mac_model found for %q", b.parts["model"])
			}
		}
	} else {
		d["gpu"] = "none"
		if d["os"] == DEFAULT_OS_LINUX_GCE {
			if b.extraConfig("CanvasKit", "CMake", "Docker", "PathKit") || b.role("BuildStats", "CodeSize") {
				b.linuxGceDimensions(MACHINE_TYPE_MEDIUM)
			} else {
				// Use many-core machines for Build tasks.
				b.linuxGceDimensions(MACHINE_TYPE_LARGE)
			}
		} else if d["os"] == DEFAULT_OS_WIN_GCE {
			// Windows CPU bots.
			d["cpu"] = "x86-64-Haswell_GCE"
			d["gce"] = "1"
			// Use many-core machines for Build tasks.
			d["machine_type"] = MACHINE_TYPE_LARGE
		} else if d["os"] == DEFAULT_OS_MAC || d["os"] == "Mac-10.15.7" {
			// Mac CPU bots are no longer VMs.
			d["cpu"] = "x86-64"
			d["cores"] = "12"
			delete(d, "gpu")
		}
	}

	dims := make([]string, 0, len(d))
	for k, v := range d {
		dims = append(dims, fmt.Sprintf("%s:%s", k, v))
	}
	sort.Strings(dims)
	b.dimension(dims...)
}