[metal] Expose the exact subgroup size for Apple GPUs
Apple GPUs have a fixed subgroup size of 32. Exposing the actual
subgroup size makes it easier to write high performing shaders,
particularly when using the subgroup matrix extension which requires
the workgroup size to be a multiple of the maximum subgroup size.
This does not increase the ability to fingerprint these devices, since
the presence of the subgroup matrix extension on Metal is already an
indication that the device is an Apple GPU.
Fixed: 416313648
Change-Id: Iaa701d290cae2531a77b14c83b5b7e6d375f6de0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/264274
Reviewed-by: Peter McNeeley <petermcneeley@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
diff --git a/src/dawn/native/metal/PhysicalDeviceMTL.mm b/src/dawn/native/metal/PhysicalDeviceMTL.mm
index d282533..ef51766 100644
--- a/src/dawn/native/metal/PhysicalDeviceMTL.mm
+++ b/src/dawn/native/metal/PhysicalDeviceMTL.mm
@@ -308,8 +308,15 @@
NSString* osVersion = [[NSProcessInfo processInfo] operatingSystemVersionString];
mDriverDescription = "Metal driver on " + std::string(systemName) + [osVersion UTF8String];
- mSubgroupMinSize = 4; // The 4 comes from the minimum derivative group.
- mSubgroupMaxSize = 64; // In MSL, a ballot is a uint64, so the max subgroup size is 64.
+ if (gpu_info::IsApple(mVendorId)) {
+ // Apple M1 tech talk: https://developer.apple.com/videos/play/wwdc2022/10159/
+ // "on all Apple GPUs, it is equal to 32"
+ mSubgroupMinSize = 32;
+ mSubgroupMaxSize = 32;
+ } else {
+ mSubgroupMinSize = 4; // The 4 comes from the minimum derivative group.
+ mSubgroupMaxSize = 64; // In MSL, a ballot is a uint64, so the max subgroup size is 64.
+ }
}
bool PhysicalDevice::IsMetalValidationEnabled() const {