Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
ae8a34ed
Commit
ae8a34ed
authored
13 years ago
by
Moe Jette
Browse files
Options
Downloads
Patches
Plain Diff
aprun wrapper should be close to as good as possible
parent
5498bb90
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contribs/cray/srun2.pl
+112
-10
112 additions, 10 deletions
contribs/cray/srun2.pl
with
112 additions
and
10 deletions
contribs/cray/srun2.pl
+
112
−
10
View file @
ae8a34ed
...
@@ -89,15 +89,15 @@ my ( $account,
...
@@ -89,15 +89,15 @@ my ( $account,
$man
,
$man
,
$memory
,
$memory
,
$memory_per_cpu
,
$memory_per_cpu
,
$memory_bind
,
$memory_bind
,
$mem_local
,
$min_cpus
,
$min_cpus
,
$msg_timeout
,
$msg_timeout
,
$mpi_type
,
$mpi_type
,
$multi_prog
,
$multi_prog
,
$multi_executables
,
$network
,
$network
,
$nice
,
$nice
,
$no_allocate
,
$no_allocate
,
$nodelist
,
$nodelist
,
$nid_list
,
$ntasks_per_core
,
$ntasks_per_core
,
$ntasks_per_node
,
$ntasks_per_node
,
$ntasks_per_socket
,
$ntasks_per_socket
,
...
@@ -376,12 +376,13 @@ $command .= " $alps" if $alps;
...
@@ -376,12 +376,13 @@ $command .= " $alps" if $alps;
# $command .= " -a" no srun equivalent
# $command .= " -a" no srun equivalent
# $command .= " -b" no srun equivalent
# $command .= " -b" no srun equivalent
# $command .= " -B" no srun equivalent
# $command .= " -B" no srun equivalent
# $command .= " -cc" N
EEDS WORK
, cpu binding
# $command .= " -cc" N
O GOOD MAPPING
, cpu binding
$command
.=
"
-d
$cpus_per_task
"
if
$cpus_per_task
;
$command
.=
"
-d
$cpus_per_task
"
if
$cpus_per_task
;
$command
.=
"
-D 1
"
if
$verbose
;
$command
.=
"
-D 1
"
if
$verbose
;
# $command .= " -F" NEEDS WORK, cpu/memory binding
# $command .= " -F" NO GOOD MAPPING, cpu/memory binding
# $command .= " -L" NEEDS WORK, nodelist
$nid_list
=
get_nids
(
$nodelist
)
if
$nodelist
;
# $command .= " -m[h|hs]" NEEDS WORK, mem per task
$command
.=
"
-L
$nid_list
"
if
$nodelist
;
$command
.=
"
-m
$memory_per_cpu
"
if
$memory_per_cpu
;
$command
.=
"
-n
$num_tasks
"
if
$num_tasks
;
$command
.=
"
-n
$num_tasks
"
if
$num_tasks
;
$command
.=
"
-N
$ntasks_per_node
"
if
$ntasks_per_node
;
$command
.=
"
-N
$ntasks_per_node
"
if
$ntasks_per_node
;
$command
.=
"
-q
"
if
$quiet
;
$command
.=
"
-q
"
if
$quiet
;
...
@@ -389,11 +390,13 @@ $command .= " -q" if $quiet;
...
@@ -389,11 +390,13 @@ $command .= " -q" if $quiet;
$command
.=
"
-S
$ntasks_per_socket
"
if
$ntasks_per_socket
;
$command
.=
"
-S
$ntasks_per_socket
"
if
$ntasks_per_socket
;
# $command .= " -sl" no srun equivalent
# $command .= " -sl" no srun equivalent
$command
.=
"
-sn
$sockets_per_node
"
if
$sockets_per_node
;
$command
.=
"
-sn
$sockets_per_node
"
if
$sockets_per_node
;
# $command .= " -ss" NEEDS WORK, mem_bind
if
(
$memory_bind
&&
(
$memory_bind
=~
/local/i
))
{
$command
.=
"
-ss
"
}
$command
.=
"
-T
";
# Line buffered is srun default
$command
.=
"
-T
";
# Line buffered is srun default
$time_secs
=
get_seconds
(
$time_limit
)
if
$time_limit
;
$time_secs
=
get_seconds
(
$time_limit
)
if
$time_limit
;
$command
.=
"
-t
$time_secs
"
if
$time_secs
;
$command
.=
"
-t
$time_secs
"
if
$time_secs
;
#$command .= " --
multi
-
prog
" NEEDS WORK
$script
=
get_
multi
_
prog
(
$script
)
if
$multi_prog
;
# Srun option which are not supported by aprun
# Srun option which are not supported by aprun
# $command .= " --disable-status" if $disable_status;
# $command .= " --disable-status" if $disable_status;
...
@@ -426,6 +429,7 @@ $command .= " $script";
...
@@ -426,6 +429,7 @@ $command .= " $script";
print
"
command=
$command
\n
";
print
"
command=
$command
\n
";
#system($command);
#system($command);
# Convert a SLURM time format to a number of seconds
sub
get_seconds
{
sub
get_seconds
{
my
(
$duration
)
=
@_
;
my
(
$duration
)
=
@_
;
$duration
=
0
unless
$duration
;
$duration
=
0
unless
$duration
;
...
@@ -442,10 +446,103 @@ sub get_seconds {
...
@@ -442,10 +446,103 @@ sub get_seconds {
}
else
{
# Unsupported format
}
else
{
# Unsupported format
die
("
Invalid time limit specified (
$duration
)
\n
");
die
("
Invalid time limit specified (
$duration
)
\n
");
}
}
return
$seconds
;
return
$seconds
;
}
}
# Convert a SLURM hostlist expression into the equivalent node index value
# expression
sub
get_nids
{
my
(
$host_list
)
=
@_
;
my
(
$nid_list
)
=
$host_list
;
$nid_list
=~
s/nid//g
;
$nid_list
=~
s/\[//g
;
$nid_list
=~
s/\]//g
;
$nid_list
=~
s/\d+/sprintf("%d", $&)/g
e
;
return
$nid_list
;
}
# Convert SLURM multi_prog file into a aprun options
# srun file format is "task_IDs command args..."
sub
get_multi_prog
{
my
(
$fname
)
=
@_
;
my
(
$out_line
);
my
(
$line_num
)
=
0
;
my
(
@words
,
$word
,
$word_num
,
$num_pes
);
open
(
MP
,
$fname
)
||
die
("
Can not read
$fname
");
while
(
<
MP
>
)
{
chop
;
if
(
$line_num
!=
0
)
{
$out_line
.=
"
:
";
}
$line_num
++
;
@words
=
split
('
',
$_
);
$word_num
=
0
;
foreach
$word
(
@words
)
{
if
(
$word_num
==
0
)
{
$num_pes
=
get_num_pes
(
$word
);
$out_line
.=
"
-n
$num_pes
";
}
else
{
$out_line
.=
"
$word
";
}
$word_num
++
;
}
}
return
$out_line
;
}
# Convert number ranges and sets into a total count
sub
get_num_pes
{
my
(
$pes_range
)
=
@_
;
my
(
@ranges
,
$range
);
my
(
@pairs
,
$value
);
my
(
$min_value
,
$max_value
);
my
(
$value_num
);
my
(
$num_pes
)
=
0
;
@ranges
=
split
('
,
',
$pes_range
);
foreach
$range
(
@ranges
)
{
@pairs
=
split
('
-
',
$range
);
$value_num
=
0
;
foreach
$value
(
@pairs
)
{
if
(
$value_num
==
0
)
{
$min_value
=
$value
;
}
$max_value
=
$value
;
$value_num
++
;
}
$num_pes
+=
(
$max_value
-
$min_value
+
1
);
}
return
$num_pes
;
}
# Convert a size format containing optional K, M, G or T suffix to the
# equvalent number of megabytes
sub
convert_mb_format
{
my
(
$value
)
=
@_
;
my
(
$amount
,
$suffix
)
=
$value
=~
/(\d+)($|[KMGT])/i
;
return
if
!
$amount
;
$suffix
=
lc
(
$suffix
);
if
(
!
$suffix
)
{
$amount
/=
1048576
;
}
elsif
(
$suffix
eq
"
k
")
{
$amount
/=
1024
;
}
elsif
(
$suffix
eq
"
m
")
{
#do nothing this is what we want.
}
elsif
(
$suffix
eq
"
g
")
{
$amount
*=
1024
;
}
elsif
(
$suffix
eq
"
t
")
{
$amount
*=
1048576
;
}
else
{
print
"
don't know what to do with suffix
$suffix
\n
";
return
;
}
return
$amount
;
}
##############################################################################
##############################################################################
__END__
__END__
...
@@ -465,6 +562,11 @@ first create a resource allocation in which to run the parallel job.
...
@@ -465,6 +562,11 @@ first create a resource allocation in which to run the parallel job.
=head1 OPTIONS
=head1 OPTIONS
The following aprun options have no equivalent in srun and must be specified
by using the B<--alps> option: B<-a>, B<-b>, B<-B>, B<-cc>, B<-f>, B<-r>, and
B<-sl>. Many other options do not exact functionality matches, but duplication
srun behavior to the extent possible.
=over 4
=over 4
=item B<-A> | B<--account=account>
=item B<-A> | B<--account=account>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment