Skip to content

Commit

Permalink
wgsl: Implement AbstractFloat ceil execution tests (#3449)
Browse files Browse the repository at this point in the history
Issue #1297
  • Loading branch information
zoddicus authored Mar 11, 2024
1 parent d5ce940 commit e91b44a
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 101 deletions.
186 changes: 93 additions & 93 deletions src/resources/cache/hashes.json
Original file line number Diff line number Diff line change
@@ -1,109 +1,109 @@
{
"webgpu/shader/execution/binary/af_addition.bin": "590ce5d0",
"webgpu/shader/execution/binary/af_addition.bin": "cc90f705",
"webgpu/shader/execution/binary/af_logical.bin": "4269127d",
"webgpu/shader/execution/binary/af_division.bin": "d4ff5475",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "298ef48e",
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "7fed8020",
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "48e954b2",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "6d4ead98",
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "209e2c19",
"webgpu/shader/execution/binary/af_multiplication.bin": "5eafc30c",
"webgpu/shader/execution/binary/af_remainder.bin": "75cfdd3",
"webgpu/shader/execution/binary/af_subtraction.bin": "5acd5252",
"webgpu/shader/execution/binary/af_division.bin": "303c23c9",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "bf3f432a",
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "f262ebd9",
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "ac0e04e3",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "ac5cd859",
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "44a39136",
"webgpu/shader/execution/binary/af_multiplication.bin": "4fa27383",
"webgpu/shader/execution/binary/af_remainder.bin": "4fa868c6",
"webgpu/shader/execution/binary/af_subtraction.bin": "8d5c9b21",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "f89aeb4",
"webgpu/shader/execution/binary/f16_addition.bin": "b3b843b9",
"webgpu/shader/execution/binary/f16_addition.bin": "f2313284",
"webgpu/shader/execution/binary/f16_logical.bin": "36a51091",
"webgpu/shader/execution/binary/f16_division.bin": "67fc610",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "d7b16cc0",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "aae9227",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "d148fe2c",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "7fdc67ab",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "6c6f0373",
"webgpu/shader/execution/binary/f16_multiplication.bin": "d4cba123",
"webgpu/shader/execution/binary/f16_remainder.bin": "39b2f3d1",
"webgpu/shader/execution/binary/f16_subtraction.bin": "eca69567",
"webgpu/shader/execution/binary/f32_addition.bin": "bc6520f4",
"webgpu/shader/execution/binary/f16_division.bin": "6d276852",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "7a8dd641",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "352fbb8f",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "7f315242",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "6e623bf7",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "bc0e0051",
"webgpu/shader/execution/binary/f16_multiplication.bin": "5ddc6615",
"webgpu/shader/execution/binary/f16_remainder.bin": "a7d11cc7",
"webgpu/shader/execution/binary/f16_subtraction.bin": "9a16a043",
"webgpu/shader/execution/binary/f32_addition.bin": "c5b2f15e",
"webgpu/shader/execution/binary/f32_logical.bin": "e1d07173",
"webgpu/shader/execution/binary/f32_division.bin": "b9b4bace",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "c1ff4f67",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "12ce1afc",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "728004ae",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "7203414c",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "60bd62d5",
"webgpu/shader/execution/binary/f32_multiplication.bin": "763a40d3",
"webgpu/shader/execution/binary/f32_remainder.bin": "a14fb18d",
"webgpu/shader/execution/binary/f32_subtraction.bin": "8bf897d8",
"webgpu/shader/execution/binary/f32_division.bin": "583afe1",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "d568c885",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "ddcd0f48",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "99892730",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "3ea99dec",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "d5235751",
"webgpu/shader/execution/binary/f32_multiplication.bin": "a465f647",
"webgpu/shader/execution/binary/f32_remainder.bin": "8402dd76",
"webgpu/shader/execution/binary/f32_subtraction.bin": "63832192",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "936d712",
"webgpu/shader/execution/binary/i32_comparison.bin": "5db8f3b0",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "415ac05e",
"webgpu/shader/execution/binary/u32_comparison.bin": "f90d60f3",
"webgpu/shader/execution/abs.bin": "ab026917",
"webgpu/shader/execution/acos.bin": "ebec4fe2",
"webgpu/shader/execution/acosh.bin": "538a0f85",
"webgpu/shader/execution/asin.bin": "8f34001e",
"webgpu/shader/execution/asinh.bin": "f6474f7e",
"webgpu/shader/execution/atan.bin": "9f57357c",
"webgpu/shader/execution/atan2.bin": "c3c9ab97",
"webgpu/shader/execution/atanh.bin": "b8c67df8",
"webgpu/shader/execution/bitcast.bin": "54c7c36a",
"webgpu/shader/execution/ceil.bin": "b60fd415",
"webgpu/shader/execution/clamp.bin": "ae2291cc",
"webgpu/shader/execution/cos.bin": "c1c8d701",
"webgpu/shader/execution/cosh.bin": "cce8eabb",
"webgpu/shader/execution/cross.bin": "385fe441",
"webgpu/shader/execution/degrees.bin": "f0fb9a6d",
"webgpu/shader/execution/determinant.bin": "7a7750f3",
"webgpu/shader/execution/distance.bin": "939b3544",
"webgpu/shader/execution/dot.bin": "f1fc309e",
"webgpu/shader/execution/exp.bin": "d49bb232",
"webgpu/shader/execution/exp2.bin": "88b69575",
"webgpu/shader/execution/faceForward.bin": "f5b0b400",
"webgpu/shader/execution/floor.bin": "41edc029",
"webgpu/shader/execution/fma.bin": "2e5b7503",
"webgpu/shader/execution/fract.bin": "dd5251b2",
"webgpu/shader/execution/frexp.bin": "43ded4af",
"webgpu/shader/execution/inverseSqrt.bin": "f6f44cf2",
"webgpu/shader/execution/ldexp.bin": "3ea94e77",
"webgpu/shader/execution/length.bin": "2296407f",
"webgpu/shader/execution/log.bin": "1d09cc4",
"webgpu/shader/execution/log2.bin": "e000def9",
"webgpu/shader/execution/max.bin": "18ccab7a",
"webgpu/shader/execution/min.bin": "ab321644",
"webgpu/shader/execution/mix.bin": "5563295f",
"webgpu/shader/execution/modf.bin": "774fe500",
"webgpu/shader/execution/normalize.bin": "35783a23",
"webgpu/shader/execution/abs.bin": "5f333",
"webgpu/shader/execution/acos.bin": "2abc764c",
"webgpu/shader/execution/acosh.bin": "accd2622",
"webgpu/shader/execution/asin.bin": "514f90a0",
"webgpu/shader/execution/asinh.bin": "55b36d3a",
"webgpu/shader/execution/atan.bin": "1e5c011e",
"webgpu/shader/execution/atan2.bin": "51bc4048",
"webgpu/shader/execution/atanh.bin": "3c86dc17",
"webgpu/shader/execution/bitcast.bin": "e10e2bf5",
"webgpu/shader/execution/ceil.bin": "9e9f3783",
"webgpu/shader/execution/clamp.bin": "f160e302",
"webgpu/shader/execution/cos.bin": "f0047dd0",
"webgpu/shader/execution/cosh.bin": "58d620e5",
"webgpu/shader/execution/cross.bin": "f5c1fd91",
"webgpu/shader/execution/degrees.bin": "fbbc1fa3",
"webgpu/shader/execution/determinant.bin": "35335634",
"webgpu/shader/execution/distance.bin": "c0783351",
"webgpu/shader/execution/dot.bin": "fe3b0bf4",
"webgpu/shader/execution/exp.bin": "10e9c894",
"webgpu/shader/execution/exp2.bin": "6fef9b0b",
"webgpu/shader/execution/faceForward.bin": "596738cf",
"webgpu/shader/execution/floor.bin": "d2efe779",
"webgpu/shader/execution/fma.bin": "25db025e",
"webgpu/shader/execution/fract.bin": "8d9072e",
"webgpu/shader/execution/frexp.bin": "49afbf7f",
"webgpu/shader/execution/inverseSqrt.bin": "5bffd293",
"webgpu/shader/execution/ldexp.bin": "d0947f57",
"webgpu/shader/execution/length.bin": "3d4adcaa",
"webgpu/shader/execution/log.bin": "703cca75",
"webgpu/shader/execution/log2.bin": "7fa8bb66",
"webgpu/shader/execution/max.bin": "a9f6689f",
"webgpu/shader/execution/min.bin": "51966c50",
"webgpu/shader/execution/mix.bin": "b9f407dc",
"webgpu/shader/execution/modf.bin": "1e9c1919",
"webgpu/shader/execution/normalize.bin": "a3c6ac4",
"webgpu/shader/execution/pack2x16float.bin": "54f11627",
"webgpu/shader/execution/pow.bin": "7421e698",
"webgpu/shader/execution/quantizeToF16.bin": "7f112f83",
"webgpu/shader/execution/radians.bin": "98a95e1b",
"webgpu/shader/execution/reflect.bin": "3f180462",
"webgpu/shader/execution/refract.bin": "b08230a3",
"webgpu/shader/execution/round.bin": "476b7078",
"webgpu/shader/execution/saturate.bin": "d2b2a9bc",
"webgpu/shader/execution/sign.bin": "b70cde44",
"webgpu/shader/execution/sin.bin": "26beb35a",
"webgpu/shader/execution/sinh.bin": "7c561ea2",
"webgpu/shader/execution/smoothstep.bin": "c889c68a",
"webgpu/shader/execution/sqrt.bin": "dbda0613",
"webgpu/shader/execution/step.bin": "7c108793",
"webgpu/shader/execution/tan.bin": "879dd531",
"webgpu/shader/execution/tanh.bin": "7e1d66a6",
"webgpu/shader/execution/transpose.bin": "762ed60",
"webgpu/shader/execution/trunc.bin": "8c46cbe8",
"webgpu/shader/execution/unpack2x16float.bin": "5bd42344",
"webgpu/shader/execution/unpack2x16snorm.bin": "478e7fa5",
"webgpu/shader/execution/unpack2x16unorm.bin": "a2f9b4f5",
"webgpu/shader/execution/unpack4x8snorm.bin": "93d90295",
"webgpu/shader/execution/unpack4x8unorm.bin": "31999cab",
"webgpu/shader/execution/unary/af_arithmetic.bin": "446e85d9",
"webgpu/shader/execution/unary/af_assignment.bin": "9911dc5f",
"webgpu/shader/execution/pow.bin": "87e8391c",
"webgpu/shader/execution/quantizeToF16.bin": "c5be64e5",
"webgpu/shader/execution/radians.bin": "5bd5a987",
"webgpu/shader/execution/reflect.bin": "e6ba9df9",
"webgpu/shader/execution/refract.bin": "7f1a1889",
"webgpu/shader/execution/round.bin": "f3376643",
"webgpu/shader/execution/saturate.bin": "2a8d20df",
"webgpu/shader/execution/sign.bin": "e7232801",
"webgpu/shader/execution/sin.bin": "8acb35",
"webgpu/shader/execution/sinh.bin": "f356d922",
"webgpu/shader/execution/smoothstep.bin": "24299f69",
"webgpu/shader/execution/sqrt.bin": "724c8512",
"webgpu/shader/execution/step.bin": "4fe42940",
"webgpu/shader/execution/tan.bin": "3366acbb",
"webgpu/shader/execution/tanh.bin": "b4f80ddb",
"webgpu/shader/execution/transpose.bin": "9a65abfa",
"webgpu/shader/execution/trunc.bin": "9292ec12",
"webgpu/shader/execution/unpack2x16float.bin": "81649bef",
"webgpu/shader/execution/unpack2x16snorm.bin": "fbbaa36f",
"webgpu/shader/execution/unpack2x16unorm.bin": "37f1917",
"webgpu/shader/execution/unpack4x8snorm.bin": "46b063cd",
"webgpu/shader/execution/unpack4x8unorm.bin": "ffb80fc5",
"webgpu/shader/execution/unary/af_arithmetic.bin": "8f9a3824",
"webgpu/shader/execution/unary/af_assignment.bin": "d8fab2f2",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "497ec1e1",
"webgpu/shader/execution/unary/ai_assignment.bin": "fc978bdd",
"webgpu/shader/execution/unary/bool_conversion.bin": "bcab7d9a",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "b0a84279",
"webgpu/shader/execution/unary/f16_conversion.bin": "4bbd348e",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "a98d962e",
"webgpu/shader/execution/unary/f32_conversion.bin": "9af02ab5",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "13caa810",
"webgpu/shader/execution/unary/f16_conversion.bin": "3699afe4",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "9236999",
"webgpu/shader/execution/unary/f32_conversion.bin": "416b0d0",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "8f3c4616",
"webgpu/shader/execution/unary/i32_conversion.bin": "972063c",
"webgpu/shader/execution/unary/u32_conversion.bin": "168fcf74"
Expand Down
Binary file modified src/resources/cache/webgpu/shader/execution/ceil.bin
Binary file not shown.
9 changes: 7 additions & 2 deletions src/unittests/floating_point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2657,12 +2657,17 @@ const kCeilIntervalCases = {
{ input: -(2 ** 14), expected: -(2 ** 14) },
{ input: 0x8000, expected: 0x8000 }, // https://github.com/gpuweb/cts/issues/2766
],
abstract: [
{ input: 2 ** 52, expected: 2 ** 52 },
{ input: -(2 ** 52), expected: -(2 ** 52) },
{ input: 0x8000000000000000, expected: 0x8000000000000000 }, // https://github.com/gpuweb/cts/issues/2766
],
} as const;

g.test('ceilInterval')
.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 All @@ -2689,7 +2694,7 @@ g.test('ceilInterval')
{ input: constants.negative.max, expected: 0 },
...kCeilIntervalCases[p.trait],

// 32-bit subnormals
// Subnormals
{ input: constants.positive.subnormal.max, expected: [0, 1] },
{ input: constants.positive.subnormal.min, expected: [0, 1] },
{ input: constants.negative.subnormal.min, expected: 0 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ const kSmallMagnitudeTestValues = [0.1, 0.9, 1.0, 1.1, 1.9, -0.1, -0.9, -1.0, -1
const kIssue2766Value = {
f32: 0x8000_0000,
f16: 0x8000,
abstract: 0x8000_0000_0000_0000,
};

// Cases: [f32|f16]
const cases = (['f32', 'f16'] as const)
const cases = (['f32', 'f16', 'abstract'] as const)
.map(trait => ({
[`${trait}`]: () => {
return FP[trait].generateScalarToIntervalCases(
Expand Down
20 changes: 16 additions & 4 deletions src/webgpu/shader/execution/expression/call/builtin/ceil.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Returns the ceiling of e. 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 './ceil.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('ceil'),
[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 @@ -5120,7 +5120,7 @@ class FPAbstractTraits extends FPTraits {
'atan2Interval'
);
public readonly atanhInterval = this.unimplementedScalarToInterval.bind(this, 'atanhInterval');
public readonly ceilInterval = this.unimplementedScalarToInterval.bind(this, 'ceilInterval');
public readonly ceilInterval = this.ceilIntervalImpl.bind(this);
public readonly clampMedianInterval = this.clampMedianIntervalImpl.bind(this);
public readonly clampMinMaxInterval = this.clampMinMaxIntervalImpl.bind(this);
public readonly clampIntervals = [this.clampMedianInterval, this.clampMinMaxInterval];
Expand Down

0 comments on commit e91b44a

Please sign in to comment.