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-367] Update oneapi to 2024.0.0 #368

Merged
merged 26 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
14 changes: 12 additions & 2 deletions mllib-dal/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ if [[ -z $(which mvn) ]]; then
exit 1
fi

if [[ -z $DAALROOT ]]; then
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
if [[ -z $DAALROOT && -z $DALROOT ]]; then
echo DAALROOT not defined!
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi

if [[ -e $DAALROOT ]]; then
export ONEDAL_VERSION=$(echo "$DAALROOT" | awk -F '/' '{print $(NF)}')
elif [[ -e $DALROOT ]]; then
export ONEDAL_VERSION=$(echo "$DALROOT" | awk -F '/' '{print $(NF)}')
fi

if [[ -z $TBBROOT ]]; then
echo TBBROOT not defined!
exit 1
Expand Down Expand Up @@ -89,7 +95,11 @@ then
echo GCC Version: $(gcc -dumpversion)
fi
echo JAVA_HOME=$JAVA_HOME
echo DAALROOT=$DAALROOT
if [[ -e $DAALROOT ]]; then
echo DAALROOT=$DAALROOT
elif [[ -e $DALROOT ]]; then
echo DAALROOT=$DALROOT
fi
echo TBBROOT=$TBBROOT
echo CCL_ROOT=$CCL_ROOT
echo =============================
Expand Down
1 change: 1 addition & 0 deletions mllib-dal/src/main/java/com/intel/oap/mllib/LibLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ private static synchronized void loadLibMLlibDAL() throws IOException {
// oneDAL Java API doesn't load correct libtbb version
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
// See https://github.com/oneapi-src/oneDAL/issues/1254
// Workaround: Load packaged libtbb & libtbbmalloc & libJavaAPI.so manually
System.loadLibrary("onedal_thread");
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
loadFromJar(subDir, "libMLlibDAL.so");
}

Expand Down
30 changes: 8 additions & 22 deletions mllib-dal/src/main/native/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ $(info )

CFLAGS_COMMON := -Wall -Wno-deprecated-declarations -fPIC -std=c++17 \
-I $(I_MPI_ROOT)/include \
-I $(DAALROOT)/include \
-I $(CCL_ROOT)/include/cpu/oneapi/ \
-I $(DALROOT)/include \
-I $(CCL_ROOT)/include/oneapi/ \
-I $(CMPLR_ROOT)/linux/include \
-I $(CMPLR_ROOT)/linux/include/sycl

Expand All @@ -41,40 +41,26 @@ ifeq ($(PLATFORM_PROFILE),CPU_ONLY_PROFILE)
else ifeq ($(PLATFORM_PROFILE),CPU_GPU_PROFILE)
CFLAGS := $(CFLAGS_COMMON) -fsycl \
-fsycl-device-code-split=per_kernel \
-I $(CCL_ROOT)/include/cpu_gpu_dpcpp/oneapi/
-fno-sycl-id-queries-fit-in-int
else
$(error Unknow building profile, should be CPU_ONLY_PROFILE or CPU_GPU_PROFILE)
exit 1
endif

INCS := -I $(CCL_ROOT)/include/cpu \
INCS := -I $(CCL_ROOT)/include \
-I $(JAVA_HOME)/include \
-I $(JAVA_HOME)/include/linux \
-I $(DAALROOT)/include \
-I $(DALROOT)/include \
-I ./javah \
-I ./

ifeq ($(PLATFORM_PROFILE),CPU_ONLY_PROFILE)
INCS := $(INCS)
else ifeq ($(PLATFORM_PROFILE),CPU_GPU_PROFILE)
INCS := $(INCS) -I $(CCL_ROOT)/include/cpu_gpu_dpcpp
else
$(error Unknow building profile, should be CPU_ONLY_PROFILE or CPU_GPU_PROFILE)
exit 1
endif

# Use static link if possible, TBB is only available as dynamic libs
LIBS_COMMON := -L$(CCL_ROOT)/lib/cpu -lccl \
-L$(CMPLR_ROOT)/linux/compiler/lib/intel64_lin -l:libirc.a \
-L$(DAALROOT)/lib/intel64 -lonedal_core -lonedal_thread -lonedal_dpc \
LIBS_COMMON := -L$(CCL_ROOT)/lib -lccl \
-L$(CMPLR_ROOT)/linux/compiler/lib -l:libirc.a \
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
-L$(DALROOT)/lib/intel64 -lonedal_core -lonedal_thread -lonedal_dpc -lonedal_parameters_dpc \
-L$(TBBROOT)/lib/intel64/gcc4.8 -ltbb -ltbbmalloc \
-L$(I_MPI_ROOT)

ifeq ($(PLATFORM_PROFILE),CPU_GPU_PROFILE)
LIBS_COMMON := $(LIBS_COMMON) \
-L$(CCL_ROOT)/lib/cpu_gpu_dpcpp -lccl
endif

