Skip to content

Commit

Permalink
wgsl: Implement AbstractFloat ceil execution tests
Browse files Browse the repository at this point in the history
Issue #1297
  • Loading branch information
zoddicus committed Feb 29, 2024
1 parent 8ae71f6 commit d6dc01e
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 99 deletions.
180 changes: 90 additions & 90 deletions src/resources/cache/hashes.json
Original file line number Diff line number Diff line change
@@ -1,103 +1,103 @@
{
"webgpu/shader/execution/binary/af_addition.bin": "38b261fa",
"webgpu/shader/execution/binary/af_addition.bin": "5d336557",
"webgpu/shader/execution/binary/af_logical.bin": "a483b968",
"webgpu/shader/execution/binary/af_division.bin": "ec39b0da",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "ca1373a8",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "406d99af",
"webgpu/shader/execution/binary/af_multiplication.bin": "2eb6d50d",
"webgpu/shader/execution/binary/af_remainder.bin": "e2b6b21",
"webgpu/shader/execution/binary/af_subtraction.bin": "84794350",
"webgpu/shader/execution/binary/f16_addition.bin": "19e8823d",
"webgpu/shader/execution/binary/af_division.bin": "85961fcf",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "90260a8c",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "1b4543c9",
"webgpu/shader/execution/binary/af_multiplication.bin": "94a1f882",
"webgpu/shader/execution/binary/af_remainder.bin": "c611c962",
"webgpu/shader/execution/binary/af_subtraction.bin": "7ab56516",
"webgpu/shader/execution/binary/f16_addition.bin": "16ae7028",
"webgpu/shader/execution/binary/f16_logical.bin": "b89ca9b9",
"webgpu/shader/execution/binary/f16_division.bin": "6dc4b748",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "7533842",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "2d799920",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "44e3b295",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "412f0911",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "a231201b",
"webgpu/shader/execution/binary/f16_multiplication.bin": "94b11030",
"webgpu/shader/execution/binary/f16_remainder.bin": "de68a200",
"webgpu/shader/execution/binary/f16_subtraction.bin": "f308327a",
"webgpu/shader/execution/binary/f32_addition.bin": "c87c8c08",
"webgpu/shader/execution/binary/f16_division.bin": "7dfb7c0c",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "ce547a1b",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "61c006fe",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "6427ae57",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "989615a6",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "ad5ef480",
"webgpu/shader/execution/binary/f16_multiplication.bin": "6bfb9d08",
"webgpu/shader/execution/binary/f16_remainder.bin": "d707476e",
"webgpu/shader/execution/binary/f16_subtraction.bin": "30795da0",
"webgpu/shader/execution/binary/f32_addition.bin": "f98c0d2f",
"webgpu/shader/execution/binary/f32_logical.bin": "c7370c09",
"webgpu/shader/execution/binary/f32_division.bin": "34ce65ae",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "f3808d0c",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "e33e7fe5",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "41091ebf",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "37ccb101",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "4d67866",
"webgpu/shader/execution/binary/f32_multiplication.bin": "5d85a36c",
"webgpu/shader/execution/binary/f32_remainder.bin": "62f591b2",
"webgpu/shader/execution/binary/f32_subtraction.bin": "60fc275a",
"webgpu/shader/execution/binary/f32_division.bin": "ce8649ef",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "106b5025",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "f84eaad1",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "1795e787",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "89cacd9e",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "f6f4aafe",
"webgpu/shader/execution/binary/f32_multiplication.bin": "cc9e6c85",
"webgpu/shader/execution/binary/f32_remainder.bin": "26e3083d",
"webgpu/shader/execution/binary/f32_subtraction.bin": "75467b64",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "a0b0a016",
"webgpu/shader/execution/binary/i32_comparison.bin": "f3d9b3f9",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "16e32fd",
"webgpu/shader/execution/binary/u32_comparison.bin": "da33cc5d",
"webgpu/shader/execution/abs.bin": "1ead834c",
"webgpu/shader/execution/acos.bin": "e25802ba",
"webgpu/shader/execution/acosh.bin": "2321726f",
"webgpu/shader/execution/asin.bin": "d554a73b",
"webgpu/shader/execution/asinh.bin": "d2bdb21b",
"webgpu/shader/execution/atan.bin": "eb6476f3",
"webgpu/shader/execution/atan2.bin": "cf15e7fa",
"webgpu/shader/execution/atanh.bin": "6c57cc3",
"webgpu/shader/execution/bitcast.bin": "a25e9714",
"webgpu/shader/execution/ceil.bin": "8d120ea3",
"webgpu/shader/execution/clamp.bin": "a762ef58",
"webgpu/shader/execution/cos.bin": "a859da89",
"webgpu/shader/execution/cosh.bin": "86abdd85",
"webgpu/shader/execution/cross.bin": "e4556729",
"webgpu/shader/execution/degrees.bin": "1fa19a41",
"webgpu/shader/execution/determinant.bin": "108c3d65",
"webgpu/shader/execution/distance.bin": "77a1baa6",
"webgpu/shader/execution/dot.bin": "d4ac2e8a",
"webgpu/shader/execution/exp.bin": "15539afd",
"webgpu/shader/execution/exp2.bin": "7f6a8523",
"webgpu/shader/execution/faceForward.bin": "e7b35f43",
"webgpu/shader/execution/floor.bin": "b26656ca",
"webgpu/shader/execution/fma.bin": "5a70c683",
"webgpu/shader/execution/fract.bin": "23c0d5ec",
"webgpu/shader/execution/frexp.bin": "d28e66be",
"webgpu/shader/execution/inverseSqrt.bin": "9f297854",
"webgpu/shader/execution/ldexp.bin": "638db0c7",
"webgpu/shader/execution/length.bin": "7d237c62",
"webgpu/shader/execution/log.bin": "70720bf0",
"webgpu/shader/execution/log2.bin": "93a309be",
"webgpu/shader/execution/max.bin": "36eb4779",
"webgpu/shader/execution/min.bin": "ca772bf1",
"webgpu/shader/execution/mix.bin": "ecbf61ae",
"webgpu/shader/execution/modf.bin": "6ddea900",
"webgpu/shader/execution/normalize.bin": "d3e47c61",
"webgpu/shader/execution/abs.bin": "cf8072fc",
"webgpu/shader/execution/acos.bin": "c37c5ecf",
"webgpu/shader/execution/acosh.bin": "b46bb1b9",
"webgpu/shader/execution/asin.bin": "549cadb1",
"webgpu/shader/execution/asinh.bin": "86f0e114",
"webgpu/shader/execution/atan.bin": "93a2e1b6",
"webgpu/shader/execution/atan2.bin": "9311a6dd",
"webgpu/shader/execution/atanh.bin": "6a0514c6",
"webgpu/shader/execution/bitcast.bin": "76afbe50",
"webgpu/shader/execution/ceil.bin": "8a61cab0",
"webgpu/shader/execution/clamp.bin": "78824c9e",
"webgpu/shader/execution/cos.bin": "76b7a1b2",
"webgpu/shader/execution/cosh.bin": "1106efa7",
"webgpu/shader/execution/cross.bin": "fccf4527",
"webgpu/shader/execution/degrees.bin": "9c1be90d",
"webgpu/shader/execution/determinant.bin": "c32b24b7",
"webgpu/shader/execution/distance.bin": "901d6577",
"webgpu/shader/execution/dot.bin": "3d20c0b8",
"webgpu/shader/execution/exp.bin": "19521a81",
"webgpu/shader/execution/exp2.bin": "10ea9f82",
"webgpu/shader/execution/faceForward.bin": "9b8de1f3",
"webgpu/shader/execution/floor.bin": "57d4094b",
"webgpu/shader/execution/fma.bin": "7ea3be70",
"webgpu/shader/execution/fract.bin": "815e653",
"webgpu/shader/execution/frexp.bin": "3f506ce4",
"webgpu/shader/execution/inverseSqrt.bin": "ef416b51",
"webgpu/shader/execution/ldexp.bin": "e85e840c",
"webgpu/shader/execution/length.bin": "9323bd89",
"webgpu/shader/execution/log.bin": "1adb8114",
"webgpu/shader/execution/log2.bin": "9c917f84",
"webgpu/shader/execution/max.bin": "24fdbd2",
"webgpu/shader/execution/min.bin": "f0f36951",
"webgpu/shader/execution/mix.bin": "b42696e6",
"webgpu/shader/execution/modf.bin": "eef05b87",
"webgpu/shader/execution/normalize.bin": "2c351486",
"webgpu/shader/execution/pack2x16float.bin": "e6859c1a",
"webgpu/shader/execution/pow.bin": "a58be71c",
"webgpu/shader/execution/quantizeToF16.bin": "eca85bca",
"webgpu/shader/execution/radians.bin": "a216c9aa",
"webgpu/shader/execution/reflect.bin": "ebce9830",
"webgpu/shader/execution/refract.bin": "59d1e5d6",
"webgpu/shader/execution/round.bin": "9389a090",
"webgpu/shader/execution/saturate.bin": "7ca4b681",
"webgpu/shader/execution/sign.bin": "1f4eeb34",
"webgpu/shader/execution/sin.bin": "a1e234b4",
"webgpu/shader/execution/sinh.bin": "1a62054b",
"webgpu/shader/execution/smoothstep.bin": "d5824fd6",
"webgpu/shader/execution/sqrt.bin": "66f21d02",
"webgpu/shader/execution/step.bin": "310cb6c7",
"webgpu/shader/execution/tan.bin": "1e26f533",
"webgpu/shader/execution/tanh.bin": "4c546d1c",
"webgpu/shader/execution/transpose.bin": "7bef2494",
"webgpu/shader/execution/trunc.bin": "e72535eb",
"webgpu/shader/execution/unpack2x16float.bin": "593d88c6",
"webgpu/shader/execution/unpack2x16snorm.bin": "9ebd3e40",
"webgpu/shader/execution/unpack2x16unorm.bin": "83a36fa9",
"webgpu/shader/execution/unpack4x8snorm.bin": "41b12606",
"webgpu/shader/execution/unpack4x8unorm.bin": "96f1850b",
"webgpu/shader/execution/unary/af_arithmetic.bin": "6fa1d84a",
"webgpu/shader/execution/unary/af_assignment.bin": "98c8f82a",
"webgpu/shader/execution/pow.bin": "26942dbd",
"webgpu/shader/execution/quantizeToF16.bin": "26100618",
"webgpu/shader/execution/radians.bin": "73bfe50b",
"webgpu/shader/execution/reflect.bin": "e6767c84",
"webgpu/shader/execution/refract.bin": "e56c075b",
"webgpu/shader/execution/round.bin": "7ae2893b",
"webgpu/shader/execution/saturate.bin": "fabb2d73",
"webgpu/shader/execution/sign.bin": "5774c5b0",
"webgpu/shader/execution/sin.bin": "dfeb334c",
"webgpu/shader/execution/sinh.bin": "3999882",
"webgpu/shader/execution/smoothstep.bin": "c740a8c5",
"webgpu/shader/execution/sqrt.bin": "799bd44e",
"webgpu/shader/execution/step.bin": "7ffbb642",
"webgpu/shader/execution/tan.bin": "eb64ab8b",
"webgpu/shader/execution/tanh.bin": "f7308142",
"webgpu/shader/execution/transpose.bin": "77deefb9",
"webgpu/shader/execution/trunc.bin": "5140bc4b",
"webgpu/shader/execution/unpack2x16float.bin": "d3df7e5b",
"webgpu/shader/execution/unpack2x16snorm.bin": "9cccf8cc",
"webgpu/shader/execution/unpack2x16unorm.bin": "96195630",
"webgpu/shader/execution/unpack4x8snorm.bin": "e5aafd2e",
"webgpu/shader/execution/unpack4x8unorm.bin": "3b500ec6",
"webgpu/shader/execution/unary/af_arithmetic.bin": "23d96b20",
"webgpu/shader/execution/unary/af_assignment.bin": "5e435db4",
"webgpu/shader/execution/unary/bool_conversion.bin": "dd71f171",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "2f2d38fc",
"webgpu/shader/execution/unary/f16_conversion.bin": "70c94538",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "db90c01c",
"webgpu/shader/execution/unary/f32_conversion.bin": "81912140",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "6fe30d61",
"webgpu/shader/execution/unary/f16_conversion.bin": "317b6bd8",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "15dcd62b",
"webgpu/shader/execution/unary/f32_conversion.bin": "215a4765",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "c69716e2",
"webgpu/shader/execution/unary/i32_conversion.bin": "83218e69",
"webgpu/shader/execution/unary/u32_conversion.bin": "8f5bad00",
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
22 changes: 17 additions & 5 deletions src/webgpu/shader/execution/expression/call/builtin/ceil.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ 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 { TypeF16, TypeF32 } from '../../../../../util/conversion.js';
import { allInputSources, run } from '../../expression.js';
import { TypeAbstractFloat, TypeF16, TypeF32 } from '../../../../../util/conversion.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'),
[TypeAbstractFloat],
TypeAbstractFloat,
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 d6dc01e

Please sign in to comment.