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

wgsl: Add AbstractFloat sign execution tests #3081

Merged
merged 1 commit into from
Oct 23, 2023
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
2 changes: 1 addition & 1 deletion src/unittests/floating_point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3647,7 +3647,7 @@ g.test('saturateInterval')
g.test('signInterval')
.params(u =>
u
.combine('trait', ['f32', 'f16'] as const)
.combine('trait', ['f32', 'f16', 'abstract'] as const)
.beginSubcases()
.expandWithParams<ScalarToIntervalCase>(p => {
const constants = FP[p.trait].constants();
Expand Down
2 changes: 1 addition & 1 deletion src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@
"webgpu:shader,execution,expression,call,builtin,saturate:f32:*": { "subcaseMS": 116.275 },
"webgpu:shader,execution,expression,call,builtin,select:scalar:*": { "subcaseMS": 6.882 },
"webgpu:shader,execution,expression,call,builtin,select:vector:*": { "subcaseMS": 7.096 },
"webgpu:shader,execution,expression,call,builtin,sign:abstract_float:*": { "subcaseMS": 31.708 },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Does this actually need to be added? When I read the docs a couple of weeks ago I thought the actual numbers were updated by some other process at some time.

Copy link
Contributor Author

@zoddicus zoddicus Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not aware of a process that updates them.
Are you thinking of the steps in adding_timing_metadata.md that describe using the tooling to update things instead of manually editing the file? (That is what I did)

I have updated these tests, since they are going from being a no-op .unimplemented() to actually running code, so the runtime will likely be significantly longer now.

When just fixing a bug in a test, I generally don't update the values, unless I have reason to think the estimate will change significant.

"webgpu:shader,execution,expression,call,builtin,sign:abstract_float:*": { "subcaseMS": 412.925 },
"webgpu:shader,execution,expression,call,builtin,sign:abstract_int:*": { "subcaseMS": 25.806 },
"webgpu:shader,execution,expression,call,builtin,sign:f16:*": { "subcaseMS": 25.103 },
"webgpu:shader,execution,expression,call,builtin,sign:f32:*": { "subcaseMS": 8.188 },
Expand Down
37 changes: 30 additions & 7 deletions src/webgpu/shader/execution/expression/call/builtin/sign.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,24 @@ Returns the sign of e. Component-wise when T is a vector.

import { makeTestGroup } from '../../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../../gpu_test.js';
import { i32, TypeF32, TypeF16, TypeI32 } from '../../../../../util/conversion.js';
import {
i32,
TypeF32,
TypeF16,
TypeI32,
TypeAbstractFloat,
} from '../../../../../util/conversion.js';
import { FP } from '../../../../../util/floating_point.js';
import { fullF32Range, fullF16Range, fullI32Range } from '../../../../../util/math.js';
import {
fullF32Range,
fullF16Range,
fullI32Range,
fullF64Range,
} from '../../../../../util/math.js';
import { makeCaseCache } from '../../case_cache.js';
import { allInputSources, run } from '../../expression.js';
import { allInputSources, onlyConstInputSource, run } from '../../expression.js';

import { builtin } from './builtin.js';
import { abstractBuiltin, builtin } from './builtin.js';

export const g = makeTestGroup(GPUTest);

Expand All @@ -26,6 +37,13 @@ export const d = makeCaseCache('sign', {
f16: () => {
return FP.f16.generateScalarToIntervalCases(fullF16Range(), 'unfiltered', FP.f16.signInterval);
},
abstract_float: () => {
return FP.abstract.generateScalarToIntervalCases(
fullF64Range(),
'unfiltered',
FP.abstract.signInterval
);
},
i32: () =>
fullI32Range().map(i => {
const signFunc = (i: number): number => (i < 0 ? -1 : i > 0 ? 1 : 0);
Expand All @@ -37,13 +55,18 @@ g.test('abstract_float')
.specURL('https://www.w3.org/TR/WGSL/#sign-builtin')
.desc(`abstract float tests`)
.params(u =>
u.combine('inputSource', allInputSources).combine('vectorize', [undefined, 2, 3, 4] as const)
u
.combine('inputSource', onlyConstInputSource)
.combine('vectorize', [undefined, 2, 3, 4] as const)
)
.unimplemented();
.fn(async t => {
const cases = await d.get('abstract_float');
await run(t, abstractBuiltin('sign'), [TypeAbstractFloat], TypeAbstractFloat, t.params, cases);
});

g.test('abstract_int')
.specURL('https://www.w3.org/TR/WGSL/#sign-builtin')
.desc(`abstract float tests`)
.desc(`abstract int tests`)
.params(u =>
u.combine('inputSource', allInputSources).combine('vectorize', [undefined, 2, 3, 4] as const)
)
Expand Down
2 changes: 1 addition & 1 deletion src/webgpu/util/floating_point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5070,7 +5070,7 @@ class FPAbstractTraits extends FPTraits {
};
public readonly roundInterval = this.unimplementedScalarToInterval.bind(this, 'roundInterval');
public readonly saturateInterval = this.saturateIntervalImpl.bind(this);
public readonly signInterval = this.unimplementedScalarToInterval.bind(this, 'signInterval');
public readonly signInterval = this.signIntervalImpl.bind(this);
public readonly sinInterval = this.unimplementedScalarToInterval.bind(this, 'sinInterval');
public readonly sinhInterval = this.unimplementedScalarToInterval.bind(this, 'sinhInterval');
public readonly smoothStepInterval = this.unimplementedScalarTripleToInterval.bind(
Expand Down
Loading