Skip to content

Commit

Permalink
Restore ?worker and ?worker=1 to mean ?worker=dedicated (#3485)
Browse files Browse the repository at this point in the history
The parsing for `?worker` and `?worker=1` changed with the addition of
`?worker=shared` but these should keep being treated the way they were
before.
  • Loading branch information
kainino0x authored Mar 12, 2024
1 parent 53158b8 commit 3c2c107
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 122 deletions.
2 changes: 1 addition & 1 deletion docs/intro/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The following url parameters change how the harness runs:

- `runnow=1` runs all matching tests on page load.
- `debug=1` enables verbose debug logging from tests.
- `worker=dedicated` runs the tests on a dedicated worker instead of the main thread.
- `worker=dedicated` (or `worker` or `worker=1`) runs the tests on a dedicated worker instead of the main thread.
- `worker=shared` runs the tests on a shared worker instead of the main thread.
- `worker=service` runs the tests on a service worker instead of the main thread.
- `power_preference=low-power` runs most tests passing `powerPreference: low-power` to `requestAdapter`
Expand Down
4 changes: 2 additions & 2 deletions src/common/internal/query/query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TestParams } from '../../framework/fixture.js';
import { optionString } from '../../runtime/helper/options.js';
import { optionWorkerMode } from '../../runtime/helper/options.js';
import { assert, unreachable } from '../../util/util.js';
import { Expectation } from '../logging/result.js';

Expand Down Expand Up @@ -193,7 +193,7 @@ Expectation should be of the form path/to/cts.https.html?debug=0&q=suite:test_pa
);

