Skip to content

Commit

Permalink
update code style and unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
minmingzhu committed Aug 19, 2024
1 parent b07fe36 commit 4fe2416
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 34 deletions.
6 changes: 3 additions & 3 deletions mllib-dal/src/main/native/CorrelationImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ static void doCorrelationOneAPICompute(

JNIEXPORT jlong JNICALL
Java_com_intel_oap_mllib_stat_CorrelationDALImpl_cCorrelationTrainDAL(
JNIEnv *env, jobject obj, jint rank, jlong pNumTabData, jlong numRows, jlong numCols,
jint executorNum, jint executorCores, jint computeDeviceOrdinal,
jintArray gpuIdxArray, jobject resultObj) {
JNIEnv *env, jobject obj, jint rank, jlong pNumTabData, jlong numRows,
jlong numCols, jint executorNum, jint executorCores,
jint computeDeviceOrdinal, jintArray gpuIdxArray, jobject resultObj) {
logger::println(logger::INFO,
"oneDAL (native): use DPC++ kernels; device %s",
ComputeDeviceString[computeDeviceOrdinal].c_str());
Expand Down
8 changes: 4 additions & 4 deletions mllib-dal/src/main/native/DecisionForestClassifierImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ static jobject doRFClassifierOneAPICompute(
*/
JNIEXPORT jobject JNICALL
Java_com_intel_oap_mllib_classification_RandomForestClassifierDALImpl_cRFClassifierTrainDAL(
JNIEnv *env, jobject obj, jint rank, jlong pNumTabFeature, jlong featureRows,
jlong featureCols, jlong pNumTabLabel, jlong labelCols, jint executorNum,
jint computeDeviceOrdinal, jint classCount, jint treeCount,
jint numFeaturesPerNode, jint minObservationsLeafNode,
JNIEnv *env, jobject obj, jint rank, jlong pNumTabFeature,
jlong featureRows, jlong featureCols, jlong pNumTabLabel, jlong labelCols,
jint executorNum, jint computeDeviceOrdinal, jint classCount,
jint treeCount, jint numFeaturesPerNode, jint minObservationsLeafNode,
jint minObservationsSplitNode, jdouble minWeightFractionLeafNode,
jdouble minImpurityDecreaseSplitNode, jint maxTreeDepth, jlong seed,
jint maxBins, jboolean bootstrap, jintArray gpuIdxArray,
Expand Down
11 changes: 6 additions & 5 deletions mllib-dal/src/main/native/DecisionForestRegressorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,12 @@ static jobject doRFRegressorOneAPICompute(

JNIEXPORT jobject JNICALL
Java_com_intel_oap_mllib_regression_RandomForestRegressorDALImpl_cRFRegressorTrainDAL(
JNIEnv *env, jobject obj, jint rank, jlong pNumTabFeature, jlong featureRows,
jlong featureCols, jlong pNumTabLabel, jlong labelCols, jint executorNum,
jint computeDeviceOrdinal, jint treeCount, jint numFeaturesPerNode,
jint minObservationsLeafNode, jint maxTreeDepth, jlong seed, jint maxbins,
jboolean bootstrap, jintArray gpuIdxArray, jobject resultObj) {
JNIEnv *env, jobject obj, jint rank, jlong pNumTabFeature,
jlong featureRows, jlong featureCols, jlong pNumTabLabel, jlong labelCols,
jint executorNum, jint computeDeviceOrdinal, jint treeCount,
jint numFeaturesPerNode, jint minObservationsLeafNode, jint maxTreeDepth,
jlong seed, jint maxbins, jboolean bootstrap, jintArray gpuIdxArray,
jobject resultObj) {
logger::println(logger::INFO,
"OneDAL (native): use DPC++ kernels; device %s",
ComputeDeviceString[computeDeviceOrdinal].c_str());
Expand Down
8 changes: 4 additions & 4 deletions mllib-dal/src/main/native/KMeansImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ static jlong doKMeansOneAPICompute(
*/
JNIEXPORT jlong JNICALL
Java_com_intel_oap_mllib_clustering_KMeansDALImpl_cKMeansOneapiComputeWithInitCenters(
JNIEnv *env, jobject obj, jint rank, jlong pNumTabData, jlong numRows, jlong numCols,
jlong pNumTabCenters, jint clusterNum, jdouble tolerance, jint iterationNum,
jint executorNum, jint executorCores, jint computeDeviceOrdinal,
jintArray gpuIdxArray, jobject resultObj) {
JNIEnv *env, jobject obj, jint rank, jlong pNumTabData, jlong numRows,
jlong numCols, jlong pNumTabCenters, jint clusterNum, jdouble tolerance,
jint iterationNum, jint executorNum, jint executorCores,
jint computeDeviceOrdinal, jintArray gpuIdxArray, jobject resultObj) {
logger::println(logger::INFO,
"OneDAL (native): use DPC++ kernels; device %s",
ComputeDeviceString[computeDeviceOrdinal].c_str());
Expand Down
11 changes: 5 additions & 6 deletions mllib-dal/src/main/native/LinearRegressionImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ ridge_regression_compute(size_t rankId, ccl::communicator &comm,
}

#ifdef CPU_GPU_PROFILE
static jlong doLROneAPICompute(JNIEnv *env, size_t rankId,
sycl::queue &queue,
static jlong doLROneAPICompute(JNIEnv *env, size_t rankId, sycl::queue &queue,
jlong pNumTabFeature, jlong featureRows,
jlong featureCols, jlong pNumTabLabel,
jlong labelCols, jboolean jfitIntercept,
Expand Down Expand Up @@ -289,9 +288,9 @@ Java_com_intel_oap_mllib_regression_LinearRegressionDALImpl_cLinearRegressionTra
jint *gpuIndices = env->GetIntArrayElements(gpuIdxArray, 0);
auto queue = getAssignedGPU(device, gpuIndices);

resultptr = doLROneAPICompute(
env, rank, queue, feature, featureRows, featureCols,
label, labelCols, fitIntercept, executorNum, resultObj);
resultptr = doLROneAPICompute(env, rank, queue, feature, featureRows,
featureCols, label, labelCols,
fitIntercept, executorNum, resultObj);
env->ReleaseIntArrayElements(gpuIdxArray, gpuIndices, 0);
#endif
} else {
Expand Down Expand Up @@ -320,7 +319,7 @@ Java_com_intel_oap_mllib_regression_LinearRegressionDALImpl_cLinearRegressionTra

NumericTablePtr *coeffvectors = new NumericTablePtr(resultTable);
resultptr = (jlong)coeffvectors;
if (rankId == ccl_root) {
if (rankId == ccl_root) {
// Get the class of the result object
jclass clazz = env->GetObjectClass(resultObj);
// Get Field references
Expand Down
6 changes: 3 additions & 3 deletions mllib-dal/src/main/native/PCAImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ static void doPCAOneAPICompute(

JNIEXPORT jlong JNICALL
Java_com_intel_oap_mllib_feature_PCADALImpl_cPCATrainDAL(
JNIEnv *env, jobject obj, jint rank, jlong pNumTabData, jlong numRows, jlong numCols,
jint executorNum, jint executorCores, jint computeDeviceOrdinal,
jintArray gpuIdxArray, jobject resultObj) {
JNIEnv *env, jobject obj, jint rank, jlong pNumTabData, jlong numRows,
jlong numCols, jint executorNum, jint executorCores,
jint computeDeviceOrdinal, jintArray gpuIdxArray, jobject resultObj) {
logger::println(logger::INFO,
"oneDAL (native): use DPC++ kernels; device %s",
ComputeDeviceString[computeDeviceOrdinal].c_str());
Expand Down
9 changes: 5 additions & 4 deletions mllib-dal/src/main/native/SummarizerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ static void doSummarizerOneAPICompute(

JNIEXPORT jlong JNICALL
Java_com_intel_oap_mllib_stat_SummarizerDALImpl_cSummarizerTrainDAL(
JNIEnv *env, jobject obj, jint rank, jlong pNumTabData, jlong numRows, jlong numCols,
jint executorNum, jint executorCores, jint computeDeviceOrdinal,
jintArray gpuIdxArray, jobject resultObj) {
JNIEnv *env, jobject obj, jint rank, jlong pNumTabData, jlong numRows,
jlong numCols, jint executorNum, jint executorCores,
jint computeDeviceOrdinal, jintArray gpuIdxArray, jobject resultObj) {
logger::println(logger::INFO,
"oneDAL (native): use DPC++ kernels; device %s",
ComputeDeviceString[computeDeviceOrdinal].c_str());
Expand Down Expand Up @@ -315,7 +315,8 @@ Java_com_intel_oap_mllib_stat_SummarizerDALImpl_cSummarizerTrainDAL(
}
#endif
default: {
deviceError("Summarizer", ComputeDeviceString[computeDeviceOrdinal].c_str());
deviceError("Summarizer",
ComputeDeviceString[computeDeviceOrdinal].c_str());
}
}
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CorrelationHomogenTableSuite extends FunctionsSuite with Logging {
val correlationDAL = new CorrelationDALImpl(1, 1)
val gpuIndices = Array(0)
val result = new CorrelationResult()
correlationDAL.cCorrelationTrainDAL(dataTable.getcObejct(), sourceData.length, sourceData(0).length, 1, 1, Common.ComputeDevice.HOST.ordinal(), gpuIndices, result);
correlationDAL.cCorrelationTrainDAL(0, dataTable.getcObejct(), sourceData.length, sourceData(0).length, 1, 1, Common.ComputeDevice.HOST.ordinal(), gpuIndices, result);
val correlationMatrix = TestCommon.getMatrixFromTable(OneDAL.makeHomogenTable(
result.getCorrelationNumericTable), TestCommon.getComputeDevice)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class KmeansHomogenTableSuite extends FunctionsSuite with Logging {
OneCCL.init(1, 1, "127.0.0.1_3000")
val gpuIndices = Array(0)
val result = new KMeansResult();
val centroids = kmeansDAL.cKMeansOneapiComputeWithInitCenters(dataTable.getcObejct(), sourceData.length, sourceData(0).length, centroidsTable.getcObejct(),10, 0.001,
val centroids = kmeansDAL.cKMeansOneapiComputeWithInitCenters(0, dataTable.getcObejct(), sourceData.length, sourceData(0).length, centroidsTable.getcObejct(),10, 0.001,
5, 1, 1, TestCommon.getComputeDevice.ordinal(), gpuIndices, result);
val resultVectors = OneDAL.homogenTableToVectors(OneDAL.makeHomogenTable(centroids), TestCommon.getComputeDevice);
assertArrayEquals(TestCommon.convertArray(expectCentroids), TestCommon.convertArray(resultVectors), 0.000001)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PCAHomogenTableSuite extends FunctionsSuite with Logging {
val pcaDAL = new PCADALImpl(5, 1, 1)
val gpuIndices = Array(0)
val result = new PCAResult()
pcaDAL.cPCATrainDAL(dataTable.getcObejct(), sourceData.length, sourceData(0).length, 1, 1, TestCommon.getComputeDevice.ordinal(), gpuIndices, result);
pcaDAL.cPCATrainDAL(0, dataTable.getcObejct(), sourceData.length, sourceData(0).length, 1, 1, TestCommon.getComputeDevice.ordinal(), gpuIndices, result);
val pcNumericTable = OneDAL.makeHomogenTable(result.getPcNumericTable)
val explainedVarianceNumericTable = OneDAL.makeHomogenTable(
result.getExplainedVarianceNumericTable)
Expand Down Expand Up @@ -79,7 +79,7 @@ class PCAHomogenTableSuite extends FunctionsSuite with Logging {
val pcaDAL = new PCADALImpl(5, 1, 1)
val gpuIndices = Array(0)
val result = new PCAResult()
pcaDAL.cPCATrainDAL(dataTable.getcObejct(), sourceData.length, sourceData(0).length, 1, 1, TestCommon.getComputeDevice.ordinal(), gpuIndices, result);
pcaDAL.cPCATrainDAL(0, dataTable.getcObejct(), sourceData.length, sourceData(0).length, 1, 1, TestCommon.getComputeDevice.ordinal(), gpuIndices, result);
val pcNumericTable = OneDAL.makeHomogenTable(result.getPcNumericTable)
val explainedVarianceNumericTable = OneDAL.makeHomogenTable(
result.getExplainedVarianceNumericTable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SummarizerHomogenTableSuite extends FunctionsSuite with Logging{
val summarizerDAL = new SummarizerDALImpl(1, 1)
val gpuIndices = Array(0)
val result = new SummarizerResult()
summarizerDAL.cSummarizerTrainDAL(dataTable.getcObejct(), sourceData.length, sourceData(0).length, 1, 1, Common.ComputeDevice.HOST.ordinal(), gpuIndices, result)
summarizerDAL.cSummarizerTrainDAL(0, dataTable.getcObejct(), sourceData.length, sourceData(0).length, 1, 1, Common.ComputeDevice.HOST.ordinal(), gpuIndices, result)
val meanTable = OneDAL.homogenTable1xNToVector(OneDAL.makeHomogenTable(result.getMeanNumericTable), Common.ComputeDevice.HOST)
val varianceTable = OneDAL.homogenTable1xNToVector(OneDAL.makeHomogenTable(result.getVarianceNumericTable), Common.ComputeDevice.HOST)
val minimumTable = OneDAL.homogenTable1xNToVector(OneDAL.makeHomogenTable(result.getMinimumNumericTable), Common.ComputeDevice.HOST)
Expand Down

0 comments on commit 4fe2416

Please sign in to comment.