[Distributed Places] Docs clean up part 2
This commit is contained in:
parent
29a401b692
commit
fbbf8579e0
|
@ -1624,16 +1624,20 @@
|
|||
|
||||
(define ch (make-channel))
|
||||
(thread
|
||||
(lambda () (channel-put ch (spawn-remote-racket-node host #:listen-port listen-port
|
||||
#:racket-path racketpath
|
||||
#:ssh-bin-path sshpath
|
||||
#:distributed-launch-path distributedlaunchpath))))
|
||||
(lambda ()
|
||||
(with-handlers ([exn:fail? (lambda (e) (channel-put #f))])
|
||||
(channel-put ch (spawn-remote-racket-node host #:listen-port listen-port
|
||||
#:racket-path racketpath
|
||||
#:ssh-bin-path sshpath
|
||||
#:distributed-launch-path distributedlaunchpath)))))
|
||||
ch)
|
||||
|
||||
(define/provide (spawn-nodes/join nodes-descs)
|
||||
(for/list ([x
|
||||
(for/list ([n nodes-descs])
|
||||
(apply keyword-apply spawn-node-at n))])
|
||||
(unless x
|
||||
(raise "Failed to connect to a remotely spawned node"))
|
||||
(channel-get x)))
|
||||
|
||||
#;(define build-node-args
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
rmpi-partition
|
||||
rmpi-build-default-config
|
||||
rmpi-launch
|
||||
rmpi-finish)
|
||||
rmpi-finish
|
||||
(struct-out rmpi-comm))
|
||||
|
||||
(struct rmpi-comm (id cnt channels) #:transparent)
|
||||
|
||||
|
@ -29,7 +30,7 @@
|
|||
|
||||
(define (rmpi-init ch)
|
||||
(define tc (new named-place-typed-channel% [ch ch]))
|
||||
(match-define (list (list 'mpi-id id config) return-ch) (tc-get 'mpi-id tc))
|
||||
(match-define (list (list 'rmpi-id id config) return-ch) (tc-get 'rmpi-id tc))
|
||||
(match-define (list (list 'args args) src-ch) (tc-get 'args tc))
|
||||
(define mpi-comm-vector
|
||||
(for/vector #:length (length config) ([c config])
|
||||
|
@ -186,19 +187,20 @@
|
|||
(hash-set (car _rest) (string->keyword "listen-port") port))]))
|
||||
; (printf/f "~a\n" rest)
|
||||
(define-values (k v)
|
||||
(let loop ([keys (list "racket-path" "listen-port" "distributed-launch-path")]
|
||||
(let loop ([keys (map string->keyword
|
||||
(sort (list "racket-path" "listen-port" "distributed-launch-path")))]
|
||||
[k null]
|
||||
[v null])
|
||||
(cond
|
||||
[(pair? keys)
|
||||
(match keys
|
||||
[(cons head tail)
|
||||
(cond
|
||||
[(lookup-config-value rest (car keys)) => (lambda (x)
|
||||
(loop (cdr keys)
|
||||
(cons (string->keyword (car keys)) k)
|
||||
[(lookup-config-value rest head) => (lambda (x)
|
||||
(loop tail
|
||||
(cons head k)
|
||||
(cons x v)))]
|
||||
[else
|
||||
(loop (cdr keys) k v)])]
|
||||
[else
|
||||
[(list)
|
||||
(values k v)])))
|
||||
; (printf/f "~a\n" (list k v (list host)))
|
||||
(list k v (list host)))))
|
||||
|
@ -208,18 +210,23 @@
|
|||
(match-define (list-rest host port name id rest) c)
|
||||
(supervise-named-dynamic-place-at n
|
||||
name
|
||||
(lookup-config-value rest "mpi-module")
|
||||
(lookup-config-value rest "mpi-func")))
|
||||
(lookup-config-value rest "rmpi-module")
|
||||
(lookup-config-value rest "rmpi-func")))
|
||||
|
||||
(define-values (mrth ch)
|
||||
(start-message-router/thread
|
||||
#:nodes nodes))
|
||||
|
||||
(define simple-config
|
||||
(for/list ([c config])
|
||||
(match-define (list-rest host port name id rest) c)
|
||||
(list host port name id)))
|
||||
|
||||
(for ([c config])
|
||||
(match-define (list-rest host port name id rest) c)
|
||||
(define npch (mr-connect-to ch (list host port) name))
|
||||
(*channel-put npch (list 'mpi-id id config))
|
||||
(*channel-put npch (list 'args (or (lookup-config-value rest "mpi-args") null))))
|
||||
(*channel-put npch (list 'rmpi-id id simple-config))
|
||||
(*channel-put npch (list 'args (or (lookup-config-value rest "rmpi-args") null))))
|
||||
|
||||
(for/first ([c config])
|
||||
(match-define (list-rest host port name id rest) c)
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
The @racketmodname[racket/place/distributed] library provides support for
|
||||
distributed programming.
|
||||
|
||||
The example bellow demonstrates how to launch a remote racket vm instance,
|
||||
launch remote places on the new remote vm instance, and start an
|
||||
event loop that monitors the remote vm instance.
|
||||
The example bellow demonstrates how to launch a remote racket node instance,
|
||||
launch remote places on the new remote node instance, and start an
|
||||
event loop that monitors the remote node instance.
|
||||
|
||||
The example code can also be found in
|
||||
@filepath{racket/distributed/examples/named/master.rkt}.
|
||||
|
@ -39,14 +39,14 @@ The example code can also be found in
|
|||
|
||||
|
||||
|
||||
The @racket[spawn-remote-racket-vm] primitive connects to
|
||||
The @racket[spawn-remote-racket-node] primitive connects to
|
||||
@tt{"localhost"} and starts a racloud node there that listens on port
|
||||
6344 for further instructions. The handle to the new racloud node is
|
||||
assigned to the @racket[remote-vm] variable. Localhost is used so that
|
||||
assigned to the @racket[remote-node] variable. Localhost is used so that
|
||||
the example can be run using only a single machine. However localhost
|
||||
can be replaced by any host with ssh publickey access and racket. The
|
||||
@racket[supervise-named-dynamic-place-at] creates a new place on the
|
||||
@racket[remote-vm]. The new place will be identified in the future by
|
||||
@racket[remote-node]. The new place will be identified in the future by
|
||||
its name symbol @racket['tuple-server]. A place descriptor is
|
||||
expected to be returned by invoking @racket[dynamic-place] with the
|
||||
@racket[tuple-path] module path and the @racket['make-tuple-server]
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
racket/class
|
||||
(for-label (except-in racket/base log-message))
|
||||
(for-label
|
||||
racket/place
|
||||
racket/place/define-remote-server
|
||||
racket/place/distributed
|
||||
racket/class
|
||||
racket/contract))
|
||||
racket/contract
|
||||
racket/place
|
||||
racket/place/private/async-bi-channel))
|
||||
|
||||
|
||||
@(define evaler (make-base-eval))
|
||||
|
@ -93,13 +95,21 @@ The use of Distributed Places is predicated on a couple assumptions:
|
|||
(require 'hello-world-example)
|
||||
]
|
||||
|
||||
@defproc[(message-router [ec events-container<%>?] ...+) void?]{
|
||||
@definterface[events-container<%> ()]{
|
||||
Every event container must implement the @racket[register] method.
|
||||
@defmethod[(register [rl (listof evt?)]) (listof evt?)]{
|
||||
Event containers should @racket[cons] on their events to the supplied list of events, @racket[rl],
|
||||
and return the resulting list.
|
||||
}
|
||||
}
|
||||
|
||||
@defproc[(message-router [ec (is-a?/c events-container<%>)] ...+) void?]{
|
||||
Waits in an endless loop for one of many events to become ready. The
|
||||
@racket[message-router] procedure constructs a @racket[node%]
|
||||
instance to serve as the message router for the node. The
|
||||
@racket[message-router] procedure then adds all the declared
|
||||
@racket[events-container<%>]s to the @racket[node%] and finally calls
|
||||
the never ending loop @racket[sync-events] method, which handles
|
||||
the never ending loop @method[node% sync-events] method, which handles
|
||||
events for the node.
|
||||
}
|
||||
|
||||
|
@ -107,8 +117,8 @@ The use of Distributed Places is predicated on a couple assumptions:
|
|||
@(define spawn-node-note
|
||||
(make-splice
|
||||
(list
|
||||
@p{This function returns a @racket[remote-node%] instance not a @racket[remote-place%]
|
||||
Call @racket[(send node get-first-place)] to obtain the @racket[remote-place%] instance.})) )
|
||||
@p{This function returns a @racket[remote-node%] instance not a @racket[remote-connection%]
|
||||
Call @racket[(send node get-first-place)] to obtain the @racket[remote-connection%] instance.})) )
|
||||
|
||||
@(define spawn-node-dynamic-note
|
||||
(make-splice
|
||||
|
@ -116,7 +126,7 @@ The use of Distributed Places is predicated on a couple assumptions:
|
|||
@p{
|
||||
Spawns a new remote node at @racket[hostname] with one instance place specified by
|
||||
the @racket[instance-module-path] and @racket[instance-place-function-name]
|
||||
parameters. This procedure constructs the new remote-place by calling
|
||||
parameters. This procedure constructs the new remote-connection by calling
|
||||
@racket[(dynamic-place instance-module-path instance-place-function-name)].
|
||||
})))
|
||||
|
||||
|
@ -128,8 +138,8 @@ parameters. This procedure constructs the new remote-place by calling
|
|||
[#:initial-message initial-message any #f]
|
||||
[#:racket-path racketpath string-path? (racket-path)]
|
||||
[#:ssh-bin-path sshpath string-path? (ssh-bin-path)]
|
||||
[#:launcher-path launcherpath string-path? (->string distributed-launch-path)]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) remote-place?]{
|
||||
[#:distributed-launch-path launcherpath string-path? (path->string distributed-launch-path)]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-connection%)]{
|
||||
@|spawn-node-dynamic-note|
|
||||
@|spawn-node-note|
|
||||
}
|
||||
|
@ -142,10 +152,10 @@ parameters. This procedure constructs the new remote-place by calling
|
|||
[#:initial-message initial-message any #f]
|
||||
[#:racket-path racketpath string-path? (racket-path)]
|
||||
[#:ssh-bin-path sshpath string-path? (ssh-bin-path)]
|
||||
[#:launcher-path launcherpath string-path? (->string distributed-launch-path)]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (values (is-a?/c remote-node%) (is-a?/c remote-place%))]{
|
||||
[#:distributed-launch-path launcherpath string-path? (path->string distributed-launch-path)]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (values (is-a?/c remote-node%) (is-a?/c remote-connection%))]{
|
||||
@|spawn-node-dynamic-note|
|
||||
The new @racket[remote-node%] and @racket[remote-place%] instances make up the two return values.
|
||||
The new @racket[remote-node%] and @racket[remote-connection%] instances make up the two return values.
|
||||
}
|
||||
|
||||
@(define place-thunk-function
|
||||
|
@ -166,7 +176,7 @@ accomplish this by calling either @racket[dynamic-place] or
|
|||
@p{
|
||||
Spawns a new remote node at @racket[hostname] with one instance place.
|
||||
the @racket[instance-module-path] and @racket[instance-thunk-function-name]
|
||||
parameters. This procedure constructs the new remote-place by calling
|
||||
parameters. This procedure constructs the new remote-connection by calling
|
||||
dynamically requiring the
|
||||
@racket[instance-thunk-function-name] and invoking the
|
||||
@racket[instance-thunk-function-name].
|
||||
|
@ -182,8 +192,8 @@ dynamically requiring the
|
|||
[#:initial-message initial-message any #f]
|
||||
[#:racket-path racketpath string-path? (racket-path)]
|
||||
[#:ssh-bin-path sshpath string-path? (ssh-bin-path)]
|
||||
[#:launcher-path launcherpath string-path? (->string distributed-launch-path)]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-place%)]{
|
||||
[#:distributed-launch-path launcherpath string-path? (path->string distributed-launch-path)]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-connection%)]{
|
||||
@|spawn-node-thunk-note|
|
||||
@|place-thunk-function|
|
||||
@|spawn-node-note|
|
||||
|
@ -196,11 +206,11 @@ dynamically requiring the
|
|||
[#:initial-message initial-message any #f]
|
||||
[#:racket-path racketpath string-path? (racket-path)]
|
||||
[#:ssh-bin-path sshpath string-path? (ssh-bin-path)]
|
||||
[#:launcher-path launcherpath string-path? (->string distributed-launch-path)]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (values (is-a?/c remote-node%) (is-a?/c remote-place%))]{
|
||||
[#:distributed-launch-path launcherpath string-path? (path->string distributed-launch-path)]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (values (is-a?/c remote-node%) (is-a?/c remote-connection%))]{
|
||||
@|spawn-node-thunk-note|
|
||||
@|place-thunk-function|
|
||||
The new @racket[remote-node%] and @racket[remote-place%] instances make up the two return values.
|
||||
The new @racket[remote-node%] and @racket[remote-connection%] instances make up the two return values.
|
||||
}
|
||||
|
||||
@defproc[(spawn-remote-racket-node
|
||||
|
@ -208,14 +218,14 @@ The new @racket[remote-node%] and @racket[remote-place%] instances make up the t
|
|||
[#:listen-port port port-no? DEFAULT-ROUTER-PORT]
|
||||
[#:racket-path racketpath string-path? (racket-path)]
|
||||
[#:ssh-bin-path sshpath string-path? (ssh-bin-path)]
|
||||
[#:launcher-path launcherpath string-path? (->string distributed-launch-path)]) (is-a?/c remote-node%)]{
|
||||
[#:distributed-launch-path launcherpath string-path? (path->string distributed-launch-path)]) (is-a?/c remote-node%)]{
|
||||
Spawns a new remote node at @racket[hostname] and returns a @racket[remote-node%] handle.
|
||||
}
|
||||
@defproc[(supervise-dynamic-place-at
|
||||
[remote-node (is-a?/c remote-node%)]
|
||||
[instance-module-path module-path?]
|
||||
[instance-place-function-name symbol?]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-place%)]{
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-connection%)]{
|
||||
Creates a new place on the @racket[remote-node] by using
|
||||
@racket[dynamic-place] to invoke
|
||||
@racket[instance-place-function-name] from the module
|
||||
|
@ -226,7 +236,7 @@ Creates a new place on the @racket[remote-node] by using
|
|||
[remote-node (is-a?/c remote-node%)]
|
||||
[instance-module-path module-path?]
|
||||
[instance-thunk-function-name symbol?]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-place%)]{
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-connection%)]{
|
||||
Creates a new place on the @racket[remote-node] by executing the thunk
|
||||
@racket[instance-thunk-function-name] from the module
|
||||
@racket[instance-module-path].
|
||||
|
@ -246,7 +256,7 @@ Spawns an attached external process at host @racket[hostname].
|
|||
[place-name symbol?]
|
||||
[instance-module-path module-path?]
|
||||
[instance-place-function-name symbol?]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-place%)]{
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-connection%)]{
|
||||
Creates a new place on the @racket[remote-node] by using
|
||||
@racket[dynamic-place] to invoke
|
||||
@racket[instance-place-function-name] from the module
|
||||
|
@ -259,7 +269,7 @@ is used to establish later connections to the named place.
|
|||
[place-name symbol?]
|
||||
[instance-module-path module-path?]
|
||||
[instance-thunk-function-name symbol?]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-place%)]{
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-connection%)]{
|
||||
Creates a new place on the @racket[remote-node] by executing the thunk
|
||||
@racket[instance-thunk-function-name] from the module
|
||||
@racket[instance-module-path]. The @racket[place-name] symbol
|
||||
|
@ -273,7 +283,7 @@ is used to establish later connections to the named place.
|
|||
[remote-node (is-a?/c remote-node%)]
|
||||
[instance-module-path module-path?]
|
||||
[instance-thunk-function-name symbol?]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-place%)]{
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (is-a?/c remote-connection%)]{
|
||||
Creates a new threadon the @racket[remote-node] by using
|
||||
@racket[dynamic-require] to invoke
|
||||
@racket[instance-place-function-name] from the module
|
||||
|
@ -320,7 +330,7 @@ Connects to a named place on the @racket[node] named @racket[name] and returns a
|
|||
The following classes all implement @racket[event-container<%>] and
|
||||
can be supplied to a @racket[message-router]:
|
||||
@racket[spawned-process%], @racket[place-socket-bridge%],
|
||||
@racket[node%], @racket[remote-node%], @racket[remote-place%],
|
||||
@racket[node%], @racket[remote-node%], @racket[remote-connection%],
|
||||
@racket[place%] @racket[connection%], @racket[respawn-and-fire%], and
|
||||
@racket[after-seconds%].
|
||||
|
||||
|
@ -436,7 +446,7 @@ node's message router.
|
|||
(make-splice
|
||||
(list
|
||||
@p{The @racket[#:restart-on-exit] boolean argument instructs the
|
||||
remote-place% instance to respawn the place on the remote node
|
||||
remote-connection% instance to respawn the place on the remote node
|
||||
should it exit or terminate at any time. This boolean needs to
|
||||
be expanded to a restart criteria object in the future.})))
|
||||
|
||||
|
@ -461,8 +471,8 @@ node's message router.
|
|||
dies.
|
||||
}
|
||||
|
||||
@defmethod[(get-first-place) (is-a?/c remote-place%)]{
|
||||
Returns the @racket[remote-place%] object instance for the first place spawned on this node.
|
||||
@defmethod[(get-first-place) (is-a?/c remote-connection%)]{
|
||||
Returns the @racket[remote-connection%] object instance for the first place spawned on this node.
|
||||
}
|
||||
@defmethod[(get-first-place-channel) place-channel?]{
|
||||
Returns the communication channel for the first place spawned on this node.
|
||||
|
@ -474,7 +484,7 @@ node's message router.
|
|||
@defmethod[(launch-place
|
||||
[place-exec list?]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]
|
||||
[#:one-sided-place? one-sided-place? any/c #f]) (is-a?/c remote-place%)]{
|
||||
[#:one-sided-place? one-sided-place? any/c #f]) (is-a?/c remote-connection%)]{
|
||||
Launches a place on the remote node represented by this @racket[remote-node%] instance.
|
||||
@|place-exec-note|
|
||||
@|one-sided-note|
|
||||
|
@ -494,8 +504,8 @@ node's message router.
|
|||
@defproc[(node-send-exit [remote-node% node]) void?]{
|
||||
Sends @racket[node] a message telling it to exit immediately.
|
||||
}
|
||||
@defproc[(node-get-first-place [remote-node% node]) (is-a?/c remote-place%)]{
|
||||
Returns the @racket[remote-place%] instance of the first place spawned at this node
|
||||
@defproc[(node-get-first-place [remote-node% node]) (is-a?/c remote-connection%)]{
|
||||
Returns the @racket[remote-connection%] instance of the first place spawned at this node
|
||||
}
|
||||
|
||||
|
||||
|
@ -533,12 +543,12 @@ places or connects to a named place and routes inter-node place messages to the
|
|||
distributed places node at that node. It launches a compute places and
|
||||
routes inter-node place messages to the place.
|
||||
|
||||
@defconstructor[([node (is-a?/c remote-place%)]
|
||||
@defconstructor[([node (is-a?/c remote-connection%)]
|
||||
[place-exec list?]
|
||||
[ch-id exact-positive-integer?]
|
||||
[sc (is-a?/c socket-connection%)]
|
||||
[on-place-dead (-> event void?) default-on-place-dead])]{
|
||||
Constructs a @racket[remote-place%] instance.
|
||||
Constructs a @racket[remote-connection%] instance.
|
||||
@|place-exec-note|
|
||||
The @racket[ch-id] and @racket[sc] arguments are internally used to
|
||||
establish routing between the remote node spawning this place and the
|
||||
|
@ -561,7 +571,7 @@ place messages to the named place.
|
|||
[name string?]
|
||||
[ch-id exact-positive-integer?]
|
||||
[sc (is-a?/c socket-connection%)])]{
|
||||
Constructs a @racket[remote-place%] instance.
|
||||
Constructs a @racket[remote-connection%] instance.
|
||||
@|place-exec-note|
|
||||
The @racket[ch-id] and @racket[sc] arguments are internally used to
|
||||
establish routing between the remote node and this named-place.
|
||||
|
@ -640,6 +650,15 @@ Takes all the positional and keyword arguments pass to it and builds a
|
|||
suitable as an argument to @racket[(lambda (x) (apply keyword-apply spawn-node-at x))].}
|
||||
}
|
||||
|
||||
@defproc[(spawn-node-at [hostname string?]
|
||||
[#:listen-port port port-no? DEFAULT-ROUTER-PORT]
|
||||
[#:racket-path racketpath string-path? (racket-path)]
|
||||
[#:ssh-bin-path sshpath string-path? (ssh-bin-path)]
|
||||
[#:distributed-launch-path launcherpath string-path? (path->string distributed-launch-path)]) channel?]{
|
||||
Spawns a node in the background using a Racket thread and returns a channel that becomes ready with a @racket[remote-node%]
|
||||
once the node has spawned successfully
|
||||
}
|
||||
|
||||
@defproc[(spawn-nodes/join [nodes-descs list?]) void?]{
|
||||
Spawns a list of nodes by calling @racket[(lambda (x) (apply keyword-apply spawn-node-at x))] for each node description in
|
||||
@racket[nodes-descs] and then waits for each node to spawn.
|
||||
|
@ -794,7 +813,7 @@ list of custom expressions as its arguments. From the identifier a
|
|||
function is created by prepending the @tt{make-} prefix. This
|
||||
procedure takes a single argument a @racket[place-channel]. In the
|
||||
example below, the @racket[make-tuple-server] identifier is the
|
||||
@racket{place-function-name} given to the
|
||||
@racket[place-function-name] given to the
|
||||
@racket[supervise-named-dynamic-place-at] form to spawn an rpc server.
|
||||
The server created by the @racket[make-tuple-server] procedure sits in
|
||||
a loop waiting for rpc requests from the @racket[define-rpc] functions
|
||||
|
@ -878,7 +897,7 @@ except there is no reply message from the server to client
|
|||
[else
|
||||
(hash-set! accounts who 0)
|
||||
(list 'created who)]))
|
||||
(define-rpc (removeM who amount)
|
||||
(define-rpc (remove who amount)
|
||||
(cond
|
||||
[(hash-ref accounts who (lambda () #f)) =>
|
||||
(lambda (balance)
|
||||
|
@ -907,6 +926,25 @@ except there is no reply message from the server to client
|
|||
@racket[define-remote-server] or @racket[define-named-remote-server] form to
|
||||
send a logging message to the remote owner of the rpc server.
|
||||
}
|
||||
@section{Async Bidirectional Channels}
|
||||
|
||||
@defmodule[racket/place/private/async-bi-channel]
|
||||
|
||||
@defproc[(make-async-bi-channel) async-bi-channel?]{
|
||||
Creates and returns a opaque structure, which is the async bidirectional channel.
|
||||
}
|
||||
|
||||
@defproc[(async-bi-channel? [ch any]) boolean?]{
|
||||
A predicate that returns @racket[#t] for async bidirectional channels.
|
||||
}
|
||||
|
||||
@defproc[(async-bi-channel-get [ch async-bi-channel?]) any]{
|
||||
Returns the next available message from the async bidirectional channel @racket[ch].
|
||||
}
|
||||
|
||||
@defproc[(async-bi-channel-put [ch async-bi-channel?] [msg any]) void?]{
|
||||
Sends message @racket[msg] to the remote end of the async bidirectional channel @racket[ch].
|
||||
}
|
||||
|
||||
@(close-eval evaler)
|
||||
@include-section["rmpi.scrbl"]
|
||||
|
|
|
@ -7,87 +7,87 @@
|
|||
racket/place/distributed/rmpi
|
||||
racket/sandbox
|
||||
racket/class)
|
||||
@(require (for-label racket/base
|
||||
racket/place/distributed/rmpi))
|
||||
@(require (for-label (except-in racket/base log-message)
|
||||
racket/contract
|
||||
racket/class
|
||||
racket/place
|
||||
racket/place/distributed
|
||||
racket/place/distributed/rmpi
|
||||
racket/place/private/async-bi-channel))
|
||||
|
||||
|
||||
@(define evaler (make-base-eval))
|
||||
@(interaction-eval #:eval evaler (require racket/place/distributed
|
||||
racket/class
|
||||
#;racket/place/distributed/rmpi))
|
||||
racket/class))
|
||||
|
||||
@(define output-evaluator
|
||||
(parameterize ([sandbox-output 'string]
|
||||
[sandbox-error-output 'string])
|
||||
(make-evaluator 'racket/base)))
|
||||
|
||||
@(define-syntax interaction-output
|
||||
(syntax-rules ()
|
||||
[(_ #:eval evaluator e)
|
||||
(begin
|
||||
(interaction #:eval evaluator e)
|
||||
(printf "K ~a\n" (get-output evaluator)))]))
|
||||
|
||||
@title[#:tag "distributed-places-MPI"]{Distributed Places MPI}
|
||||
|
||||
@defmodule[racket/place/distributed/rmpi]
|
||||
|
||||
@defproc[(rmpi-id [comm RMPI-comm?]) exact-nonnegative-integer? ]{
|
||||
@defstruct*[rmpi-comm ([id exact-nonnegative-integer?] [cnt exact-positive-integer?] [channels vector?])]{
|
||||
The communicator struct @racket[rmpi-comm] contains the rmpi process
|
||||
rank @racket[id], the quantity of processes in the communicator group,
|
||||
@racket[cnt], and a vector of place-channels, one for each process in
|
||||
the group.
|
||||
}
|
||||
|
||||
@defproc[(rmpi-id [comm rmpi-comm?]) exact-nonnegative-integer? ]{
|
||||
Takes a rmpi communicator structure, @racket[comm], and returns the node id of the RMPI
|
||||
process.
|
||||
}
|
||||
|
||||
@defproc[(rmpi-cnt [comm RMPI-comm?]) positive-integer? ]{
|
||||
@defproc[(rmpi-cnt [comm rmpi-comm?]) exact-positive-integer? ]{
|
||||
Takes a rmpi communicator structure, @racket[comm], and returns the count of the RMPI
|
||||
processes in the communicator group.
|
||||
}
|
||||
|
||||
@defproc[(rmpi-send [comm RMPI-comm?] [dest exact-nonnegative-integer?] [val any]) void?]{
|
||||
@defproc[(rmpi-send [comm rmpi-comm?] [dest exact-nonnegative-integer?] [val any]) void?]{
|
||||
Sends @racket[val] to destination rmpi process number @racket[dest]
|
||||
using the RMPI communicator structure @racket[comm].
|
||||
}
|
||||
|
||||
@defproc[(rmpi-recv [comm RMPI-comm?] [src exact-nonnegative-integer?]) any]{
|
||||
@defproc[(rmpi-recv [comm rmpi-comm?] [src exact-nonnegative-integer?]) any]{
|
||||
Receives a message from source rmpi process number @racket[src]
|
||||
using the RMPI communicator structure @racket[comm].
|
||||
}
|
||||
|
||||
@defproc[(rmpi-init [ch place-channel?]) (values RMPI-comm? (listof any) (is-a?/c named-place-type-channel%))]{
|
||||
@defproc[(rmpi-init [ch place-channel?]) (values rmpi-comm? (listof any) (is-a?/c named-place-typed-channel%))]{
|
||||
Creates the @racket[rmpi-comm] structure instance using the named
|
||||
place's original place-channel @racket[ch]. In addition to the
|
||||
communicator structure, @racket[rmpi-init] returns a list of initial
|
||||
arguments and the original place-channel @racket[ch] wrapped in a
|
||||
@racket[named-place-type-channel%]. The
|
||||
@racket[named-place-type-channel%] wrapper allows for the reception
|
||||
@racket[named-place-typed-channel%]. The
|
||||
@racket[named-place-typed-channel%] wrapper allows for the reception
|
||||
of list messages typed by an initial symbol.
|
||||
}
|
||||
|
||||
@defproc*[([(rmpi-broadcast [comm RMPI-comm?] [src exact-nonnegative-integer?]) any]
|
||||
[(rmpi-broadcast [comm RMPI-comm?] [src exact-nonnegative-integer?] [val any]) any])]{
|
||||
@defproc*[([(rmpi-broadcast [comm rmpi-comm?] [src exact-nonnegative-integer?]) any]
|
||||
[(rmpi-broadcast [comm rmpi-comm?] [src exact-nonnegative-integer?] [val any]) any])]{
|
||||
Broadcasts @racket[val] from @racket[src] to all rmpi processes in
|
||||
the communication group using a hypercube algorithm. Receiving
|
||||
processes call @racket[(rmpi-broadcast comm src)].
|
||||
}
|
||||
|
||||
@defproc[(rmpi-reduce [comm RMPI-comm?] [dest exact-nonnegative-integer?] [op procedure?] [val any]) any]{
|
||||
@defproc[(rmpi-reduce [comm rmpi-comm?] [dest exact-nonnegative-integer?] [op procedure?] [val any]) any]{
|
||||
Reduces @racket[val] using the @racket[op] operator to @racket[dest]
|
||||
rmpi node using a hypercube algorithm.
|
||||
}
|
||||
|
||||
@defproc[(rmpi-barrier [comm RMPI-comm?]) void?]{
|
||||
@defproc[(rmpi-barrier [comm rmpi-comm?]) void?]{
|
||||
Introduces a synchronization barrier for all rmpi processes in the
|
||||
communcication group @racket[comm].
|
||||
}
|
||||
|
||||
@defproc[(rmpi-allreduce [comm RMPI-comm?] [op procedure?] [val any]) any]{
|
||||
@defproc[(rmpi-allreduce [comm rmpi-comm?] [op procedure?] [val any]) any]{
|
||||
Reduces @racket[val] using the @racket[op] operator to rmpi node
|
||||
@racket[0] and then broadcasts the reduced value to all nodes in the
|
||||
communication group.
|
||||
}
|
||||
|
||||
@defproc[(rmpi-partition [comm RMPI-comm?] [num positive-integer?]) (values positive-integer? positive-integer?)]{
|
||||
@defproc[(rmpi-partition [comm rmpi-comm?] [num exact-nonnegative-integer?]) (values exact-nonnegative-integer? exact-nonnegative-integer?)]{
|
||||
Partitions @racket[num] into @racket[rmpi-cnt] equal pieces and
|
||||
returns the offset and length for the @racket[RMPI-id]th piece.
|
||||
returns the offset and length for the @racket[rmpi-id]th piece.
|
||||
}
|
||||
|
||||
@defproc[(rmpi-build-default-config
|
||||
|
@ -114,15 +114,16 @@
|
|||
@racket[default-node-config] hash of keyword arguments.
|
||||
}
|
||||
|
||||
@defproc[(rmpi-finish [comm RMPI-comm?] [tc (is-a?/c named-place-type-channel%)]) void?]{
|
||||
@defproc[(rmpi-finish [comm rmpi-comm?] [tc (is-a?/c named-place-typed-channel%)]) void?]{
|
||||
Rendezvous with the @racket[rmpi-launch], using the @racket[tc]
|
||||
returned by @racket[RMPI-launch], to indicate that the RMPI module
|
||||
is done executing and that @racket[RMPI-launch] can return control
|
||||
returned by @racket[rmpi-launch], to indicate that the RMPI module
|
||||
is done executing and that @racket[rmpi-launch] can return control
|
||||
to its caller.
|
||||
}
|
||||
|
||||
|
||||
@examples[ #:eval evaler
|
||||
(eval:alts
|
||||
(rmpi-launch
|
||||
(rmpi-build-default-config
|
||||
#:racket-path "/tmp/mplt/bin/racket"
|
||||
|
@ -135,6 +136,7 @@
|
|||
(list "nodeb.example.com" 6340 'kmeans_1 1)
|
||||
(list "nodec.example.com" 6340 'kmeans_2 2)
|
||||
(list "noded.example.com" 6340 'kmeans_3 3)))
|
||||
(void))
|
||||
]
|
||||
|
||||
@(close-eval evaler)
|
||||
|
|
Loading…
Reference in New Issue
Block a user