Skip to content

Commit

Permalink
wgsl: Implement AbstractFloat fract execution tests
Browse files Browse the repository at this point in the history
Implementing recommendation from gpuweb/gpuweb#4523

Fixes #1297
  • Loading branch information
zoddicus committed Mar 19, 2024
1 parent 68753bb commit ae123cd
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 103 deletions.
186 changes: 93 additions & 93 deletions src/resources/cache/hashes.json
Original file line number Diff line number Diff line change
@@ -1,110 +1,110 @@
{
"webgpu/shader/execution/binary/af_addition.bin": "7ce358c0",
"webgpu/shader/execution/binary/af_addition.bin": "661a0b8d",
"webgpu/shader/execution/binary/af_logical.bin": "4f841d5b",
"webgpu/shader/execution/binary/af_division.bin": "4d9441a",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "cfabb7cf",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "4073ab7",
"webgpu/shader/execution/binary/af_multiplication.bin": "314f459d",
"webgpu/shader/execution/binary/af_remainder.bin": "7957e61a",
"webgpu/shader/execution/binary/af_subtraction.bin": "4e079c33",
"webgpu/shader/execution/binary/f16_addition.bin": "fb951e0b",
"webgpu/shader/execution/binary/af_division.bin": "fb19de38",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "330cd28",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "bb90f550",
"webgpu/shader/execution/binary/af_multiplication.bin": "9f7be179",
"webgpu/shader/execution/binary/af_remainder.bin": "35c839e0",
"webgpu/shader/execution/binary/af_subtraction.bin": "7db57e0b",
"webgpu/shader/execution/binary/f16_addition.bin": "f669aa38",
"webgpu/shader/execution/binary/f16_logical.bin": "9b8d9213",
"webgpu/shader/execution/binary/f16_division.bin": "50e59ff7",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "fea79c44",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "2537923d",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "d2d11f12",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "15f22b30",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "e78c619d",
"webgpu/shader/execution/binary/f16_multiplication.bin": "d4f268f2",
"webgpu/shader/execution/binary/f16_remainder.bin": "229402ce",
"webgpu/shader/execution/binary/f16_subtraction.bin": "fb1f92c5",
"webgpu/shader/execution/binary/f32_addition.bin": "50ce83bd",
"webgpu/shader/execution/binary/f16_division.bin": "cd596c14",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "394fc30a",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "1a6ddee1",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "2a7e5a76",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "65362330",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "41352fe9",
"webgpu/shader/execution/binary/f16_multiplication.bin": "71c8148d",
"webgpu/shader/execution/binary/f16_remainder.bin": "15f2a48",
"webgpu/shader/execution/binary/f16_subtraction.bin": "4cf33123",
"webgpu/shader/execution/binary/f32_addition.bin": "c331bac1",
"webgpu/shader/execution/binary/f32_logical.bin": "5c6b5f70",
"webgpu/shader/execution/binary/f32_division.bin": "e9ee3d15",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "5268ff93",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "b544a90d",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "1a8369f5",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "f8205c67",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "1d645d7d",
"webgpu/shader/execution/binary/f32_multiplication.bin": "d7c76e9",
"webgpu/shader/execution/binary/f32_remainder.bin": "a4c5ac72",
"webgpu/shader/execution/binary/f32_subtraction.bin": "e122631c",
"webgpu/shader/execution/binary/f32_division.bin": "e1c04c21",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "e87939c2",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "9bc7a5c6",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "30ad7d66",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "4c42270c",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "c4450bad",
"webgpu/shader/execution/binary/f32_multiplication.bin": "7f2bba03",
"webgpu/shader/execution/binary/f32_remainder.bin": "8936bac1",
"webgpu/shader/execution/binary/f32_subtraction.bin": "79caa6b1",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "4de0a760",
"webgpu/shader/execution/binary/i32_comparison.bin": "43fa569a",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "27268577",
"webgpu/shader/execution/binary/u32_comparison.bin": "daa10109",
"webgpu/shader/execution/abs.bin": "eb80796a",
"webgpu/shader/execution/acos.bin": "fba0df22",
"webgpu/shader/execution/acosh.bin": "c9c6163f",
"webgpu/shader/execution/asin.bin": "cafcc06e",
"webgpu/shader/execution/asinh.bin": "66c9ef9a",
"webgpu/shader/execution/atan.bin": "c3081ff0",
"webgpu/shader/execution/atan2.bin": "5e756536",
"webgpu/shader/execution/atanh.bin": "61eed097",
"webgpu/shader/execution/bitcast.bin": "8ded343e",
"webgpu/shader/execution/ceil.bin": "ff34d08b",
"webgpu/shader/execution/clamp.bin": "4a47c2ba",
"webgpu/shader/execution/cos.bin": "b181f8f6",
"webgpu/shader/execution/cosh.bin": "5f0dacaa",
"webgpu/shader/execution/cross.bin": "40853d3b",
"webgpu/shader/execution/degrees.bin": "b0fe04da",
"webgpu/shader/execution/determinant.bin": "9f1e22bc",
"webgpu/shader/execution/distance.bin": "6e061016",
"webgpu/shader/execution/dot.bin": "c2006ea5",
"webgpu/shader/execution/exp.bin": "9c4f523c",
"webgpu/shader/execution/exp2.bin": "2c32c324",
"webgpu/shader/execution/faceForward.bin": "af680aaa",
"webgpu/shader/execution/floor.bin": "73da0f53",
"webgpu/shader/execution/fma.bin": "50302348",
"webgpu/shader/execution/fract.bin": "ff39c6ad",
"webgpu/shader/execution/frexp.bin": "24c9f488",
"webgpu/shader/execution/inverseSqrt.bin": "1b804c0c",
"webgpu/shader/execution/ldexp.bin": "31252855",
"webgpu/shader/execution/length.bin": "4a59b13",
"webgpu/shader/execution/log.bin": "e5257ca7",
"webgpu/shader/execution/log2.bin": "98c9d48b",
"webgpu/shader/execution/max.bin": "b51cbdc3",
"webgpu/shader/execution/min.bin": "b7a1bb54",
"webgpu/shader/execution/mix.bin": "45015b11",
"webgpu/shader/execution/modf.bin": "29b98e66",
"webgpu/shader/execution/normalize.bin": "5c00f125",
"webgpu/shader/execution/abs.bin": "8909678b",
"webgpu/shader/execution/acos.bin": "ee20f6",
"webgpu/shader/execution/acosh.bin": "7cf7eeed",
"webgpu/shader/execution/asin.bin": "3d39f46f",
"webgpu/shader/execution/asinh.bin": "873a5106",
"webgpu/shader/execution/atan.bin": "d2fa60ca",
"webgpu/shader/execution/atan2.bin": "6a671c9a",
"webgpu/shader/execution/atanh.bin": "9607a111",
"webgpu/shader/execution/bitcast.bin": "4fbb0691",
"webgpu/shader/execution/ceil.bin": "a68239f",
"webgpu/shader/execution/clamp.bin": "1992c151",
"webgpu/shader/execution/cos.bin": "1b8f0624",
"webgpu/shader/execution/cosh.bin": "86569af2",
"webgpu/shader/execution/cross.bin": "b2d1ada",
"webgpu/shader/execution/degrees.bin": "7d966331",
"webgpu/shader/execution/determinant.bin": "7e3c8b44",
"webgpu/shader/execution/distance.bin": "84d969cb",
"webgpu/shader/execution/dot.bin": "4b6d52d7",
"webgpu/shader/execution/exp.bin": "adb1c8e6",
"webgpu/shader/execution/exp2.bin": "bf6c3677",
"webgpu/shader/execution/faceForward.bin": "143d98d6",
"webgpu/shader/execution/floor.bin": "b658dd93",
"webgpu/shader/execution/fma.bin": "2511ccc6",
"webgpu/shader/execution/fract.bin": "eccf8ce2",
"webgpu/shader/execution/frexp.bin": "16270efe",
"webgpu/shader/execution/inverseSqrt.bin": "d887127",
"webgpu/shader/execution/ldexp.bin": "2f49a5c",
"webgpu/shader/execution/length.bin": "919b9af3",
"webgpu/shader/execution/log.bin": "4ee5b910",
"webgpu/shader/execution/log2.bin": "db3e1352",
"webgpu/shader/execution/max.bin": "ca583da0",
"webgpu/shader/execution/min.bin": "4bcb4a88",
"webgpu/shader/execution/mix.bin": "a8e11c44",
"webgpu/shader/execution/modf.bin": "62a4dfb9",
"webgpu/shader/execution/normalize.bin": "3d11639e",
"webgpu/shader/execution/pack2x16float.bin": "2e344361",
"webgpu/shader/execution/pow.bin": "3e883036",
"webgpu/shader/execution/quantizeToF16.bin": "29f8ad28",
"webgpu/shader/execution/radians.bin": "98840ac9",
"webgpu/shader/execution/reflect.bin": "d86261b0",
"webgpu/shader/execution/refract.bin": "d16ee553",
"webgpu/shader/execution/round.bin": "331b3f29",
"webgpu/shader/execution/saturate.bin": "732d92e",
"webgpu/shader/execution/sign.bin": "6e23ffff",
"webgpu/shader/execution/sin.bin": "65959031",
"webgpu/shader/execution/sinh.bin": "bf50e06",
"webgpu/shader/execution/smoothstep.bin": "9f1c6459",
"webgpu/shader/execution/sqrt.bin": "1685fb38",
"webgpu/shader/execution/step.bin": "f54a01f6",
"webgpu/shader/execution/tan.bin": "ecbcdf75",
"webgpu/shader/execution/tanh.bin": "cc8d0a39",
"webgpu/shader/execution/transpose.bin": "1d29e3f1",
"webgpu/shader/execution/trunc.bin": "b0aa10fc",
"webgpu/shader/execution/unpack2x16float.bin": "d18f1932",
"webgpu/shader/execution/unpack2x16snorm.bin": "6efd551",
"webgpu/shader/execution/unpack2x16unorm.bin": "32b063e8",
"webgpu/shader/execution/unpack4x8snorm.bin": "bbdb7af7",
"webgpu/shader/execution/unpack4x8unorm.bin": "79773cdc",
"webgpu/shader/execution/unary/af_arithmetic.bin": "ea8cdb53",
"webgpu/shader/execution/unary/af_assignment.bin": "d0209f98",
"webgpu/shader/execution/pow.bin": "62f9d1c8",
"webgpu/shader/execution/quantizeToF16.bin": "a1262d8c",
"webgpu/shader/execution/radians.bin": "893d5f86",
"webgpu/shader/execution/reflect.bin": "a3d0b6e5",
"webgpu/shader/execution/refract.bin": "d0e4eda8",
"webgpu/shader/execution/round.bin": "aa895f72",
"webgpu/shader/execution/saturate.bin": "a9a967b7",
"webgpu/shader/execution/sign.bin": "e19ec28e",
"webgpu/shader/execution/sin.bin": "5cb3209f",
"webgpu/shader/execution/sinh.bin": "1018501d",
"webgpu/shader/execution/smoothstep.bin": "41e82d38",
"webgpu/shader/execution/sqrt.bin": "49b9ee6e",
"webgpu/shader/execution/step.bin": "d82b554",
"webgpu/shader/execution/tan.bin": "ea8ac676",
"webgpu/shader/execution/tanh.bin": "5915c828",
"webgpu/shader/execution/transpose.bin": "ae084eb",
"webgpu/shader/execution/trunc.bin": "723cfe9",
"webgpu/shader/execution/unpack2x16float.bin": "2f3c163",
"webgpu/shader/execution/unpack2x16snorm.bin": "776b0cc1",
"webgpu/shader/execution/unpack2x16unorm.bin": "5e4f1c12",
"webgpu/shader/execution/unpack4x8snorm.bin": "66de52b3",
"webgpu/shader/execution/unpack4x8unorm.bin": "12358e9e",
"webgpu/shader/execution/unary/af_arithmetic.bin": "8b65d31e",
"webgpu/shader/execution/unary/af_assignment.bin": "af9b9264",
"webgpu/shader/execution/unary/bool_conversion.bin": "eb77c972",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "6936be94",
"webgpu/shader/execution/unary/f16_conversion.bin": "eeabc58f",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "e1a45f70",
"webgpu/shader/execution/unary/f32_conversion.bin": "3afd9d69",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "1ee336fa",
"webgpu/shader/execution/unary/f16_conversion.bin": "5ab04da",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "aac81d07",
"webgpu/shader/execution/unary/f32_conversion.bin": "5bac8213",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "44fc246d",
"webgpu/shader/execution/unary/i32_conversion.bin": "ae197d05",
"webgpu/shader/execution/unary/u32_conversion.bin": "ebb53722",
"webgpu/shader/execution/unary/ai_assignment.bin": "b8f56b9",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "81216e44",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "ca04838a",
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "e53fc5b2",
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "59dcdf08",
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "c253fad1"
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "130af687",
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "53aee88c",
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "5966f593"
}
Binary file modified src/resources/cache/webgpu/shader/execution/bitcast.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/fract.bin
Binary file not shown.
14 changes: 13 additions & 1 deletion src/unittests/floating_point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3093,12 +3093,24 @@ const kFractIntervalCases = {
{ input: -1.1, expected: [reinterpretU16AsF16(0x3b32), reinterpretU16AsF16(0x3b34)] }, // ~0.9
{ input: 658.5, expected: 0.5 },
] as ScalarToIntervalCase[],
abstract: [
{ input: 0.1, expected: reinterpretU64AsF64(0x3fb999999999999an) },
{ input: 0.9, expected: reinterpretU64AsF64(0x3feccccccccccccdn) },
{ input: 1.1, expected: reinterpretU64AsF64(0x3fb99999999999a0n) },
{ input: -0.1, expected: reinterpretU64AsF64(0x3feccccccccccccdn) },
{ input: -0.9, expected: reinterpretU64AsF64(0x3fb9999999999998n) },
{ input: -1.1, expected: reinterpretU64AsF64(0x3fecccccccccccccn) },

// https://github.com/gpuweb/cts/issues/2766
{ input: 0x80000000, expected: 0 },
] as ScalarToIntervalCase[],

} as const;

g.test('fractInterval')
.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 @@ -1321,7 +1321,7 @@
"webgpu:shader,execution,expression,call,builtin,fma:abstract_float:*": { "subcaseMS": 148432.980 },
"webgpu:shader,execution,expression,call,builtin,fma:f16:*": { "subcaseMS": 485.857 },
"webgpu:shader,execution,expression,call,builtin,fma:f32:*": { "subcaseMS": 80.388 },
"webgpu:shader,execution,expression,call,builtin,fract:abstract_float:*": { "subcaseMS": 113.157 },
"webgpu:shader,execution,expression,call,builtin,fract:abstract_float:*": { "subcaseMS": 8575.078 },
"webgpu:shader,execution,expression,call,builtin,fract:f16:*": { "subcaseMS": 46.500 },
"webgpu:shader,execution,expression,call,builtin,fract:f32:*": { "subcaseMS": 12.269 },
"webgpu:shader,execution,expression,call,builtin,frexp:f16_exp:*": { "subcaseMS": 8.503 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,20 @@ const kTraitSpecificValues = {
658.5, // 658.5 -> 0.5
0x8000, // https://github.com/gpuweb/cts/issues/2766
],
abstract: [
10.0001, // ~10.0001 -> ~0.0001
-10.0001, // -10.0001 -> ~0.9999
0x8000_0000, // https://github.com/gpuweb/cts/issues/2766
],
};