ifeq ($(PLATFORM_PROFILE),CPU_ONLY_PROFILE)
LIBS := $(LIBS_COMMON) $(ONEDAL_LIBS)
else ifeq ($(PLATFORM_PROFILE),CPU_GPU_PROFILE)
Expand Down
169 changes: 169 additions & 0 deletions mllib-dal/src/main/native/Makefile_2023.2.0
xwu99 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Copyright 2020 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Use gcc for CPU and dpcpp for GPU
ifeq ($(PLATFORM_PROFILE),CPU_ONLY_PROFILE)
CC := gcc
CXX := g++
else ifeq ($(PLATFORM_PROFILE),CPU_GPU_PROFILE)
CC := icpx
CXX := icpx
endif

RM := rm -rf

PLATFORM_PROFILE ?= CPU_ONLY_PROFILE
ONEDAL_VERSION=2023.2.0

$(info )
$(info === Profile is $(PLATFORM_PROFILE) ===)
$(info )

CFLAGS_COMMON := -Wall -Wno-deprecated-declarations -fPIC -std=c++17 \
-I $(I_MPI_ROOT)/include \
-I $(DAALROOT)/include \
-I $(CCL_ROOT)/include/cpu/oneapi/ \
-I $(CMPLR_ROOT)/linux/include \
-I $(CMPLR_ROOT)/linux/include/sycl

ifeq ($(PLATFORM_PROFILE),CPU_ONLY_PROFILE)
CFLAGS := $(CFLAGS_COMMON)
else ifeq ($(PLATFORM_PROFILE),CPU_GPU_PROFILE)
CFLAGS := $(CFLAGS_COMMON) -fsycl \
-fsycl-device-code-split=per_kernel \
-I $(CCL_ROOT)/include/cpu_gpu_dpcpp/oneapi/
else
$(error Unknow building profile, should be CPU_ONLY_PROFILE or CPU_GPU_PROFILE)
exit 1
endif

INCS := -I $(CCL_ROOT)/include/cpu \
-I $(JAVA_HOME)/include \
-I $(JAVA_HOME)/include/linux \
-I $(DAALROOT)/include \
-I ./javah \
-I ./

ifeq ($(PLATFORM_PROFILE),CPU_ONLY_PROFILE)
INCS := $(INCS)
else ifeq ($(PLATFORM_PROFILE),CPU_GPU_PROFILE)
INCS := $(INCS) -I $(CCL_ROOT)/include/cpu_gpu_dpcpp
else
$(error Unknow building profile, should be CPU_ONLY_PROFILE or CPU_GPU_PROFILE)
exit 1
endif

# Use static link if possible, TBB is only available as dynamic libs
LIBS_COMMON := -L$(CCL_ROOT)/lib/cpu -lccl \
-L$(CMPLR_ROOT)/linux/compiler/lib/intel64_lin -l:libirc.a \
-L$(DAALROOT)/lib/intel64 -lonedal_core -lonedal_thread -lonedal_dpc \
-L$(TBBROOT)/lib/intel64/gcc4.8 -ltbb -ltbbmalloc \
-L$(I_MPI_ROOT)

ifeq ($(PLATFORM_PROFILE),CPU_GPU_PROFILE)
LIBS_COMMON := $(LIBS_COMMON) \
-L$(CCL_ROOT)/lib/cpu_gpu_dpcpp -lccl
endif

ifeq ($(PLATFORM_PROFILE),CPU_ONLY_PROFILE)
LIBS := $(LIBS_COMMON) $(ONEDAL_LIBS)
else ifeq ($(PLATFORM_PROFILE),CPU_GPU_PROFILE)
LIBS := $(LIBS_COMMON) $(ONEDAL_LIBS) -l:libonedal_sycl.a
endif

CPP_SRCS += \
./service.cpp ./error_handling.cpp \
./daal/csr_numeric_table_impl.cpp \
./daal/homogen_numeric_table_byte_buffer_impl.cpp \
./daal/merged_numeric_table_impl.cpp \
./daal/numeric_table_impl.cpp \
./daal/row_merged_numeric_table_impl.cpp \
./daal/data_dictionary.cpp \
./daal/data_feature.cpp \
./oneapi/dal/HomogenTableImpl.cpp \
./oneapi/dal/SimpleMetadataImpl.cpp \
./oneapi/dal/ColumnAccessorImpl.cpp \
./oneapi/dal/RowAccessorImpl.cpp \
./OneCCL.cpp ./OneDAL.cpp \
./Logger.cpp \
./KMeansImpl.cpp \
./PCAImpl.cpp \
./ALSDALImpl.cpp ./ALSShuffle.cpp \
./NaiveBayesDALImpl.cpp \
./LinearRegressionImpl.cpp \
./CorrelationImpl.cpp \
./SummarizerImpl.cpp \
./DecisionForestClassifierImpl.cpp \
./DecisionForestRegressorImpl.cpp



