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
An attempt I tried a few weeks ago which worked out and I forgot to document (OS-process-based ambivalence to let one easily make use of CPU resources)
(import (chicken process) (chicken string) (chicken file posix) amb)
(define-syntax hyperpose
(syntax-rules ()
((_ arg1 arg2)
(receive (pipefd0 pipefd1) (create-pipe)
(let ((pid (process-fork)))
(if (eq? pid 0)
(begin (write arg1 (open-output-file* pipefd1))
(exit 0)) ;child is done
(let* ((res1 arg2) ;get to work before waiting for child to return result
(res2 (read (open-input-file* pipefd0))))
(amb res1 res2))))))))
;example:
(define (test x) (list 2 x (+ 2 x)))
(display (amb-collect (hyperpose (test 1) (test 2))))
(newline)
This is just an example, forking has some time overhead so use only if you have computationally expensive branches which should be able to be explored with different CPU cores!
The text was updated successfully, but these errors were encountered:
patham9
changed the title
Hyperpose (OS-process-based ambivalence to let one easily make use of CPU resources)
Concurrent superpose
Nov 29, 2023
An attempt I tried a few weeks ago which worked out and I forgot to document (OS-process-based ambivalence to let one easily make use of CPU resources)
This is just an example, forking has some time overhead so use only if you have computationally expensive branches which should be able to be explored with different CPU cores!
The text was updated successfully, but these errors were encountered: