From 0a76551afa0ca88981841e8a081b69a0cc905bff Mon Sep 17 00:00:00 2001 From: Mamy Ratsimbazafy Date: Tue, 8 Feb 2022 11:55:31 +0100 Subject: [PATCH] Re-expose tp.numThreads (#13) Necessary for nim-blscurve batch sizing: https://github.com/status-im/nim-blscurve/blob/dad2041/blscurve/bls_batch_verifier.nim#L250 --- taskpools/taskpools.nim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/taskpools/taskpools.nim b/taskpools/taskpools.nim index da5689d..d33c8d6 100644 --- a/taskpools/taskpools.nim +++ b/taskpools/taskpools.nim @@ -90,7 +90,6 @@ type # Thefts rng: Rand # RNG state to select victims - numThreads: int otherDeques: ptr UncheckedArray[ChaseLevDeque[TaskNode]] victims: SparseSet @@ -102,7 +101,7 @@ type eventNotifier: EventNotifier ## Puts thread to sleep - numThreads{.align: 64.}: int + numThreads*{.align: 64.}: int workerDeques: ptr UncheckedArray[ChaseLevDeque[TaskNode]] ## Direct access for task stealing workers: ptr UncheckedArray[Thread[(Taskpool, WorkerID)]] @@ -127,7 +126,6 @@ proc setupWorker() = # Thefts ctx.rng = initRand(0xEFFACED + ctx.id) - ctx.numThreads = ctx.taskpool.numThreads ctx.otherDeques = ctx.taskpool.workerDeques ctx.victims.allocate(ctx.taskpool.numThreads) @@ -322,7 +320,7 @@ proc syncAll*(tp: Taskpool) {.raises: [Exception].} = debug: log("Worker %2d: syncAll 1 - running task 0x%.08x (parent 0x%.08x, current 0x%.08x)\n", ctx.id, taskNode, taskNode.parent, ctx.currentTask) taskNode.runTask() - if ctx.numThreads == 1 or foreignThreadsParked: + if tp.numThreads == 1 or foreignThreadsParked: break # 2. Help other threads