]> zoso.dev Git - nano-pow.git/commitdiff
Adjust how effort is set. Log search parameters when debugging.
authorChris Duncan <chris@zoso.dev>
Fri, 17 Jan 2025 19:12:26 +0000 (11:12 -0800)
committerChris Duncan <chris@zoso.dev>
Fri, 17 Jan 2025 19:12:26 +0000 (11:12 -0800)
src/classes/gpu.ts
test.html

index d0a699e1629224d94976896ba910c0960787b45b..bc7348aa8545cb391fa766370073d449c21924b4 100644 (file)
@@ -216,8 +216,8 @@ export class NanoPowGpu {
                        ? 0xfffffff8
                        : options.threshold
                const effort = (typeof options?.effort !== 'number' || options.effort < 0x1 || options.effort > 0x10)
-                       ? 0x8
-                       : options.effort
+                       ? 0x800
+                       : options.effort * 0x100
                const debug = !!(options?.debug)
 
                // Ensure WebGPU is initialized before calculating
@@ -236,12 +236,15 @@ export class NanoPowGpu {
                        start = performance.now()
                        const random = Math.floor(Math.random() * 0xffffffff)
                        const seed = (BigInt(random) << 32n) | BigInt(random)
-                       const data = await this.#dispatch(this.#searchPipeline, seed, hash, threshold, effort * 0x100)
+                       const data = await this.#dispatch(this.#searchPipeline, seed, hash, threshold, effort)
                        nonce = data.getBigUint64(0, true)
                        this.#busy = !data.getUint32(8)
                        times.push(performance.now() - start)
                } while (this.#busy)
-               if (debug) this.#logAverages(times)
+               if (debug) {
+                       console.log(`%cNanoPow (WebGPU) | Dispatch: ${effort ** 2} | Threads: ${8 * 8 * (effort ** 2)}`)
+                       this.#logAverages(times)
+               }
                return nonce.toString(16).padStart(16, '0')
        }
 
index 3d03b1efdb3a381cd9ecdb2b920b87a3ca111105..0e2857688b102d5ddbee8af642db1c8a7a361e07 100644 (file)
--- a/test.html
+++ b/test.html
@@ -89,7 +89,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
 
                        console.log(`%cNanoPow (${type})`, 'color:green', `Calculate proof-of-work for ${size} unique send block hashes`)
                        const times = []
-                       document.getElementById('output').innerHTML += `Now testing: NanoPow (${type}) | Dispatch: ${(effort * 0x100) ** 2} | Threads/Dispatch: ${8 * 8 * ((effort * 0x100) ** 2)}<br/>`
                        for (let i = 0; i < size; i++) {
                                document.getElementById('status').innerHTML = `TESTING IN PROGRESS ${i}/${size}<br/>`
                                const hash = random()
@@ -108,8 +107,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
                                // console.log(msg)
                                if (isOutputShown) document.getElementById('output').innerHTML += `${msg}<br/>`
                        }
-                       document.getElementById('output').innerHTML += `-----<br/>`
-                       document.getElementById('summary').innerHTML += `NanoPow (${type})<br/>${JSON.stringify(average(times), null, '\t')}<br/>`
+                       document.getElementById('output').innerHTML += `<hr/>`
+                       document.getElementById('summary').innerHTML += `${JSON.stringify(average(times), null, '\t')}<br/>`
                        print(times)
                        document.getElementById('status').innerHTML = `TESTING COMPLETE<br/>`
                        console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold')
@@ -142,7 +141,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
                        run(+size.value, +effort.value, isOutputShown.checked, isGlForced.checked, isDebug.checked)
                })
        </script>
-       <style>body{background:black;color:white;}a{color:darkcyan;}input[type=number]{width:5em;}</style>
+       <style>body{background:black;color:white;}a{color:darkcyan;}input[type=number]{width:5em;}span{margin:0.5em;}</style>
 </head>
 
 <body>
@@ -165,12 +164,18 @@ SPDX-License-Identifier: GPL-3.0-or-later
        <input id="size" type="number" value="64" />
        <label for="effort">Effort (1-16)</label>
        <input id="effort" type="number" value="8" min="1" max="16" />
-       <label for="isOutputShown">Show output?</label>
-       <input id="isOutputShown" type="checkbox" checked />
-       <label for="isGlForced">Force WebGL?</label>
-       <input id="isGlForced" type="checkbox" />
-       <label for="isDebug">Debug?</label>
-       <input id="isDebug" type="checkbox" />
+       <span>
+               <label for="isOutputShown">Show output?</label>
+               <input id="isOutputShown" type="checkbox" checked />
+       </span>
+       <span>
+               <label for="isGlForced">Force WebGL?</label>
+               <input id="isGlForced" type="checkbox" />
+       </span>
+       <span>
+               <label for="isDebug">Debug?</label>
+               <input id="isDebug" type="checkbox" />
+       </span>
        <button id="go">Go</button>
        <h3 id="status">WAITING</h3>
        <hr />