You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to use one kernel for multiple tasks (to have a fixed amount of threads active); these need some special variable set, to different values depending on callsite.
Now, :BINDINGS in MAKE-KERNEL (if I read that correctly) takes the value of the thread running MAKE-KERNEL; I need to have different values, so that's out.
Next idea was to pass the needed value to the thread:
(lparallel:pmap
nil
(lambda (a b)
(let ((*special* a))
(... b)))
(alexandria:make-circular-list 1:initial-element*special*)
(list:a:b:c:d))
But that just hangs, because PMAP* runs LENGTH on the input, which won't work with the circular list.
Of course I could build a list with the same length as the other input sequence... but that's quite CONSing, isn't it? ;)
I found :SIZE, but that should be set to a smaller value than the list length - and then not all elements will be processed. (Otherwise, I could use MOST-POSITIVE-FIXNUM ;)
:CONTEXT is for the whole length of a worker thread, so I can't rebind the special if the same kernel is used for another task.
Is there some easy way to get a call-size specific special into the work items?
Thank you for any help!
The text was updated successfully, but these errors were encountered:
Well :bindingscan use the values from the thread calling make-kernel, but it's more general than that since the values for the bindings are obtained from eval in each worker thread. This isn't lparallel-specific; it's just the behavior of bordeaux-threads. Conceptually, :bindings is just a convenience wrapper for :context that is tailored for initializing specials. Both are one-time triggers called at the start of each worker thread.
But you want to rebind a dynamic variable inside tasks, so, right, neither :bindings nor :context are going to help in this case.
It's not clear to me why :size wouldn't work here. It doesn't call length and thus works fine on circular lists which are effectively treated as sequences of infinite length. The value of :size is not restricted.
I'd like to use one kernel for multiple tasks (to have a fixed amount of threads active); these need some special variable set, to different values depending on callsite.
Now,
:BINDINGS
inMAKE-KERNEL
(if I read that correctly) takes the value of the thread runningMAKE-KERNEL
; I need to have different values, so that's out.Next idea was to pass the needed value to the thread:
But that just hangs, because
PMAP*
runsLENGTH
on the input, which won't work with the circular list.Of course I could build a list with the same length as the other input sequence... but that's quite
CONS
ing, isn't it? ;)I found
:SIZE
, but that should be set to a smaller value than the list length - and then not all elements will be processed. (Otherwise, I could useMOST-POSITIVE-FIXNUM
;):CONTEXT
is for the whole length of a worker thread, so I can't rebind the special if the same kernel is used for another task.Is there some easy way to get a call-size specific special into the work items?
Thank you for any help!
The text was updated successfully, but these errors were encountered: