Skip to content

Commit

Permalink
wgsl: Implement i32 & u32 dot execution tests (#3411)
Browse files Browse the repository at this point in the history
Fixes #2516
Fixes #2515
  • Loading branch information
zoddicus authored Feb 29, 2024
1 parent f0bd2fe commit 57bd1b0
Show file tree
Hide file tree
Showing 7 changed files with 340 additions and 120 deletions.
214 changes: 107 additions & 107 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": "5067132e",
"webgpu/shader/execution/binary/af_logical.bin": "a7bde13e",
"webgpu/shader/execution/binary/af_division.bin": "19678742",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "42689934",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "c6322f74",
"webgpu/shader/execution/binary/af_multiplication.bin": "5f12d793",
"webgpu/shader/execution/binary/af_remainder.bin": "df05ecb8",
"webgpu/shader/execution/binary/af_subtraction.bin": "a13ed62f",
"webgpu/shader/execution/binary/f16_addition.bin": "14e49495",
"webgpu/shader/execution/binary/f16_logical.bin": "9e733738",
"webgpu/shader/execution/binary/f16_division.bin": "f42b09dc",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "517b60f1",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "66a87207",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "a9c3e5f1",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "f2a25933",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "a886a0b5",
"webgpu/shader/execution/binary/f16_multiplication.bin": "be77033b",
"webgpu/shader/execution/binary/f16_remainder.bin": "50b0b02",
"webgpu/shader/execution/binary/f16_subtraction.bin": "93f65d9",
"webgpu/shader/execution/binary/f32_addition.bin": "278d2454",
"webgpu/shader/execution/binary/f32_logical.bin": "55bcf58e",
"webgpu/shader/execution/binary/f32_division.bin": "3a457201",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "660aad6a",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "a278509a",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "ace2da73",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "8f986eff",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "c26e2700",
"webgpu/shader/execution/binary/f32_multiplication.bin": "4cdfcb27",
"webgpu/shader/execution/binary/f32_remainder.bin": "e3119b6d",
"webgpu/shader/execution/binary/f32_subtraction.bin": "d71a5a86",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "b880610d",
"webgpu/shader/execution/binary/i32_comparison.bin": "f2f668b2",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "164ebf51",
"webgpu/shader/execution/binary/u32_comparison.bin": "35a31af1",
"webgpu/shader/execution/abs.bin": "ec6cc570",
"webgpu/shader/execution/acos.bin": "d61bb028",
"webgpu/shader/execution/acosh.bin": "609af763",
"webgpu/shader/execution/asin.bin": "64bf727b",
"webgpu/shader/execution/asinh.bin": "273b8028",
"webgpu/shader/execution/atan.bin": "f6384fbb",
"webgpu/shader/execution/atan2.bin": "64163f99",
"webgpu/shader/execution/atanh.bin": "bacbfd59",
"webgpu/shader/execution/bitcast.bin": "4a0d7d41",
"webgpu/shader/execution/ceil.bin": "48020ceb",
"webgpu/shader/execution/clamp.bin": "402bf6c9",
"webgpu/shader/execution/cos.bin": "6b4d2358",
"webgpu/shader/execution/cosh.bin": "dccbe75f",
"webgpu/shader/execution/cross.bin": "a550a630",
"webgpu/shader/execution/degrees.bin": "72d5163b",
"webgpu/shader/execution/determinant.bin": "f1378c53",
"webgpu/shader/execution/distance.bin": "48ee3f00",
"webgpu/shader/execution/dot.bin": "d2f81d75",
"webgpu/shader/execution/exp.bin": "36af62ed",
"webgpu/shader/execution/exp2.bin": "8675703d",
"webgpu/shader/execution/faceForward.bin": "568cc6b8",
"webgpu/shader/execution/floor.bin": "e7ab0a1e",
"webgpu/shader/execution/fma.bin": "3b4ebf3f",
"webgpu/shader/execution/fract.bin": "130ceb8a",
"webgpu/shader/execution/frexp.bin": "a5868197",
"webgpu/shader/execution/inverseSqrt.bin": "e2a63a07",
"webgpu/shader/execution/ldexp.bin": "62948ba1",
"webgpu/shader/execution/length.bin": "ce1440e5",
"webgpu/shader/execution/log.bin": "69b69fa1",
"webgpu/shader/execution/log2.bin": "dc5c999d",
"webgpu/shader/execution/max.bin": "58fc2b9a",
"webgpu/shader/execution/min.bin": "84eec3dd",
"webgpu/shader/execution/mix.bin": "8c176bc2",
"webgpu/shader/execution/modf.bin": "9fcb3629",
"webgpu/shader/execution/normalize.bin": "4bf45f2a",
"webgpu/shader/execution/pack2x16float.bin": "74aac2f5",
"webgpu/shader/execution/pow.bin": "976aaac6",
"webgpu/shader/execution/quantizeToF16.bin": "9b60dec9",
"webgpu/shader/execution/radians.bin": "f37fa7ad",
"webgpu/shader/execution/reflect.bin": "d0da3a14",
"webgpu/shader/execution/refract.bin": "f426dd6e",
"webgpu/shader/execution/round.bin": "ffc365ff",
"webgpu/shader/execution/saturate.bin": "253ffcc7",
"webgpu/shader/execution/sign.bin": "ee72deed",
"webgpu/shader/execution/sin.bin": "c685df75",
"webgpu/shader/execution/sinh.bin": "404bade3",
"webgpu/shader/execution/smoothstep.bin": "4631743e",
"webgpu/shader/execution/sqrt.bin": "29d895f1",
"webgpu/shader/execution/step.bin": "e246e2ed",
"webgpu/shader/execution/tan.bin": "37d5e55c",
"webgpu/shader/execution/tanh.bin": "4964f0af",
"webgpu/shader/execution/transpose.bin": "c0688654",
"webgpu/shader/execution/trunc.bin": "29a4bedf",
"webgpu/shader/execution/unpack2x16float.bin": "45a53d8d",
"webgpu/shader/execution/unpack2x16snorm.bin": "827b024f",
"webgpu/shader/execution/unpack2x16unorm.bin": "dc1bd85a",
"webgpu/shader/execution/unpack4x8snorm.bin": "f9525320",
"webgpu/shader/execution/unpack4x8unorm.bin": "27facc7f",
"webgpu/shader/execution/unary/af_arithmetic.bin": "213bf535",
"webgpu/shader/execution/unary/af_assignment.bin": "7d092411",
"webgpu/shader/execution/unary/bool_conversion.bin": "ef64f29e",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "e7a930c",
"webgpu/shader/execution/unary/f16_conversion.bin": "ed0ad482",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "e32dcdbd",
"webgpu/shader/execution/unary/f32_conversion.bin": "b0b23a1a",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "5a180128",
"webgpu/shader/execution/unary/i32_complement.bin": "7266637b",
"webgpu/shader/execution/unary/i32_conversion.bin": "5f788044",
"webgpu/shader/execution/unary/u32_complement.bin": "44efa30e",
"webgpu/shader/execution/unary/u32_conversion.bin": "d9aec403",
"webgpu/shader/execution/unary/ai_assignment.bin": "cb574671",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "9c9ef2a4",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "6fadb5ac"
"webgpu/shader/execution/binary/af_addition.bin": "bbc5103c",
"webgpu/shader/execution/binary/af_logical.bin": "a483b968",
"webgpu/shader/execution/binary/af_division.bin": "7c221c28",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "ebab2b30",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "6078475c",
"webgpu/shader/execution/binary/af_multiplication.bin": "66ad501",
"webgpu/shader/execution/binary/af_remainder.bin": "5a87ed27",
"webgpu/shader/execution/binary/af_subtraction.bin": "66bad739",
"webgpu/shader/execution/binary/f16_addition.bin": "3ff7fed3",
"webgpu/shader/execution/binary/f16_logical.bin": "b89ca9b9",
"webgpu/shader/execution/binary/f16_division.bin": "a01c2499",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "cb64b0b6",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "edbbdd7b",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "f5ded61d",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "11ad421b",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "5ef65699",
"webgpu/shader/execution/binary/f16_multiplication.bin": "24c6a56f",
"webgpu/shader/execution/binary/f16_remainder.bin": "d47a8347",
"webgpu/shader/execution/binary/f16_subtraction.bin": "755f4b0b",
"webgpu/shader/execution/binary/f32_addition.bin": "6db93d07",
"webgpu/shader/execution/binary/f32_logical.bin": "c7370c09",
"webgpu/shader/execution/binary/f32_division.bin": "c28058b5",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "3f49bac9",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "592cc2c4",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "e3750b3c",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "b16d21e2",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "c982cd63",
"webgpu/shader/execution/binary/f32_multiplication.bin": "835ec6ee",
"webgpu/shader/execution/binary/f32_remainder.bin": "daf70203",
"webgpu/shader/execution/binary/f32_subtraction.bin": "2fc781f8",
"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": "e8dce87a",
"webgpu/shader/execution/acos.bin": "2762bad",
"webgpu/shader/execution/acosh.bin": "a3b96c53",
"webgpu/shader/execution/asin.bin": "1d9d590",
"webgpu/shader/execution/asinh.bin": "c2cc05",
"webgpu/shader/execution/atan.bin": "3f701bba",
"webgpu/shader/execution/atan2.bin": "559fb65a",
"webgpu/shader/execution/atanh.bin": "6d352d21",
"webgpu/shader/execution/bitcast.bin": "ec72fa7",
"webgpu/shader/execution/ceil.bin": "42f80be0",
"webgpu/shader/execution/clamp.bin": "1440b818",
"webgpu/shader/execution/cos.bin": "c5da20d",
"webgpu/shader/execution/cosh.bin": "a01e8091",
"webgpu/shader/execution/cross.bin": "c756d650",
"webgpu/shader/execution/degrees.bin": "2c481603",
"webgpu/shader/execution/determinant.bin": "1e67d0f3",
"webgpu/shader/execution/distance.bin": "9a305a9d",
"webgpu/shader/execution/dot.bin": "1a3853b8",
"webgpu/shader/execution/exp.bin": "11112dba",
"webgpu/shader/execution/exp2.bin": "583e9c6a",
"webgpu/shader/execution/faceForward.bin": "7528aff7",
"webgpu/shader/execution/floor.bin": "96044530",
"webgpu/shader/execution/fma.bin": "8e795844",
"webgpu/shader/execution/fract.bin": "997d1bb5",
"webgpu/shader/execution/frexp.bin": "4a1efc69",
"webgpu/shader/execution/inverseSqrt.bin": "3e7d725",
"webgpu/shader/execution/ldexp.bin": "79646a61",
"webgpu/shader/execution/length.bin": "177f62e6",
"webgpu/shader/execution/log.bin": "4e0f535c",
"webgpu/shader/execution/log2.bin": "a961449",
"webgpu/shader/execution/max.bin": "3d764667",
"webgpu/shader/execution/min.bin": "c02f865",
"webgpu/shader/execution/mix.bin": "9431b1b0",
"webgpu/shader/execution/modf.bin": "1fdcef82",
"webgpu/shader/execution/normalize.bin": "78dd7ec5",
"webgpu/shader/execution/pack2x16float.bin": "e6859c1a",
"webgpu/shader/execution/pow.bin": "4877dcfb",
"webgpu/shader/execution/quantizeToF16.bin": "c80d80ea",
"webgpu/shader/execution/radians.bin": "ac062ec8",
"webgpu/shader/execution/reflect.bin": "a4e70e5a",
"webgpu/shader/execution/refract.bin": "2ca0bc97",
"webgpu/shader/execution/round.bin": "3471eaad",
"webgpu/shader/execution/saturate.bin": "5bb3dced",
"webgpu/shader/execution/sign.bin": "5b54134",
"webgpu/shader/execution/sin.bin": "c5bb923c",
"webgpu/shader/execution/sinh.bin": "122dba1b",
"webgpu/shader/execution/smoothstep.bin": "91223043",
"webgpu/shader/execution/sqrt.bin": "e630cb4e",
"webgpu/shader/execution/step.bin": "a3349b96",
"webgpu/shader/execution/tan.bin": "ecc23f5e",
"webgpu/shader/execution/tanh.bin": "96c30607",
"webgpu/shader/execution/transpose.bin": "8968d6f9",
"webgpu/shader/execution/trunc.bin": "6c17efc2",
"webgpu/shader/execution/unpack2x16float.bin": "f035f149",
"webgpu/shader/execution/unpack2x16snorm.bin": "e92a1762",
"webgpu/shader/execution/unpack2x16unorm.bin": "abe4e594",
"webgpu/shader/execution/unpack4x8snorm.bin": "9bb9c594",
"webgpu/shader/execution/unpack4x8unorm.bin": "53ceebc",
"webgpu/shader/execution/unary/af_arithmetic.bin": "cd5b7fa3",
"webgpu/shader/execution/unary/af_assignment.bin": "86b66309",
"webgpu/shader/execution/unary/bool_conversion.bin": "dd71f171",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "9537b14",
"webgpu/shader/execution/unary/f16_conversion.bin": "3948e7eb",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "f8aa7493",
"webgpu/shader/execution/unary/f32_conversion.bin": "7ee18c9e",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "c69716e2",
"webgpu/shader/execution/unary/i32_complement.bin": "70c49c98",
"webgpu/shader/execution/unary/i32_conversion.bin": "83218e69",
"webgpu/shader/execution/unary/u32_complement.bin": "84f3d299",
"webgpu/shader/execution/unary/u32_conversion.bin": "8f5bad00",
"webgpu/shader/execution/unary/ai_assignment.bin": "c7e6ac33",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "81c11ec2",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "3d27dc97"
}
Binary file modified src/resources/cache/webgpu/shader/execution/dot.bin
Binary file not shown.
10 changes: 8 additions & 2 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -1263,8 +1263,14 @@
"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:*": { "subcaseMS": 3.103 },
"webgpu:shader,execution,expression,call,builtin,dot:u32:*": { "subcaseMS": 3.101 },
"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,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
33 changes: 32 additions & 1 deletion src/webgpu/shader/execution/expression/call/builtin/dot.cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ import { kValue } from '../../../../../util/constants.js';
import { FP } from '../../../../../util/floating_point.js';
import {
calculatePermutations,
sparseVectorI32Range,
sparseVectorI64Range,
sparseVectorU32Range,
vectorI32Range,
vectorI64Range,
vectorU32Range,
} from '../../../../../util/math.js';
import { generateVectorVectorToI64Cases } from '../../case.js';
import {
generateVectorVectorToI32Cases,
generateVectorVectorToI64Cases,
generateVectorVectorToU32Cases,
} from '../../case.js';
import { makeCaseCache } from '../../case_cache.js';

