Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML-116] use getOneCCLIPPort and fix lib loading #118

Merged
merged 1 commit into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.intel.daal.services.DaalContext
import org.apache.spark.TaskContext
import org.apache.spark.internal.Logging
import org.apache.spark.ml.linalg.Vector
import org.apache.spark.ml.util.Utils.getOneCCLIPPort
import org.apache.spark.ml.util._
import org.apache.spark.mllib.clustering.{KMeansModel => MLlibKMeansModel}
import org.apache.spark.mllib.linalg.{Vector => OldVector, Vectors => OldVectors}
Expand All @@ -39,14 +40,7 @@ class KMeansDALImpl(var nClusters: Int,

val coalescedTables = OneDAL.rddVectorToMergedTables(data, executorNum)

val executorIPAddress = Utils.sparkFirstExecutorIP(coalescedTables.sparkContext)
val kvsIP = coalescedTables.sparkContext.conf.get("spark.oap.mllib.oneccl.kvs.ip",
executorIPAddress)
val kvsPortDetected = Utils.checkExecutorAvailPort(coalescedTables, kvsIP)
val kvsPort = coalescedTables.sparkContext.conf.getInt("spark.oap.mllib.oneccl.kvs.port",
kvsPortDetected)

val kvsIPPort = kvsIP + "_" + kvsPort
val kvsIPPort = getOneCCLIPPort(coalescedTables)

val sparkContext = data.sparkContext
val useGPU = sparkContext.conf.getBoolean("spark.oap.mllib.useGPU", false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.intel.daal.data_management.data.{HomogenNumericTable, NumericTable}
import org.apache.spark.TaskContext
import org.apache.spark.internal.Logging
import org.apache.spark.ml.linalg._
import org.apache.spark.ml.util.Utils.getOneCCLIPPort
import org.apache.spark.ml.util.{OneCCL, OneDAL, Utils}
import org.apache.spark.mllib.feature.{PCAModel => MLlibPCAModel, StandardScaler => MLlibStandardScaler}
import org.apache.spark.mllib.linalg.{DenseMatrix => OldDenseMatrix, Vectors => OldVectors}
Expand All @@ -37,15 +38,7 @@ class PCADALImpl(val k: Int,

val coalescedTables = OneDAL.rddVectorToMergedTables(normalizedData, executorNum)

val executorIPAddress = Utils.sparkFirstExecutorIP(coalescedTables.sparkContext)
val kvsIP = coalescedTables.sparkContext.conf.get("spark.oap.mllib.oneccl.kvs.ip",
executorIPAddress)

val kvsPortDetected = Utils.checkExecutorAvailPort(coalescedTables, kvsIP)
val kvsPort = coalescedTables.sparkContext.conf.getInt("spark.oap.mllib.oneccl.kvs.port",
kvsPortDetected)

val kvsIPPort = kvsIP + "_" + kvsPort
val kvsIPPort = getOneCCLIPPort(coalescedTables)

val sparkContext = data.sparkContext
val useGPU = sparkContext.conf.getBoolean("spark.oap.mllib.useGPU", false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
package org.apache.spark.ml.recommendation

import java.nio.{ByteBuffer, ByteOrder, FloatBuffer}

import scala.collection.mutable.ArrayBuffer
import scala.reflect.ClassTag

import com.intel.daal.data_management.data.CSRNumericTable
import com.intel.daal.services.DaalContext

import org.apache.spark.Partitioner
import org.apache.spark.internal.Logging
import org.apache.spark.ml.recommendation.ALS.Rating
import org.apache.spark.ml.util.LibLoader.loadLibraries
import org.apache.spark.ml.util.Utils.getOneCCLIPPort
import org.apache.spark.ml.util._
import org.apache.spark.rdd.RDD

Expand Down Expand Up @@ -77,23 +76,16 @@ class ALSDALImpl[@specialized(Int, Long) ID: ClassTag]( data: RDD[Rating[ID]],
val numericTables = data.repartition(executorNum)
.setName("Repartitioned for conversion").cache()

val executorIPAddress = Utils.sparkFirstExecutorIP(numericTables.sparkContext)
val kvsIP = numericTables.sparkContext.conf.get(
"spark.oap.mllib.oneccl.kvs.ip", executorIPAddress)

val kvsPortDetected = Utils.checkExecutorAvailPort(numericTables, kvsIP)
val kvsPort = numericTables.sparkContext.conf.getInt(
"spark.oap.mllib.oneccl.kvs.port", kvsPortDetected)

val kvsIPPort = kvsIP + "_" + kvsPort
val kvsIPPort = getOneCCLIPPort(numericTables)

val results = numericTables
// Transpose the dataset
.map { p =>
Rating(p.item, p.user, p.rating)
}
.mapPartitionsWithIndex { (rank, iter) =>
val context = new DaalContext()
// TODO: Use one-time init to load libraries
loadLibraries()

OneCCL.init(executorNum, rank, kvsIPPort)
val rankId = OneCCL.rankID()
Expand Down
9 changes: 5 additions & 4 deletions mllib-dal/src/main/scala/org/apache/spark/ml/util/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ object Utils {
val executorIPAddress = Utils.sparkFirstExecutorIP(data.sparkContext)
val kvsIP = data.sparkContext.conf.get("spark.oap.mllib.oneccl.kvs.ip",
executorIPAddress)
val kvsPortDetected = 5000
// val kvsPortDetected = Utils.checkExecutorAvailPort(data, kvsIP)
// TODO: right now we use a configured port, will optimize auto port detection
// val kvsPortDetected = Utils.checkExecutorAvailPort(data, kvsIP)
val kvsPortDetected = 3000
val kvsPort = data.sparkContext.conf.getInt("spark.oap.mllib.oneccl.kvs.port",
kvsPortDetected)

Expand Down Expand Up @@ -126,9 +127,9 @@ object Utils {
// check workers' platform compatibility
val executor_num = Utils.sparkExecutorNum(sc)
val data = sc.parallelize(1 to executor_num, executor_num)
val result = data.map { p =>
val result = data.mapPartitions { p =>
LibLoader.loadLibraries()
OneDAL.cCheckPlatformCompatibility()
Iterator(OneDAL.cCheckPlatformCompatibility())
}.collect()

result.forall(_ == true)
Expand Down