From 2920b0fdf77675a0a4b746700730b55462b47486 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Tue, 13 Feb 2024 11:30:30 -0500 Subject: [PATCH] wgsl: Implement AbstractInt negation execution tests (#3390) Issue #1626 --- src/resources/cache/hashes.json | 3 +- .../shader/execution/unary/ai_arithmetic.bin | Bin 0 -> 3256 bytes src/webgpu/listing_meta.json | 1 + .../expression/unary/af_arithmetic.spec.ts | 12 +++++-- .../expression/unary/ai_arithmetic.cache.ts | 11 +++++++ .../expression/unary/ai_arithmetic.spec.ts | 30 ++++++++++++++++++ .../execution/expression/unary/unary.ts | 8 ++++- 7 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 src/resources/cache/webgpu/shader/execution/unary/ai_arithmetic.bin create mode 100644 src/webgpu/shader/execution/expression/unary/ai_arithmetic.cache.ts create mode 100644 src/webgpu/shader/execution/expression/unary/ai_arithmetic.spec.ts diff --git a/src/resources/cache/hashes.json b/src/resources/cache/hashes.json index 1127fa47fdcf..dfbdd3912675 100644 --- a/src/resources/cache/hashes.json +++ b/src/resources/cache/hashes.json @@ -103,5 +103,6 @@ "webgpu/shader/execution/unary/i32_conversion.bin": "70bd317b", "webgpu/shader/execution/unary/u32_complement.bin": "b8dd9928", "webgpu/shader/execution/unary/u32_conversion.bin": "750cf298", - "webgpu/shader/execution/unary/ai_assignment.bin": "8123c23d" + "webgpu/shader/execution/unary/ai_assignment.bin": "8123c23d", + "webgpu/shader/execution/unary/ai_arithmetic.bin": "ada333c7" } \ No newline at end of file diff --git a/src/resources/cache/webgpu/shader/execution/unary/ai_arithmetic.bin b/src/resources/cache/webgpu/shader/execution/unary/ai_arithmetic.bin new file mode 100644 index 0000000000000000000000000000000000000000..2fa273ff1940fc17223d47a0483278d320e556d6 GIT binary patch literal 3256 zcmZwI3pmwx9LMo>( zhGRtHE5?Pp;lUh3zxv-h`CQhiCPD906+V}4oRK~%G(8gg0mtvVzKwF-1v>^^Ir{FE z$6okUtc9oS*yJ$y2TjGcs9x(Rcu7mIdZ=P?C|qExelRo4HX61sZ1WNCEewI{T1v+3 zYxdg*8)#a+-Z?p8C!8*)Qaf~~C%UpL%zG#vUYq;f*lGJhL;u99 z-tar=!J8IoYmUNl{yuZBNX~e|ZJLu+6PHCM!xLMYJA5zg@_?1)<{O=?txkoX4^&jI zGca<4wJuxEnviUi4mU3?{pFcQwJSU^=6t~Z_>0Hkw&0cVI|7z(gx~0XlxlZ&bv8Vv z;e}hl>a)(Us%pQqt5_iy?(C5F7g_hMhyBGt);0(0^WcQc*y17|JxBObP}580%&ODy z@>s2L-C|>V*tE6YElv8M2(Hx7OO^Ofw}JceJx+J8?JtHE9g^*pPsv-u-_C2P%CK2* z0hZj*G~QJ7^9p#kPFI>BrQ{JE^Jcly}n#DPz_gEC*_)T$r-^~Ee0BG*(&$oX3g4Gb?446;FSEV zIa%K?e*k+pxZHMGa&bDGJ6xOn%r2uAb`lskPbk=A0C%6sc_LGz&wg!R5^GB>i^mg=NRW7 ziL3iu9v)^FEEM44?O+f5zdzjn@bz|3Uq)Voo*zqn8HVpsU-*0`^@Y#9s4skel={Nw z$Wc{by4060nDylonDymP zc#!&{0?SfgI$_oqHJJ6K9TrhvCc@p+m#45c^+gkIqQ11ilc+CR@Kfqb6a1F?q63en zzVP!zjruYL^A76EV>p2N!p|cq^@X2TCDfN`*k49{c?i#?zRZAcQD5%Eucq`dA`r;0=zNEmcFJ3U~%MqCM#TRCMNrYKn0%6vdIGFV%1ZI7ShFK57Vd2P0 IJ#t0-4Ke5<>Hq)$ literal 0 HcmV?d00001 diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index 96656cad0648..a5e742d8c04f 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -1529,6 +1529,7 @@ "webgpu:shader,execution,expression,call,user,ptr_params:write_ptr_to_member:*": { "subcaseMS": 0.000 }, "webgpu:shader,execution,expression,call,user,ptr_params:write_ptr_to_element:*": { "subcaseMS": 0.000 }, "webgpu:shader,execution,expression,call,user,ptr_params:mixed_ptr_parameters:*": { "subcaseMS": 0.000 }, + "webgpu:shader,execution,expression,unary,ai_arithmetic:negation:*": { "subcaseMS": 0.000 }, "webgpu:shader,execution,expression,unary,af_arithmetic:negation:*": { "subcaseMS": 2165.950 }, "webgpu:shader,execution,expression,unary,af_assignment:abstract:*": { "subcaseMS": 788.400 }, "webgpu:shader,execution,expression,unary,af_assignment:f16:*": { "subcaseMS": 1.000 }, diff --git a/src/webgpu/shader/execution/expression/unary/af_arithmetic.spec.ts b/src/webgpu/shader/execution/expression/unary/af_arithmetic.spec.ts index ef148833eb17..005ddc6448ea 100644 --- a/src/webgpu/shader/execution/expression/unary/af_arithmetic.spec.ts +++ b/src/webgpu/shader/execution/expression/unary/af_arithmetic.spec.ts @@ -8,7 +8,7 @@ import { TypeAbstractFloat } from '../../../../util/conversion.js'; import { onlyConstInputSource, run } from '../expression.js'; import { d } from './af_arithmetic.cache.js'; -import { abstractUnary } from './unary.js'; +import { abstractFloatUnary } from './unary.js'; export const g = makeTestGroup(GPUTest); @@ -27,5 +27,13 @@ Accuracy: Correctly rounded ) .fn(async t => { const cases = await d.get('negation'); - await run(t, abstractUnary('-'), [TypeAbstractFloat], TypeAbstractFloat, t.params, cases, 1); + await run( + t, + abstractFloatUnary('-'), + [TypeAbstractFloat], + TypeAbstractFloat, + t.params, + cases, + 1 + ); }); diff --git a/src/webgpu/shader/execution/expression/unary/ai_arithmetic.cache.ts b/src/webgpu/shader/execution/expression/unary/ai_arithmetic.cache.ts new file mode 100644 index 000000000000..904c0bc70010 --- /dev/null +++ b/src/webgpu/shader/execution/expression/unary/ai_arithmetic.cache.ts @@ -0,0 +1,11 @@ +import { abstractInt } from '../../../../util/conversion.js'; +import { fullI64Range } from '../../../../util/math.js'; +import { makeCaseCache } from '../case_cache.js'; + +export const d = makeCaseCache('unary/ai_arithmetic', { + negation: () => { + return fullI64Range().map(e => { + return { input: abstractInt(e), expected: abstractInt(-e) }; + }); + }, +}); diff --git a/src/webgpu/shader/execution/expression/unary/ai_arithmetic.spec.ts b/src/webgpu/shader/execution/expression/unary/ai_arithmetic.spec.ts new file mode 100644 index 000000000000..bc50be4a7b62 --- /dev/null +++ b/src/webgpu/shader/execution/expression/unary/ai_arithmetic.spec.ts @@ -0,0 +1,30 @@ +export const description = ` +Execution Tests for the abstract integer arithmetic unary expression operations +`; + +import { makeTestGroup } from '../../../../../common/framework/test_group.js'; +import { GPUTest } from '../../../../gpu_test.js'; +import { TypeAbstractInt } from '../../../../util/conversion.js'; +import { onlyConstInputSource, run } from '../expression.js'; + +import { d } from './ai_arithmetic.cache.js'; +import { abstractIntUnary } from './unary.js'; + +export const g = makeTestGroup(GPUTest); + +g.test('negation') + .specURL('https://www.w3.org/TR/WGSL/#arithmetic-expr') + .desc( + ` +Expression: -x +` + ) + .params(u => + u + .combine('inputSource', onlyConstInputSource) + .combine('vectorize', [undefined, 2, 3, 4] as const) + ) + .fn(async t => { + const cases = await d.get('negation'); + await run(t, abstractIntUnary('-'), [TypeAbstractInt], TypeAbstractInt, t.params, cases); + }); diff --git a/src/webgpu/shader/execution/expression/unary/unary.ts b/src/webgpu/shader/execution/expression/unary/unary.ts index 160e4651783d..109e6c142167 100644 --- a/src/webgpu/shader/execution/expression/unary/unary.ts +++ b/src/webgpu/shader/execution/expression/unary/unary.ts @@ -1,5 +1,6 @@ import { abstractFloatShaderBuilder, + abstractIntShaderBuilder, basicExpressionBuilder, ShaderBuilder, } from '../expression.js'; @@ -10,6 +11,11 @@ export function unary(op: string): ShaderBuilder { } /* @returns a ShaderBuilder that evaluates a prefix unary operation that returns AbstractFloats */ -export function abstractUnary(op: string): ShaderBuilder { +export function abstractFloatUnary(op: string): ShaderBuilder { return abstractFloatShaderBuilder(value => `${op}(${value})`); } + +/* @returns a ShaderBuilder that evaluates a prefix unary operation that returns AbstractInts */ +export function abstractIntUnary(op: string): ShaderBuilder { + return abstractIntShaderBuilder(value => `${op}(${value})`); +}