From e8ee55f77e4340816d8be232f504ef811e4e77a8 Mon Sep 17 00:00:00 2001 From: minmingzhu <45281494+minmingzhu@users.noreply.github.com> Date: Mon, 8 May 2023 15:20:51 +0800 Subject: [PATCH] [ML-271] [Core] Resolve build warnings (#285) 2. c++: switch warning and size_t type mismatch Signed-off-by: minmingzhu --- mllib-dal/src/main/native/CorrelationImpl.cpp | 6 +++++- mllib-dal/src/main/native/KMeansImpl.cpp | 8 ++++++-- mllib-dal/src/main/native/LinearRegressionImpl.cpp | 8 ++++---- mllib-dal/src/main/native/Makefile | 2 +- mllib-dal/src/main/native/NaiveBayesDALImpl.cpp | 6 +++--- mllib-dal/src/main/native/OneCCL.cpp | 2 +- mllib-dal/src/main/native/OneCCL.h | 2 +- mllib-dal/src/main/native/PCAImpl.cpp | 10 +++++++--- mllib-dal/src/main/native/SummarizerImpl.cpp | 6 +++++- 9 files changed, 33 insertions(+), 17 deletions(-) diff --git a/mllib-dal/src/main/native/CorrelationImpl.cpp b/mllib-dal/src/main/native/CorrelationImpl.cpp index aba09e5a1..f42811d36 100644 --- a/mllib-dal/src/main/native/CorrelationImpl.cpp +++ b/mllib-dal/src/main/native/CorrelationImpl.cpp @@ -35,7 +35,7 @@ namespace covariance_cpu = daal::algorithms::covariance; typedef double algorithmFPType; /* Algorithm floating-point type */ -static void doCorrelationDaalCompute(JNIEnv *env, jobject obj, int rankId, +static void doCorrelationDaalCompute(JNIEnv *env, jobject obj, size_t rankId, ccl::communicator &comm, const NumericTablePtr &pData, size_t nBlocks, jobject resultObj) { @@ -235,6 +235,10 @@ Java_com_intel_oap_mllib_stat_CorrelationDALImpl_cCorrelationTrainDAL( break; } #endif + default: { + std::cout << "no supported device!" << std::endl; + exit(-1); + } } return 0; } diff --git a/mllib-dal/src/main/native/KMeansImpl.cpp b/mllib-dal/src/main/native/KMeansImpl.cpp index f167d41ed..a7a40a90f 100644 --- a/mllib-dal/src/main/native/KMeansImpl.cpp +++ b/mllib-dal/src/main/native/KMeansImpl.cpp @@ -37,7 +37,7 @@ namespace kmeans_cpu = daal::algorithms::kmeans; typedef double algorithmFPType; /* Algorithm floating-point type */ -static NumericTablePtr kmeans_compute(int rankId, ccl::communicator &comm, +static NumericTablePtr kmeans_compute(size_t rankId, ccl::communicator &comm, const NumericTablePtr &pData, const NumericTablePtr &initialCentroids, size_t nClusters, size_t nBlocks, @@ -174,7 +174,7 @@ static bool areAllCentersConverged(const NumericTablePtr &oldCenters, return true; } -static jlong doKMeansDaalCompute(JNIEnv *env, jobject obj, int rankId, +static jlong doKMeansDaalCompute(JNIEnv *env, jobject obj, size_t rankId, ccl::communicator &comm, NumericTablePtr &pData, NumericTablePtr ¢roids, jint cluster_num, @@ -354,6 +354,10 @@ Java_com_intel_oap_mllib_clustering_KMeansDALImpl_cKMeansOneapiComputeWithInitCe break; } #endif + default: { + std::cout << "no supported device!" << std::endl; + exit(-1); + } } return ret; } diff --git a/mllib-dal/src/main/native/LinearRegressionImpl.cpp b/mllib-dal/src/main/native/LinearRegressionImpl.cpp index 0d74f5a9f..51e6401b4 100644 --- a/mllib-dal/src/main/native/LinearRegressionImpl.cpp +++ b/mllib-dal/src/main/native/LinearRegressionImpl.cpp @@ -41,7 +41,7 @@ namespace ridge_regression_cpu = daal::algorithms::ridge_regression; typedef double algorithmFPType; /* Algorithm floating-point type */ -static NumericTablePtr linear_regression_compute(int rankId, +static NumericTablePtr linear_regression_compute(size_t rankId, ccl::communicator &comm, const NumericTablePtr &pData, const NumericTablePtr &pLabel, @@ -126,7 +126,7 @@ static NumericTablePtr linear_regression_compute(int rankId, } static NumericTablePtr ridge_regression_compute( - int rankId, ccl::communicator &comm, const NumericTablePtr &pData, + size_t rankId, ccl::communicator &comm, const NumericTablePtr &pData, const NumericTablePtr &pLabel, double regParam, size_t nBlocks) { using daal::byte; @@ -213,7 +213,7 @@ static NumericTablePtr ridge_regression_compute( } #ifdef CPU_GPU_PROFILE -static jlong doLROneAPICompute(JNIEnv *env, int rankId, +static jlong doLROneAPICompute(JNIEnv *env, size_t rankId, ccl::communicator &cclComm, sycl::queue &queue, jlong pData, jlong pLabel, jint executorNum, jobject resultObj) { @@ -262,7 +262,7 @@ Java_com_intel_oap_mllib_regression_LinearRegressionDALImpl_cLinearRegressionTra << std::endl; ccl::communicator &cclComm = getComm(); - int rankId = cclComm.rank(); + size_t rankId = cclComm.rank(); ComputeDevice device = getComputeDeviceByOrdinal(computeDeviceOrdinal); bool useGPU = false; diff --git a/mllib-dal/src/main/native/Makefile b/mllib-dal/src/main/native/Makefile index 90042ca2f..ca333c2c0 100644 --- a/mllib-dal/src/main/native/Makefile +++ b/mllib-dal/src/main/native/Makefile @@ -29,7 +29,7 @@ $(info ) $(info === Profile is $(PLATFORM_PROFILE) ===) $(info ) -CFLAGS_COMMON := -g -Wall -Wno-deprecated-declarations -fPIC -std=c++17 \ +CFLAGS_COMMON := -Wall -Wno-deprecated-declarations -fPIC -std=c++17 \ -I $(I_MPI_ROOT)/include \ -I $(DAALROOT)/include \ -I $(CCL_ROOT)/include/cpu/oneapi/ \ diff --git a/mllib-dal/src/main/native/NaiveBayesDALImpl.cpp b/mllib-dal/src/main/native/NaiveBayesDALImpl.cpp index 02ed6c504..305a867df 100644 --- a/mllib-dal/src/main/native/NaiveBayesDALImpl.cpp +++ b/mllib-dal/src/main/native/NaiveBayesDALImpl.cpp @@ -26,8 +26,8 @@ trainModel(const ccl::communicator &comm, const NumericTablePtr &featuresTab, Profiler profiler("NaiveBayes"); #endif - auto rankId = comm.rank(); - auto nBlocks = comm.size(); + size_t rankId = comm.rank(); + size_t nBlocks = comm.size(); /* Create an algorithm object to train the Naive Bayes model based on the * local-node data */ @@ -127,7 +127,7 @@ Java_com_intel_oap_mllib_classification_NaiveBayesDALImpl_cNaiveBayesDALCompute( jint class_num, jint executor_num, jint executor_cores, jobject resultObj) { ccl::communicator &comm = getComm(); - auto rankId = comm.rank(); + size_t rankId = comm.rank(); NumericTablePtr featuresTab = *((NumericTablePtr *)pFeaturesTab); NumericTablePtr labelsTab = *((NumericTablePtr *)pLabelsTab); diff --git a/mllib-dal/src/main/native/OneCCL.cpp b/mllib-dal/src/main/native/OneCCL.cpp index 6264d36ca..38557d615 100644 --- a/mllib-dal/src/main/native/OneCCL.cpp +++ b/mllib-dal/src/main/native/OneCCL.cpp @@ -31,7 +31,7 @@ #include "OneCCL.h" #include "com_intel_oap_mllib_OneCCL__.h" -extern const int ccl_root = 0; +extern const size_t ccl_root = 0; static const int CCL_IP_LEN = 128; static std::list local_host_ips; diff --git a/mllib-dal/src/main/native/OneCCL.h b/mllib-dal/src/main/native/OneCCL.h index 4be15fcab..7fda0c639 100644 --- a/mllib-dal/src/main/native/OneCCL.h +++ b/mllib-dal/src/main/native/OneCCL.h @@ -44,4 +44,4 @@ event CCL_API gather(const BufferType *sendbuf, int sendcount, ccl::communicator &getComm(); ccl::shared_ptr_class &getKvs(); -extern const int ccl_root; +extern const size_t ccl_root; diff --git a/mllib-dal/src/main/native/PCAImpl.cpp b/mllib-dal/src/main/native/PCAImpl.cpp index 5fabd3e24..33a0aa2a7 100644 --- a/mllib-dal/src/main/native/PCAImpl.cpp +++ b/mllib-dal/src/main/native/PCAImpl.cpp @@ -39,9 +39,9 @@ namespace covariance_cpu = daal::algorithms::covariance; typedef double algorithmFPType; /* Algorithm floating-point type */ -static void doPCADAALCompute(JNIEnv *env, jobject obj, int rankId, +static void doPCADAALCompute(JNIEnv *env, jobject obj, size_t rankId, ccl::communicator &comm, NumericTablePtr &pData, - int nBlocks, jobject resultObj) { + size_t nBlocks, jobject resultObj) { std::cout << "oneDAL (native): CPU compute start" << std::endl; using daal::byte; auto t1 = std::chrono::high_resolution_clock::now(); @@ -252,7 +252,7 @@ Java_com_intel_oap_mllib_feature_PCADALImpl_cPCATrainDAL( << "; device " << ComputeDeviceString[computeDeviceOrdinal] << std::endl; ccl::communicator &cclComm = getComm(); - int rankId = cclComm.rank(); + size_t rankId = cclComm.rank(); ComputeDevice device = getComputeDeviceByOrdinal(computeDeviceOrdinal); switch (device) { case ComputeDevice::host: @@ -292,6 +292,10 @@ Java_com_intel_oap_mllib_feature_PCADALImpl_cPCATrainDAL( break; } #endif + default: { + std::cout << "no supported device!" << std::endl; + exit(-1); + } } return 0; } diff --git a/mllib-dal/src/main/native/SummarizerImpl.cpp b/mllib-dal/src/main/native/SummarizerImpl.cpp index 8333be531..1e99be460 100644 --- a/mllib-dal/src/main/native/SummarizerImpl.cpp +++ b/mllib-dal/src/main/native/SummarizerImpl.cpp @@ -35,7 +35,7 @@ using namespace daal::services; typedef double algorithmFPType; /* Algorithm floating-point type */ -static void doSummarizerDAALCompute(JNIEnv *env, jobject obj, int rankId, +static void doSummarizerDAALCompute(JNIEnv *env, jobject obj, size_t rankId, ccl::communicator &comm, const NumericTablePtr &pData, size_t nBlocks, jobject resultObj) { @@ -304,6 +304,10 @@ Java_com_intel_oap_mllib_stat_SummarizerDALImpl_cSummarizerTrainDAL( break; } #endif + default: { + std::cout << "no supported device!" << std::endl; + exit(-1); + } } return 0; }