// Cases: [f32|f16]
const cases = (['f32', 'f16'] as const)
// Cases: [f32|f16|abstract]
const cases = (['f32', 'f16', 'abstract'] as const)
.map(trait => ({
[`${trait}`]: () => {
return FP[trait].generateScalarToIntervalCases(
[...kCommonValues, ...kTraitSpecificValues[trait], ...FP[trait].scalarRange()],
'unfiltered',
trait === 'abstract' ? 'finite' : 'unfiltered',
FP[trait].fractInterval
);
},
Expand Down
20 changes: 16 additions & 4 deletions src/webgpu/shader/execution/expression/call/builtin/fract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Component-wise when T is a vector.
import { makeTestGroup } from '../../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../../gpu_test.js';
import { Type } from '../../../../../util/conversion.js';
import { allInputSources, run } from '../../expression.js';
import { allInputSources, onlyConstInputSource, run } from '../../expression.js';

import { builtin } from './builtin.js';
import { abstractFloatBuiltin, builtin } from './builtin.js';
import { d } from './fract.cache.js';

export const g = makeTestGroup(GPUTest);
Expand All @@ -22,9 +22,21 @@ g.test('abstract_float')
.specURL('https://www.w3.org/TR/WGSL/#float-builtin-functions')
.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');
await run(
t,
abstractFloatBuiltin('fract'),
[Type.abstractFloat],
Type.abstractFloat,
t.params,
cases
);
});

g.test('f32')
.specURL('https://www.w3.org/TR/WGSL/#float-builtin-functions')
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 @@ -5147,7 +5147,7 @@ class FPAbstractTraits extends FPTraits {
public readonly faceForwardIntervals = this.unimplementedFaceForward.bind(this);
public readonly floorInterval = this.floorIntervalImpl.bind(this);
public readonly fmaInterval = this.unimplementedScalarTripleToInterval.bind(this, 'fmaInterval');
public readonly fractInterval = this.unimplementedScalarToInterval.bind(this, 'fractInterval');
public readonly fractInterval = this.fractIntervalImpl.bind(this);
public readonly inverseSqrtInterval = this.unimplementedScalarToInterval.bind(
this,
'inverseSqrtInterval'
Expand Down

0 comments on commit ae123cd

Please sign in to comment.