wbo4958 commented on code in PR #45794:
URL: https://github.com/apache/spark/pull/45794#discussion_r1546949333
##########
core/src/test/scala/org/apache/spark/scheduler/CoarseGrainedSchedulerBackendSuite.scala:
##########
@@ -179,6 +179,53 @@ class CoarseGrainedSchedulerBackendSuite extends
SparkFunSuite with LocalSparkCo
}
}
+ // Every item corresponds to (CPU resources per task, GPU resources per task,
+ // and the GPU addresses assigned to all tasks).
+ Seq(
+ (1, 1, Array(Array("0"), Array("1"), Array("2"), Array("3"))),
+ (1, 2, Array(Array("0", "1"), Array("2", "3"))),
+ (1, 4, Array(Array("0", "1", "2", "3"))),
+ (2, 1, Array(Array("0"), Array("1"))),
+ (4, 1, Array(Array("0"))),
+ (4, 2, Array(Array("0", "1"))),
+ (2, 2, Array(Array("0", "1"), Array("2", "3"))),
+ (4, 4, Array(Array("0", "1", "2", "3"))),
+ (1, 3, Array(Array("0", "1", "2"))),
+ (3, 1, Array(Array("0")))
+ ).foreach { case (taskCpus, taskGpus, expectedGpuAddresses) =>
+ test(s"SPARK-47663 end to end test validating if task cpus:${taskCpus} and
" +
+ s"task gpus: ${taskGpus} works") {
+ withTempDir { dir =>
+ val discoveryScript = createTempScriptWithExpectedOutput(
+ dir, "gpuDiscoveryScript", """{"name": "gpu","addresses":["0", "1",
"2", "3"]}""")
+ val conf = new SparkConf()
+ .set(CPUS_PER_TASK, taskCpus)
+ .setMaster("local-cluster[1, 4, 1024]")
+ .setAppName("test")
+ .set(WORKER_GPU_ID.amountConf, "4")
+ .set(WORKER_GPU_ID.discoveryScriptConf, discoveryScript)
+ .set(EXECUTOR_GPU_ID.amountConf, "4")
+ .set(TASK_GPU_ID.amountConf, taskGpus.toString)
+
+ sc = new SparkContext(conf)
Review Comment:
After each test, the `sc.stop()` will be called automatically in the
`afterEach` of LocalSparkContext, more details can be found at
https://github.com/apache/spark/blob/master/core/src/test/scala/org/apache/spark/LocalSparkContext.scala#L37-L51
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]