Skip to content

Commit

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

Fixes #1297
  • Loading branch information
zoddicus authored Mar 21, 2024
1 parent 783153c commit f44b0fa
Show file tree
Hide file tree
Showing 7 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": "120b0299",
"webgpu/shader/execution/binary/af_addition.bin": "daeacb87",
"webgpu/shader/execution/binary/af_logical.bin": "a96d0397",
"webgpu/shader/execution/binary/af_division.bin": "ac59aa23",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "9804c75c",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "7761d693",
"webgpu/shader/execution/binary/af_multiplication.bin": "b89bfd3f",
"webgpu/shader/execution/binary/af_remainder.bin": "85aeeae",
"webgpu/shader/execution/binary/af_subtraction.bin": "5c5210a6",
"webgpu/shader/execution/binary/f16_addition.bin": "fe267615",
"webgpu/shader/execution/binary/af_division.bin": "238c0f93",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "243104d8",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "126f5c0b",
"webgpu/shader/execution/binary/af_multiplication.bin": "460193c7",
"webgpu/shader/execution/binary/af_remainder.bin": "10affd06",
"webgpu/shader/execution/binary/af_subtraction.bin": "ff0fd262",
"webgpu/shader/execution/binary/f16_addition.bin": "98ac9cd5",
"webgpu/shader/execution/binary/f16_logical.bin": "d1f632dd",
"webgpu/shader/execution/binary/f16_division.bin": "df668b0a",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "ccc54edf",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "f2f641b1",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "b92bbc1e",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "3cdc6048",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "eb5774bf",
"webgpu/shader/execution/binary/f16_multiplication.bin": "4dd28c86",
"webgpu/shader/execution/binary/f16_remainder.bin": "6b85ab32",
"webgpu/shader/execution/binary/f16_subtraction.bin": "db794da4",
"webgpu/shader/execution/binary/f32_addition.bin": "616611b9",
"webgpu/shader/execution/binary/f16_division.bin": "b6fe4240",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "96a439ed",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "84d851b0",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "18d2ebef",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "205b161e",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "f07ccb3c",
"webgpu/shader/execution/binary/f16_multiplication.bin": "fba0e596",
"webgpu/shader/execution/binary/f16_remainder.bin": "b59c02b8",
"webgpu/shader/execution/binary/f16_subtraction.bin": "475434aa",
"webgpu/shader/execution/binary/f32_addition.bin": "7d0ca4e0",
"webgpu/shader/execution/binary/f32_logical.bin": "8759f532",
"webgpu/shader/execution/binary/f32_division.bin": "c8d5eaea",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "c20b3029",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "58051f59",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "9af1c79e",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "7509079d",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "a2a9df30",
"webgpu/shader/execution/binary/f32_multiplication.bin": "e730f6ce",
"webgpu/shader/execution/binary/f32_remainder.bin": "bf328256",
"webgpu/shader/execution/binary/f32_subtraction.bin": "ad95d2f8",
"webgpu/shader/execution/binary/f32_division.bin": "1da8db77",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "276112ee",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "e55798dd",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "de6976c3",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "9c66f881",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "fe8545f3",
"webgpu/shader/execution/binary/f32_multiplication.bin": "ea58c251",
"webgpu/shader/execution/binary/f32_remainder.bin": "c8851fdd",
"webgpu/shader/execution/binary/f32_subtraction.bin": "7436431a",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "119fe0bd",
"webgpu/shader/execution/binary/i32_comparison.bin": "9749440b",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "902e89b8",
"webgpu/shader/execution/binary/u32_comparison.bin": "a5f8da57",
"webgpu/shader/execution/abs.bin": "99ce1599",
"webgpu/shader/execution/acos.bin": "306e8319",
"webgpu/shader/execution/acosh.bin": "36660581",
"webgpu/shader/execution/asin.bin": "2c7e6a39",
"webgpu/shader/execution/asinh.bin": "1a876442",
"webgpu/shader/execution/atan.bin": "658d73cf",
"webgpu/shader/execution/atan2.bin": "3682bf6f",
"webgpu/shader/execution/atanh.bin": "8cefd75d",
"webgpu/shader/execution/bitcast.bin": "8aac75fe",
"webgpu/shader/execution/ceil.bin": "9aed57a4",
"webgpu/shader/execution/clamp.bin": "b21a1f68",
"webgpu/shader/execution/cos.bin": "e0124922",
"webgpu/shader/execution/cosh.bin": "38a0e519",
"webgpu/shader/execution/cross.bin": "2519efdd",
"webgpu/shader/execution/degrees.bin": "b7ecc453",
"webgpu/shader/execution/determinant.bin": "934b3491",
"webgpu/shader/execution/distance.bin": "6cd619f",
"webgpu/shader/execution/dot.bin": "ca1d811f",
"webgpu/shader/execution/exp.bin": "f79f7f73",
"webgpu/shader/execution/exp2.bin": "3612290f",
"webgpu/shader/execution/faceForward.bin": "f1edf98b",
"webgpu/shader/execution/floor.bin": "eee7b3a8",
"webgpu/shader/execution/fma.bin": "2b45444e",
"webgpu/shader/execution/fract.bin": "18ccdfe3",
"webgpu/shader/execution/frexp.bin": "c24193b0",
"webgpu/shader/execution/inverseSqrt.bin": "a9308598",
"webgpu/shader/execution/ldexp.bin": "e8ccd454",
"webgpu/shader/execution/length.bin": "a7831d48",
"webgpu/shader/execution/log.bin": "3a05ac55",
"webgpu/shader/execution/log2.bin": "e9effb5c",
"webgpu/shader/execution/max.bin": "a9683a83",
"webgpu/shader/execution/min.bin": "58c7c058",
"webgpu/shader/execution/mix.bin": "b9562a60",
"webgpu/shader/execution/modf.bin": "5c9be9f2",
"webgpu/shader/execution/normalize.bin": "c8deea41",
"webgpu/shader/execution/abs.bin": "68bf8417",
"webgpu/shader/execution/acos.bin": "33e100d0",
"webgpu/shader/execution/acosh.bin": "b5cc8e42",
"webgpu/shader/execution/asin.bin": "b9f8ea42",
"webgpu/shader/execution/asinh.bin": "d8518a79",
"webgpu/shader/execution/atan.bin": "694017d1",
"webgpu/shader/execution/atan2.bin": "744d31c3",
"webgpu/shader/execution/atanh.bin": "4b7c0be8",
"webgpu/shader/execution/bitcast.bin": "5d613d5a",
"webgpu/shader/execution/ceil.bin": "11f5bcc1",
"webgpu/shader/execution/clamp.bin": "6bb5c187",
"webgpu/shader/execution/cos.bin": "761f4735",
"webgpu/shader/execution/cosh.bin": "e6fe6a",
"webgpu/shader/execution/cross.bin": "88c7223",
"webgpu/shader/execution/degrees.bin": "87a70f5a",
"webgpu/shader/execution/determinant.bin": "559f2b14",
"webgpu/shader/execution/distance.bin": "deb3c29d",
"webgpu/shader/execution/dot.bin": "c2a8848c",
"webgpu/shader/execution/exp.bin": "bc501742",
"webgpu/shader/execution/exp2.bin": "4d7ae2ef",
"webgpu/shader/execution/faceForward.bin": "eec6f376",
"webgpu/shader/execution/floor.bin": "fcf81d69",
"webgpu/shader/execution/fma.bin": "dd18d518",
"webgpu/shader/execution/fract.bin": "c6c3220c",
"webgpu/shader/execution/frexp.bin": "be6fbce3",
"webgpu/shader/execution/inverseSqrt.bin": "e33195d8",
"webgpu/shader/execution/ldexp.bin": "bf6a2c9d",
"webgpu/shader/execution/length.bin": "a4633529",
"webgpu/shader/execution/log.bin": "85d8138",
"webgpu/shader/execution/log2.bin": "8d33e262",
"webgpu/shader/execution/max.bin": "8fc8f9a5",
"webgpu/shader/execution/min.bin": "82e4cad6",
"webgpu/shader/execution/mix.bin": "9be4cc8a",
"webgpu/shader/execution/modf.bin": "6cdf3af3",
"webgpu/shader/execution/normalize.bin": "2a2c2e2a",
"webgpu/shader/execution/pack2x16float.bin": "83b4b256",
"webgpu/shader/execution/pow.bin": "ac862364",
"webgpu/shader/execution/quantizeToF16.bin": "2d2282b2",
"webgpu/shader/execution/radians.bin": "22d792c3",
"webgpu/shader/execution/reflect.bin": "fe9d7b45",
"webgpu/shader/execution/refract.bin": "eaee4a84",
"webgpu/shader/execution/round.bin": "779ee489",
"webgpu/shader/execution/saturate.bin": "c98ab10b",
"webgpu/shader/execution/sign.bin": "c2469a86",
"webgpu/shader/execution/sin.bin": "f06016d9",
"webgpu/shader/execution/sinh.bin": "eb4314b0",
"webgpu/shader/execution/smoothstep.bin": "c91ccf23",
"webgpu/shader/execution/sqrt.bin": "17899c50",
"webgpu/shader/execution/step.bin": "565d461b",
"webgpu/shader/execution/tan.bin": "1a4ae6d",
"webgpu/shader/execution/tanh.bin": "ff124cd3",
"webgpu/shader/execution/transpose.bin": "fafbc42",
"webgpu/shader/execution/trunc.bin": "be374270",
"webgpu/shader/execution/unpack2x16float.bin": "6032e028",
"webgpu/shader/execution/unpack2x16snorm.bin": "d2e11b25",
"webgpu/shader/execution/unpack2x16unorm.bin": "84156a6a",
"webgpu/shader/execution/unpack4x8snorm.bin": "887311df",
"webgpu/shader/execution/unpack4x8unorm.bin": "b2442020",
"webgpu/shader/execution/unary/af_arithmetic.bin": "19d001ef",
"webgpu/shader/execution/unary/af_assignment.bin": "565e26d1",
"webgpu/shader/execution/pow.bin": "88383a6e",
"webgpu/shader/execution/quantizeToF16.bin": "4f8b81a1",
"webgpu/shader/execution/radians.bin": "d3e9ec30",
"webgpu/shader/execution/reflect.bin": "b4c99ffa",
"webgpu/shader/execution/refract.bin": "3a26114c",
"webgpu/shader/execution/round.bin": "dbc8f3a8",
"webgpu/shader/execution/saturate.bin": "fceefa52",
"webgpu/shader/execution/sign.bin": "389b918e",
"webgpu/shader/execution/sin.bin": "e791a46f",
"webgpu/shader/execution/sinh.bin": "63b75022",
"webgpu/shader/execution/smoothstep.bin": "42718e5e",
"webgpu/shader/execution/sqrt.bin": "4172a17b",
"webgpu/shader/execution/step.bin": "c6dccf99",
"webgpu/shader/execution/tan.bin": "319b2f97",
"webgpu/shader/execution/tanh.bin": "4c679103",
"webgpu/shader/execution/transpose.bin": "6ecdc77f",
"webgpu/shader/execution/trunc.bin": "d1a54190",
"webgpu/shader/execution/unpack2x16float.bin": "7aa7561",
"webgpu/shader/execution/unpack2x16snorm.bin": "eeb40da9",
"webgpu/shader/execution/unpack2x16unorm.bin": "c17788f8",
"webgpu/shader/execution/unpack4x8snorm.bin": "8cb0dde5",
"webgpu/shader/execution/unpack4x8unorm.bin": "39bfc945",
"webgpu/shader/execution/unary/af_arithmetic.bin": "4390e337",
"webgpu/shader/execution/unary/af_assignment.bin": "8e4f16be",
"webgpu/shader/execution/unary/bool_conversion.bin": "247f2b83",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "3d9f043e",
"webgpu/shader/execution/unary/f16_conversion.bin": "b2ceb97a",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "d4b0b87b",
"webgpu/shader/execution/unary/f32_conversion.bin": "9ac02a7d",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "ea851ac",
"webgpu/shader/execution/unary/f16_conversion.bin": "5aa744e9",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "15db1efa",
"webgpu/shader/execution/unary/f32_conversion.bin": "147318a8",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "d51bbffb",
"webgpu/shader/execution/unary/i32_conversion.bin": "76c9d481",
"webgpu/shader/execution/unary/u32_conversion.bin": "f6b0e41",
"webgpu/shader/execution/unary/ai_assignment.bin": "79ae98e8",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "c59804c3",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "9e23d866",
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "ab9d1adc",
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "85218049",
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "3d30361b"
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "b683ca3",
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "d952c9f1",
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "76743c4a"
}
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 @@ -5148,7 +5148,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 f44b0fa

Please sign in to comment.