Skip to content

Commit

Permalink
Address kainino0x feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois committed Mar 6, 2024
1 parent 7a96c3c commit 4116482
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 201 deletions.
2 changes: 1 addition & 1 deletion src/common/internal/query/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function compareOneLevel(ordering: Ordering, aIsBig: boolean, bIsBig: boolean):
return Ordering.Unordered;
}

function comparePaths(a: readonly string[], b: readonly string[]): Ordering {
export function comparePaths(a: readonly string[], b: readonly string[]): Ordering {
const shorter = Math.min(a.length, b.length);

for (let i = 0; i < shorter; ++i) {
Expand Down
85 changes: 32 additions & 53 deletions src/common/runtime/helper/test_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,39 @@ import { TestQueryWithExpectation } from '../../internal/query/query.js';

import { CTSOptions, kDefaultCTSOptions } from './options.js';

export class TestDedicatedWorker {
private readonly ctsOptions: CTSOptions;
class TestBaseWorker {
protected readonly ctsOptions: CTSOptions;
protected readonly resolvers = new Map<string, (result: LiveTestCaseResult) => void>();

constructor(worker: CTSOptions['worker'], ctsOptions?: CTSOptions) {
this.ctsOptions = { ...(ctsOptions || kDefaultCTSOptions), ...{ worker } };
}

onmessage(ev: MessageEvent) {
const query: string = ev.data.query;
const result: TransferredTestCaseResult = ev.data.result;
if (result.logs) {
for (const l of result.logs) {
Object.setPrototypeOf(l, LogMessageWithStack.prototype);
}
}
this.resolvers.get(query)!(result as LiveTestCaseResult);

// MAINTENANCE_TODO(kainino0x): update the Logger with this result (or don't have a logger and
// update the entire results JSON somehow at some point).
}
}

export class TestDedicatedWorker extends TestBaseWorker {
private readonly worker: Worker;
private readonly resolvers = new Map<string, (result: LiveTestCaseResult) => void>();

constructor(ctsOptions?: CTSOptions) {
this.ctsOptions = { ...(ctsOptions || kDefaultCTSOptions), ...{ worker: 'dedicated' } };
super('dedicated', ctsOptions);
const selfPath = import.meta.url;
const selfPathDir = selfPath.substring(0, selfPath.lastIndexOf('/'));
const workerPath = selfPathDir + '/test_worker-worker.js';
this.worker = new Worker(workerPath, { type: 'module' });
this.worker.onmessage = ev => {
const query: string = ev.data.query;
const result: TransferredTestCaseResult = ev.data.result;
if (result.logs) {
for (const l of result.logs) {
Object.setPrototypeOf(l, LogMessageWithStack.prototype);
}
}
this.resolvers.get(query)!(result as LiveTestCaseResult);

// MAINTENANCE_TODO(kainino0x): update the Logger with this result (or don't have a logger and
// update the entire results JSON somehow at some point).
};
this.worker.onmessage = ev => this.onmessage(ev);
}

async run(
Expand All @@ -50,32 +59,18 @@ export class TestDedicatedWorker {

export class TestWorker extends TestDedicatedWorker {}

export class TestSharedWorker {
private readonly ctsOptions: CTSOptions;
export class TestSharedWorker extends TestBaseWorker {
private readonly port: MessagePort;
private readonly resolvers = new Map<string, (result: LiveTestCaseResult) => void>();

constructor(ctsOptions?: CTSOptions) {
this.ctsOptions = { ...(ctsOptions || kDefaultCTSOptions), ...{ worker: 'shared' } };
super('shared', ctsOptions);
const selfPath = import.meta.url;
const selfPathDir = selfPath.substring(0, selfPath.lastIndexOf('/'));
const workerPath = selfPathDir + '/test_worker-worker.js';
const worker = new SharedWorker(workerPath, { type: 'module' });
this.port = worker.port;
this.port.start();
this.port.onmessage = ev => {
const query: string = ev.data.query;
const result: TransferredTestCaseResult = ev.data.result;
if (result.logs) {
for (const l of result.logs) {
Object.setPrototypeOf(l, LogMessageWithStack.prototype);
}
}
this.resolvers.get(query)!(result as LiveTestCaseResult);

// MAINTENANCE_TODO(kainino0x): update the Logger with this result (or don't have a logger and
// update the entire results JSON somehow at some point).
};
this.port.onmessage = ev => this.onmessage(ev);
}

async run(
Expand All @@ -95,12 +90,9 @@ export class TestSharedWorker {
}
}

export class TestServiceWorker {
private readonly ctsOptions: CTSOptions;
private readonly resolvers = new Map<string, (result: LiveTestCaseResult) => void>();

export class TestServiceWorker extends TestBaseWorker {
constructor(ctsOptions?: CTSOptions) {
this.ctsOptions = { ...(ctsOptions || kDefaultCTSOptions), ...{ worker: 'service' } };
super('service', ctsOptions);
}

async run(
Expand All @@ -117,20 +109,7 @@ export class TestServiceWorker {
scope: '/',
});
await registration.update();

navigator.serviceWorker.onmessage = ev => {
const query: string = ev.data.query;
const result: TransferredTestCaseResult = ev.data.result;
if (result.logs) {
for (const l of result.logs) {
Object.setPrototypeOf(l, LogMessageWithStack.prototype);
}
}
this.resolvers.get(query)!(result as LiveTestCaseResult);

// MAINTENANCE_TODO(kainino0x): update the Logger with this result (or don't have a logger and
// update the entire results JSON somehow at some point).
};
navigator.serviceWorker.onmessage = ev => this.onmessage(ev);

registration.active?.postMessage({
query,
Expand Down
21 changes: 6 additions & 15 deletions src/common/tools/gen_listings_and_webworkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ import { globalTestConfig } from '/out/common/framework/test_config.js';
import { Logger } from '/out/common/internal/logging/logger.js';
import { setDefaultRequestAdapterOptions } from '/out/common/util/navigator_gpu.js';
import { parseQuery } from '/out/common/internal/query/parseQuery.js';
import { comparePublicParamsPaths, Ordering } from '/out/common/internal/query/compare.js';
import { comparePaths, comparePublicParamsPaths, Ordering } from '/out/common/internal/query/compare.js';
import { assert } from '/out/common/util/util.js';
async function reportTestResults(ev) {
self.onmessage = async (ev) => {
const query = ev.data.query;
const expectations = ev.data.expectations;
const ctsOptions = ev.data.ctsOptions;
Expand All @@ -111,6 +111,9 @@ async function reportTestResults(ev) {
const testQuerySingleCase = parseQuery(query);
let testcase = null;
for (const t of g.iterate()) {
if (comparePaths(t.testPath, testQuerySingleCase.testPathParts) !== Ordering.Equal) {
continue;
}
for (const c of t.iterate(testQuerySingleCase.params)) {
if (comparePublicParamsPaths(c.id.params, testQuerySingleCase.params) === Ordering.Equal) {
testcase = c;
Expand All @@ -120,20 +123,8 @@ async function reportTestResults(ev) {
assert(testcase);
const [rec, result] = log.record(query);
await testcase.run(rec, testQuerySingleCase, expectations);
this.postMessage({ query, result });
ev.source.postMessage({ query, result });
}
self.onmessage = (ev) => {
void reportTestResults.call(ev.source || self, ev);
};
self.onconnect = (event) => {
const port = event.ports[0];
port.onmessage = (ev) => {
void reportTestResults.call(port, ev);
};
};
`
);
}
Expand Down
210 changes: 105 additions & 105 deletions src/resources/cache/hashes.json
Original file line number Diff line number Diff line change
@@ -1,107 +1,107 @@
{
"webgpu/shader/execution/binary/af_addition.bin": "fc43d206",
"webgpu/shader/execution/binary/af_logical.bin": "3dc912ac",
"webgpu/shader/execution/binary/af_division.bin": "6cbdaf09",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "d61fe049",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "16d18276",
"webgpu/shader/execution/binary/af_multiplication.bin": "ce2a0e9e",
"webgpu/shader/execution/binary/af_remainder.bin": "4032e3cf",
"webgpu/shader/execution/binary/af_subtraction.bin": "67a1c189",
"webgpu/shader/execution/binary/f16_addition.bin": "3edd84a3",
"webgpu/shader/execution/binary/f16_logical.bin": "adcc36e9",
"webgpu/shader/execution/binary/f16_division.bin": "81168258",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "3497729d",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "767e22c7",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "356acec0",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "ed00c0e4",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "f089b873",
"webgpu/shader/execution/binary/f16_multiplication.bin": "4675c758",
"webgpu/shader/execution/binary/f16_remainder.bin": "5ea2af46",
"webgpu/shader/execution/binary/f16_subtraction.bin": "a7962472",
"webgpu/shader/execution/binary/f32_addition.bin": "ef624c29",
"webgpu/shader/execution/binary/f32_logical.bin": "68c1e846",
"webgpu/shader/execution/binary/f32_division.bin": "cc886305",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "b3bab14a",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "afccd9d5",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "c8a022a1",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "b0db93fb",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "d90fbe21",
"webgpu/shader/execution/binary/f32_multiplication.bin": "693597cf",
"webgpu/shader/execution/binary/f32_remainder.bin": "fe630a4b",
"webgpu/shader/execution/binary/f32_subtraction.bin": "e3409ba2",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "bd8d0b9b",
"webgpu/shader/execution/binary/i32_comparison.bin": "aec6e622",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "f5907c7e",
"webgpu/shader/execution/binary/u32_comparison.bin": "7160f1c7",
"webgpu/shader/execution/abs.bin": "c884966",
"webgpu/shader/execution/acos.bin": "3e371b22",
"webgpu/shader/execution/acosh.bin": "25b25012",
"webgpu/shader/execution/asin.bin": "75d5b677",
"webgpu/shader/execution/asinh.bin": "92fe4ad3",
"webgpu/shader/execution/atan.bin": "5a7834a4",
"webgpu/shader/execution/atan2.bin": "79487bb",
"webgpu/shader/execution/atanh.bin": "804ad33f",
"webgpu/shader/execution/bitcast.bin": "69a86c70",
"webgpu/shader/execution/ceil.bin": "46bca9a0",
"webgpu/shader/execution/clamp.bin": "620739ae",
"webgpu/shader/execution/cos.bin": "bd7467e4",
"webgpu/shader/execution/cosh.bin": "315aad98",
"webgpu/shader/execution/cross.bin": "d9a91811",
"webgpu/shader/execution/degrees.bin": "27df6eb0",
"webgpu/shader/execution/determinant.bin": "67380eba",
"webgpu/shader/execution/distance.bin": "91d94128",
"webgpu/shader/execution/dot.bin": "3644a88a",
"webgpu/shader/execution/exp.bin": "786e68bc",
"webgpu/shader/execution/exp2.bin": "454ee68d",
"webgpu/shader/execution/faceForward.bin": "625903d3",
"webgpu/shader/execution/floor.bin": "db4c92f7",
"webgpu/shader/execution/fma.bin": "b049ac43",
"webgpu/shader/execution/fract.bin": "84ce9ec3",
"webgpu/shader/execution/frexp.bin": "5320c481",
"webgpu/shader/execution/inverseSqrt.bin": "7aeff2c0",
"webgpu/shader/execution/ldexp.bin": "71b3930f",
"webgpu/shader/execution/length.bin": "e96b503a",
"webgpu/shader/execution/log.bin": "eba7ec7d",
"webgpu/shader/execution/log2.bin": "54ddf967",
"webgpu/shader/execution/max.bin": "a83a582a",
"webgpu/shader/execution/min.bin": "7c2811c1",
"webgpu/shader/execution/mix.bin": "9aa0305f",
"webgpu/shader/execution/modf.bin": "ca3173c2",
"webgpu/shader/execution/normalize.bin": "3c3a347f",
"webgpu/shader/execution/pack2x16float.bin": "73ddf92f",
"webgpu/shader/execution/pow.bin": "d2c3fd97",
"webgpu/shader/execution/quantizeToF16.bin": "ad3587f0",
"webgpu/shader/execution/radians.bin": "d5f10c52",
"webgpu/shader/execution/reflect.bin": "219e2df",
"webgpu/shader/execution/refract.bin": "fa841745",
"webgpu/shader/execution/round.bin": "74f863ec",
"webgpu/shader/execution/saturate.bin": "457fd49d",
"webgpu/shader/execution/sign.bin": "e44d954c",
"webgpu/shader/execution/sin.bin": "67bac1fd",
"webgpu/shader/execution/sinh.bin": "e37cb02b",
"webgpu/shader/execution/smoothstep.bin": "d279bc42",
"webgpu/shader/execution/sqrt.bin": "551939af",
"webgpu/shader/execution/step.bin": "72cf60af",
"webgpu/shader/execution/tan.bin": "f632f032",
"webgpu/shader/execution/tanh.bin": "72c375cb",
"webgpu/shader/execution/transpose.bin": "e968d355",
"webgpu/shader/execution/trunc.bin": "16f79aa5",
"webgpu/shader/execution/unpack2x16float.bin": "c85da768",
"webgpu/shader/execution/unpack2x16snorm.bin": "3f3dbc81",
"webgpu/shader/execution/unpack2x16unorm.bin": "2862cb20",
"webgpu/shader/execution/unpack4x8snorm.bin": "b4c90280",
"webgpu/shader/execution/unpack4x8unorm.bin": "ab1a627b",
"webgpu/shader/execution/unary/af_arithmetic.bin": "67d2b7eb",
"webgpu/shader/execution/unary/af_assignment.bin": "7964e983",
"webgpu/shader/execution/unary/bool_conversion.bin": "349303eb",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "95908291",
"webgpu/shader/execution/unary/f16_conversion.bin": "df34e3f9",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "dea317cd",
"webgpu/shader/execution/unary/f32_conversion.bin": "fb0ff55a",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "d1b09384",
"webgpu/shader/execution/unary/i32_conversion.bin": "7ae3fc76",
"webgpu/shader/execution/unary/u32_conversion.bin": "a1c35c09",
"webgpu/shader/execution/unary/ai_assignment.bin": "bde2f00d",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "f99fb5b7",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "5784ac67"
"webgpu/shader/execution/binary/af_addition.bin": "26c839f3",
"webgpu/shader/execution/binary/af_logical.bin": "8cb7baa9",
"webgpu/shader/execution/binary/af_division.bin": "5bfa337d",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "15e2cc6c",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "c4053c51",
"webgpu/shader/execution/binary/af_multiplication.bin": "56dcbeb",
"webgpu/shader/execution/binary/af_remainder.bin": "2a54afb8",
"webgpu/shader/execution/binary/af_subtraction.bin": "747e33d",
"webgpu/shader/execution/binary/f16_addition.bin": "d436308a",
"webgpu/shader/execution/binary/f16_logical.bin": "c5c10109",
"webgpu/shader/execution/binary/f16_division.bin": "f3415323",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "a7048e1e",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "e61dd111",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "b15ead1a",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "eb73c16b",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "87122cb2",
"webgpu/shader/execution/binary/f16_multiplication.bin": "3e1cfdd",
"webgpu/shader/execution/binary/f16_remainder.bin": "22772021",
"webgpu/shader/execution/binary/f16_subtraction.bin": "ef25c2b3",
"webgpu/shader/execution/binary/f32_addition.bin": "a8c1fead",
"webgpu/shader/execution/binary/f32_logical.bin": "61cb3658",
"webgpu/shader/execution/binary/f32_division.bin": "3611d929",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "c4e0ba95",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "b955da3b",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "88771f84",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "9a4c11b5",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "68855926",
"webgpu/shader/execution/binary/f32_multiplication.bin": "71a27ae2",
"webgpu/shader/execution/binary/f32_remainder.bin": "d969b12a",
"webgpu/shader/execution/binary/f32_subtraction.bin": "8f224610",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "30ad7a5a",
"webgpu/shader/execution/binary/i32_comparison.bin": "77147f47",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "ec2909af",
"webgpu/shader/execution/binary/u32_comparison.bin": "522ceb7a",
"webgpu/shader/execution/abs.bin": "8c2cd451",
"webgpu/shader/execution/acos.bin": "51d44bce",
"webgpu/shader/execution/acosh.bin": "42108617",
"webgpu/shader/execution/asin.bin": "8cdfa135",
"webgpu/shader/execution/asinh.bin": "c4098f08",
"webgpu/shader/execution/atan.bin": "d2c4c6f4",
"webgpu/shader/execution/atan2.bin": "458d806",
"webgpu/shader/execution/atanh.bin": "1f3046d7",
"webgpu/shader/execution/bitcast.bin": "bc4ef138",
"webgpu/shader/execution/ceil.bin": "d63bfa45",
"webgpu/shader/execution/clamp.bin": "a72cc7a0",
"webgpu/shader/execution/cos.bin": "4b942fe6",
"webgpu/shader/execution/cosh.bin": "3f4e8659",
"webgpu/shader/execution/cross.bin": "5896e7d4",
"webgpu/shader/execution/degrees.bin": "ddf99143",
"webgpu/shader/execution/determinant.bin": "6541e6e",
"webgpu/shader/execution/distance.bin": "9c5f12ff",
"webgpu/shader/execution/dot.bin": "20287700",
"webgpu/shader/execution/exp.bin": "f2fdb481",
"webgpu/shader/execution/exp2.bin": "98e68bd",
"webgpu/shader/execution/faceForward.bin": "628bb202",
"webgpu/shader/execution/floor.bin": "a90e2bd9",
"webgpu/shader/execution/fma.bin": "197dba2b",
"webgpu/shader/execution/fract.bin": "d06f909b",
"webgpu/shader/execution/frexp.bin": "f9892b7b",
"webgpu/shader/execution/inverseSqrt.bin": "126eeeca",
"webgpu/shader/execution/ldexp.bin": "5b190eb8",
"webgpu/shader/execution/length.bin": "4928fb2",
"webgpu/shader/execution/log.bin": "1041194c",
"webgpu/shader/execution/log2.bin": "e34a4602",
"webgpu/shader/execution/max.bin": "a9f2264c",
"webgpu/shader/execution/min.bin": "f73df563",
"webgpu/shader/execution/mix.bin": "63c7abe1",
"webgpu/shader/execution/modf.bin": "72a62d62",
"webgpu/shader/execution/normalize.bin": "123fbc90",
"webgpu/shader/execution/pack2x16float.bin": "87b76e98",
"webgpu/shader/execution/pow.bin": "8434384c",
"webgpu/shader/execution/quantizeToF16.bin": "46f03192",
"webgpu/shader/execution/radians.bin": "b951d73",
"webgpu/shader/execution/reflect.bin": "23d10a66",
"webgpu/shader/execution/refract.bin": "34a865b3",
"webgpu/shader/execution/round.bin": "1e011783",
"webgpu/shader/execution/saturate.bin": "17607b79",
"webgpu/shader/execution/sign.bin": "9bea75b2",
"webgpu/shader/execution/sin.bin": "874922c6",
"webgpu/shader/execution/sinh.bin": "b634ab6c",
"webgpu/shader/execution/smoothstep.bin": "c75008c",
"webgpu/shader/execution/sqrt.bin": "87847268",
"webgpu/shader/execution/step.bin": "c9776350",
"webgpu/shader/execution/tan.bin": "f11f930b",
"webgpu/shader/execution/tanh.bin": "c86dce7c",
"webgpu/shader/execution/transpose.bin": "3e691d19",
"webgpu/shader/execution/trunc.bin": "b8cedd5e",
"webgpu/shader/execution/unpack2x16float.bin": "164932c2",
"webgpu/shader/execution/unpack2x16snorm.bin": "14430f38",
"webgpu/shader/execution/unpack2x16unorm.bin": "2c798bbc",
"webgpu/shader/execution/unpack4x8snorm.bin": "9fd6301",
"webgpu/shader/execution/unpack4x8unorm.bin": "534c4f7b",
"webgpu/shader/execution/unary/af_arithmetic.bin": "a2a92cc7",
"webgpu/shader/execution/unary/af_assignment.bin": "8b36668",
"webgpu/shader/execution/unary/bool_conversion.bin": "2a937fe2",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "f362e104",
"webgpu/shader/execution/unary/f16_conversion.bin": "a33af291",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "9d4ebd3d",
"webgpu/shader/execution/unary/f32_conversion.bin": "55b007fd",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "188397c0",
"webgpu/shader/execution/unary/i32_conversion.bin": "ffa6aa43",
"webgpu/shader/execution/unary/u32_conversion.bin": "8dffc602",
"webgpu/shader/execution/unary/ai_assignment.bin": "a84b66e",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "77d0d588",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "5b0fe7e"
}
Loading

0 comments on commit 4116482

Please sign in to comment.