tgravescs commented on a change in pull request #24374:
[WIP][SPARK-27366][CORE] Support GPU Resources in Spark job scheduling
URL: https://github.com/apache/spark/pull/24374#discussion_r284252377
##########
File path: core/src/main/scala/org/apache/spark/SparkConf.scala
##########
@@ -491,6 +491,101 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable
with Logging with Seria
}
}
+ /**
+ * Set available resources on the driver/executor.
+ */
+ private[spark] def setResources(
+ resourceName: String,
+ resourceCount: Int,
+ resourceAddresses: Option[Seq[String]],
+ isDriver: Boolean): SparkConf = {
+ if (resourceAddresses.isDefined && resourceAddresses.get.size !=
resourceCount) {
+ val nodeType = if (isDriver) {
+ "driver"
+ } else {
+ "executor"
+ }
+ throw new SparkException(s"Specified $resourceCount $resourceName(s) on
$nodeType, while " +
+ s"the size of device addresses is ${resourceAddresses.size}.")
+ }
+ val prefix = if (isDriver) {
+ s"$SPARK_DRIVER_RESOURCE_PREFIX.$resourceName"
+ } else {
+ s"$SPARK_EXECUTOR_RESOURCE_PREFIX.$resourceName"
+ }
+ set(s"$prefix.$SPARK_RESOURCE_COUNT", resourceCount.toString)
+ if (resourceAddresses.isDefined) {
+ set(s"$prefix.$SPARK_RESOURCE_ADDRESSES",
resourceAddresses.get.mkString(","))
+ }
+ this
+ }
+
+ /**
+ * Set task resource requirement.
+ */
+ private[spark] def setResourceRequirement(
+ resourceName: String, resourceCount: Int): SparkConf = {
+ val key =
s"$SPARK_TASK_RESOURCE_PREFIX.$resourceName.$SPARK_RESOURCE_COUNT"
+ set(key, resourceCount.toString)
+ this
+ }
+
+ /**
+ * Get available resources on the driver/executor.
+ */
+ private[spark] def getResources(isDriver: Boolean): Map[String,
ResourceInformation] = {
Review comment:
We have a separate jira for the Driver side changes that I'm working on and
that getResources goes into the SparkContext for user to get actual resources.
This appears to be just to get the confs vs getting the Resources the
driver/executor discovered. Its nice to have in one place but the executor
won't have addresses and the driver might -> only in standalone mode, yarn and
k8s would have discovery script. You can see
https://issues.apache.org/jira/browse/SPARK-27364 for more details.
so if we leave this here, I would say it just gets the count for all
resources.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]