Skip to content

Commit

Permalink
- make workers work with multiple adapters in local case
Browse files Browse the repository at this point in the history
  • Loading branch information
swadey authored and Wade Shen committed Jan 3, 2013
1 parent cccc489 commit 8d3d902
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function process_options(args::Array{Any,1})
if args[i]=="-q" || args[i]=="--quiet"
quiet = true
elseif args[i]=="--worker"
start_worker()
start_worker(args[i+1])
# doesn't return
elseif args[i]=="-e"
# TODO: support long options
Expand Down
15 changes: 8 additions & 7 deletions base/multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -876,17 +876,18 @@ end

# the entry point for julia worker processes. does not return.
# argument is descriptor to write listening port # to.
start_worker() = start_worker(1)
function start_worker(wrfd)
start_worker(mode :: String) = start_worker(mode, 1)
function start_worker(mode :: String, wrfd)
port = [int16(9009)]
sockfd = ccall(:open_any_tcp_port, Int32, (Ptr{Int16},), port)
if sockfd == -1
error("could not bind socket")
end
io = fdio(wrfd)
host = mode == "local" ? "localhost" : getipaddr()
write(io, "julia_worker:") # print header
write(io, "$(dec(port[1]))#") # print port
write(io, getipaddr()) # print hostname
write(io, host) # print hostname
write(io, '\n')
flush(io)
# close stdin; workers will not use it
Expand Down Expand Up @@ -974,11 +975,11 @@ function ssh_tunnel(user, host, port)
end

function worker_ssh_cmd(host)
`ssh -n $host "bash -l -c \"cd $JULIA_HOME && ./julia-release-basic --worker\""`
`ssh -n $host "bash -l -c \"cd $JULIA_HOME && ./julia-release-basic --worker remote\""`
end

#function worker_ssh_cmd(host, key)
# `ssh -i $key -n $host "bash -l -c \"cd $JULIA_HOME && ./julia-release-basic --worker\""`
# `ssh -i $key -n $host "bash -l -c \"cd $JULIA_HOME && ./julia-release-basic --worker remote\""`
#end

function addprocs_ssh(machines)
Expand All @@ -1003,7 +1004,7 @@ end
# add_workers(PGRP, start_remote_workers(machines, map(x->worker_ssh_cmd(x[1],x[2]), cmdargs)))
#end

worker_local_cmd() = `$JULIA_HOME/julia-release-basic --worker`
worker_local_cmd() = `$JULIA_HOME/julia-release-basic --worker local`

addprocs_local(np::Integer) =
add_workers(PGRP, start_remote_workers({ "localhost" for i=1:np },
Expand All @@ -1015,7 +1016,7 @@ function start_sge_workers(n)
sgedir = "$home/../../SGE"
run(`mkdir -p $sgedir`)
qsub_cmd = `qsub -N JULIA -terse -e $sgedir -o $sgedir -t 1:$n`
`echo $home/julia-release-basic --worker` | qsub_cmd
`echo $home/julia-release-basic --worker remote` | qsub_cmd
out = cmd_stdout_stream(qsub_cmd)
if !success(qsub_cmd)
error("batch queue not available (could not run qsub)")
Expand Down

0 comments on commit 8d3d902

Please sign in to comment.