Skip to content

Commit

Permalink
wgsl: Implement AbstractInt comparison execution tests (#3401)
Browse files Browse the repository at this point in the history
Fixes #1627
  • Loading branch information
zoddicus authored Feb 29, 2024
1 parent 69f8a9b commit 8ae71f6
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,12 @@
"webgpu:shader,execution,expression,binary,ai_arithmetic:subtraction:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,expression,binary,ai_arithmetic:subtraction_scalar_vector:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,expression,binary,ai_arithmetic:subtraction_vector_scalar:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,expression,binary,ai_comparison:equals:*": { "subcaseMS": 338.609 },
"webgpu:shader,execution,expression,binary,ai_comparison:greater_equals:*": { "subcaseMS": 219.452 },
"webgpu:shader,execution,expression,binary,ai_comparison:greater_than:*": { "subcaseMS": 232.750 },
"webgpu:shader,execution,expression,binary,ai_comparison:less_equals:*": { "subcaseMS": 228.676 },
"webgpu:shader,execution,expression,binary,ai_comparison:less_than:*": { "subcaseMS": 245.506 },
"webgpu:shader,execution,expression,binary,ai_comparison:not_equals:*": { "subcaseMS": 222.561 },
"webgpu:shader,execution,expression,binary,bitwise:bitwise_and:*": { "subcaseMS": 20.982 },
"webgpu:shader,execution,expression,binary,bitwise:bitwise_and_compound:*": { "subcaseMS": 22.513 },
"webgpu:shader,execution,expression,binary,bitwise:bitwise_exclusive_or:*": { "subcaseMS": 21.294 },
Expand Down Expand Up @@ -1254,23 +1260,21 @@
"webgpu:shader,execution,expression,call,builtin,dot4I8Packed:basic:*": { "subcaseMS": 1.000 },
"webgpu:shader,execution,expression,call,builtin,dot4U8Packed:basic:*": { "subcaseMS": 1.000 },
"webgpu:shader,execution,expression,call,builtin,dot:abstract_float:*": { "subcaseMS": 8.902 },
"webgpu:shader,execution,expression,call,builtin,dot:abstract_int_vec2:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,call,builtin,dot:abstract_int_vec3:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,call,builtin,dot:abstract_int_vec4:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,call,builtin,dot:abstract_int_vec2:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,expression,call,builtin,dot:abstract_int_vec3:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,expression,call,builtin,dot:abstract_int_vec4:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,expression,call,builtin,dot:f16_vec2:*": { "subcaseMS": 981.225 },
"webgpu:shader,execution,expression,call,builtin,dot:f16_vec3:*": { "subcaseMS": 50.350 },
"webgpu:shader,execution,expression,call,builtin,dot:f16_vec4:*": { "subcaseMS": 52.250 },
"webgpu:shader,execution,expression,call,builtin,dot:f32_vec2:*": { "subcaseMS": 210.350 },
"webgpu:shader,execution,expression,call,builtin,dot:f32_vec3:*": { "subcaseMS": 11.176 },
"webgpu:shader,execution,expression,call,builtin,dot:f32_vec4:*": { "subcaseMS": 11.876 },
"webgpu:shader,execution,expression,call,builtin,dot:i32_vec2:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,call,builtin,dot:i32_vec3:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,call,builtin,dot:i32_vec4:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,call,builtin,dot:u32_vec2:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,call,builtin,dot:u32_vec3:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,call,builtin,dot:u32_vec4:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,call,builtin,dot4I8Packed:basic:*": { "subcaseMS": 1.000 },
"webgpu:shader,execution,expression,call,builtin,dot4U8Packed:basic:*": { "subcaseMS": 1.000 },
"webgpu:shader,execution,expression,call,builtin,dot:i32_vec2:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,expression,call,builtin,dot:i32_vec3:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,expression,call,builtin,dot:i32_vec4:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,expression,call,builtin,dot:u32_vec2:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,expression,call,builtin,dot:u32_vec3:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,expression,call,builtin,dot:u32_vec4:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,expression,call,builtin,dpdx:f32:*": { "subcaseMS": 22.804 },
"webgpu:shader,execution,expression,call,builtin,dpdxCoarse:f32:*": { "subcaseMS": 22.404 },
"webgpu:shader,execution,expression,call,builtin,dpdxFine:f32:*": { "subcaseMS": 17.708 },
Expand Down Expand Up @@ -1687,9 +1691,9 @@
"webgpu:shader,execution,flow_control,switch:switch:*": { "subcaseMS": 12.750 },
"webgpu:shader,execution,flow_control,switch:switch_default:*": { "subcaseMS": 5.400 },
"webgpu:shader,execution,flow_control,switch:switch_default_only:*": { "subcaseMS": 12.550 },
"webgpu:shader,execution,flow_control,switch:switch_inside_loop_with_continue:*": { "subcaseMS": 0.000 },
"webgpu:shader,execution,flow_control,switch:switch_multiple_case:*": { "subcaseMS": 5.550 },
"webgpu:shader,execution,flow_control,switch:switch_multiple_case_default:*": { "subcaseMS": 12.000 },
"webgpu:shader,execution,flow_control,switch:switch_inside_loop_with_continue:*": { "subcaseMS": 0 },
"webgpu:shader,execution,flow_control,while:while_basic:*": { "subcaseMS": 5.951 },
"webgpu:shader,execution,flow_control,while:while_break:*": { "subcaseMS": 12.450 },
"webgpu:shader,execution,flow_control,while:while_continue:*": { "subcaseMS": 5.650 },
Expand Down Expand Up @@ -1842,8 +1846,8 @@
"webgpu:shader,validation,expression,call,builtin,cosh:values:*": { "subcaseMS": 0.272 },
"webgpu:shader,validation,expression,call,builtin,degrees:integer_argument:*": { "subcaseMS": 1.311 },
"webgpu:shader,validation,expression,call,builtin,degrees:values:*": { "subcaseMS": 0.303 },
"webgpu:shader,validation,expression,call,builtin,derivatives:only_in_fragment:*": { "subcaseMS": 1.000 },
"webgpu:shader,validation,expression,call,builtin,derivatives:invalid_argument_types:*": { "subcaseMS": 1.000 },
"webgpu:shader,validation,expression,call,builtin,derivatives:only_in_fragment:*": { "subcaseMS": 1.000 },
"webgpu:shader,validation,expression,call,builtin,dot4I8Packed:bad_args:*": { "subcaseMS": 0.302 },
"webgpu:shader,validation,expression,call,builtin,dot4I8Packed:must_use:*": { "subcaseMS": 0.300 },
"webgpu:shader,validation,expression,call,builtin,dot4I8Packed:supported:*": { "subcaseMS": 1.100 },
Expand Down Expand Up @@ -1911,10 +1915,8 @@
"webgpu:shader,validation,expression,call,builtin,unpack4xU8:must_use:*": { "subcaseMS": 32.800 },
"webgpu:shader,validation,expression,call,builtin,unpack4xU8:supported:*": { "subcaseMS": 98.501 },
"webgpu:shader,validation,expression,call,builtin,unpack4xU8:unsupported:*": { "subcaseMS": 346.801 },
"webgpu:shader,validation,expression,call,builtin,workgroupUniformLoad:only_in_compute:*": { "subcaseMS": 1.000 },
"webgpu:shader,validation,expression,call,builtin,workgroupUniformLoad:no_atomics:*": { "subcaseMS": 1.000 },
"webgpu:shader,validation,extension,pointer_composite_access:deref:*": { "subcaseMS": 0.0 },
"webgpu:shader,validation,extension,pointer_composite_access:pointer:*": { "subcaseMS": 0.0 },
"webgpu:shader,validation,expression,call,builtin,workgroupUniformLoad:only_in_compute:*": { "subcaseMS": 1.000 },
"webgpu:shader,validation,expression,unary,address_of_and_indirection:basic:*": { "subcaseMS": 0.000 },
"webgpu:shader,validation,expression,unary,address_of_and_indirection:composite:*": { "subcaseMS": 0.000 },
"webgpu:shader,validation,expression,unary,address_of_and_indirection:invalid:*": { "subcaseMS": 0.000 },
Expand Down
124 changes: 124 additions & 0 deletions src/webgpu/shader/execution/expression/binary/ai_comparison.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
export const description = `
Execution Tests for the abstract int comparison expressions
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { TypeBool, TypeAbstractInt, bool, abstractInt } from '../../../../util/conversion.js';
import { vectorI64Range } from '../../../../util/math.js';
import { Case } from '../case.js';
import { onlyConstInputSource, run } from '../expression.js';

import { binary } from './binary.js';

export const g = makeTestGroup(GPUTest);

/**
* @returns a test case for the provided left hand & right hand values and
* expected boolean result.
*/
function makeCase(lhs: bigint, rhs: bigint, expected_answer: boolean): Case {
return { input: [abstractInt(lhs), abstractInt(rhs)], expected: bool(expected_answer) };
}

g.test('equals')
.specURL('https://www.w3.org/TR/WGSL/#comparison-expr')
.desc(
`
Expression: x == y
`
)
.params(u =>
u
.combine('inputSource', onlyConstInputSource)
.combine('vectorize', [undefined, 2, 3, 4] as const)
)
.fn(async t => {
const cases = vectorI64Range(2).map(v => makeCase(v[0], v[1], v[0] === v[1]));
await run(t, binary('=='), [TypeAbstractInt, TypeAbstractInt], TypeBool, t.params, cases);
});

g.test('not_equals')
.specURL('https://www.w3.org/TR/WGSL/#comparison-expr')
.desc(
`
Expression: x != y
`
)
.params(u =>
u
.combine('inputSource', onlyConstInputSource)
.combine('vectorize', [undefined, 2, 3, 4] as const)
)
.fn(async t => {
const cases = vectorI64Range(2).map(v => makeCase(v[0], v[1], v[0] !== v[1]));
await run(t, binary('!='), [TypeAbstractInt, TypeAbstractInt], TypeBool, t.params, cases);
});

g.test('less_than')
.specURL('https://www.w3.org/TR/WGSL/#comparison-expr')
.desc(
`
Expression: x < y
`
)
.params(u =>
u
.combine('inputSource', onlyConstInputSource)
.combine('vectorize', [undefined, 2, 3, 4] as const)
)
.fn(async t => {
const cases = vectorI64Range(2).map(v => makeCase(v[0], v[1], v[0] < v[1]));
await run(t, binary('<'), [TypeAbstractInt, TypeAbstractInt], TypeBool, t.params, cases);
});

g.test('less_equals')
.specURL('https://www.w3.org/TR/WGSL/#comparison-expr')
.desc(
`
Expression: x <= y
`
)
.params(u =>
u
.combine('inputSource', onlyConstInputSource)
.combine('vectorize', [undefined, 2, 3, 4] as const)
)
.fn(async t => {
const cases = vectorI64Range(2).map(v => makeCase(v[0], v[1], v[0] <= v[1]));
await run(t, binary('<='), [TypeAbstractInt, TypeAbstractInt], TypeBool, t.params, cases);
});

g.test('greater_than')
.specURL('https://www.w3.org/TR/WGSL/#comparison-expr')
.desc(
`
Expression: x > y
`
)
.params(u =>
u
.combine('inputSource', onlyConstInputSource)
.combine('vectorize', [undefined, 2, 3, 4] as const)
)
.fn(async t => {
const cases = vectorI64Range(2).map(v => makeCase(v[0], v[1], v[0] > v[1]));
await run(t, binary('>'), [TypeAbstractInt, TypeAbstractInt], TypeBool, t.params, cases);
});

g.test('greater_equals')
.specURL('https://www.w3.org/TR/WGSL/#comparison-expr')
.desc(
`
Expression: x >= y
`
)
.params(u =>
u
.combine('inputSource', onlyConstInputSource)
.combine('vectorize', [undefined, 2, 3, 4] as const)
)
.fn(async t => {
const cases = vectorI64Range(2).map(v => makeCase(v[0], v[1], v[0] >= v[1]));
await run(t, binary('>='), [TypeAbstractInt, TypeAbstractInt], TypeBool, t.params, cases);
});

0 comments on commit 8ae71f6

Please sign in to comment.