Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wgsl: Replace CaseList with Case[] #3463

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 108 additions & 108 deletions src/resources/cache/hashes.json
Original file line number Diff line number Diff line change
@@ -1,110 +1,110 @@
{
"webgpu/shader/execution/binary/af_addition.bin": "de575056",
"webgpu/shader/execution/binary/af_logical.bin": "dc2105f8",
"webgpu/shader/execution/binary/af_division.bin": "d7e6d98f",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "c215cf6d",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "57892276",
"webgpu/shader/execution/binary/af_multiplication.bin": "4c282ac2",
"webgpu/shader/execution/binary/af_remainder.bin": "9fdddf97",
"webgpu/shader/execution/binary/af_subtraction.bin": "a27de3c1",
"webgpu/shader/execution/binary/f16_addition.bin": "ecc2aa17",
"webgpu/shader/execution/binary/f16_logical.bin": "1851f647",
"webgpu/shader/execution/binary/f16_division.bin": "2cfec6de",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "f5b6ef4f",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "c47070a0",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "30b9d67c",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "46b631ba",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "19e6a937",
"webgpu/shader/execution/binary/f16_multiplication.bin": "8fbfc97c",
"webgpu/shader/execution/binary/f16_remainder.bin": "66cd384c",
"webgpu/shader/execution/binary/f16_subtraction.bin": "8b5fed3d",
"webgpu/shader/execution/binary/f32_addition.bin": "2ef1211a",
"webgpu/shader/execution/binary/f32_logical.bin": "3c97c69d",
"webgpu/shader/execution/binary/f32_division.bin": "2867ef0a",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "da9390d1",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "2d67296e",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "c79709f5",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "38b7c05f",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "f9b675d7",
"webgpu/shader/execution/binary/f32_multiplication.bin": "bb7ee512",
"webgpu/shader/execution/binary/f32_remainder.bin": "e0d16b8f",
"webgpu/shader/execution/binary/f32_subtraction.bin": "755fc63",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "3c1d6f0f",
"webgpu/shader/execution/binary/i32_comparison.bin": "4759dfea",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "6bf6989d",
"webgpu/shader/execution/binary/u32_comparison.bin": "ca8b140b",
"webgpu/shader/execution/abs.bin": "a79b85f3",
"webgpu/shader/execution/acos.bin": "eed1c72",
"webgpu/shader/execution/acosh.bin": "a1b7dc12",
"webgpu/shader/execution/asin.bin": "fbf69cb0",
"webgpu/shader/execution/asinh.bin": "7b8f7a8",
"webgpu/shader/execution/atan.bin": "250334d8",
"webgpu/shader/execution/atan2.bin": "9df3f787",
"webgpu/shader/execution/atanh.bin": "5c79c30d",
"webgpu/shader/execution/bitcast.bin": "964fdecd",
"webgpu/shader/execution/ceil.bin": "246bf087",
"webgpu/shader/execution/clamp.bin": "3a299eaf",
"webgpu/shader/execution/cos.bin": "d3efc52b",
"webgpu/shader/execution/cosh.bin": "867cbf85",
"webgpu/shader/execution/cross.bin": "a1089567",
"webgpu/shader/execution/degrees.bin": "d1cfaeac",
"webgpu/shader/execution/determinant.bin": "44faf0f8",
"webgpu/shader/execution/distance.bin": "e1191c92",
"webgpu/shader/execution/dot.bin": "242201b",
"webgpu/shader/execution/exp.bin": "e5f97f39",
"webgpu/shader/execution/exp2.bin": "65bd37ec",
"webgpu/shader/execution/faceForward.bin": "ebb6017a",
"webgpu/shader/execution/floor.bin": "a24e0ff8",
"webgpu/shader/execution/fma.bin": "87615a5f",
"webgpu/shader/execution/fract.bin": "eab1b9fa",
"webgpu/shader/execution/frexp.bin": "7dd8033",
"webgpu/shader/execution/inverseSqrt.bin": "356b47c5",
"webgpu/shader/execution/ldexp.bin": "788fdf3e",
"webgpu/shader/execution/length.bin": "69f13c20",
"webgpu/shader/execution/log.bin": "dc9c311c",
"webgpu/shader/execution/log2.bin": "d1a49443",
"webgpu/shader/execution/max.bin": "6750f2eb",
"webgpu/shader/execution/min.bin": "c8200395",
"webgpu/shader/execution/mix.bin": "86c40712",
"webgpu/shader/execution/modf.bin": "50483a83",
"webgpu/shader/execution/normalize.bin": "244a8e05",
"webgpu/shader/execution/pack2x16float.bin": "dcd8656d",
"webgpu/shader/execution/pow.bin": "633c917a",
"webgpu/shader/execution/quantizeToF16.bin": "f6044bd2",
"webgpu/shader/execution/radians.bin": "a90b21ea",
"webgpu/shader/execution/reflect.bin": "670fbba2",
"webgpu/shader/execution/refract.bin": "63b06feb",
"webgpu/shader/execution/round.bin": "d4c09bde",
"webgpu/shader/execution/saturate.bin": "d4f8a4d0",
"webgpu/shader/execution/sign.bin": "57c988b9",
"webgpu/shader/execution/sin.bin": "59aab9f5",
"webgpu/shader/execution/sinh.bin": "3890a90c",
"webgpu/shader/execution/smoothstep.bin": "b695fd45",
"webgpu/shader/execution/sqrt.bin": "9524c93",
"webgpu/shader/execution/step.bin": "b9cc90a4",
"webgpu/shader/execution/tan.bin": "e5792957",
"webgpu/shader/execution/tanh.bin": "ba99c688",
"webgpu/shader/execution/transpose.bin": "83588805",
"webgpu/shader/execution/trunc.bin": "aad5d037",
"webgpu/shader/execution/unpack2x16float.bin": "493cbe7b",
"webgpu/shader/execution/unpack2x16snorm.bin": "fd0b5eb9",
"webgpu/shader/execution/unpack2x16unorm.bin": "f7436a6c",
"webgpu/shader/execution/unpack4x8snorm.bin": "eca842d9",
"webgpu/shader/execution/unpack4x8unorm.bin": "8654f67e",
"webgpu/shader/execution/unary/af_arithmetic.bin": "e05d3c45",
"webgpu/shader/execution/unary/af_assignment.bin": "45da8cfe",
"webgpu/shader/execution/unary/bool_conversion.bin": "dd71f171",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "9c17fdca",
"webgpu/shader/execution/unary/f16_conversion.bin": "c02b6c8",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "feff26f7",
"webgpu/shader/execution/unary/f32_conversion.bin": "f2639f4c",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "c69716e2",
"webgpu/shader/execution/unary/i32_conversion.bin": "83218e69",
"webgpu/shader/execution/unary/u32_conversion.bin": "8f5bad00",
"webgpu/shader/execution/unary/ai_assignment.bin": "c7e6ac33",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "dfcd593a",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "3d27dc97",
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "7e551ea1",
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "fe7ea65b",
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "2a98deaa"
"webgpu/shader/execution/binary/af_addition.bin": "4440d4b4",
"webgpu/shader/execution/binary/af_logical.bin": "c54d7fff",
"webgpu/shader/execution/binary/af_division.bin": "d17fa436",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "7a788e99",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "f84dd903",
"webgpu/shader/execution/binary/af_multiplication.bin": "5334f9e1",
"webgpu/shader/execution/binary/af_remainder.bin": "470a66d7",
"webgpu/shader/execution/binary/af_subtraction.bin": "2c78e197",
"webgpu/shader/execution/binary/f16_addition.bin": "a579fc47",
"webgpu/shader/execution/binary/f16_logical.bin": "1f3267c4",
"webgpu/shader/execution/binary/f16_division.bin": "dfb9f322",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "ca9128f5",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "88155047",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "15278661",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "aaa23b6",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "7d9e4d5c",
"webgpu/shader/execution/binary/f16_multiplication.bin": "f9d4994",
"webgpu/shader/execution/binary/f16_remainder.bin": "244c4ad6",
"webgpu/shader/execution/binary/f16_subtraction.bin": "ed388083",
"webgpu/shader/execution/binary/f32_addition.bin": "22c323e7",
"webgpu/shader/execution/binary/f32_logical.bin": "b5a1fcd6",
"webgpu/shader/execution/binary/f32_division.bin": "af0c6a91",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "cea1c11f",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "4ca215e2",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "e0ecc16f",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "cd1f8542",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "d4d592a1",
"webgpu/shader/execution/binary/f32_multiplication.bin": "bad73246",
"webgpu/shader/execution/binary/f32_remainder.bin": "fd8b81ca",
"webgpu/shader/execution/binary/f32_subtraction.bin": "ab7a62cd",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "390c929d",
"webgpu/shader/execution/binary/i32_comparison.bin": "21a872e9",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "b6785d3e",
"webgpu/shader/execution/binary/u32_comparison.bin": "20e75aaf",
"webgpu/shader/execution/abs.bin": "7a1a8101",
"webgpu/shader/execution/acos.bin": "4f35a566",
"webgpu/shader/execution/acosh.bin": "1ddcdd7f",
"webgpu/shader/execution/asin.bin": "8c73cd",
"webgpu/shader/execution/asinh.bin": "9737e4c9",
"webgpu/shader/execution/atan.bin": "1274adbb",
"webgpu/shader/execution/atan2.bin": "6d414c8c",
"webgpu/shader/execution/atanh.bin": "ae463ca8",
"webgpu/shader/execution/bitcast.bin": "6acaafbe",
"webgpu/shader/execution/ceil.bin": "891015dc",
"webgpu/shader/execution/clamp.bin": "b1a757bd",
"webgpu/shader/execution/cos.bin": "1754b8bf",
"webgpu/shader/execution/cosh.bin": "db77b7bb",
"webgpu/shader/execution/cross.bin": "b4242751",
"webgpu/shader/execution/degrees.bin": "c19fa30",
"webgpu/shader/execution/determinant.bin": "28eea1a1",
"webgpu/shader/execution/distance.bin": "286532ef",
"webgpu/shader/execution/dot.bin": "68354d0d",
"webgpu/shader/execution/exp.bin": "8df9e76d",
"webgpu/shader/execution/exp2.bin": "494e5007",
"webgpu/shader/execution/faceForward.bin": "944e22",
"webgpu/shader/execution/floor.bin": "24434e6e",
"webgpu/shader/execution/fma.bin": "14d92aba",
"webgpu/shader/execution/fract.bin": "7bc1425a",
"webgpu/shader/execution/frexp.bin": "f6631fec",
"webgpu/shader/execution/inverseSqrt.bin": "511e859",
"webgpu/shader/execution/ldexp.bin": "f5d530d6",
"webgpu/shader/execution/length.bin": "b3dac96e",
"webgpu/shader/execution/log.bin": "34156eea",
"webgpu/shader/execution/log2.bin": "877d274b",
"webgpu/shader/execution/max.bin": "42174209",
"webgpu/shader/execution/min.bin": "e3ebfbb8",
"webgpu/shader/execution/mix.bin": "fd942c9a",
"webgpu/shader/execution/modf.bin": "1679c273",
"webgpu/shader/execution/normalize.bin": "be31d825",
"webgpu/shader/execution/pack2x16float.bin": "7e3e86c3",
"webgpu/shader/execution/pow.bin": "bf4ec2d7",
"webgpu/shader/execution/quantizeToF16.bin": "5d067d96",
"webgpu/shader/execution/radians.bin": "ebe086b6",
"webgpu/shader/execution/reflect.bin": "700f38a0",
"webgpu/shader/execution/refract.bin": "c859267f",
"webgpu/shader/execution/round.bin": "88045cd4",
"webgpu/shader/execution/saturate.bin": "dae68a14",
"webgpu/shader/execution/sign.bin": "91b4c481",
"webgpu/shader/execution/sin.bin": "1300bbbf",
"webgpu/shader/execution/sinh.bin": "27ab484c",
"webgpu/shader/execution/smoothstep.bin": "cfcaa136",
"webgpu/shader/execution/sqrt.bin": "4ae8ec04",
"webgpu/shader/execution/step.bin": "a83d7ab5",
"webgpu/shader/execution/tan.bin": "68b7a197",
"webgpu/shader/execution/tanh.bin": "32474b6e",
"webgpu/shader/execution/transpose.bin": "84e5ec15",
"webgpu/shader/execution/trunc.bin": "2fb9f2b",
"webgpu/shader/execution/unpack2x16float.bin": "4eef83ca",
"webgpu/shader/execution/unpack2x16snorm.bin": "5a8de9dc",
"webgpu/shader/execution/unpack2x16unorm.bin": "24b228cc",
"webgpu/shader/execution/unpack4x8snorm.bin": "7d98eec7",
"webgpu/shader/execution/unpack4x8unorm.bin": "546459f9",
"webgpu/shader/execution/unary/af_arithmetic.bin": "e31cea5d",
"webgpu/shader/execution/unary/af_assignment.bin": "ce59880f",
"webgpu/shader/execution/unary/bool_conversion.bin": "1bae513f",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "9276efd8",
"webgpu/shader/execution/unary/f16_conversion.bin": "254f60da",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "ed5d236e",
"webgpu/shader/execution/unary/f32_conversion.bin": "c570be4c",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "cc46fe",
"webgpu/shader/execution/unary/i32_conversion.bin": "457ade75",
"webgpu/shader/execution/unary/u32_conversion.bin": "4900fd1c",
"webgpu/shader/execution/unary/ai_assignment.bin": "1bdfc2f",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "80388ed7",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "fb7c8c8b",
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "64af08ac",
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "58e9a3ca",
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "77ca543f"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Execution Tests for the bitwise shift binary expression operations
import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { i32, scalarType, ScalarType, TypeU32, u32 } from '../../../../util/conversion.js';
import { CaseList } from '../case.js';
import { Case } from '../case.js';
import { allInputSources, run } from '../expression.js';

import { binary, compoundBinary } from './binary.js';
Expand Down Expand Up @@ -66,9 +66,9 @@ function is_valid_const_shift_right(e1: number, e1Type: string, e2: number) {

// Returns all cases of shifting e1 left by [0,63]. If `is_const` is true, cases that are
// invalid for const eval are not returned.
function generate_shift_left_cases(e1: number, e1Type: string, is_const: boolean): CaseList {
function generate_shift_left_cases(e1: number, e1Type: string, is_const: boolean): Case[] {
const V = e1Type === 'i32' ? i32 : u32;
const cases: CaseList = [];
const cases: Case[] = [];
for (let shift = 0; shift < 64; ++shift) {
const e2 = shift;
if (is_const && !is_valid_const_shift_left(e1, e1Type, e2)) {
Expand All @@ -82,9 +82,9 @@ function generate_shift_left_cases(e1: number, e1Type: string, is_const: boolean

// Returns all cases of shifting e1 right by [0,63]. If `is_const` is true, cases that are
// invalid for const eval are not returned.
function generate_shift_right_cases(e1: number, e1Type: string, is_const: boolean): CaseList {
function generate_shift_right_cases(e1: number, e1Type: string, is_const: boolean): Case[] {
const V = e1Type === 'i32' ? i32 : u32;
const cases: CaseList = [];
const cases: Case[] = [];
for (let shift = 0; shift < 64; ++shift) {
const e2 = shift;
if (is_const && !is_valid_const_shift_right(e1, e1Type, e2)) {
Expand All @@ -108,7 +108,7 @@ function makeShiftLeftConcreteCases(inputType: string, inputSource: string, type
const V = inputType === 'i32' ? i32 : u32;
const is_const = inputSource === 'const';

const cases: CaseList = [
const cases: Case[] = [
{
input: /* */ [V(0b00000000000000000000000000000001), u32(1)],
expected: /**/ V(0b00000000000000000000000000000010),
Expand Down Expand Up @@ -222,7 +222,7 @@ function makeShiftRightConcreteCases(inputType: string, inputSource: string, typ
const V = inputType === 'i32' ? i32 : u32;
const is_const = inputSource === 'const';

const cases: CaseList = [
const cases: Case[] = [
{
input: /* */ [V(0b00000000000000000000000000000001), u32(1)],
expected: /**/ V(0b00000000000000000000000000000000),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
abstractInt,
Scalar,
} from '../../../../../util/conversion.js';
import { CaseList } from '../../case.js';
import { Case } from '../../case.js';
import { run, allInputSources } from '../../expression.js';

import { abstractFloatBuiltin, abstractIntBuiltin, builtin } from './builtin.js';
Expand Down Expand Up @@ -198,7 +198,7 @@ g.test('vector')
const T = True;
const F = False;

let tests: { dataType: VectorType; boolType: VectorType; cases: CaseList };
let tests: { dataType: VectorType; boolType: VectorType; cases: Case[] };

switch (t.params.overload) {
case 'vec2': {
Expand Down
5 changes: 1 addition & 4 deletions src/webgpu/shader/execution/expression/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ export type Case = {
expected: Expectation;
};

/** CaseList is a list of Cases */
export type CaseList = Array<Case>;

/**
* Filters a given set of Cases down to a target number of cases by
* randomly selecting which Cases to return.
Expand Down Expand Up @@ -58,7 +55,7 @@ export type CaseList = Array<Case>;
* items, they can just use [].
* @param cases list of Cases to be selected from.
*/
export function selectNCases(dis: string, n: number, cases: CaseList): CaseList {
export function selectNCases(dis: string, n: number, cases: Case[]): Case[] {
assert(n > 0 && Math.round(n) === n, `n ${n} is expected to be a positive integer`);
const count = cases.length;
if (n >= count) {
Expand Down
22 changes: 11 additions & 11 deletions src/webgpu/shader/execution/expression/case_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '../../../util/floating_point.js';
import { flatten2DArray, unflatten2DArray } from '../../../util/math.js';

import { Case, CaseList } from './case.js';
import { Case } from './case.js';
import { Expectation, isComparator } from './expectation.js';

enum SerializedExpectationKind {
Expand Down Expand Up @@ -123,15 +123,15 @@ export function deserializeCase(s: BinaryStream): Case {
return { input, expected };
}

/** CaseListBuilder is a function that builds a CaseList */
export type CaseListBuilder = () => CaseList;
/** CaseListBuilder is a function that builds a list of cases, Case[] */
export type CaseListBuilder = () => Case[];

/**
* CaseCache is a cache of CaseList.
* CaseCache is a cache of Case[].
* CaseCache implements the Cacheable interface, so the cases can be pre-built
* and stored in the data cache, reducing computation costs at CTS runtime.
*/
export class CaseCache implements Cacheable<Record<string, CaseList>> {
export class CaseCache implements Cacheable<Record<string, Case[]>> {
/**
* Constructor
* @param name the name of the cache. This must be globally unique.
Expand All @@ -143,7 +143,7 @@ export class CaseCache implements Cacheable<Record<string, CaseList>> {
}

/** get() returns the list of cases with the given name */
public async get(name: string): Promise<CaseList> {
public async get(name: string): Promise<Case[]> {
const data = await dataCache.fetch(this);
return data[name];
}
Expand All @@ -152,8 +152,8 @@ export class CaseCache implements Cacheable<Record<string, CaseList>> {
* build() implements the Cacheable.build interface.
* @returns the data.
*/
build(): Promise<Record<string, CaseList>> {
const built: Record<string, CaseList> = {};
build(): Promise<Record<string, Case[]>> {
const built: Record<string, Case[]> = {};
for (const name in this.builders) {
const cases = this.builders[name]();
built[name] = cases;
Expand All @@ -165,7 +165,7 @@ export class CaseCache implements Cacheable<Record<string, CaseList>> {
* serialize() implements the Cacheable.serialize interface.
* @returns the serialized data.
*/
serialize(data: Record<string, CaseList>): Uint8Array {
serialize(data: Record<string, Case[]>): Uint8Array {
const maxSize = 32 << 20; // 32MB - max size for a file
const stream = new BinaryStream(new ArrayBuffer(maxSize));
stream.writeU32(Object.keys(data).length);
Expand All @@ -180,9 +180,9 @@ export class CaseCache implements Cacheable<Record<string, CaseList>> {
* deserialize() implements the Cacheable.deserialize interface.
* @returns the deserialize data.
*/
deserialize(array: Uint8Array): Record<string, CaseList> {
deserialize(array: Uint8Array): Record<string, Case[]> {
const s = new BinaryStream(array.buffer);
const casesByName: Record<string, CaseList> = {};
const casesByName: Record<string, Case[]> = {};
const numRecords = s.readU32();
for (let i = 0; i < numRecords; i++) {
const name = s.readString();
Expand Down
Loading
Loading