Skip to content

Commit d11a3e6

Browse files
committed
Add subgroupsize restriction for other targets
1 parent 458c5f0 commit d11a3e6

File tree

165 files changed

+413
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+413
-170
lines changed

include/API/Device.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class Device {
4545
virtual GPUAPI getAPI() const = 0;
4646
virtual llvm::Error executeProgram(Pipeline &P) = 0;
4747
virtual void printExtra(llvm::raw_ostream &OS) {}
48-
virtual uint32_t getSubgroupSize() = 0;
48+
virtual uint32_t getSubgroupSize() const = 0;
49+
virtual std::pair<uint32_t, uint32_t> getMinMaxSubgroupSize() const = 0;
4950

5051
virtual ~Device() = 0;
5152

lib/API/DX/Device.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,28 @@ class DXDevice : public offloadtest::Device {
337337
return Caps;
338338
}
339339

340+
uint32_t getSubgroupSize() const override {
341+
D3D12_FEATURE_DATA_D3D12_OPTIONS1 Options1 = {};
342+
if (FAILED(Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1,
343+
&Options1, sizeof(Options1))))
344+
return 0;
345+
return Options1.WaveLaneCountMin;
346+
}
347+
std::pair<uint32_t, uint32_t> getMinMaxSubgroupSize() const override {
348+
D3D12_FEATURE_DATA_D3D12_OPTIONS1 Options1 = {};
349+
if (FAILED(Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1,
350+
&Options1, sizeof(Options1))))
351+
return {0, 0};
352+
return {Options1.WaveLaneCountMin, Options1.WaveLaneCountMax};
353+
}
354+
355+
void printExtra(llvm::raw_ostream &OS) override {
356+
OS << " SubgroupSize: " << getSubgroupSize() << "\n";
357+
auto MinMax = getMinMaxSubgroupSize();
358+
OS << " MinSubgroupSize: " << MinMax.first << "\n";
359+
OS << " MaxSubgroupSize: " << MinMax.second << "\n";
360+
}
361+
340362
void queryCapabilities() {
341363
CD3DX12FeatureSupport Features;
342364
Features.Init(Device.Get());

lib/API/MTL/MTLDevice.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,47 @@ class MTLDevice : public offloadtest::Device {
484484
MTLDevice(MTL::Device *D) : Device(D) {
485485
Description = Device->name()->utf8String();
486486
}
487+
uint32_t getSubgroupSize() const override {
488+
const char *Src = R"(
489+
#include <metal_stdlib>
490+
using namespace metal;
491+
kernel void k() {}
492+
)";
493+
NS::Error *Err = nullptr;
494+
MTL::Library *Lib = Device->newLibrary(
495+
NS::String::string(Src, NS::UTF8StringEncoding), nullptr, &Err);
496+
if (!Lib) {
497+
if (Err)
498+
Err->release();
499+
return 0;
500+
}
501+
MTL::Function *Func =
502+
Lib->newFunction(NS::String::string("k", NS::UTF8StringEncoding));
503+
Lib->release();
504+
if (!Func)
505+
return 0;
506+
MTL::ComputePipelineState *PSO =
507+
Device->newComputePipelineState(Func, &Err);
508+
Func->release();
509+
if (!PSO) {
510+
if (Err)
511+
Err->release();
512+
return 0;
513+
}
514+
uint32_t SubgroupSize = PSO->threadExecutionWidth();
515+
PSO->release();
516+
return SubgroupSize;
517+
}
518+
void printExtra(llvm::raw_ostream &OS) override {
519+
OS << " SubgroupSize: " << getSubgroupSize() << "\n";
520+
}
521+
522+
std::pair<uint32_t, uint32_t> getMinMaxSubgroupSize() const override {
523+
// Metal currently only exposes a single subgroup size.
524+
const uint32_t SGSize = getSubgroupSize();
525+
return {SGSize, SGSize};
526+
}
527+
487528
const Capabilities &getCapabilities() override {
488529
if (Caps.empty())
489530
queryCapabilities();

lib/API/VK/Device.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,20 +322,34 @@ class VKDevice : public offloadtest::Device {
322322
VKDevice(const VKDevice &) = default;
323323

324324
~VKDevice() override = default;
325-
326325
llvm::StringRef getAPIName() const override { return "Vulkan"; }
327326
GPUAPI getAPI() const override { return GPUAPI::Vulkan; }
328-
uint32_t getSubgroupSize() override {
327+
uint32_t getSubgroupSize() const override {
329328
VkPhysicalDeviceSubgroupProperties SubgroupProps = {};
330329
SubgroupProps.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES;
331330

332-
VkPhysicalDeviceProperties2 subgroupProperties2 = {};
333-
subgroupProperties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
334-
subgroupProperties2.pNext = &SubgroupProps;
335-
vkGetPhysicalDeviceProperties2(Device, &subgroupProperties2);
331+
VkPhysicalDeviceProperties2 SubgroupProperties2 = {};
332+
SubgroupProperties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
333+
SubgroupProperties2.pNext = &SubgroupProps;
334+
vkGetPhysicalDeviceProperties2(Device, &SubgroupProperties2);
336335
return SubgroupProps.subgroupSize;
337336
}
338337

338+
std::pair<uint32_t, uint32_t> getMinMaxSubgroupSize() const override {
339+
VkPhysicalDeviceSubgroupSizeControlPropertiesEXT SubgroupSizeControlProps =
340+
{};
341+
SubgroupSizeControlProps.sType =
342+
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES_EXT;
343+
344+
VkPhysicalDeviceProperties2 Props2 = {};
345+
Props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
346+
Props2.pNext = &SubgroupSizeControlProps;
347+
348+
vkGetPhysicalDeviceProperties2(Device, &Props2);
349+
return {SubgroupSizeControlProps.minSubgroupSize,
350+
SubgroupSizeControlProps.maxSubgroupSize};
351+
}
352+
339353
const Capabilities &getCapabilities() override {
340354
if (Caps.empty())
341355
queryCapabilities();
@@ -372,6 +386,10 @@ class VKDevice : public offloadtest::Device {
372386

373387
void printExtra(llvm::raw_ostream &OS) override {
374388
OS << " SubgroupSize: " << getSubgroupSize() << "\n";
389+
auto MinMax = getMinMaxSubgroupSize();
390+
OS << " MinSubgroupSize: " << MinMax.first << "\n";
391+
OS << " MaxSubgroupSize: " << MinMax.second << "\n";
392+
375393
OS << " Layers:\n";
376394
for (auto Layer : getLayers()) {
377395
uint64_t Sz = strnlen(Layer.layerName, VK_MAX_EXTENSION_NAME_SIZE);

test/Feature/MaximalReconvergence/cts/tests/16/test_2_16_7_13_0.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ DescriptorSets:
109109

110110
...
111111
#--- end
112-
# UNSUPPORTED: Vulkan && ( !VK_KHR_shader_maximal_reconvergence || !SubgroupSize16 )
112+
# UNSUPPORTED: Vulkan && !VK_KHR_shader_maximal_reconvergence
113+
# UNSUPPORTED: !SubgroupSize16
113114

114115
# Bug: Some wave operations are not yet implemented.
115116
# XFAIL: Clang

test/Feature/MaximalReconvergence/cts/tests/16/test_2_16_7_13_1.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ DescriptorSets:
120120

121121
...
122122
#--- end
123-
# UNSUPPORTED: Vulkan && ( !VK_KHR_shader_maximal_reconvergence || !SubgroupSize16 )
123+
# UNSUPPORTED: Vulkan && !VK_KHR_shader_maximal_reconvergence
124+
# UNSUPPORTED: !SubgroupSize16
124125

125126
# Bug: Some wave operations are not yet implemented.
126127
# XFAIL: Clang

test/Feature/MaximalReconvergence/cts/tests/16/test_2_16_7_13_2.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ DescriptorSets:
9898

9999
...
100100
#--- end
101-
# UNSUPPORTED: Vulkan && ( !VK_KHR_shader_maximal_reconvergence || !SubgroupSize16 )
101+
# UNSUPPORTED: Vulkan && !VK_KHR_shader_maximal_reconvergence
102+
# UNSUPPORTED: !SubgroupSize16
102103

103104
# Bug: Some wave operations are not yet implemented.
104105
# XFAIL: Clang

test/Feature/MaximalReconvergence/cts/tests/16/test_2_16_7_13_3.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ DescriptorSets:
136136

137137
...
138138
#--- end
139-
# UNSUPPORTED: Vulkan && ( !VK_KHR_shader_maximal_reconvergence || !SubgroupSize16 )
139+
# UNSUPPORTED: Vulkan && !VK_KHR_shader_maximal_reconvergence
140+
# UNSUPPORTED: !SubgroupSize16
140141

141142
# Bug: Some wave operations are not yet implemented.
142143
# XFAIL: Clang

test/Feature/MaximalReconvergence/cts/tests/16/test_2_16_7_13_4.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ DescriptorSets:
107107

108108
...
109109
#--- end
110-
# UNSUPPORTED: Vulkan && ( !VK_KHR_shader_maximal_reconvergence || !SubgroupSize16 )
110+
# UNSUPPORTED: Vulkan && !VK_KHR_shader_maximal_reconvergence
111+
# UNSUPPORTED: !SubgroupSize16
111112

112113
# Bug: Some wave operations are not yet implemented.
113114
# XFAIL: Clang

test/Feature/MaximalReconvergence/cts/tests/16/test_2_16_7_13_5.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ DescriptorSets:
105105

106106
...
107107
#--- end
108-
# UNSUPPORTED: Vulkan && ( !VK_KHR_shader_maximal_reconvergence || !SubgroupSize16 )
108+
# UNSUPPORTED: Vulkan && !VK_KHR_shader_maximal_reconvergence
109+
# UNSUPPORTED: !SubgroupSize16
109110

110111
# Bug: Some wave operations are not yet implemented.
111112
# XFAIL: Clang

0 commit comments

Comments
 (0)