Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use minSubgroupSize, maxSubgroupSize from GPUAdapterInfo #4058

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,12 @@ g.test('fragment,all_active')
.fn(async t => {
const numInputs = t.params.size[0] * t.params.size[1];

interface SubgroupLimits extends GPUSupportedLimits {
minSubgroupSize: number;
interface SubgroupProperties extends GPUAdapterInfo {
subgroupMinSize: number;
}
const { minSubgroupSize } = t.device.limits as SubgroupLimits;
const { subgroupMinSize } = t.device.adapterInfo as SubgroupProperties;
const innerTexels = (t.params.size[0] - 1) * (t.params.size[1] - 1);
t.skipIf(innerTexels < minSubgroupSize, 'Too few texels to be reliable');
t.skipIf(innerTexels < subgroupMinSize, 'Too few texels to be reliable');

const inputData = generateInputData(t.params.case, numInputs, identity(t.params.op));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,12 @@ g.test('compute,split')
const testcase = kPredicateCases[t.params.predicate];
const wgThreads = t.params.wgSize[0] * t.params.wgSize[1] * t.params.wgSize[2];

interface SubgroupLimits extends GPUSupportedLimits {
minSubgroupSize: number;
maxSubgroupSize: number;
interface SubgroupProperties extends GPUAdapterInfo {
subgroupMinSize: number;
subgroupMaxSize: number;
}
const { minSubgroupSize, maxSubgroupSize } = t.device.limits as SubgroupLimits;
for (let size = minSubgroupSize; size <= maxSubgroupSize; size *= 2) {
const { subgroupMinSize, subgroupMaxSize } = t.device.adapterInfo as SubgroupProperties;
for (let size = subgroupMinSize; size <= subgroupMaxSize; size *= 2) {
t.skipIf(!testcase.filter(t.params.id, size), 'Skipping potential undefined behavior');
}

Expand Down Expand Up @@ -669,11 +669,11 @@ g.test('fragment')
})
.fn(async t => {
const innerTexels = (t.params.size[0] - 1) * (t.params.size[1] - 1);
interface SubgroupLimits extends GPUSupportedLimits {
maxSubgroupSize: number;
interface SubgroupProperties extends GPUAdapterInfo {
subgroupMaxSize: number;
}
const { maxSubgroupSize } = t.device.limits as SubgroupLimits;
t.skipIf(innerTexels < maxSubgroupSize, 'Too few texels to be reliable');
const { subgroupMaxSize } = t.device.adapterInfo as SubgroupProperties;
t.skipIf(innerTexels < subgroupMaxSize, 'Too few texels to be reliable');

const broadcast =
t.params.id === 0
Expand Down
12 changes: 6 additions & 6 deletions src/webgpu/shader/execution/shader_io/compute_builtins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,11 @@ g.test('subgroup_size')
t.selectDeviceOrSkipTestCase('subgroups' as GPUFeatureName);
})
.fn(async t => {
interface SubgroupLimits extends GPUSupportedLimits {
minSubgroupSize: number;
maxSubgroupSize: number;
interface SubgroupProperties extends GPUAdapterInfo {
subgroupMinSize: number;
subgroupMaxSize: number;
}
const { minSubgroupSize, maxSubgroupSize } = t.device.limits as SubgroupLimits;
const { subgroupMinSize, subgroupMaxSize } = t.device.adapterInfo as SubgroupProperties;

const wgx = t.params.sizes[0];
const wgy = t.params.sizes[1];
Expand Down Expand Up @@ -518,8 +518,8 @@ fn main(@builtin(subgroup_size) size : u32,
checkSubgroupSizeConsistency(
sizesData,
compareData,
minSubgroupSize,
maxSubgroupSize,
subgroupMinSize,
subgroupMaxSize,
wgThreads
)
);
Expand Down
24 changes: 12 additions & 12 deletions src/webgpu/shader/execution/shader_io/fragment_builtins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1655,16 +1655,16 @@ g.test('subgroup_size')
t.selectDeviceOrSkipTestCase('subgroups' as GPUFeatureName);
})
.fn(async t => {
interface SubgroupLimits extends GPUSupportedLimits {
minSubgroupSize: number;
maxSubgroupSize: number;
interface SubgroupProperties extends GPUAdapterInfo {
subgroupMinSize: number;
subgroupMaxSize: number;
}
const { minSubgroupSize, maxSubgroupSize } = t.device.limits as SubgroupLimits;
const { subgroupMinSize, subgroupMaxSize } = t.device.adapterInfo as SubgroupProperties;

const fsShader = `
enable subgroups;

const maxSubgroupSize = ${kMaximiumSubgroupSize}u;
const subgroupMaxSize = ${kMaximiumSubgroupSize}u;
const noError = ${kSubgroupShaderNoError}u;

const width = ${t.params.size[0]};
Expand All @@ -1686,7 +1686,7 @@ fn fsMain(

var subgroupSizeBallotedInvocations: u32 = 0u;
var ballotedSubgroupSize: u32 = 0u;
for (var i: u32 = 0; i <= maxSubgroupSize; i++) {
for (var i: u32 = 0; i <= subgroupMaxSize; i++) {
let ballotSubgroupSizeEqualI = countOneBits(subgroupBallot(sg_size == i));
let countSubgroupSizeEqualI = ballotSubgroupSizeEqualI.x + ballotSubgroupSizeEqualI.y + ballotSubgroupSizeEqualI.z + ballotSubgroupSizeEqualI.w;
subgroupSizeBallotedInvocations += countSubgroupSizeEqualI;
Expand Down Expand Up @@ -1716,8 +1716,8 @@ fn fsMain(
return checkSubgroupSizeConsistency(
data,
t.params.format,
minSubgroupSize,
maxSubgroupSize,
subgroupMinSize,
subgroupMaxSize,
t.params.size[0],
t.params.size[1]
);
Expand Down Expand Up @@ -1816,7 +1816,7 @@ enable subgroups;
const width = ${t.params.size[0]};
const height = ${t.params.size[1]};

const maxSubgroupSize = ${kMaximiumSubgroupSize}u;
const subgroupMaxSize = ${kMaximiumSubgroupSize}u;
// A non-zero magic number indicating no expectation error, in order to prevent the
// false no-error result from zero-initialization.
const noError = ${kSubgroupShaderNoError}u;
Expand All @@ -1830,8 +1830,8 @@ fn fsMain(

var error: u32 = noError;

// Validate that reported subgroup size is no larger than maxSubgroupSize
if (sg_size > maxSubgroupSize) {
// Validate that reported subgroup size is no larger than subgroupMaxSize
if (sg_size > subgroupMaxSize) {
error++;
}

Expand All @@ -1843,7 +1843,7 @@ fn fsMain(
// Validate that each subgroup id is assigned to at most one active invocation
// in the subgroup
var countAssignedId: u32 = 0u;
for (var i: u32 = 0; i < maxSubgroupSize; i++) {
for (var i: u32 = 0; i < subgroupMaxSize; i++) {
let ballotIdEqualsI = countOneBits(subgroupBallot(id == i));
let countInvocationIdEqualsI = ballotIdEqualsI.x + ballotIdEqualsI.y + ballotIdEqualsI.z + ballotIdEqualsI.w;
// Validate an id assigned at most once
Expand Down
Loading