Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F59856641
cost_estimation.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Apr 25, 15:59
Size
2 KB
Mime Type
text/x-python
Expires
Sat, Apr 27, 15:59 (2 d)
Engine
blob
Format
Raw Data
Handle
17258590
Attached To
R11599 sausage-binary
cost_estimation.py
View Options
'''
Estimation cost module
'''
from
sys
import
version_info
import
re
from
sausage.readconf
import
ReadConf
from
sausage.appargs
import
AppArgs
# from sausage.esclient import ESClient
from
sausage.debug
import
debug
from
sausage.logging
import
setup_logging
AppArgs
(
cost
=
True
)
ReadConf
()
@debug
(
timer
=
AppArgs
.
verbose
)
@debug
(
prof
=
AppArgs
.
verbose
)
def
estimation
():
assert
version_info
>=
(
3
,
8
)
logger
=
setup_logging
(
ReadConf
.
debug
,
AppArgs
.
verbose
)
logger
.
debug
(
"START"
)
# client = ESClient()
# print(client.get_estimation())
args
=
vars
(
AppArgs
.
response
)
args
.
pop
(
"verbose"
,
None
)
print
(
_estimation
(
**
args
))
logger
.
debug
(
"END"
)
def
is_zero
(
val
):
'''
Check default zero in a slurmctld context
'''
infisixteen
=
2
**
16
-
2
infithirtytwo
=
2
**
32
-
2
ret
=
True
if
val
==
infithirtytwo
or
val
==
infisixteen
or
val
is
None
:
ret
=
False
return
ret
def
_estimation
(
partition
,
array
,
nodes
=
0
,
nbtasks
=
0
,
time
=
0
,
ntasks_per_node
=
0
,
gres
=
0
,
cpus_per_task
=
0
,
):
# DEFAULT (TODO)
defaultwtime
=
1
corespernode
=
20
gpuspernode
=
2
est
=
0
cgpu_cost
=
1
# time
if
is_zero
(
time
):
timeinsec
=
defaultwtime
else
:
timeinsec
=
int
(
time
)
*
60
# cpu
if
is_zero
(
cpus_per_task
):
cpus
=
corespernode
else
:
cpus
=
cpus_per_task
# (g|c)putres
gputmp
=
re
.
match
(
r'gpu:(\d+)'
,
gres
)
gpus
=
int
(
gputmp
.
group
(
1
))
if
gputmp
else
0
tres
=
cpus
if
gpus
==
0
else
gpus
# nodes
nodes
=
int
(
nodes
)
if
is_zero
(
nodes
):
if
gpus
!=
0
:
nodes
=
cpus
/
corespernode
elif
gpus
==
0
:
nodes
=
gpus
/
gpuspernode
else
:
nodes
=
0
# array
if
array
is
None
:
arrayindex
=
1
else
:
arrayindex
=
array
.
split
(
"-"
)
if
array
else
[
0
,
0
]
arrayindex
=
abs
(
int
(
arrayindex
[
1
])
-
int
(
arrayindex
[
0
]))
+
1
est
=
nodes
*
tres
*
cgpu_cost
*
timeinsec
*
arrayindex
return
est
Event Timeline
Log In to Comment