poker-flopsolve 0.5.0-beta.0 → 0.5.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ function serveEngine(setup) {
10
10
  const TRAVERSER = 4;
11
11
  const READY = 5;
12
12
  const FAILED = 6;
13
+ const NEXT = 7;
13
14
  const EXIT = 1;
14
15
  const api = globalThis.WebAssembly;
15
16
  const memory = setup.memory;
@@ -25,7 +26,8 @@ function serveEngine(setup) {
25
26
  engine.init(setup.header);
26
27
  engine.setMaxActions(setup.maxActions);
27
28
  engine.setExchange(setup.exchange[0], setup.exchange[1], setup.exchange[2], setup.exchange[3]);
28
- engine.setShard(setup.shard[0], setup.shard[1], setup.shard[2]);
29
+ const [round, boards] = setup.shard;
30
+ engine.setShard(round, 0, 0);
29
31
  engine.setPhase(0, 1);
30
32
  const shared = setup.shared;
31
33
  if (shared) engine.setShared(shared[0], shared[1], shared[2]);
@@ -36,8 +38,19 @@ function serveEngine(setup) {
36
38
  const settings = new Float64Array(setup.settings);
37
39
  const entries = setup.entryNodes.length;
38
40
  const rowBytes = setup.stride * 4;
39
- const partials = new Float32Array(memory.buffer, setup.partial, entries * setup.stride);
41
+ const stride = setup.stride;
40
42
  const reach = setup.exchange[1];
43
+ const order = new Int32Array(setup.schedule, 0, boards);
44
+ const cost = new Float64Array(setup.schedule, Math.ceil(boards / 2) * 8, 2 * boards);
45
+ const into = setup.boardValues >>> 2;
46
+ const profile = new Float64Array(setup.profile[0]);
47
+ const busy = setup.profile[1];
48
+ const pages = new Uint8Array(memory.buffer);
49
+ if (Atomics.load(control, COMMAND) !== EXIT) {
50
+ for (let r = 0; r < setup.touch.length; r += 2) {
51
+ for (let at = setup.touch[r]; at < setup.touch[r + 1]; at += 4096) pages[at] = 0;
52
+ }
53
+ }
41
54
  let generation = Atomics.load(control, GENERATION);
42
55
  Atomics.add(control, READY, 1);
43
56
  Atomics.notify(control, READY);
@@ -56,22 +69,33 @@ function serveEngine(setup) {
56
69
  try {
57
70
  engine.setPhase(0, settings[5]);
58
71
  if (needsIteration) engine.setIteration(settings[6], settings[7]);
59
- for (let entry = 0; entry < entries; entry++) {
60
- const slot = reach + entry * 2 * rowBytes;
61
- const out = engine.runChance(
62
- mode,
63
- traverser,
64
- setup.entryNodes[entry],
65
- slot,
66
- slot + rowBytes,
67
- positive,
68
- negative,
69
- sum,
70
- weight,
71
- clamp
72
- ) >>> 0;
73
- partials.set(new Float32Array(memory.buffer, out, setup.stride), entry * setup.stride);
72
+ const heap = new Float32Array(memory.buffer);
73
+ const started = performance.now();
74
+ for (; ; ) {
75
+ const taken = Atomics.add(control, NEXT, 1);
76
+ if (taken >= boards) break;
77
+ const board = order[taken];
78
+ engine.setShard(round, board, board + 1);
79
+ const boardStarted = performance.now();
80
+ for (let entry = 0; entry < entries; entry++) {
81
+ const slot = reach + entry * 2 * rowBytes;
82
+ const out = engine.runChance(
83
+ mode,
84
+ traverser,
85
+ setup.entryNodes[entry],
86
+ slot,
87
+ slot + rowBytes,
88
+ positive,
89
+ negative,
90
+ sum,
91
+ weight,
92
+ clamp
93
+ ) >>> 2;
94
+ heap.copyWithin(into + (board * entries + entry) * stride, out, out + stride);
95
+ }
96
+ if (mode === 0 && settings[5] === 1) cost[traverser * boards + board] = performance.now() - boardStarted;
74
97
  }
98
+ profile[busy] += performance.now() - started;
75
99
  } catch (error) {
76
100
  Atomics.store(control, FAILED, 1);
77
101
  throw error;
@@ -83,6 +107,13 @@ function serveEngine(setup) {
83
107
  }
84
108
 
85
109
  // src/engine-worker.ts
86
- serveEngine(workerData);
87
- parentPort?.close();
110
+ if (workerData) {
111
+ serveEngine(workerData);
112
+ parentPort?.close();
113
+ } else {
114
+ parentPort?.once("message", (setup) => {
115
+ serveEngine(setup);
116
+ parentPort?.close();
117
+ });
118
+ }
88
119
  //# sourceMappingURL=engine-worker.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/engine-worker.ts","../src/engine-thread.ts"],"sourcesContent":["/**\n * An engine worker in Node: one thread of a WebAssembly solve.\n *\n * Purpose: start `serveEngine` (src/engine-thread.ts) on the setup the main\n * thread passed, and let the thread end once it returns.\n */\n\nimport { parentPort, workerData } from 'node:worker_threads';\nimport type { EngineWorkerSetup } from './engine.ts';\nimport { serveEngine } from './engine-thread.ts';\n\nserveEngine(workerData as EngineWorkerSetup);\nparentPort?.close();\n","/**\n * One thread of a WebAssembly solve: the loop every engine worker runs.\n *\n * Purpose: walk this thread's slice of the runouts at the split round, over\n * the memory every thread shares, each time the main thread signals, until it\n * says exit. The protocol is src/parallel.ts's: the main thread collects the\n * reach each entry needs, every thread walks its slice from each entry, the\n * main thread adds the slices up and finishes. All of it happens in shared\n * WebAssembly memory, so nothing is copied between threads but a few numbers\n * of control.\n *\n * Node runs it from `engine-worker.ts`. The browser build has no file to\n * start a worker from, so `platform/browser.ts` ships this function as its\n * own source text (`Function.prototype.toString`) inside a Blob worker. That\n * is why it must stay self-contained: no imports, no reference to anything\n * outside its body, no nested named functions (a bundler may wrap those in a\n * helper the worker would not have). The control slots are written out as\n * numbers for the same reason; a test pins them to `ENGINE_CONTROL`.\n */\n\nimport type { EngineWorkerSetup } from './engine.ts';\n\n/**\n * Serve one solve, returning once the main thread sends exit.\n * @param setup what `createEngine` hands each worker\n */\nexport function serveEngine(setup: EngineWorkerSetup): void {\n\t// ENGINE_CONTROL, inlined.\n\tconst GENERATION = 0;\n\tconst DONE = 1;\n\tconst COMMAND = 2;\n\tconst MODE = 3;\n\tconst TRAVERSER = 4;\n\tconst READY = 5;\n\tconst FAILED = 6;\n\tconst EXIT = 1;\n\n\tconst api = (globalThis as unknown as {\n\t\tWebAssembly: { Instance: new (module: unknown, imports: object) => { exports: Record<string, unknown> } };\n\t}).WebAssembly;\n\tconst memory = setup.memory as { buffer: SharedArrayBuffer };\n\tconst imports = {\n\t\tenv: {\n\t\t\tmemory,\n\t\t\tabort(): never {\n\t\t\t\tthrow new Error('engine abort');\n\t\t\t},\n\t\t},\n\t};\n\tconst engine = new api.Instance(setup.module, imports).exports as unknown as {\n\t\tinit(header: number): void;\n\t\tsetMaxActions(count: number): void;\n\t\tsetShard(round: number, start: number, end: number): void;\n\t\tsetExchange(entries: number, reach: number, values: number, stride: number): void;\n\t\tsetPhase(phase: number, apply: number): void;\n\t\tsetShared(marks: number, blockOffsets: number, weighted: number): void;\n\t\tsetSampling(\n\t\t\trounds: number, p: number, every: number, unbiased: number, catchUp: number,\n\t\t\tbaseOffsets: number, boardOffsets: number, walkOffsets: number,\n\t\t\tbaselines: number, lastWalks: number, lastUpdates: number, blockOffsets: number,\n\t\t): void;\n\t\tsetIteration(t: number, dcfr: number): void;\n\t\trunChance(\n\t\t\tmode: number, traverser: number, node: number, me: number, opp: number,\n\t\t\tpositive: number, negative: number, sum: number, weight: number, clamp: number,\n\t\t): number;\n\t};\n\tengine.init(setup.header);\n\tengine.setMaxActions(setup.maxActions);\n\tengine.setExchange(setup.exchange[0], setup.exchange[1], setup.exchange[2], setup.exchange[3]);\n\tengine.setShard(setup.shard[0], setup.shard[1], setup.shard[2]);\n\tengine.setPhase(0, 1);\n\tconst shared = setup.shared;\n\tif (shared) engine.setShared(shared[0], shared[1], shared[2]);\n\t// Chance sampling's state is in the shared memory, at the main thread's offsets.\n\tconst s = setup.sampling;\n\tif (s) engine.setSampling(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11]);\n\t// Shared storage discounts by iteration, the storage engine's rounding\n\t// hashes it, and chance sampling picks deals and catches up by it.\n\tconst needsIteration = shared !== undefined || setup.storage === true || s !== undefined;\n\n\tconst control = new Int32Array(setup.control);\n\tconst settings = new Float64Array(setup.settings);\n\tconst entries = setup.entryNodes.length;\n\tconst rowBytes = setup.stride * 4;\n\tconst partials = new Float32Array(memory.buffer, setup.partial, entries * setup.stride);\n\tconst reach = setup.exchange[1];\n\n\t// Latch the generation before announcing readiness, so no dispatch is missed.\n\tlet generation = Atomics.load(control, GENERATION);\n\tAtomics.add(control, READY, 1);\n\tAtomics.notify(control, READY);\n\t// A solve that gave up before this thread started has already said exit.\n\tif (Atomics.load(control, COMMAND) === EXIT) return;\n\n\tfor (;;) {\n\t\tAtomics.wait(control, GENERATION, generation);\n\t\tgeneration = Atomics.load(control, GENERATION);\n\t\tif (Atomics.load(control, COMMAND) === EXIT) return;\n\t\tconst mode = Atomics.load(control, MODE);\n\t\tconst traverser = Atomics.load(control, TRAVERSER);\n\t\tconst positive = settings[0];\n\t\tconst negative = settings[1];\n\t\tconst sum = settings[2];\n\t\tconst weight = settings[3];\n\t\tconst clamp = settings[4];\n\t\ttry {\n\t\t\t// Off for a current-profile read, which updates nothing.\n\t\t\tengine.setPhase(0, settings[5]);\n\t\t\tif (needsIteration) engine.setIteration(settings[6], settings[7]);\n\t\t\tfor (let entry = 0; entry < entries; entry++) {\n\t\t\t\tconst slot = reach + entry * 2 * rowBytes;\n\t\t\t\tconst out = engine.runChance(\n\t\t\t\t\tmode, traverser, setup.entryNodes[entry], slot, slot + rowBytes, positive, negative, sum, weight, clamp,\n\t\t\t\t) >>> 0; // a usize, signed on its way out; see `EngineExports`\n\t\t\t\tpartials.set(new Float32Array(memory.buffer, out, setup.stride), entry * setup.stride);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// The main thread is blocked in Atomics.wait and cannot see this\n\t\t\t// thread's error event, so say so in shared memory (and count as\n\t\t\t// done, below). Then let the thread die: its engine is not to be trusted.\n\t\t\tAtomics.store(control, FAILED, 1);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tAtomics.add(control, DONE, 1);\n\t\t\tAtomics.notify(control, DONE);\n\t\t}\n\t}\n}\n"],"mappings":";AAOA,SAAS,YAAY,kBAAkB;;;ACmBhC,SAAS,YAAY,OAAgC;AAE3D,QAAM,aAAa;AACnB,QAAM,OAAO;AACb,QAAM,UAAU;AAChB,QAAM,OAAO;AACb,QAAM,YAAY;AAClB,QAAM,QAAQ;AACd,QAAM,SAAS;AAC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,EACD;AACD;;;ADrHA,YAAY,UAA+B;AAC3C,YAAY,MAAM;","names":[]}
1
+ {"version":3,"sources":["../src/engine-worker.ts","../src/engine-thread.ts"],"sourcesContent":["/**\n * An engine worker in Node: one thread of a WebAssembly solve.\n *\n * Purpose: run `serveEngine` (src/engine-thread.ts) on the setup the main\n * thread passes, and let the thread end once it returns.\n */\n\nimport { parentPort, workerData } from 'node:worker_threads';\nimport type { EngineWorkerSetup } from './engine.ts';\nimport { serveEngine } from './engine-thread.ts';\n\n// Started on a solve, or ahead of one to wait for its setup\n// (`warmEngineThreads` in src/platform/node.ts). Either way it serves that\n// one solve, and the thread ends when the solve lets it go.\nif (workerData) {\n\tserveEngine(workerData as EngineWorkerSetup);\n\tparentPort?.close();\n} else {\n\tparentPort?.once('message', (setup: EngineWorkerSetup) => {\n\t\tserveEngine(setup);\n\t\tparentPort?.close();\n\t});\n}\n","/**\n * One thread of a WebAssembly solve: the loop every engine worker runs.\n *\n * Purpose: walk this thread's slice of the runouts at the split round, over\n * the memory every thread shares, each time the main thread signals, until it\n * says exit. The protocol is src/parallel.ts's: the main thread collects the\n * reach each entry needs, every thread walks its slice from each entry, the\n * main thread adds the slices up and finishes. All of it happens in shared\n * WebAssembly memory, so nothing is copied between threads but a few numbers\n * of control.\n *\n * Node runs it from `engine-worker.ts`. The browser build has no file to\n * start a worker from, so `platform/browser.ts` ships this function as its\n * own source text (`Function.prototype.toString`) inside a Blob worker. That\n * is why it must stay self-contained: no imports, no reference to anything\n * outside its body, no nested named functions (a bundler may wrap those in a\n * helper the worker would not have). The control slots are written out as\n * numbers for the same reason; a test pins them to `ENGINE_CONTROL`.\n */\n\nimport type { EngineWorkerSetup } from './engine.ts';\n\n/**\n * Serve one solve, returning once the main thread sends exit.\n * @param setup what `createEngine` hands each worker\n */\nexport function serveEngine(setup: EngineWorkerSetup): void {\n\t// ENGINE_CONTROL, inlined.\n\tconst GENERATION = 0;\n\tconst DONE = 1;\n\tconst COMMAND = 2;\n\tconst MODE = 3;\n\tconst TRAVERSER = 4;\n\tconst READY = 5;\n\tconst FAILED = 6;\n\tconst NEXT = 7;\n\tconst EXIT = 1;\n\n\tconst api = (globalThis as unknown as {\n\t\tWebAssembly: { Instance: new (module: unknown, imports: object) => { exports: Record<string, unknown> } };\n\t}).WebAssembly;\n\tconst memory = setup.memory as { buffer: SharedArrayBuffer };\n\tconst imports = {\n\t\tenv: {\n\t\t\tmemory,\n\t\t\tabort(): never {\n\t\t\t\tthrow new Error('engine abort');\n\t\t\t},\n\t\t},\n\t};\n\tconst engine = new api.Instance(setup.module, imports).exports as unknown as {\n\t\tinit(header: number): void;\n\t\tsetMaxActions(count: number): void;\n\t\tsetShard(round: number, start: number, end: number): void;\n\t\tsetExchange(entries: number, reach: number, values: number, stride: number): void;\n\t\tsetPhase(phase: number, apply: number): void;\n\t\tsetShared(marks: number, blockOffsets: number, weighted: number): void;\n\t\tsetSampling(\n\t\t\trounds: number, p: number, every: number, unbiased: number, catchUp: number,\n\t\t\tbaseOffsets: number, boardOffsets: number, walkOffsets: number,\n\t\t\tbaselines: number, lastWalks: number, lastUpdates: number, blockOffsets: number,\n\t\t): void;\n\t\tsetIteration(t: number, dcfr: number): void;\n\t\trunChance(\n\t\t\tmode: number, traverser: number, node: number, me: number, opp: number,\n\t\t\tpositive: number, negative: number, sum: number, weight: number, clamp: number,\n\t\t): number;\n\t};\n\tengine.init(setup.header);\n\tengine.setMaxActions(setup.maxActions);\n\tengine.setExchange(setup.exchange[0], setup.exchange[1], setup.exchange[2], setup.exchange[3]);\n\tconst [round, boards] = setup.shard;\n\tengine.setShard(round, 0, 0);\n\tengine.setPhase(0, 1);\n\tconst shared = setup.shared;\n\tif (shared) engine.setShared(shared[0], shared[1], shared[2]);\n\t// Chance sampling's state is in the shared memory, at the main thread's offsets.\n\tconst s = setup.sampling;\n\tif (s) engine.setSampling(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11]);\n\t// Shared storage discounts by iteration, the storage engine's rounding\n\t// hashes it, and chance sampling picks deals and catches up by it.\n\tconst needsIteration = shared !== undefined || setup.storage === true || s !== undefined;\n\n\tconst control = new Int32Array(setup.control);\n\tconst settings = new Float64Array(setup.settings);\n\tconst entries = setup.entryNodes.length;\n\tconst rowBytes = setup.stride * 4;\n\tconst stride = setup.stride;\n\tconst reach = setup.exchange[1];\n\t// `scheduleViews` in src/engine.ts, inlined.\n\tconst order = new Int32Array(setup.schedule, 0, boards);\n\tconst cost = new Float64Array(setup.schedule, Math.ceil(boards / 2) * 8, 2 * boards);\n\tconst into = setup.boardValues >>> 2;\n\tconst profile = new Float64Array(setup.profile[0]);\n\tconst busy = setup.profile[1];\n\n\t// This thread's share of the empty storage, mapped before the solve needs\n\t// it; `touchStorage` in src/engine.ts, inlined.\n\t// Not for a solve that gave up before this thread started.\n\tconst pages = new Uint8Array(memory.buffer);\n\tif (Atomics.load(control, COMMAND) !== EXIT) {\n\t\tfor (let r = 0; r < setup.touch.length; r += 2) {\n\t\t\tfor (let at = setup.touch[r]; at < setup.touch[r + 1]; at += 4096) pages[at] = 0;\n\t\t}\n\t}\n\n\t// Latch the generation before announcing readiness, so no dispatch is missed.\n\tlet generation = Atomics.load(control, GENERATION);\n\tAtomics.add(control, READY, 1);\n\tAtomics.notify(control, READY);\n\t// A solve that gave up before this thread started has already said exit.\n\tif (Atomics.load(control, COMMAND) === EXIT) return;\n\n\tfor (;;) {\n\t\tAtomics.wait(control, GENERATION, generation);\n\t\tgeneration = Atomics.load(control, GENERATION);\n\t\tif (Atomics.load(control, COMMAND) === EXIT) return;\n\t\tconst mode = Atomics.load(control, MODE);\n\t\tconst traverser = Atomics.load(control, TRAVERSER);\n\t\tconst positive = settings[0];\n\t\tconst negative = settings[1];\n\t\tconst sum = settings[2];\n\t\tconst weight = settings[3];\n\t\tconst clamp = settings[4];\n\t\ttry {\n\t\t\t// Off for a current-profile read, which updates nothing.\n\t\t\tengine.setPhase(0, settings[5]);\n\t\t\tif (needsIteration) engine.setIteration(settings[6], settings[7]);\n\t\t\tconst heap = new Float32Array(memory.buffer);\n\t\t\tconst started = performance.now();\n\t\t\t// Boards off the shared order until none are left; each board's\n\t\t\t// values in its own rows, so whoever walks it gives the same sum.\n\t\t\tfor (;;) {\n\t\t\t\tconst taken = Atomics.add(control, NEXT, 1);\n\t\t\t\tif (taken >= boards) break;\n\t\t\t\tconst board = order[taken];\n\t\t\t\tengine.setShard(round, board, board + 1);\n\t\t\t\tconst boardStarted = performance.now();\n\t\t\t\tfor (let entry = 0; entry < entries; entry++) {\n\t\t\t\t\tconst slot = reach + entry * 2 * rowBytes;\n\t\t\t\t\tconst out = engine.runChance(\n\t\t\t\t\t\tmode, traverser, setup.entryNodes[entry], slot, slot + rowBytes, positive, negative, sum, weight, clamp,\n\t\t\t\t\t) >>> 2; // a usize, signed on its way out; see `EngineExports`\n\t\t\t\t\theap.copyWithin(into + (board * entries + entry) * stride, out, out + stride);\n\t\t\t\t}\n\t\t\t\t// Training walks only, as `runThreaded` in src/engine.ts.\n\t\t\t\tif (mode === 0 && settings[5] === 1) cost[traverser * boards + board] = performance.now() - boardStarted;\n\t\t\t}\n\t\t\tprofile[busy] += performance.now() - started;\n\t\t} catch (error) {\n\t\t\t// The main thread is blocked in Atomics.wait and cannot see this\n\t\t\t// thread's error event, so say so in shared memory (and count as\n\t\t\t// done, below). Then let the thread die: its engine is not to be trusted.\n\t\t\tAtomics.store(control, FAILED, 1);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tAtomics.add(control, DONE, 1);\n\t\t\tAtomics.notify(control, DONE);\n\t\t}\n\t}\n}\n"],"mappings":";AAOA,SAAS,YAAY,kBAAkB;;;ACmBhC,SAAS,YAAY,OAAgC;AAE3D,QAAM,aAAa;AACnB,QAAM,OAAO;AACb,QAAM,UAAU;AAChB,QAAM,OAAO;AACb,QAAM,YAAY;AAClB,QAAM,QAAQ;AACd,QAAM,SAAS;AACf,QAAM,OAAO;AACb,QAAM,OAAO;AAEb,QAA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