-
Notifications
You must be signed in to change notification settings - Fork 0
/
greeneCPU.lua
213 lines (171 loc) · 5.33 KB
/
greeneCPU.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/bin/env lua
local greeneCPU = { }
local greeneUtils = require "greeneUtils"
local greeneCommon = require "greeneCommon"
local greeneSpecialUsers = require "greeneSpecialUsers"
local slurm_log = greeneUtils.slurm_log
local user_log = greeneUtils.user_log
local cpus = 0
local memory = 0
local nodes = 0
local time_limit = greeneUtils.unlimited_time
local ave_memory = 0
-- this is the order to assign partitions
local function available_partitions()
local partitions = nil
if greeneCommon.is_interactive_job() then
partitions = { "xwang", "chem_cpu0", "cs", "cm", "cpu_a100_2", "cpu_a100_1", "cpu_gpu", "cl", "mi50" }
else
partitions = { "xwang", "chem_cpu0", "cl", "cm", "cs", "cpu_a100_2", "cpu_gpu" }
end
return partitions
end
local partition_configurations = {
cs = { min_cpus = 1, max_cpus = 48,
max_nodes = 524,
min_memory = 0, max_memory = 180,
min_ave_memory = 0, max_ave_memory = 16,
},
cm = { min_cpus = 1, max_cpus = 48,
max_nodes = 40,
min_memory = 10, max_memory = 369,
min_ave_memory = 4, max_ave_memory = 64
},
cl = { min_cpus = 1, max_cpus = 96,
max_nodes = 4,
min_memory = 40, max_memory = 3014,
min_ave_memory = 10, max_ave_memory = 3014
},
cpu_gpu = { min_cpus = 1, max_cpus = 20,
max_nodes = 2,
min_memory = 0, max_memory = 180,
min_ave_memory = 0, max_ave_memory = 180,
time_limit = greeneUtils.hours_to_mins(4)
},
mi50 = { min_cpus = 1, max_cpus = 48,
max_nodes = 20,
min_memory = 0, max_memory = 180,
min_ave_memory = 0, max_ave_memory = 180,
time_limit = greeneUtils.hours_to_mins(48),
require_partition = true
},
cpu_a100_1 = { min_cpus = 1, max_cpus = 16,
max_nodes = 4,
min_memory = 0, max_memory = 200,
min_ave_memory = 0, max_ave_memory = 60,
time_limit = greeneUtils.hours_to_mins(4),
},
cpu_a100_2 = { min_cpus = 1, max_cpus = 64,
max_nodes = 20,
min_memory = 0, max_memory = 500,
min_ave_memory = 0, max_ave_memory = 120,
time_limit = greeneUtils.hours_to_mins(4),
},
xwang = { min_cpus = 1, max_cpus = 48,
max_nodes = 10,
min_memory = 0, max_memory = 180,
min_ave_memory = 0, max_ave_memory = 180,
users = greeneSpecialUsers.cns_wang_users
},
chem_cpu0 = { min_cpus = 1, max_cpus = 48,
max_nodes = 10,
min_memory = 0, max_memory = 180,
min_ave_memory = 0, max_ave_memory = 180,
users = greeneSpecialUsers.chem_cpu0_users
}
}
local special_partition_configurations = {
cs = { min_cpus = 48, max_cpus = 48,
max_nodes = 524,
min_memory = 0, max_memory = 180
},
cm = { min_cpus = 48, max_cpus = 48,
max_nodes = 40,
min_memory = 180.001, max_memory = 300
}
}
local function fit_into_single_partition(part_name)
local partition_conf = special_partition_configurations[part_name]
if partition_conf == nil then return false end
if nodes <= partition_conf.max_nodes and
cpus == partition_conf.min_cpus and
cpus == partition_conf.max_cpus and
memory >= partition_conf.min_memory and
memory <= partition_conf.max_memory then
return true
end
return false
end
local function fit_into_partition(part_name)
local partition_conf = partition_configurations[part_name]
if partition_conf == nil then return false end
if partition_conf.users ~= nil and
not greeneUtils.in_table(partition_conf.users, greeneCommon.netid()) then
return false
end
if partition_conf.require_partition and part_name ~= greeneCommon.partition() then return false end
if partition_conf.time_limit ~= nil and time_limit > partition_conf.time_limit then
return false
end
if nodes <= partition_conf.max_nodes and
cpus >= partition_conf.min_cpus and
cpus <= partition_conf.max_cpus and
memory >= partition_conf.min_memory and
memory <= partition_conf.max_memory and
ave_memory >= partition_conf.min_ave_memory and
ave_memory <= partition_conf.max_ave_memory then
return true
end
return false
end
local function valid_partitions()
local partitions = available_partitions()
local partitions_ = nil
for _, part_name in pairs(partitions) do
if fit_into_single_partition(part_name) then
return part_name
end
if fit_into_partition(part_name) then
if partitions_ == nil then
partitions_ = part_name
else
partitions_ = partitions_ .. "," .. part_name
end
end
end
return partitions_
end
local function partitions_are_valid()
local partitions = greeneUtils.split(greeneCommon.job_desc.partition, ",")
local part_name = nil
for _, part_name in pairs(partitions) do
if not fit_into_partition(part_name) then
user_log("*** Error partition '%s' is not valid for this job", part_name)
return false
end
end
return true
end
local function setup_is_valid()
if not partitions_are_valid() then return false end
return true
end
local function setup_parameters(args)
cpus = args.cpus
memory = args.memory
nodes = args.nodes
time_limit = args.time_limit
ave_memory = memory/cpus
end
-- functions
greeneCPU.setup_parameters = setup_parameters
greeneCPU.valid_partitions = valid_partitions
greeneCPU.setup_is_valid = setup_is_valid
slurm_log("To load greeneCPU.lua")
return greeneCPU
--[[
To do list
job_desc.shared == 0
For exclusive access, when max_memory < 180GB, cs partition only
... to append partitions
--]]