Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for specifying cores for the adapters that can support it #851

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ood_core/job/adapters/fujitsu_tcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def submit(script, after: [], afterok: [], afternotok: [], afterany: [])

args.concat ["-N", script.job_name] unless script.job_name.nil?
args.concat ["-o", script.output_path] unless script.output_path.nil?
args.concat ['--mpi', "proc=#{script.cores}"] unless script.cores.nil?
if script.error_path.nil?
args.concat ["-j"]
else
Expand Down
1 change: 1 addition & 0 deletions lib/ood_core/job/adapters/lsf/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def batch_submit_args(script, after: [], afterok: [], afternotok: [], afterany:
args.concat ["-b", script.start_time.localtime.strftime("%Y:%m:%d:%H:%M")] unless script.start_time.nil?
args.concat ["-W", (script.wall_time / 60).to_i] unless script.wall_time.nil?
args.concat ["-L", script.shell_path.to_s] unless script.shell_path.nil?
args.concat ['-n', script.cores] unless script.cores.nil?

# environment
env = script.job_environment || {}
Expand Down
8 changes: 8 additions & 0 deletions lib/ood_core/job/adapters/pbspro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def submit(script, after: [], afterok: [], afternotok: [], afterany: [])
args.concat ["-a", script.start_time.localtime.strftime("%C%y%m%d%H%M.%S")] unless script.start_time.nil?
args.concat ["-A", script.accounting_id] unless script.accounting_id.nil?
args.concat ["-l", "walltime=#{seconds_to_duration(script.wall_time)}"] unless script.wall_time.nil?
args.concat ppn(script)

# Set dependencies
depend = []
Expand Down Expand Up @@ -422,6 +423,13 @@ def directive_prefix
'#PBS'
end

# place holder for when we support both nodes and cpus.
def ppn(script)
return [] if script.cores.nil?

['-l', "ncpus=#{script.cpus}"]
end

private
# Convert duration to seconds
def duration_in_seconds(time)
Expand Down
1 change: 1 addition & 0 deletions lib/ood_core/job/adapters/slurm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ def submit(script, after: [], afterok: [], afternotok: [], afterany: [])
args.concat ['-a', script.job_array_request] unless script.job_array_request.nil?
args.concat ['--qos', script.qos] unless script.qos.nil?
args.concat ['--gpus-per-node', script.gpus_per_node] unless script.gpus_per_node.nil?
args.concat ['-n', script.cores] unless script.cores.nil?
# ignore nodes, don't know how to do this for slurm

# Set dependencies
Expand Down
8 changes: 8 additions & 0 deletions lib/ood_core/job/adapters/torque.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def submit(script, after: [], afterok: [], afternotok: [], afterany: [])
args.concat ['-t', script.job_array_request] unless script.job_array_request.nil?
args.concat ['-l', "qos=#{script.qos}"] unless script.qos.nil?
args.concat ['-l', "gpus=#{script.gpus_per_node}"] unless script.gpus_per_node.nil?
args.concat ppn(script)

# Set environment variables
env = script.job_environment.to_h
Expand Down Expand Up @@ -302,6 +303,13 @@ def directive_prefix
'#QSUB'
end

# place holder for when we support both nodes and cpus.
def ppn(script)
return [] if script.cores.nil?

['-l', "procs=#{script.cpus}"]
end

private
# Convert duration to seconds
def duration_in_seconds(time)
Expand Down
11 changes: 9 additions & 2 deletions lib/ood_core/job/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ class Script
# @return [Integer, nil] gpus per node
attr_reader :gpus_per_node

# The core request for this job
# @return [Integer, nil] cores
attr_reader :cores

# Object detailing any native specifications that are implementation specific
# @note Should not be used at all costs.
# @return [Object, nil] native specifications
Expand Down Expand Up @@ -151,7 +155,8 @@ def initialize(content:, args: nil, submit_as_hold: nil, rerunnable: nil,
output_path: nil, error_path: nil, reservation_id: nil,
queue_name: nil, priority: nil, start_time: nil,
wall_time: nil, accounting_id: nil, job_array_request: nil,
qos: nil, gpus_per_node: nil, native: nil, copy_environment: nil, **_)
qos: nil, gpus_per_node: nil, native: nil, copy_environment: nil,
cores: nil, **_)
@content = content.to_s

@submit_as_hold = submit_as_hold
Expand Down Expand Up @@ -179,6 +184,7 @@ def initialize(content:, args: nil, submit_as_hold: nil, rerunnable: nil,
@gpus_per_node = gpus_per_node && gpus_per_node.to_i
@native = native
@copy_environment = (copy_environment.nil?) ? nil : !! copy_environment
@cores = cores&.to_i
end

# Convert object to hash
Expand Down Expand Up @@ -209,7 +215,8 @@ def to_h
qos: qos,
gpus_per_node: gpus_per_node,
native: native,
copy_environment: copy_environment
cores: cores,
copy_environment: copy_environment,
}
end

Expand Down
Loading