Skip to content

Commit

Permalink
wgsl: Implement AbstractInt multiplication execution tests (#3398)
Browse files Browse the repository at this point in the history
Issue #1626
  • Loading branch information
zoddicus authored Feb 13, 2024
1 parent c37082f commit 42b0189
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/resources/cache/hashes.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@
"webgpu/shader/execution/unary/u32_complement.bin": "d00cdf00",
"webgpu/shader/execution/unary/u32_conversion.bin": "2940ba5e",
"webgpu/shader/execution/unary/ai_assignment.bin": "9c0d8f91",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "1e43f807",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "f48612cb",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "2a1ff461"
}
Binary file not shown.
3 changes: 3 additions & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,9 @@
"webgpu:shader,execution,expression,binary,ai_arithmetic:division:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,binary,ai_arithmetic:division_scalar_vector:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,binary,ai_arithmetic:division_vector_scalar:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,binary,ai_arithmetic:multiplication:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,binary,ai_arithmetic:multiplication_scalar_vector:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,binary,ai_arithmetic:multiplication_vector_scalar:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,binary,ai_arithmetic:subtraction:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,binary,ai_arithmetic:subtraction_scalar_vector:*": { "subcaseMS": 0 },
"webgpu:shader,execution,expression,binary,ai_arithmetic:subtraction_vector_scalar:*": { "subcaseMS": 0 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ function ai_div(x: bigint, y: bigint): bigint | undefined {
return !isOOB(result) ? result : undefined;
}

function ai_mul(x: bigint, y: bigint): bigint | undefined {
const result = x * y;
return !isOOB(result) ? result : undefined;
}

function ai_sub(x: bigint, y: bigint): bigint | undefined {
const result = x - y;
return !isOOB(result) ? result : undefined;
Expand Down Expand Up @@ -70,6 +75,27 @@ export const d = makeCaseCache('binary/ai_arithmetic', {
division_vector4_scalar: () => {
return generateVectorI64BinaryToVectorCases(vectorI64Range(4), sparseI64Range(), ai_div);
},
multiplication: () => {
return generateBinaryToI64Cases(sparseI64Range(), sparseI64Range(), ai_mul);
},
multiplication_scalar_vector2: () => {
return generateI64VectorBinaryToVectorCases(sparseI64Range(), vectorI64Range(2), ai_mul);
},
multiplication_scalar_vector3: () => {
return generateI64VectorBinaryToVectorCases(sparseI64Range(), vectorI64Range(3), ai_mul);
},
multiplication_scalar_vector4: () => {
return generateI64VectorBinaryToVectorCases(sparseI64Range(), vectorI64Range(4), ai_mul);
},
multiplication_vector2_scalar: () => {
return generateVectorI64BinaryToVectorCases(vectorI64Range(2), sparseI64Range(), ai_mul);
},
multiplication_vector3_scalar: () => {
return generateVectorI64BinaryToVectorCases(vectorI64Range(3), sparseI64Range(), ai_mul);
},
multiplication_vector4_scalar: () => {
return generateVectorI64BinaryToVectorCases(vectorI64Range(4), sparseI64Range(), ai_mul);
},
subtraction: () => {
return generateBinaryToI64Cases(sparseI64Range(), sparseI64Range(), ai_sub);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,64 @@ Expression: x / y
await run(t, abstractIntBinary('/'), [vec_type, TypeAbstractInt], vec_type, t.params, cases);
});

g.test('multiplication')
.specURL('https://www.w3.org/TR/WGSL/#arithmetic-expr')
.desc(
`
Expression: x * y
`
)
.params(u =>
u
.combine('inputSource', onlyConstInputSource)
.combine('vectorize', [undefined, 2, 3, 4] as const)
)
.fn(async t => {
const cases = await d.get('multiplication');
await run(
t,
abstractIntBinary('*'),
[TypeAbstractInt, TypeAbstractInt],
TypeAbstractInt,
t.params,
cases
);
});

g.test('multiplication_scalar_vector')
.specURL('https://www.w3.org/TR/WGSL/#arithmetic-expr')
.desc(
`
Expression: x * y
`
)
.params(u =>
u.combine('inputSource', onlyConstInputSource).combine('vectorize_rhs', [2, 3, 4] as const)
)
.fn(async t => {
const vec_size = t.params.vectorize_rhs;
const vec_type = TypeVec(vec_size, TypeAbstractInt);
const cases = await d.get(`multiplication_scalar_vector${vec_size}`);
await run(t, abstractIntBinary('*'), [TypeAbstractInt, vec_type], vec_type, t.params, cases);
});

g.test('multiplication_vector_scalar')
.specURL('https://www.w3.org/TR/WGSL/#arithmetic-expr')
.desc(
`
Expression: x * y
`
)
.params(u =>
u.combine('inputSource', onlyConstInputSource).combine('vectorize_lhs', [2, 3, 4] as const)
)
.fn(async t => {
const vec_size = t.params.vectorize_lhs;
const vec_type = TypeVec(vec_size, TypeAbstractInt);
const cases = await d.get(`multiplication_vector${vec_size}_scalar`);
await run(t, abstractIntBinary('*'), [vec_type, TypeAbstractInt], vec_type, t.params, cases);
});

g.test('subtraction')
.specURL('https://www.w3.org/TR/WGSL/#arithmetic-expr')
.desc(
Expand Down

0 comments on commit 42b0189

Please sign in to comment.