const params = expectationURL.searchParams;
if (optionString('worker', params) !== optionString('worker', wptURL.searchParams)) {
if (optionWorkerMode('worker', params) !== optionWorkerMode('worker', wptURL.searchParams)) {
continue;
}

Expand Down
34 changes: 29 additions & 5 deletions src/common/runtime/helper/options.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { unreachable } from '../../util/util.js';

let windowURL: URL | undefined = undefined;
function getWindowURL() {
if (windowURL === undefined) {
Expand All @@ -6,6 +8,7 @@ function getWindowURL() {
return windowURL;
}

/** Parse a runner option that is always boolean-typed. False if missing or '0'. */
export function optionEnabled(
opt: string,
searchParams: URLSearchParams = getWindowURL().searchParams
Expand All @@ -14,27 +17,48 @@ export function optionEnabled(
return val !== null && val !== '0';
}

/** Parse a runner option that is always string-typed. If the option is missing, returns `''`. */
export function optionString(
opt: string,
searchParams: URLSearchParams = getWindowURL().searchParams
): string {
return searchParams.get(opt) || '';
}

/** Runtime modes for whether to run tests in a worker. '0' means no worker. */
type WorkerMode = '0' | 'dedicated' | 'service' | 'shared';
/** Parse a runner option for different worker modes (as in `?worker=shared`). */
export function optionWorkerMode(
opt: string,
searchParams: URLSearchParams = getWindowURL().searchParams
): WorkerMode {
const value = searchParams.get(opt);
if (value === null || value === '0') {
return '0';
} else if (value === 'service') {
return 'service';
} else if (value === 'shared') {
return 'shared';
} else if (value === '' || value === '1' || value === 'dedicated') {
return 'dedicated';
}
unreachable('invalid worker= option value');
}

/**
* The possible options for the tests.
*/
export interface CTSOptions {
worker?: 'dedicated' | 'shared' | 'service' | '';
worker: WorkerMode;
debug: boolean;
compatibility: boolean;
forceFallbackAdapter: boolean;
unrollConstEvalLoops: boolean;
powerPreference?: GPUPowerPreference | '';
powerPreference: GPUPowerPreference | '';
}

export const kDefaultCTSOptions: CTSOptions = {
worker: '',
worker: '0',
debug: true,
compatibility: false,
forceFallbackAdapter: false,
Expand Down Expand Up @@ -63,9 +87,9 @@ export type OptionsInfos<Type> = Record<keyof Type, OptionInfo>;
export const kCTSOptionsInfo: OptionsInfos<CTSOptions> = {
worker: {
description: 'run in a worker',
parser: optionString,
parser: optionWorkerMode,
selectValueDescriptions: [
{ value: '', description: 'no worker' },
{ value: '0', description: 'no worker' },
{ value: 'dedicated', description: 'dedicated worker' },
{ value: 'shared', description: 'shared worker' },
{ value: 'service', description: 'service worker' },
Expand Down
2 changes: 1 addition & 1 deletion src/common/runtime/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ function keyValueToPairs([k, v]: [string, ParamValue]): [string, string][] {
*/
function prepareParams(params: Record<string, ParamValue>): string {
const pairsArrays = Object.entries(params)
.filter(([, v]) => !!v)
.filter(([, v]) => !!v && v !== '0')
.map(keyValueToPairs);
const pairs = pairsArrays.flat();
return new URLSearchParams(pairs).toString();
Expand Down
4 changes: 2 additions & 2 deletions src/common/runtime/wpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { parseQuery } from '../internal/query/parseQuery.js';
import { parseExpectationsForTestQuery, relativeQueryString } from '../internal/query/query.js';
import { assert } from '../util/util.js';

import { optionEnabled, optionString } from './helper/options.js';
import { optionEnabled, optionWorkerMode } from './helper/options.js';
import { TestDedicatedWorker, TestServiceWorker, TestSharedWorker } from './helper/test_worker.js';

// testharness.js API (https://web-platform-tests.org/writing-tests/testharness-api.html)
Expand All @@ -31,7 +31,7 @@ setup({
});

void (async () => {
const workerString = optionString('worker');
const workerString = optionWorkerMode('worker');
const dedicatedWorker = workerString === 'dedicated' ? new TestDedicatedWorker() : undefined;
const sharedWorker = workerString === 'shared' ? new TestSharedWorker() : undefined;
const serviceWorker = workerString === 'service' ? new TestServiceWorker() : undefined;
Expand Down
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": "f50d0054",
"webgpu/shader/execution/binary/af_logical.bin": "ef38f267",
"webgpu/shader/execution/binary/af_division.bin": "dabbb1d1",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "8d41501a",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "2b5eb822",
"webgpu/shader/execution/binary/af_multiplication.bin": "6fb45595",
"webgpu/shader/execution/binary/af_remainder.bin": "25e662b1",
"webgpu/shader/execution/binary/af_subtraction.bin": "37703233",
"webgpu/shader/execution/binary/f16_addition.bin": "a712df38",
"webgpu/shader/execution/binary/f16_logical.bin": "e4f7d8",
"webgpu/shader/execution/binary/f16_division.bin": "4793560a",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "a079337b",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "65fe996",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "3f97acdd",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "1fc983d8",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "7e97d699",
"webgpu/shader/execution/binary/f16_multiplication.bin": "c77e8821",
"webgpu/shader/execution/binary/f16_remainder.bin": "e57bdbd7",
"webgpu/shader/execution/binary/f16_subtraction.bin": "85420ccf",
"webgpu/shader/execution/binary/f32_addition.bin": "d2790380",
"webgpu/shader/execution/binary/f32_logical.bin": "d8a1e4a4",
"webgpu/shader/execution/binary/f32_division.bin": "a75642db",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "5b0b0511",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "671efb98",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "bea0478c",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "e6fc9dfb",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "b6b1b664",
"webgpu/shader/execution/binary/f32_multiplication.bin": "8c8cf117",
"webgpu/shader/execution/binary/f32_remainder.bin": "43e749be",
"webgpu/shader/execution/binary/f32_subtraction.bin": "50da2154",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "ecb16a4f",
"webgpu/shader/execution/binary/i32_comparison.bin": "579cc94",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "e08964b4",
"webgpu/shader/execution/binary/u32_comparison.bin": "8c8538e1",
"webgpu/shader/execution/abs.bin": "5c17e46c",
"webgpu/shader/execution/acos.bin": "120bfdf",
"webgpu/shader/execution/acosh.bin": "942cc2bb",
"webgpu/shader/execution/asin.bin": "fe636cf0",
"webgpu/shader/execution/asinh.bin": "61d55466",
"webgpu/shader/execution/atan.bin": "cac44506",
"webgpu/shader/execution/atan2.bin": "3403e5f",
"webgpu/shader/execution/atanh.bin": "6221541c",
"webgpu/shader/execution/bitcast.bin": "945e5c2a",
"webgpu/shader/execution/ceil.bin": "ad590261",
"webgpu/shader/execution/clamp.bin": "fb7095fa",
"webgpu/shader/execution/cos.bin": "f76f3cfc",
"webgpu/shader/execution/cosh.bin": "23274e7d",
"webgpu/shader/execution/cross.bin": "d81d20b",
"webgpu/shader/execution/degrees.bin": "ad65e311",
"webgpu/shader/execution/determinant.bin": "eb512a79",
"webgpu/shader/execution/distance.bin": "868585b7",
"webgpu/shader/execution/dot.bin": "db38aa67",
"webgpu/shader/execution/exp.bin": "62705ef9",
"webgpu/shader/execution/exp2.bin": "54d0df5e",
"webgpu/shader/execution/faceForward.bin": "f7e3a12b",
"webgpu/shader/execution/floor.bin": "6083291e",
"webgpu/shader/execution/fma.bin": "3cb81190",
"webgpu/shader/execution/fract.bin": "d000d278",
"webgpu/shader/execution/frexp.bin": "15d2eb99",
"webgpu/shader/execution/inverseSqrt.bin": "98598f6b",
"webgpu/shader/execution/ldexp.bin": "7cda090b",
"webgpu/shader/execution/length.bin": "a092226a",
"webgpu/shader/execution/log.bin": "4afb8069",
"webgpu/shader/execution/log2.bin": "5c10d479",
"webgpu/shader/execution/max.bin": "38cb6596",
"webgpu/shader/execution/min.bin": "715e13fc",
"webgpu/shader/execution/mix.bin": "67a69982",
"webgpu/shader/execution/modf.bin": "e9d534e0",
"webgpu/shader/execution/normalize.bin": "ec5df722",
"webgpu/shader/execution/pack2x16float.bin": "e4852967",
"webgpu/shader/execution/pow.bin": "8b43d36d",
"webgpu/shader/execution/quantizeToF16.bin": "34152620",
"webgpu/shader/execution/radians.bin": "9953e412",
"webgpu/shader/execution/reflect.bin": "59fae21b",
"webgpu/shader/execution/refract.bin": "79650096",
"webgpu/shader/execution/round.bin": "b4533213",
"webgpu/shader/execution/saturate.bin": "37ca84d0",
"webgpu/shader/execution/sign.bin": "c2e029fd",
"webgpu/shader/execution/sin.bin": "14319b5",
"webgpu/shader/execution/sinh.bin": "bfa704c1",
"webgpu/shader/execution/smoothstep.bin": "6370f69a",
"webgpu/shader/execution/sqrt.bin": "98926bdc",
"webgpu/shader/execution/step.bin": "7375ba92",
"webgpu/shader/execution/tan.bin": "9bc439ef",
"webgpu/shader/execution/tanh.bin": "a3a298d2",
"webgpu/shader/execution/transpose.bin": "e9f7ab2e",
"webgpu/shader/execution/trunc.bin": "49dfcdee",
"webgpu/shader/execution/unpack2x16float.bin": "d93977ea",
"webgpu/shader/execution/unpack2x16snorm.bin": "764c0f13",
"webgpu/shader/execution/unpack2x16unorm.bin": "cf870fc1",
"webgpu/shader/execution/unpack4x8snorm.bin": "3ed6a27e",
"webgpu/shader/execution/unpack4x8unorm.bin": "8df9108c",
"webgpu/shader/execution/unary/af_arithmetic.bin": "80129d46",
"webgpu/shader/execution/unary/af_assignment.bin": "966a724a",
"webgpu/shader/execution/unary/bool_conversion.bin": "d0c1e5a3",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "408620de",
"webgpu/shader/execution/unary/f16_conversion.bin": "46c02cf1",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "378a4095",
"webgpu/shader/execution/unary/f32_conversion.bin": "4743152f",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "a8649cbb",
"webgpu/shader/execution/unary/i32_conversion.bin": "e5157a69",
"webgpu/shader/execution/unary/u32_conversion.bin": "d07d0c20",
"webgpu/shader/execution/unary/ai_assignment.bin": "f62c765c",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "a82361ec",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "8e448c53",
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "d55eea17",
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "31afee59",
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "255e4937"
"webgpu/shader/execution/binary/af_addition.bin": "f93f6f2",
"webgpu/shader/execution/binary/af_logical.bin": "412fdd40",
"webgpu/shader/execution/binary/af_division.bin": "7b359c01",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "ad3e51de",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "10ae4166",
"webgpu/shader/execution/binary/af_multiplication.bin": "f3eb97ee",
"webgpu/shader/execution/binary/af_remainder.bin": "1c08510d",
"webgpu/shader/execution/binary/af_subtraction.bin": "1ea78ded",
"webgpu/shader/execution/binary/f16_addition.bin": "97c6c220",
"webgpu/shader/execution/binary/f16_logical.bin": "2d07c65d",
"webgpu/shader/execution/binary/f16_division.bin": "fd11268e",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "6e8f752c",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "ebfe95b8",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "21577c69",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "ca569737",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "8d7a02b5",
"webgpu/shader/execution/binary/f16_multiplication.bin": "aee2b921",
"webgpu/shader/execution/binary/f16_remainder.bin": "f9397246",
"webgpu/shader/execution/binary/f16_subtraction.bin": "8f80b4b4",
"webgpu/shader/execution/binary/f32_addition.bin": "3b09cfd7",
"webgpu/shader/execution/binary/f32_logical.bin": "ab23c69a",
"webgpu/shader/execution/binary/f32_division.bin": "2e8d775b",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "7276a303",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "26789d70",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "beb34505",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "1b426bf8",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "ee372ef3",
"webgpu/shader/execution/binary/f32_multiplication.bin": "a58fb275",
"webgpu/shader/execution/binary/f32_remainder.bin": "4fca1678",
"webgpu/shader/execution/binary/f32_subtraction.bin": "a77fcae2",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "483b584e",
"webgpu/shader/execution/binary/i32_comparison.bin": "a1310d6d",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "4ed255b",
"webgpu/shader/execution/binary/u32_comparison.bin": "2766735c",
"webgpu/shader/execution/abs.bin": "74007d00",
"webgpu/shader/execution/acos.bin": "71afa785",
"webgpu/shader/execution/acosh.bin": "7eb972b3",
"webgpu/shader/execution/asin.bin": "cf1f15dc",
"webgpu/shader/execution/asinh.bin": "77d8090c",
"webgpu/shader/execution/atan.bin": "f984effa",
"webgpu/shader/execution/atan2.bin": "f71eeef0",
"webgpu/shader/execution/atanh.bin": "f70ef8f3",
"webgpu/shader/execution/bitcast.bin": "61596841",
"webgpu/shader/execution/ceil.bin": "d3912020",
"webgpu/shader/execution/clamp.bin": "3af7b577",
"webgpu/shader/execution/cos.bin": "a1b9931a",
"webgpu/shader/execution/cosh.bin": "9d4816da",
"webgpu/shader/execution/cross.bin": "75ee9e89",
"webgpu/shader/execution/degrees.bin": "1c88f619",
"webgpu/shader/execution/determinant.bin": "16acfafa",
"webgpu/shader/execution/distance.bin": "1098d127",
"webgpu/shader/execution/dot.bin": "e1a8d3bc",
"webgpu/shader/execution/exp.bin": "cdb0e2b9",
"webgpu/shader/execution/exp2.bin": "665ec45a",
"webgpu/shader/execution/faceForward.bin": "f22e0c0a",
"webgpu/shader/execution/floor.bin": "ede6258",
"webgpu/shader/execution/fma.bin": "34c7474",
"webgpu/shader/execution/fract.bin": "3e0d009a",
"webgpu/shader/execution/frexp.bin": "23465618",
"webgpu/shader/execution/inverseSqrt.bin": "487cf433",
"webgpu/shader/execution/ldexp.bin": "20d14a1",
"webgpu/shader/execution/length.bin": "95b9dd44",
"webgpu/shader/execution/log.bin": "13bdb23",
"webgpu/shader/execution/log2.bin": "3a5cbd55",
"webgpu/shader/execution/max.bin": "7e1f71fc",
"webgpu/shader/execution/min.bin": "6dc2bb2d",
"webgpu/shader/execution/mix.bin": "d019504f",
"webgpu/shader/execution/modf.bin": "8f3f56ec",
"webgpu/shader/execution/normalize.bin": "480fa5d8",
"webgpu/shader/execution/pack2x16float.bin": "1d32fd43",
"webgpu/shader/execution/pow.bin": "992dd6fd",
"webgpu/shader/execution/quantizeToF16.bin": "457045cb",
"webgpu/shader/execution/radians.bin": "4660460e",
"webgpu/shader/execution/reflect.bin": "d49b4a70",
"webgpu/shader/execution/refract.bin": "81d973ab",
"webgpu/shader/execution/round.bin": "a9617b62",
"webgpu/shader/execution/saturate.bin": "8616be85",
"webgpu/shader/execution/sign.bin": "4747c867",
"webgpu/shader/execution/sin.bin": "b60c310f",
"webgpu/shader/execution/sinh.bin": "8c24825e",
"webgpu/shader/execution/smoothstep.bin": "c5730ac6",
"webgpu/shader/execution/sqrt.bin": "44d4bf9b",
"webgpu/shader/execution/step.bin": "183935c1",
"webgpu/shader/execution/tan.bin": "5c8ab74a",
"webgpu/shader/execution/tanh.bin": "f233ceba",
"webgpu/shader/execution/transpose.bin": "86a6b61c",
"webgpu/shader/execution/trunc.bin": "7f07d161",
"webgpu/shader/execution/unpack2x16float.bin": "cfe367ce",
"webgpu/shader/execution/unpack2x16snorm.bin": "fcfe4174",
"webgpu/shader/execution/unpack2x16unorm.bin": "f419844a",
"webgpu/shader/execution/unpack4x8snorm.bin": "c3343320",
"webgpu/shader/execution/unpack4x8unorm.bin": "24618d08",
"webgpu/shader/execution/unary/af_arithmetic.bin": "ae3cf04d",
"webgpu/shader/execution/unary/af_assignment.bin": "823b0b98",
"webgpu/shader/execution/unary/bool_conversion.bin": "25551e87",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "b1604cf7",
"webgpu/shader/execution/unary/f16_conversion.bin": "6c9e1961",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "13fc8cf0",
"webgpu/shader/execution/unary/f32_conversion.bin": "3a4e8649",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "ca6bdc9e",
"webgpu/shader/execution/unary/i32_conversion.bin": "44881769",
"webgpu/shader/execution/unary/u32_conversion.bin": "535edb49",
"webgpu/shader/execution/unary/ai_assignment.bin": "607105c7",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "5718501b",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "9aff9753",
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "c24c52ce",
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "7df31c69",
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "eb2e28a"
}
7 changes: 4 additions & 3 deletions src/webgpu/web_platform/worker/worker.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export const description = `
Tests WebGPU is available in a dedicated worker and a shared worker.
Note: The CTS test can be run respectively in a dedicated worker and a shared worker by
passing in worker=dedicated and worker=shared as a query parameter. These tests
are specifically to check that WebGPU is available in a dedicated worker and a shared worker.
Note: Any CTS test can be run in a worker by passing ?worker=dedicated, ?worker=shared,
?worker=service as a query parameter. The tests in this file are specifically to check
that WebGPU is available in each worker type. When run in combination with a ?worker flag,
they will test workers created from other workers (where APIs exist to do so).
TODO[2]: Figure out how to make these tests run in service workers (not actually
important unless service workers gain the ability to launch other workers).
Expand Down

0 comments on commit 3c2c107

Please sign in to comment.