OBJS += \
./service.o ./error_handling.o \
./daal/csr_numeric_table_impl.o \
./daal/homogen_numeric_table_byte_buffer_impl.o \
./daal/merged_numeric_table_impl.o \
./daal/numeric_table_impl.o \
./daal/row_merged_numeric_table_impl.o \
./daal/data_dictionary.o \
./daal/data_feature.o \
./oneapi/dal/HomogenTableImpl.o \
./oneapi/dal/SimpleMetadataImpl.o \
./oneapi/dal/ColumnAccessorImpl.o \
./oneapi/dal/RowAccessorImpl.o \
./OneCCL.o ./OneDAL.o \
./Logger.o\
./KMeansImpl.o \
./PCAImpl.o \
./ALSDALImpl.o ./ALSShuffle.o \
./NaiveBayesDALImpl.o \
./LinearRegressionImpl.o \
./CorrelationImpl.o \
./SummarizerImpl.o \
./DecisionForestClassifierImpl.o \
./DecisionForestRegressorImpl.o

DEFINES=-D$(PLATFORM_PROFILE) -DONEDAL_VERSION=$(ONEDAL_VERSION)

ifeq ($(PLATFORM_PROFILE),CPU_GPU_PROFILE)
CPP_SRCS += ./GPU.cpp
OBJS += ./GPU.o
endif

# Output Binary
OUTPUT = ../../../src/main/resources/lib/libMLlibDAL.so

all: $(OUTPUT)

# Compile
%.o: %.cpp
@echo 'Building file: $<'
$(CXX) $(CFLAGS) $(INCS) $(DEFINES) -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

# Link
$(OUTPUT): $(OBJS)
@echo 'Building target: $@'
@echo 'Invoking: Linker'
$(CXX) $(CFLAGS) -shared -o $(OUTPUT) $(OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '

clean:
@echo 'Cleaning up'
-$(RM) $(OBJS) $(OUTPUT)
-@echo ' '

.PHONY: all clean
3 changes: 1 addition & 2 deletions mllib-dal/src/main/native/build-cpu-gpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@

export PLATFORM_PROFILE=CPU_GPU_PROFILE

make clean
make -j
bash build.sh
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
53 changes: 51 additions & 2 deletions mllib-dal/src/main/native/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,54 @@ if [[ $OAP_MLLIB_TESTING == "true" ]]; then
exit 0
fi

make clean
make -j
if [[ -z $ONEDAL_VERSION ]]; then
if [[ -e $DAALROOT ]]; then
export ONEDAL_VERSION=$(echo "$DAALROOT" | awk -F '/' '{print $(NF)}')
elif [[ -e $DALROOT ]]; then
export ONEDAL_VERSION=$(echo "$DALROOT" | awk -F '/' '{print $(NF)}')
else
echo DAALROOT not defined!
exit 1
fi
echo $ONEDAL_VERSION
fi

# Function to compare version strings
compare_versions() {
local v1=$1
local v2=$2

# Convert versions to arrays
IFS='.' read -ra v1_array <<< "$v1"
IFS='.' read -ra v2_array <<< "$v2"

# Iterate through each segment and compare numerically
for i in {0..2}; do
if ((v1_array[i] > v2_array[i])); then
return 0 # v1 > v2
elif ((v1_array[i] < v2_array[i])); then
return 1 # v1 < v2
fi
done

return 1 # v1 == v2
}

# Reference version
reference_version="2023.2.0"

# Compare versions
compare_versions "$ONEDAL_VERSION" "$reference_version"
result=$?
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved

# Check the result of the comparison
if [ "$result" -eq 0 ]; then
echo "$ONEDAL_VERSION is greater than $reference_version"
make clean
make -f Makefile -j
elif [ "$result" -eq 1 ]; then
echo "$ONEDAL_VERSION is less than or equal $reference_version"
make clean
make -f Makefile_2023.2.0 -j

fi
4 changes: 4 additions & 0 deletions mllib-dal/src/main/native/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ using namespace daal::data_management;

#include "Logger.h"
#include "error_handling.h"
#ifdef ONEDAL_VERSION == "2023.2.0"
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
#include "oneapi/dal/table/detail/csr.hpp"
#else
#include "oneapi/dal/table/csr.hpp"
#endif
#include "oneapi/dal/table/homogen.hpp"

using namespace oneapi::dal;
Expand Down
8 changes: 7 additions & 1 deletion mllib-dal/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ SCRIPT_DIR=$( cd $(dirname ${BASH_SOURCE[0]}) && pwd )
OAP_MLLIB_ROOT=$(cd $SCRIPT_DIR/.. && pwd)
source $OAP_MLLIB_ROOT/RELEASE

if [[ -z $DAALROOT ]]; then
if [[ -z $DAALROOT && -z $DALROOT ]]; then
echo DAALROOT not defined!
exit 1
fi

if [[ -e $DAALROOT ]]; then
export ONEDAL_VERSION=$(echo "$DAALROOT" | awk -F '/' '{print $(NF)}')
elif [[ -e $DALROOT ]]; then
export ONEDAL_VERSION=$(echo "$DALROOT" | awk -F '/' '{print $(NF)}')
fi

if [[ -z $TBBROOT ]]; then
echo TBBROOT not defined!
exit 1
Expand Down
Loading