function ai_dot(x: bigint[], y: bigint[]): bigint | undefined {
Expand Down Expand Up @@ -44,6 +52,11 @@ function ai_dot(x: bigint[], y: bigint[]): bigint | undefined {
return !kValue.i64.isOOB(result) ? result : undefined;
}

function ci_dot(x: number[], y: number[]): number | undefined {
assert(x.length === y.length, 'Cannot calculate dot for vectors of different lengths');
return x.reduce((prev, _, idx) => prev + Math.imul(x[idx], y[idx]), 0);
}

// Cases: [f32|f16]_vecN_[non_]const
const float_cases = (['f32', 'f16'] as const)
.flatMap(trait =>
Expand Down Expand Up @@ -75,6 +88,24 @@ const cases = {
abstract_int_vec4: () => {
return generateVectorVectorToI64Cases(sparseVectorI64Range(4), sparseVectorI64Range(4), ai_dot);
},
i32_vec2: () => {
return generateVectorVectorToI32Cases(vectorI32Range(2), vectorI32Range(2), ci_dot);
},
i32_vec3: () => {
return generateVectorVectorToI32Cases(sparseVectorI32Range(3), sparseVectorI32Range(3), ci_dot);
},
i32_vec4: () => {
return generateVectorVectorToI32Cases(sparseVectorI32Range(4), sparseVectorI32Range(4), ci_dot);
},
u32_vec2: () => {
return generateVectorVectorToU32Cases(vectorU32Range(2), vectorU32Range(2), ci_dot);
},
u32_vec3: () => {
return generateVectorVectorToU32Cases(sparseVectorU32Range(3), sparseVectorU32Range(3), ci_dot);
},
u32_vec4: () => {
return generateVectorVectorToU32Cases(sparseVectorU32Range(4), sparseVectorU32Range(4), ci_dot);
},
};

export const d = makeCaseCache('dot', cases);
Loading

0 comments on commit 57bd1b0

Please sign in to comment.