Skip to content

Commit 49c92d7

Browse files
GallVpjealous
authored andcommitted
[GH-105] Added support for the accelerator directive
1 parent f45394e commit 49c92d7

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed

plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,16 @@ fi
382382
return Math.max(ret, 1)
383383
}
384384

385+
private static Integer getAccelerator(TaskRun task) {
386+
final accelRes = task.config.getAccelerator()
387+
388+
if (accelRes == null) {
389+
return 0
390+
}
391+
392+
return Math.max(0, accelRes.request)
393+
}
394+
385395
List<String> getSubmitCommandLine(FloatTaskHandler handler, Path scriptFile) {
386396
final task = handler.task
387397

@@ -406,6 +416,10 @@ fi
406416
int memGiga = Math.max(getMemory(task), cpu * 2)
407417
int maxMemGiga = (floatConf.maxMemoryFactor * memGiga.doubleValue()).intValue()
408418
cmd << '--mem' << "${memGiga}:${maxMemGiga}".toString()
419+
int accelerator = getAccelerator(task)
420+
if (accelerator>0) {
421+
cmd << '--gpu-count' << accelerator.toString()
422+
}
409423
cmd << '--job' << getScriptFilePath(handler, scriptFile)
410424
getEnv(handler).each { key, val ->
411425
cmd << '--env' << "${key}=${val}".toString()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Manifest-Version: 1.0
22
Plugin-Class: com.memverge.nextflow.FloatPlugin
33
Plugin-Id: nf-float
4-
Plugin-Version: 0.4.7
4+
Plugin-Version: 0.4.8
55
Plugin-Provider: MemVerge Corp.
66
Plugin-Requires: >=23.04.0

plugins/nf-float/src/test/com/memverge/nextflow/FloatBaseTest.groovy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,24 @@ class FloatBaseTest extends BaseTest {
107107
Integer taskID = Integer.parseInt(taskIDStr)
108108
def realCpu = param.cpu ?: cpu
109109
def realMem = param.memory ?: mem
110-
return [bin, '-a', param.addr ?: addr,
110+
return [
111+
bin, '-a',
112+
param.addr ?: addr,
111113
'-u', user,
112114
'-p', pass,
113115
'submit',
114116
'--dataVolume', param.nfs ?: nfs + ':' + workDir,
115117
'--image', param.image ?: image,
116118
'--cpu', realCpu + ':' + realCpu * FloatConf.DFT_MAX_CPU_FACTOR,
117119
'--mem', realMem + ':' + realMem * FloatConf.DFT_MAX_MEM_FACTOR,
120+
param.accelerator ? "--gpu-count ${param.accelerator}": null,
118121
'--job', script,
119122
'--disableRerun',
120123
'--customTag', jobID(new TaskId(taskID)),
121124
'--customTag', "${FloatConf.NF_SESSION_ID}:uuid-$uuid",
122125
'--customTag', "${FloatConf.NF_TASK_NAME}:foo--$taskIDStr-",
123126
'--customTag', "${FloatConf.FLOAT_INPUT_SIZE}:0",
124-
'--customTag', "${FloatConf.NF_RUN_NAME}:test-run"]
127+
'--customTag', "${FloatConf.NF_RUN_NAME}:test-run"
128+
].findAll { it != null }
125129
}
126130
}

plugins/nf-float/src/test/com/memverge/nextflow/FloatGridExecutorTest.groovy

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,48 @@ class FloatGridExecutorTest extends FloatBaseTest {
183183
cmd.join(' ') == expected.join(' ')
184184
}
185185

186+
def "use cpus, memory, accelerator and container"() {
187+
given:
188+
final exec = newTestExecutor()
189+
final task = newTask(exec, 0, new TaskConfig(
190+
cpus: 8,
191+
memory: '16 GB',
192+
accelerator: 4,
193+
container: "biocontainers/star"))
194+
195+
when:
196+
final cmd = exec.getSubmitCommandLine(task, Paths.get(script))
197+
final expected = submitCmd(
198+
cpu: 8,
199+
memory: 16,
200+
accelerator: 4,
201+
image: "biocontainers/star")
202+
203+
then:
204+
cmd.join(' ') == expected.join(' ')
205+
}
206+
207+
def "use cpus, memory, accelerator type and container"() {
208+
given:
209+
final exec = newTestExecutor()
210+
final task = newTask(exec, 0, new TaskConfig(
211+
cpus: 8,
212+
memory: '16 GB',
213+
accelerator: [request: 2, type: 'nvidia-tesla-k80'],
214+
container: "biocontainers/star"))
215+
216+
when:
217+
final cmd = exec.getSubmitCommandLine(task, Paths.get(script))
218+
final expected = submitCmd(
219+
cpu: 8,
220+
memory: 16,
221+
accelerator: 2,
222+
image: "biocontainers/star")
223+
224+
then:
225+
cmd.join(' ') == expected.join(' ')
226+
}
227+
186228
def "add common extras"() {
187229
given:
188230
final exec = newTestExecutor(

0 commit comments

Comments
 (0)