diff --git a/deploy/local/vars_lnx.sh b/deploy/local/vars_lnx.sh index a39ece22af5..8cb606d13cf 100644 --- a/deploy/local/vars_lnx.sh +++ b/deploy/local/vars_lnx.sh @@ -226,9 +226,9 @@ fi ARCH_ONEDAL=$(uname -m) -if [[ "${ARCH_ONEDAL}" == "x86_64" ]]; then +if [ "${ARCH_ONEDAL}" = "x86_64" ]; then ARCH_DIR_ONEDAL="intel64" -elif [[ "${ARCH_ONEDAL}" == "aarch64" ]]; then +elif [ "${ARCH_ONEDAL}" = "aarch64" ]; then ARCH_DIR_ONEDAL="arm" else echo "Unsupported CPU architecture '${ARCH_ONEDAL}'" diff --git a/dev/make/common.mk b/dev/make/common.mk index 694d7a3bca1..291ca7e406b 100644 --- a/dev/make/common.mk +++ b/dev/make/common.mk @@ -78,6 +78,7 @@ secure.opts.link.mac = RC.COMPILE = rc.exe $(RCOPT) -fo$@ $< +# Used as $(eval $(call set_c_compile,$(COMPILER),$(_OS),$(gcc_toolchain)) C.COMPILE = $(if $(COMPILER.$(_OS).$(COMPILER)),$(COMPILER.$(_OS).$(COMPILER)),$(error COMPILER.$(_OS).$(COMPILER) must be defined)) \ $(if $(C.COMPILE.gcc_toolchain),--gcc-toolchain=$(C.COMPILE.gcc_toolchain)) \ -c $(secure.opts.icc.$(_OS)) $(COPT) $(INCLUDES) $1 $(-Fo)$@ $< diff --git a/dev/make/cmplr.clang.mkl.32e.mk b/dev/make/compiler_definitions/clang.32e.mk similarity index 82% rename from dev/make/cmplr.clang.mkl.32e.mk rename to dev/make/compiler_definitions/clang.32e.mk index 65ac0aca76b..4f4844896a9 100644 --- a/dev/make/cmplr.clang.mkl.32e.mk +++ b/dev/make/compiler_definitions/clang.32e.mk @@ -1,4 +1,4 @@ -# file: cmplt.clang.mk +# file: clang.32e.mk #=============================================================================== # Copyright 2012 Intel Corporation # @@ -16,17 +16,15 @@ #=============================================================================== #++ -# Clang definitions for makefile +# Clang definitions for makefile. +# This file contains definitions common to clang on a 32e (intel64) platform. +# It should only be included from files which have more specializations (e.g. +# clang.mkl.32e.mk) #-- -PLATs.clang = lnx32e mac32e - -CMPLRDIRSUFF.clang = _clang - -CORE.SERV.COMPILER.clang = generic +include dev/make/compiler_definitions/clang.mk --Zl.clang = --DEBC.clang = -g +PLATs.clang = lnx32e mac32e COMPILER.mac.clang = clang++ -m64 -fgnu-runtime -stdlib=libc++ -mmacosx-version-min=10.15 -fwrapv \ -Werror -Wreturn-type @@ -36,11 +34,6 @@ COMPILER.lnx.clang = clang++ -m64 \ link.dynamic.mac.clang = clang++ -m64 link.dynamic.lnx.clang = clang++ -m64 -pedantic.opts.clang = -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter - pedantic.opts.mac.clang = $(pedantic.opts.clang) pedantic.opts.lnx.clang = $(pedantic.opts.clang) diff --git a/dev/make/cmplr.clang.ref.32e.mk b/dev/make/compiler_definitions/clang.mk similarity index 57% rename from dev/make/cmplr.clang.ref.32e.mk rename to dev/make/compiler_definitions/clang.mk index 648c1042f7c..5c962ef511b 100644 --- a/dev/make/cmplr.clang.ref.32e.mk +++ b/dev/make/compiler_definitions/clang.mk @@ -1,6 +1,6 @@ -# file: cmplt.clang.mk +# file: clang.mk #=============================================================================== -# Copyright 2023 Intel Corporation +# Copyright contributors to the oneDAL project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,10 +17,11 @@ #++ # Clang definitions for makefile +# This file contains definitions common to clang on all platforms. +# It should only be included from files which have more specializations (e.g. +# clang.32e.mk) #-- -PLATs.clang = lnx32e mac32e - CMPLRDIRSUFF.clang = _clang CORE.SERV.COMPILER.clang = generic @@ -28,23 +29,7 @@ CORE.SERV.COMPILER.clang = generic -Zl.clang = -DEBC.clang = -g -COMPILER.mac.clang = clang++ -m64 -fgnu-runtime -stdlib=libc++ -mmacosx-version-min=10.15 -fwrapv \ - -DDAAL_REF -DONEDAL_REF -Werror -Wreturn-type -COMPILER.lnx.clang = clang++ -m64 \ - -DDAAL_REF -DONEDAL_REF -Werror -Wreturn-type - -link.dynamic.mac.clang = clang++ -m64 -link.dynamic.lnx.clang = clang++ -m64 - pedantic.opts.clang = -pedantic \ -Wall \ -Wextra \ -Wno-unused-parameter - -pedantic.opts.mac.clang = $(pedantic.opts.clang) -pedantic.opts.lnx.clang = $(pedantic.opts.clang) - -p4_OPT.clang = $(-Q)march=nocona -mc3_OPT.clang = $(-Q)$(if $(OS_is_mac),march=nocona,march=nehalem) $(if $(OS_is_mac),$(-Q)mtune=nehalem) -avx2_OPT.clang = $(-Q)march=haswell -skx_OPT.clang = $(-Q)march=skx diff --git a/dev/make/compiler_definitions/clang.mkl.32e.mk b/dev/make/compiler_definitions/clang.mkl.32e.mk new file mode 100644 index 00000000000..9bac0e95622 --- /dev/null +++ b/dev/make/compiler_definitions/clang.mkl.32e.mk @@ -0,0 +1,22 @@ +# file: clang.mkl.32e.mk +#=============================================================================== +# Copyright 2012 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. +#=============================================================================== + +#++ +# Clang definitions for makefile +#-- + +include dev/make/compiler_definitions/clang.32e.mk diff --git a/dev/make/compiler_definitions/clang.ref.32e.mk b/dev/make/compiler_definitions/clang.ref.32e.mk new file mode 100644 index 00000000000..291bc0295d5 --- /dev/null +++ b/dev/make/compiler_definitions/clang.ref.32e.mk @@ -0,0 +1,25 @@ +# file: clang.ref.32e.mk +#=============================================================================== +# Copyright contributors to the oneDAL project +# +# 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. +#=============================================================================== + +#++ +# Clang definitions for makefile +#-- + +include dev/make/compiler_definitions/clang.32e.mk + +COMPILER.mac.clang = $(COMPILER.mac.clang) -DDAAL_REF -DONEDAL_REF +COMPILER.lnx.clang = $(COMPILER.lnx.clang) -DDAAL_REF -DONEDAL_REF diff --git a/dev/make/cmplr.clang.ref.arm.mk b/dev/make/compiler_definitions/clang.ref.arm.mk similarity index 78% rename from dev/make/cmplr.clang.ref.arm.mk rename to dev/make/compiler_definitions/clang.ref.arm.mk index 50996dc4a06..6b61a52c0dc 100644 --- a/dev/make/cmplr.clang.ref.arm.mk +++ b/dev/make/compiler_definitions/clang.ref.arm.mk @@ -1,4 +1,4 @@ -# file: cmplr.clang.ref.arm.mk +# file: clang.ref.arm.mk #=============================================================================== # Copyright contributors to the oneDAL project # @@ -19,26 +19,15 @@ # Clang definitions for makefile #-- -PLATs.clang = lnxarm - -CMPLRDIRSUFF.clang = _clang - -CORE.SERV.COMPILER.clang = generic +include dev/make/compiler_definitions/clang.mk --Zl.clang = --DEBC.clang = -g +PLATs.clang = lnxarm COMPILER.lnx.clang= clang++ -march=armv8-a+sve \ -DDAAL_REF -DONEDAL_REF -DDAAL_CPU=sve -Werror -Wreturn-type # Linker flags link.dynamic.lnx.clang = clang++ -march=armv8-a+sve -pedantic.opts.clang = -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter - -pedantic.opts.mac.clang = $(pedantic.opts.clang) pedantic.opts.lnx.clang = $(pedantic.opts.clang) # For SVE diff --git a/dev/make/cmplr.dpcpp.mk b/dev/make/compiler_definitions/dpcpp.mk similarity index 100% rename from dev/make/cmplr.dpcpp.mk rename to dev/make/compiler_definitions/dpcpp.mk diff --git a/dev/make/cmplr.gnu.mkl.32e.mk b/dev/make/compiler_definitions/gnu.32e.mk similarity index 78% rename from dev/make/cmplr.gnu.mkl.32e.mk rename to dev/make/compiler_definitions/gnu.32e.mk index 481fda8d19e..f90f0a95eed 100644 --- a/dev/make/cmplr.gnu.mkl.32e.mk +++ b/dev/make/compiler_definitions/gnu.32e.mk @@ -1,5 +1,5 @@ #=============================================================================== -# Copyright 2023 Intel Corporation +# Copyright contributors to the oneDAL project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,34 +16,25 @@ #++ # g++ definitions for makefile +# This file contains definitions common to gnu on a 32e (intel64) platform. It +# should only be included from files which have more specializations (e.g. +# gnu.mkl.32e.mk) #-- -PLATs.gnu = lnx32e mac32e - -CMPLRDIRSUFF.gnu = _gnu - -CORE.SERV.COMPILER.gnu = generic +include dev/make/compiler_definitions/gnu.mk --Zl.gnu = --DEBC.gnu = -g +PLATs.gnu = lnx32e mac32e COMPILER.all.gnu = ${CXX} -m64 -fwrapv -fno-strict-overflow -fno-delete-null-pointer-checks \ -Werror -Wreturn-type link.dynamic.all.gnu = ${CXX} -m64 -pedantic.opts.all.gnu = -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter - -COMPILER.lnx.gnu = $(COMPILER.all.gnu) -link.dynamic.lnx.gnu = $(link.dynamic.all.gnu) pedantic.opts.lnx.gnu = $(pedantic.opts.all.gnu) +pedantic.opts.mac.gnu = $(pedantic.opts.all.gnu) -COMPILER.mac.gnu = $(COMPILER.all.gnu) +link.dynamic.lnx.gnu = $(link.dynamic.all.gnu) link.dynamic.mac.gnu = $(link.dynamic.all.gnu) -pedantic.opts.mac.gnu = $(pedantic.opts.all.gnu) p4_OPT.gnu = $(-Q)march=nocona mc3_OPT.gnu = $(-Q)march=corei7 diff --git a/dev/make/cmplr.gnu.ref.32e.mk b/dev/make/compiler_definitions/gnu.mk similarity index 59% rename from dev/make/cmplr.gnu.ref.32e.mk rename to dev/make/compiler_definitions/gnu.mk index 27f6d817605..cb0679037f1 100644 --- a/dev/make/cmplr.gnu.ref.32e.mk +++ b/dev/make/compiler_definitions/gnu.mk @@ -1,5 +1,5 @@ #=============================================================================== -# Copyright 2023 Intel Corporation +# Copyright contributors to the oneDAL project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,10 +16,11 @@ #++ # g++ definitions for makefile +# This file contains definitions common to gnu on all platforms. It +# should only be included from files which have more specializations (e.g. +# gnu.32e.mk) #-- -PLATs.gnu = lnx32e mac32e - CMPLRDIRSUFF.gnu = _gnu CORE.SERV.COMPILER.gnu = generic @@ -27,25 +28,7 @@ CORE.SERV.COMPILER.gnu = generic -Zl.gnu = -DEBC.gnu = -g -COMPILER.all.gnu = ${CXX} -m64 -fwrapv -fno-strict-overflow -fno-delete-null-pointer-checks \ - -DDAAL_REF -DONEDAL_REF -Werror -Wreturn-type - -link.dynamic.all.gnu = ${CXX} -m64 - pedantic.opts.all.gnu = -pedantic \ -Wall \ -Wextra \ -Wno-unused-parameter - -COMPILER.lnx.gnu = $(COMPILER.all.gnu) -link.dynamic.lnx.gnu = $(link.dynamic.all.gnu) -pedantic.opts.lnx.gnu = $(pedantic.opts.all.gnu) - -COMPILER.mac.gnu = $(COMPILER.all.gnu) -link.dynamic.mac.gnu = $(link.dynamic.all.gnu) -pedantic.opts.mac.gnu = $(pedantic.opts.all.gnu) - -p4_OPT.gnu = $(-Q)march=nocona -mc3_OPT.gnu = $(-Q)march=corei7 -avx2_OPT.gnu = $(-Q)march=haswell -skx_OPT.gnu = $(-Q)march=skylake diff --git a/dev/make/compiler_definitions/gnu.mkl.32e.mk b/dev/make/compiler_definitions/gnu.mkl.32e.mk new file mode 100644 index 00000000000..6877ee330dd --- /dev/null +++ b/dev/make/compiler_definitions/gnu.mkl.32e.mk @@ -0,0 +1,24 @@ +#=============================================================================== +# Copyright 2023 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. +#=============================================================================== + +#++ +# g++ definitions for makefile +#-- + +include dev/make/compiler_definitions/gnu.32e.mk + +COMPILER.lnx.gnu = $(COMPILER.all.gnu) +COMPILER.mac.gnu = $(COMPILER.all.gnu) diff --git a/dev/make/compiler_definitions/gnu.ref.32e.mk b/dev/make/compiler_definitions/gnu.ref.32e.mk new file mode 100644 index 00000000000..bd58dc8ab1d --- /dev/null +++ b/dev/make/compiler_definitions/gnu.ref.32e.mk @@ -0,0 +1,24 @@ +#=============================================================================== +# Copyright 2023 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. +#=============================================================================== + +#++ +# g++ definitions for makefile +#-- + +include dev/make/compiler_definitions/gnu.32e.mk + +COMPILER.lnx.gnu = $(COMPILER.all.gnu) -DDAAL_REF -DONEDAL_REF +COMPILER.mac.gnu = $(COMPILER.all.gnu) -DDAAL_REF -DONEDAL_REF diff --git a/dev/make/cmplr.gnu.ref.arm.mk b/dev/make/compiler_definitions/gnu.ref.arm.mk similarity index 76% rename from dev/make/cmplr.gnu.ref.arm.mk rename to dev/make/compiler_definitions/gnu.ref.arm.mk index b8567ee7b4d..bf7379cc8bc 100644 --- a/dev/make/cmplr.gnu.ref.arm.mk +++ b/dev/make/compiler_definitions/gnu.ref.arm.mk @@ -18,31 +18,17 @@ # g++ definitions for makefile #-- -PLATs.gnu = lnxarm - -CMPLRDIRSUFF.gnu = _gnu - -CORE.SERV.COMPILER.gnu = generic +include dev/make/compiler_definitions/gnu.mk --Zl.gnu = --DEBC.gnu = -g +PLATs.gnu = lnxarm COMPILER.all.gnu = ${CXX} -march=armv8-a+sve -fwrapv -fno-strict-overflow -fno-delete-null-pointer-checks \ -DDAAL_REF -DONEDAL_REF -DDAAL_CPU=sve -Werror -Wreturn-type link.dynamic.all.gnu = ${CXX} -march=native -pedantic.opts.all.gnu = -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter - COMPILER.lnx.gnu = $(COMPILER.all.gnu) link.dynamic.lnx.gnu = $(link.dynamic.all.gnu) pedantic.opts.lnx.gnu = $(pedantic.opts.all.gnu) -COMPILER.mac.gnu = $(COMPILER.all.gnu) -link.dynamic.mac.gnu = $(link.dynamic.all.gnu) -pedantic.opts.mac.gnu = $(pedantic.opts.all.gnu) - a8sve_OPT.gnu = $(-Q)march=armv8-a+sve diff --git a/dev/make/cmplr.icc.mkl.32e.mk b/dev/make/compiler_definitions/icc.mkl.32e.mk similarity index 100% rename from dev/make/cmplr.icc.mkl.32e.mk rename to dev/make/compiler_definitions/icc.mkl.32e.mk diff --git a/dev/make/cmplr.icx.mkl.32e.mk b/dev/make/compiler_definitions/icx.mkl.32e.mk similarity index 100% rename from dev/make/cmplr.icx.mkl.32e.mk rename to dev/make/compiler_definitions/icx.mkl.32e.mk diff --git a/dev/make/cmplr.vc.mkl.32e.mk b/dev/make/compiler_definitions/vc.mkl.32e.mk similarity index 100% rename from dev/make/cmplr.vc.mkl.32e.mk rename to dev/make/compiler_definitions/vc.mkl.32e.mk diff --git a/dev/make/function_definitions/32e.mk b/dev/make/function_definitions/32e.mk new file mode 100644 index 00000000000..41dfbb96fe9 --- /dev/null +++ b/dev/make/function_definitions/32e.mk @@ -0,0 +1,107 @@ +#=============================================================================== +# Copyright contributors to the oneDAL project +# +# 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. +#=============================================================================== + +ifeq ($(filter mkl ref,$(BACKEND_CONFIG)),) + $(error Unsupported backend config '$(BACKEND_CONFIG)'. \ + Supported config for '$(PLAT)' are ['mkl', 'ref']) +endif + +COMPILERs = icc icx gnu clang vc +COMPILER ?= icc +CPUs := sse2 sse42 avx2 avx512 +CPUs.files := nrh neh hsw skx + +ONEAPI.dispatcher_tag.nrh := -D__CPU_TAG__=__CPU_TAG_SSE2__ +ONEAPI.dispatcher_tag.neh := -D__CPU_TAG__=__CPU_TAG_SSE42__ +ONEAPI.dispatcher_tag.hsw := -D__CPU_TAG__=__CPU_TAG_AVX2__ +ONEAPI.dispatcher_tag.skx := -D__CPU_TAG__=__CPU_TAG_AVX512__ + +# Used as $(eval $(call add_mandatory_cpu,var_name)) to add the mandatory CPU +# sse2 to the start of the list of CPUs stored in 'var_name' +define add_mandatory_cpu + $$(eval $1 := $$(if $$(filter sse2,$$($1)),$$($1),sse2 $$($1))) +endef + +# Used as $(eval $(call set_uarch_options_for_compiler,$(COMPILER))) +define set_uarch_options_for_compiler + $$(eval p4_OPT := $$(p4_OPT.$1)) + $$(eval mc3_OPT := $$(mc3_OPT.$1)) + $$(eval avx2_OPT := $$(avx2_OPT.$1)) + $$(eval skx_OPT := $$(skx_OPT.$1)) +endef + +# Used as $(eval $(call set_arch_file_suffix,var_name)) +define set_arch_file_suffix + $$(eval $1.files := $$(subst sse2,nrh,$$(subst sse42,neh,$$(subst avx2,hsw,$$(subst avx512,skx,$$($1)))))) +endef + +# Used as $(eval $(call set_usecpu_defs)) +# There are no parameters, as we assume we want to update the variable USECPUS, +# but we can't set this without a function call, as we rely on other variables +# already being set +define set_usecpu_defs + $$(eval USECPUS.out.defs := $$(subst sse2,^\#define DAAL_KERNEL_SSE2$$(sed.eow),\ + $$(subst sse42,^\#define DAAL_KERNEL_SSE42$$(sed.eow),\ + $$(subst avx2,^\#define DAAL_KERNEL_AVX2$$(sed.eow),\ + $$(subst avx512,^\#define DAAL_KERNEL_AVX512$$(sed.eow),$$(USECPUS.out)))))) +endef + +# Used as $(eval $(call append_uarch_copt,$(OBJNAME))) +define append_uarch_copt +$$(eval $$(call containing,_nrh, $1): COPT += $$(p4_OPT) -DDAAL_CPU=sse2) +$$(eval $$(call containing,_neh, $1): COPT += $$(mc3_OPT) -DDAAL_CPU=sse42) +$$(eval $$(call containing,_hsw, $1): COPT += $$(avx2_OPT) -DDAAL_CPU=avx2) +$$(eval $$(call containing,_skx, $1): COPT += $$(skx_OPT) -DDAAL_CPU=avx512) + +$$(eval $$(call containing,_flt, $1): COPT += -DDAAL_FPTYPE=float) +$$(eval $$(call containing,_dbl, $1): COPT += -DDAAL_FPTYPE=double) +endef + +# Used as $(eval $(call subst_arch_cpu_in_var,VARNAME)) +define subst_arch_cpu_in_var + $$(eval $1 := $$(subst _cpu_nrh,_cpu,$$($1))) + $$(eval $1 := $$(subst _cpu_neh,_cpu,$$($1))) + $$(eval $1 := $$(subst _cpu_hsw,_cpu,$$($1))) + $$(eval $1 := $$(subst _cpu_skx,_cpu,$$($1))) +endef + +# Use as $(eval $(call add_cpu_to_uarch_in_files,VAR_NAME +define add_cpu_to_uarch_in_files + $$(eval nrh_files := $$(subst _nrh,_cpu_nrh,$$(call containing,_nrh,$$($1)))) + $$(eval neh_files := $$(subst _neh,_cpu_neh,$$(call containing,_neh,$$($1)))) + $$(eval hsw_files := $$(subst _hsw,_cpu_hsw,$$(call containing,_hsw,$$($1)))) + $$(eval skx_files := $$(subst _skx,_cpu_skx,$$(call containing,_skx,$$($1)))) + $$(eval user_cpu_files := $$(nrh_files) $$(neh_files) $$(hsw_files) $$(skx_files)) +endef + +# Used as $(eval $(call dispatcher_cpu_rule,rule_name,$(USECPUS)))) +define dispatcher_cpu_rule +$1: | $(dir $1)/. + $(if $(filter sse42,$2),echo "#define ONEDAL_CPU_DISPATCH_SSE42" >> $$@) + $(if $(filter avx2,$2),echo "#define ONEDAL_CPU_DISPATCH_AVX2" >> $$@) + $(if $(filter avx512,$2),echo "#define ONEDAL_CPU_DISPATCH_AVX512" >> $$@) +endef + +# Used as $(eval $(call update_copt_from_dispatcher_tag,$(OBJ_NAME),suffix)) +# This must be called after the p4_OPT, mc3_OPT, avx2_OPT, skx_OPT, a8sve_OPT, +# and ONEAPI.dispatcher_tag.* variables are defined. Otherwise this will be a +# no-op +define update_copt_from_dispatcher_tag + $$(eval $(call containing,_nrh, $1): COPT += $$(p4_OPT$2) $$(ONEAPI.dispatcher_tag.nrh)) + $$(eval $(call containing,_neh, $1): COPT += $$(mc3_OPT$2) $$(ONEAPI.dispatcher_tag.neh)) + $$(eval $(call containing,_hsw, $1): COPT += $$(avx2_OPT$2) $$(ONEAPI.dispatcher_tag.hsw)) + $$(eval $(call containing,_skx, $1): COPT += $$(skx_OPT$2) $$(ONEAPI.dispatcher_tag.skx)) +endef diff --git a/dev/make/function_definitions/arm.mk b/dev/make/function_definitions/arm.mk new file mode 100644 index 00000000000..181b1c9ee2a --- /dev/null +++ b/dev/make/function_definitions/arm.mk @@ -0,0 +1,82 @@ +#=============================================================================== +# Copyright contributors to the oneDAL project +# +# 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. +#=============================================================================== + +ifeq ($(filter ref,$(BACKEND_CONFIG)),) + $(error Unsupported backend config '$(BACKEND_CONFIG)'. \ + Supported config for '$(PLAT)' are ['ref']) +endif + +COMPILERs = gnu clang +COMPILER ?= gnu +CPUs := sve +CPUs.files := a8sve + +ONEAPI.dispatcher_tag.a8sve := -D__CPU_TAG__=__CPU_TAG_ARMV8SVE__ + +# Used as $(eval $(call add_mandatory_cpu,var_name)) to add the mandatory CPU +# sse2 to the start of the list of CPUs stored in 'var_name' +define add_mandatory_cpu + $$(eval $1 := $$(if $$(filter sve,$$($1)),$$($1),sve $$($1))) +endef + +# Used as $(eval $(call set_uarch_options_for_compiler,$(COMPILER))) +define set_uarch_options_for_compiler + $$(eval a8sve_OPT := $$(a8sve_OPT.$1)) +endef + +# Used as $(eval $(call set_arch_file_suffix,var_name)) +define set_arch_file_suffix + $$(eval $1.files := $$(subst sve,a8sve,$$($1))) +endef + +# Used as $(eval $(call set_usecpu_defs)) +# There are no parameters, as we assume we want to update the variable USECPUS, +# but we can't set this without a function call, as we rely on other variables +# already being set +define set_usecpu_defs + $$(eval USECPUS.out.defs := $$(subst sve,^\#define DAAL_KERNEL_SVE$$(sed.eow),$$(USECPUS.out))) +endef + +# Used as $(eval $(call append_uarch_copt,$(OBJNAME))) +define append_uarch_copt +$$(eval $$(call containing,_flt, $1): COPT += -DDAAL_FPTYPE=float) +$$(eval $$(call containing,_dbl, $1): COPT += -DDAAL_FPTYPE=double) +endef + +# Used as $(eval $(call subst_arch_cpu_in_var,VARNAME)) +define subst_arch_cpu_in_var + $$(eval $1 := $$(subst _cpu_a8sve,_cpu,$$($1))) +endef + +# Use as $(eval $(call add_cpu_to_uarch_in_files,VAR_NAME +define add_cpu_to_uarch_in_files + $$(eval a8sve_files := $$(subst _a8sve,_cpu_a8sve,$$(call containing,_a8sve,$$($1)))) + $$(eval user_cpu_files := $$(a8sve_files)) +endef + +# Used as $(eval $(call dispatcher_cpu_rule,rule_name,$(USECPUS)))) +define dispatcher_cpu_rule +$1: | $(dir $1)/. + $(if $(filter sve,$2),echo "#define ONEDAL_CPU_DISPATCH_A8SVE" >> $$@) +endef + +# Used as $(eval $(call update_copt_from_dispatcher_tag,$(OBJ_NAME),suffix)) +# This must be called after the p4_OPT, mc3_OPT, avx2_OPT, skx_OPT, a8sve_OPT, +# and ONEAPI.dispatcher_tag.* variables are defined. Otherwise this will be a +# no-op +define update_copt_from_dispatcher_tag + $$(eval $(call containing,_a8sve, $1): COPT += $$(a8sve_OPT$2) $$(ONEAPI.dispatcher_tag.a8sve)) +endef diff --git a/dev/make/function_definitions/lnx32e.mk b/dev/make/function_definitions/lnx32e.mk new file mode 100644 index 00000000000..ea5e759520a --- /dev/null +++ b/dev/make/function_definitions/lnx32e.mk @@ -0,0 +1,37 @@ +#=============================================================================== +# Copyright contributors to the oneDAL project +# +# 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. +#=============================================================================== + +BACKEND_CONFIG ?= mkl +ARCH = 32e +ARCH_DIR_ONEDAL = intel64 +_OS := lnx +_IA := intel64 + +include dev/make/function_definitions/32e.mk + +# Used as $(eval $(call set_daal_rt_deps)) +define set_daal_rt_deps + $$(eval daaldep.lnx32e.rt.thr := -L$$(TBBDIR.soia.lnx) -ltbb -ltbbmalloc \ + -lpthread $$(daaldep.lnx32e.rt.$$(COMPILER)) \ + $$(if $$(COV.libia),$$(COV.libia)/libcov.a)) + $$(eval daaldep.lnx32e.rt.seq := -lpthread $$(daaldep.lnx32e.rt.$$(COMPILER)) \ + $$(if $$(COV.libia),$$(COV.libia)/libcov.a)) + $$(eval daaldep.lnx32e.rt.dpc := -lpthread -lOpenCL \ + $$(if $$(COV.libia),$$(COV.libia)/libcov.a)) + $$(eval daaldep.lnx32e.threxport := export_lnx32e.$$(BACKEND_CONFIG).def) + + $$(eval daaldep.lnx.threxport.create = grep -v -E '^(EXPORTS|;|$$$$$$$$)' $$$$< $$$$(USECPUS.out.grep.filter) | sed -e 's/^/-u /') +endef diff --git a/dev/make/function_definitions/lnxarm.mk b/dev/make/function_definitions/lnxarm.mk new file mode 100644 index 00000000000..c44df217e03 --- /dev/null +++ b/dev/make/function_definitions/lnxarm.mk @@ -0,0 +1,37 @@ +#=============================================================================== +# Copyright contributors to the oneDAL project +# +# 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. +#=============================================================================== + +BACKEND_CONFIG ?= ref +ARCH = arm +ARCH_DIR_ONEDAL = arm +_OS := lnx +_IA := arm + +include dev/make/function_definitions/arm.mk + +# Used as $(eval $(call set_daal_rt_deps)) +define set_daal_rt_deps + $$(eval daaldep.lnxarm.rt.thr := -L$$(TBBDIR.soia.lnx) -ltbb -ltbbmalloc \ + -lpthread $$(daaldep.lnxarm.rt.$$(COMPILER)) \ + $$(if $$(COV.libia),$$(COV.libia)/libcov.a)) + $$(eval daaldep.lnxarm.rt.seq := -lpthread $$(daaldep.lnxarm.rt.$$(COMPILER)) \ + $$(if $$(COV.libia),$$(COV.libia)/libcov.a)) + $$(eval daaldep.lnxarm.rt.dpc := -lpthread -lOpenCL \ + $$(if $$(COV.libia),$$(COV.libia)/libcov.a)) + $$(eval daaldep.lnxarm.threxport := export_lnxarm.$$(BACKEND_CONFIG).def) + + $$(eval daaldep.lnx.threxport.create = grep -v -E '^(EXPORTS|;|$$$$$$$$)' $$$$< $$$$(USECPUS.out.grep.filter) | sed -e 's/^/-u /') +endef diff --git a/dev/make/function_definitions/mac32e.mk b/dev/make/function_definitions/mac32e.mk new file mode 100644 index 00000000000..a86b2416838 --- /dev/null +++ b/dev/make/function_definitions/mac32e.mk @@ -0,0 +1,33 @@ +#=============================================================================== +# Copyright contributors to the oneDAL project +# +# 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. +#=============================================================================== + +BACKEND_CONFIG ?= mkl +ARCH = 32e +ARCH_DIR_ONEDAL = intel64 +_OS := mac +_IA := intel64 + +include dev/make/function_definitions/32e.mk + +# Used as $(eval $(call set_daal_rt_deps)) +define set_daal_rt_deps + $$(eval daaldep.mac32e.rt.thr := -L$$(RELEASEDIR.tbb.soia) -ltbb -ltbbmalloc \ + $$(daaldep.mac32e.rt.$$(COMPILER))) + $$(eval daaldep.mac32e.rt.seq := $$(daaldep.mac32e.rt.$$(COMPILER))) + $$(eval daaldep.mac32e.threxport := export_mac.def) + + $$(eval daaldep.mac.threxport.create = grep -v -E '^(EXPORTS|;|$$$$$$$$)' $$$$< $$$$(USECPUS.out.grep.filter) | sed -e 's/^/-u /') +endef diff --git a/dev/make/function_definitions/win32e.mk b/dev/make/function_definitions/win32e.mk new file mode 100644 index 00000000000..c37480ef549 --- /dev/null +++ b/dev/make/function_definitions/win32e.mk @@ -0,0 +1,34 @@ +#=============================================================================== +# Copyright contributors to the oneDAL project +# +# 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. +#=============================================================================== + +BACKEND_CONFIG ?= mkl +ARCH = 32e +ARCH_DIR_ONEDAL = intel64 +_OS := win +_IA := intel64 + +include dev/make/function_definitions/32e.mk + +# Used as $(eval $(call set_daal_rt_deps)) +define set_daal_rt_deps + $$(eval daaldep.win32e.rt.thr := -LIBPATH:$$(RELEASEDIR.tbb.libia) \ + $$(dep_thr) $$(if $$(CHECK_DLL_SIG),Wintrust.lib)) + $$(eval daaldep.win32e.rt.seq := $$(dep_seq) \ + $$(if $$(CHECK_DLL_SIG),Wintrust.lib)) + $$(eval daaldep.win32e.threxport := export.def) + + $$(eval daaldep.win.threxport.create = grep -v -E '^(;|$$$$$$$$)' $$$$< $$$$(USECPUS.out.grep.filter)) +endef diff --git a/dev/make/identify_os.sh b/dev/make/identify_os.sh index 88843b91f82..d8d70054d9f 100755 --- a/dev/make/identify_os.sh +++ b/dev/make/identify_os.sh @@ -31,5 +31,5 @@ elif [ "${os}" = "Darwin" ]; then elif [[ "${os}" =~ "MSYS" || "${os}" =~ "CYGWIN" ]]; then echo win32e else - echo "UnknownOS" + echo "Unknown OS: ${os}" fi diff --git a/makefile b/makefile index e5abcb9846e..18211bbe973 100644 --- a/makefile +++ b/makefile @@ -19,22 +19,25 @@ # Common macros #=============================================================================== -ifeq ($(PLAT),) - PLAT:=$(shell bash dev/make/identify_os.sh) -endif - ifeq (help,$(MAKECMDGOALS)) PLAT:=win32e +else ifeq ($(PLAT),) + PLAT:=$(shell bash dev/make/identify_os.sh) endif -attr.lnx32e = lnx intel64 lin -attr.lnxarm = lnx arm lin -attr.mac32e = mac intel64 -attr.win32e = win intel64 win +# Check that we know how to build for the identified platform +PLATs := lnx32e mac32e win32e lnxarm +$(if $(filter $(PLAT),$(PLATs)),,$(error Unknown platform $(PLAT))) -_OS := $(word 1,$(attr.$(PLAT))) -_IA := $(word 2,$(attr.$(PLAT))) -_OSc:= $(word 3,$(attr.$(PLAT))) +# Non-platform or architecture specific defines live in common.mk +include dev/make/common.mk + +# Platform specific variables are set in dev/make/function_definitions/$(PLAT).mk +# There are also files dev/make/function_definitions/$(ARCH).mk, but these are included from +# the $(PLAT).mk files, rather than here. +include dev/make/function_definitions/$(PLAT).mk + +$(if $(filter $(COMPILERs),$(COMPILER)),,$(error COMPILER must be one of $(COMPILERs))) MSVC_RUNTIME_VERSIONs = release debug MSVC_RUNTIME_VERSION ?= release @@ -45,6 +48,7 @@ OS_is_$(_OS) := yes IA_is_$(_IA) := yes PLAT_is_$(PLAT) := yes MSVC_RT_is_$(MSVC_RUNTIME_VERSION) := yes +ARCH_is_$(ARCH) := yes DEFAULT_BUILD_PARAMETERS_LIB := $(if $(OS_is_win),no,yes) BUILD_PARAMETERS_LIB ?= $(DEFAULT_BUILD_PARAMETERS_LIB) @@ -55,53 +59,10 @@ $(error Building with the parameters library is not available on Windows OS) endif endif -ifeq ($(PLAT),lnx32e) - BACKEND_CONFIG ?= mkl - ARCH = 32e -else ifeq ($(PLAT),mac32e) - BACKEND_CONFIG ?= mkl - ARCH = 32e -else ifeq ($(PLAT),win32e) - BACKEND_CONFIG ?= mkl - ARCH = 32e -else ifeq ($(PLAT),lnxarm) - BACKEND_CONFIG ?= ref - ARCH = arm -else - $(error Unsupported platform: $(PLAT)) -endif - -ARCH_is_$(ARCH) := yes - -ifeq ($(ARCH_is_32e),yes) - $(if $(filter mkl ref,$(BACKEND_CONFIG)),,$(error Unsupported backend config '$(BACKEND_CONFIG)'. \ - Supported config for '${PLAT}' are ['mkl','ref'])) - COMPILERs = icc icx gnu clang vc - COMPILER ?= icc -else - $(if $(filter ref,$(BACKEND_CONFIG)),,$(error Unsupported backend config '$(BACKEND_CONFIG)'. \ - Supported config for '${PLAT}' is 'ref')) - COMPILERs = gnu clang - COMPILER ?= gnu -endif - -$(if $(filter $(COMPILERs),$(COMPILER)),,$(error COMPILER must be one of $(COMPILERs))) - -ifeq ($(ARCH_is_32e),yes) - CPUs := sse2 sse42 avx2 avx512 - CPUs.files := nrh neh hsw skx -else - CPUs := sve - CPUs.files := a8sve -endif - USERREQCPU := $(filter-out $(filter $(CPUs),$(REQCPU)),$(REQCPU)) USECPUS := $(if $(REQCPU),$(if $(USERREQCPU),$(error Unsupported value/s in REQCPU: $(USERREQCPU). List of supported CPUs: $(CPUs)),$(REQCPU)),$(CPUs)) -ifeq ($(ARCH_is_32e),yes) - USECPUS := $(if $(filter sse2,$(USECPUS)),$(USECPUS),sse2 $(USECPUS)) -else - USECPUS := $(if $(filter sve,$(USECPUS)),$(USECPUS),sve $(USECPUS)) -endif + +$(eval $(call add_mandatory_cpu,USECPUS)) $(info Selected list of CPUs - USECPUS: $(USECPUS)) @@ -127,8 +88,8 @@ endif DPC.COMPILE.gcc_toolchain := $(GCC_TOOLCHAIN_PATH) endif -include dev/make/cmplr.$(COMPILER).$(BACKEND_CONFIG).$(ARCH).mk -include dev/make/cmplr.dpcpp.mk +include dev/make/compiler_definitions/$(COMPILER).$(BACKEND_CONFIG).$(ARCH).mk +include dev/make/compiler_definitions/dpcpp.mk $(if $(filter $(PLATs.$(COMPILER)),$(PLAT)),,$(error PLAT for $(COMPILER) must be defined to one of $(PLATs.$(COMPILER)))) @@ -136,7 +97,6 @@ $(if $(filter $(PLATs.$(COMPILER)),$(PLAT)),,$(error PLAT for $(COMPILER) must b # Dependencies generation #=============================================================================== -include dev/make/common.mk include dev/make/deps.mk #=============================================================================== @@ -169,35 +129,15 @@ y := $(notdir $(filter $(_OS)/%,lnx/so win/dll mac/dylib)) -eGRP = $(if $(OS_is_lnx),-Wl$(comma)--end-group,) daalmake = make -ifeq ($(ARCH_is_32e),yes) - p4_OPT := $(p4_OPT.$(COMPILER)) - mc3_OPT := $(mc3_OPT.$(COMPILER)) - avx2_OPT := $(avx2_OPT.$(COMPILER)) - skx_OPT := $(skx_OPT.$(COMPILER)) -else - a8sve_OPT := $(a8sve_OPT.$(COMPILER)) -endif +$(eval $(call set_uarch_options_for_compiler,$(COMPILER))) -_OSr := $(if $(OS_is_win),win,$(if $(OS_is_lnx),lin,)) - -ifeq ($(ARCH_is_32e),yes) - USECPUS.files := $(subst sse2,nrh,$(subst sse42,neh,$(subst avx2,hsw,$(subst avx512,skx,$(USECPUS))))) -else - USECPUS.files := $(subst sve,a8sve,$(USECPUS)) -endif +$(eval $(call set_arch_file_suffix,USECPUS)) USECPUS.out := $(filter-out $(USECPUS),$(CPUs)) USECPUS.out.for.grep.filter := $(addprefix _,$(addsuffix _,$(subst $(space),_|_,$(USECPUS.out)))) USECPUS.out.grep.filter := $(if $(USECPUS.out),| grep -v -E '$(USECPUS.out.for.grep.filter)') -ifeq ($(ARCH_is_32e),yes) - USECPUS.out.defs := $(subst sse2,^\#define DAAL_KERNEL_SSE2$(sed.eow),\ - $(subst sse42,^\#define DAAL_KERNEL_SSE42$(sed.eow),\ - $(subst avx2,^\#define DAAL_KERNEL_AVX2$(sed.eow),\ - $(subst avx512,^\#define DAAL_KERNEL_AVX512$(sed.eow),$(USECPUS.out))))) -else - USECPUS.out.defs := $(subst sve,^\#define DAAL_KERNEL_SVE$(sed.eow),$(USECPUS.out)) -endif +$(eval $(call set_usecpu_defs)) USECPUS.out.defs := $(subst $(space)^,|^,$(strip $(USECPUS.out.defs))) USECPUS.out.defs.filter := $(if $(USECPUS.out.defs),sed $(sed.-b) $(sed.-i) -E -e 's/$(USECPUS.out.defs)/$(sed.eol)/') @@ -342,7 +282,6 @@ mklgpufpk.HEADERS := $(MKLGPUFPKDIR.include)/mkl_dal_sycl.hpp $(MKLGPUFPKDIR.inc include dev/make/deps.$(BACKEND_CONFIG).mk - #============================= oneAPI folders ===================================== ifeq ($(if $(or $(OS_is_lnx),$(OS_is_win)),yes,),yes) ONEAPIDIR := $(call topf,$$ONEAPI_ROOT) @@ -400,30 +339,8 @@ release.PARAMETERS.LIBS_A.dpc := $(parameters_a.dpc) \ $(if $(OS_is_win),$(foreach ilib,$(parameters_a.dpc),$(ilib:%.lib=%_dll.lib)),) release.PARAMETERS.LIBS_Y.dpc := $(parameters_y.dpc) -# Libraries required for building -daaldep.lnx32e.rt.thr := -L$(TBBDIR.soia.lnx) -ltbb -ltbbmalloc -lpthread $(daaldep.lnx32e.rt.$(COMPILER)) $(if $(COV.libia),$(COV.libia)/libcov.a) -daaldep.lnx32e.rt.seq := -lpthread $(daaldep.lnx32e.rt.$(COMPILER)) $(if $(COV.libia),$(COV.libia)/libcov.a) -daaldep.lnx32e.rt.dpc := -lpthread -lOpenCL $(if $(COV.libia),$(COV.libia)/libcov.a) -daaldep.lnx32e.threxport := export_lnx32e.$(BACKEND_CONFIG).def -daaldep.lnxarm.rt.thr := -L$(TBBDIR.soia.lnx) -ltbb -ltbbmalloc -lpthread $(daaldep.lnxarm.rt.$(COMPILER)) $(if $(COV.libia),$(COV.libia)/libcov.a) -daaldep.lnxarm.rt.seq := -lpthread $(daaldep.lnxarm.rt.$(COMPILER)) $(if $(COV.libia),$(COV.libia)/libcov.a) -daaldep.lnxarm.rt.dpc := -lpthread -lOpenCL $(if $(COV.libia),$(COV.libia)/libcov.a) -daaldep.lnxarm.threxport := export_lnxarm.$(BACKEND_CONFIG).def - -daaldep.lnx.threxport.create = grep -v -E '^(EXPORTS|;|$$)' $< $(USECPUS.out.grep.filter) | sed -e 's/^/-u /' - -daaldep.win32e.rt.thr := -LIBPATH:$(RELEASEDIR.tbb.libia) $(dep_thr) $(if $(CHECK_DLL_SIG),Wintrust.lib) -daaldep.win32e.rt.seq := $(dep_seq) $(if $(CHECK_DLL_SIG),Wintrust.lib) -daaldep.win32e.threxport := export.def - -daaldep.win.threxport.create = grep -v -E '^(;|$$)' $< $(USECPUS.out.grep.filter) - -daaldep.mac32e.rt.thr := -L$(RELEASEDIR.tbb.soia) -ltbb -ltbbmalloc $(daaldep.mac32e.rt.$(COMPILER)) -daaldep.mac32e.rt.seq := $(daaldep.mac32e.rt.$(COMPILER)) -daaldep.mac32e.threxport := export_mac.def - -daaldep.mac.threxport.create = grep -v -E '^(EXPORTS|;|$$)' $< $(USECPUS.out.grep.filter) | sed -e 's/^/-u /' +$(eval $(call set_daal_rt_deps)) daaldep.rt.thr := $(daaldep.$(PLAT).rt.thr) daaldep.rt.seq := $(daaldep.$(PLAT).rt.seq) @@ -571,15 +488,7 @@ $(CORE.objs_a): COPT += -D__TBB_NO_IMPLICIT_LINKAGE -DDAAL_NOTHROW_EXCEPTIONS \ $(CORE.objs_a): COPT += @$(CORE.tmpdir_a)/inc_a_folders.txt $(filter %threading.$o, $(CORE.objs_a)): COPT += -D__DO_TBB_LAYER__ -ifeq ($(ARCH_is_32e),yes) -$(call containing,_nrh, $(CORE.objs_a)): COPT += $(p4_OPT) -DDAAL_CPU=sse2 -$(call containing,_neh, $(CORE.objs_a)): COPT += $(mc3_OPT) -DDAAL_CPU=sse42 -$(call containing,_hsw, $(CORE.objs_a)): COPT += $(avx2_OPT) -DDAAL_CPU=avx2 -$(call containing,_skx, $(CORE.objs_a)): COPT += $(skx_OPT) -DDAAL_CPU=avx512 -endif - -$(call containing,_flt, $(CORE.objs_a)): COPT += -DDAAL_FPTYPE=float -$(call containing,_dbl, $(CORE.objs_a)): COPT += -DDAAL_FPTYPE=double +$(eval $(call append_uarch_copt,$(CORE.objs_a))) $(CORE.objs_y): $(CORE.tmpdir_y)/inc_y_folders.txt $(CORE.objs_y): COPT += $(-fPIC) $(-cxx11) $(-Zl) $(-DEBC) @@ -590,15 +499,7 @@ $(CORE.objs_y): COPT += -D__DAAL_IMPLEMENTATION \ $(CORE.objs_y): COPT += @$(CORE.tmpdir_y)/inc_y_folders.txt $(filter %threading.$o, $(CORE.objs_y)): COPT += -D__DO_TBB_LAYER__ -ifeq ($(ARCH_is_32e),yes) -$(call containing,_nrh, $(CORE.objs_y)): COPT += $(p4_OPT) -DDAAL_CPU=sse2 -$(call containing,_neh, $(CORE.objs_y)): COPT += $(mc3_OPT) -DDAAL_CPU=sse42 -$(call containing,_hsw, $(CORE.objs_y)): COPT += $(avx2_OPT) -DDAAL_CPU=avx2 -$(call containing,_skx, $(CORE.objs_y)): COPT += $(skx_OPT) -DDAAL_CPU=avx512 -endif - -$(call containing,_flt, $(CORE.objs_y)): COPT += -DDAAL_FPTYPE=float -$(call containing,_dbl, $(CORE.objs_y)): COPT += -DDAAL_FPTYPE=double +$(eval $(call append_uarch_copt,$(CORE.objs_y))) vpath vpath %.cpp $(CORE.srcdirs) @@ -610,25 +511,19 @@ $(CORE.tmpdir_y)/inc_y_folders.txt: makefile.lst | $(CORE.tmpdir_y)/. $(CORE.inc $(CORE.tmpdir_a)/library_version_info.$(o): $(VERSION_DATA_FILE) $(CORE.tmpdir_y)/library_version_info.$(o): $(VERSION_DATA_FILE) +# Used as $(eval $(call .compile.template.ay,obj_file)) define .compile.template.ay $(eval template_source_cpp := $(subst .$o,.cpp,$(notdir $1))) $(eval template_source_cpp := $(subst _fpt_flt,_fpt,$(template_source_cpp))) $(eval template_source_cpp := $(subst _fpt_dbl,_fpt,$(template_source_cpp))) -ifeq ($(ARCH_is_32e),yes) - $(eval template_source_cpp := $(subst _cpu_nrh,_cpu,$(template_source_cpp))) - $(eval template_source_cpp := $(subst _cpu_neh,_cpu,$(template_source_cpp))) - $(eval template_source_cpp := $(subst _cpu_hsw,_cpu,$(template_source_cpp))) - $(eval template_source_cpp := $(subst _cpu_skx,_cpu,$(template_source_cpp))) -else - $(eval template_source_cpp := $(subst _cpu_a8sve,_cpu,$(template_source_cpp))) -endif +$(eval $(call subst_arch_cpu_in_var,template_source_cpp)) $1: $(template_source_cpp) ; $(value C.COMPILE) endef -$(foreach a,$(CORE.objs_a),$(eval $(call .compile.template.ay,$a,$(CORE.tmpdir_a)))) -$(foreach a,$(CORE.objs_y),$(eval $(call .compile.template.ay,$a,$(CORE.tmpdir_y)))) +$(foreach a,$(CORE.objs_a),$(eval $(call .compile.template.ay,$a))) +$(foreach a,$(CORE.objs_y),$(eval $(call .compile.template.ay,$a))) $(CORE.tmpdir_y)/dll.res: $(VERSION_DATA_FILE) $(CORE.tmpdir_y)/dll.res: RCOPT += $(addprefix -I, $(CORE.incdirs.common)) @@ -653,15 +548,6 @@ ONEAPI.incdirs := $(ONEAPI.incdirs.common) $(CORE.incdirs.thirdp) $(ONEAPI.incdi ONEAPI.dispatcher_cpu = $(WORKDIR)/oneapi/dal/_dal_cpu_dispatcher_gen.hpp -ifeq ($(ARCH_is_32e),yes) - ONEAPI.dispatcher_tag.nrh := -D__CPU_TAG__=__CPU_TAG_SSE2__ - ONEAPI.dispatcher_tag.neh := -D__CPU_TAG__=__CPU_TAG_SSE42__ - ONEAPI.dispatcher_tag.hsw := -D__CPU_TAG__=__CPU_TAG_AVX2__ - ONEAPI.dispatcher_tag.skx := -D__CPU_TAG__=__CPU_TAG_AVX512__ -else - ONEAPI.dispatcher_tag.a8sve := -D__CPU_TAG__=__CPU_TAG_ARMV8SVE__ -endif - ONEAPI.srcdir := $(CPPDIR.onedal) ONEAPI.srcdirs.base := $(ONEAPI.srcdir) \ $(ONEAPI.srcdir)/algo \ @@ -704,16 +590,8 @@ define .populate_cpus $(eval non_cpu_files := $(call notcontaining,_cpu,$2)) $(eval cpu_files := $(call containing,_cpu,$2)) -ifeq ($(ARCH_is_32e),yes) - $(eval nrh_files := $(subst _nrh,_cpu_nrh,$(call containing,_nrh,$(non_cpu_files)))) - $(eval neh_files := $(subst _neh,_cpu_neh,$(call containing,_neh,$(non_cpu_files)))) - $(eval hsw_files := $(subst _hsw,_cpu_hsw,$(call containing,_hsw,$(non_cpu_files)))) - $(eval skx_files := $(subst _skx,_cpu_skx,$(call containing,_skx,$(non_cpu_files)))) -else - $(eval a8sve_files := $(subst _a8sve,_cpu_a8sve,$(call containing,_a8sve,$(non_cpu_files)))) -endif +$(eval $(call add_cpu_to_uarch_in_files,non_cpu_files)) -$(eval user_cpu_files := $(nrh_files) $(neh_files) $(hsw_files) $(skx_files)) $(eval populated_cpu_files := $(foreach ccc,$(USECPUS.files),$(subst _cpu,_cpu_$(ccc),$(cpu_files)))) $(eval populated_cpu_files := $(filter-out $(user_cpu_files),$(populated_cpu_files))) $(eval $1 := $(non_cpu_files) $(populated_cpu_files)) @@ -737,14 +615,7 @@ define .ONEAPI.compile $(eval template_source_cpp := $(1:$2/%.$o=%.cpp)) $(eval template_source_cpp := $(subst -,/,$(template_source_cpp))) -ifeq ($(ARCH_is_32e),yes) - $(eval template_source_cpp := $(subst _cpu_nrh,_cpu,$(template_source_cpp))) - $(eval template_source_cpp := $(subst _cpu_neh,_cpu,$(template_source_cpp))) - $(eval template_source_cpp := $(subst _cpu_hsw,_cpu,$(template_source_cpp))) - $(eval template_source_cpp := $(subst _cpu_skx,_cpu,$(template_source_cpp))) -else - $(eval template_source_cpp := $(subst _cpu_a8sve,_cpu,$(template_source_cpp))) -endif +$(eval $(call subst_arch_cpu_in_var,template_source_cpp)) $1: $(template_source_cpp) | $(dir $1)/. ; $(value $3.COMPILE) endef @@ -758,14 +629,7 @@ $1: LOPT:= $1: $(1:%.$a=%_link.txt) | $(dir $1)/. ; $(value LINK.STATIC) endef -$(ONEAPI.dispatcher_cpu): | $(dir $(ONEAPI.dispatcher_cpu))/. -ifeq ($(ARCH_is_32e),yes) - $(if $(filter sse42,$(USECPUS)),echo "#define ONEDAL_CPU_DISPATCH_SSE42" >> $@) - $(if $(filter avx2,$(USECPUS)),echo "#define ONEDAL_CPU_DISPATCH_AVX2" >> $@) - $(if $(filter avx512,$(USECPUS)),echo "#define ONEDAL_CPU_DISPATCH_AVX512" >> $@) -else - $(if $(filter sve,$(USECPUS)),echo "#define ONEDAL_CPU_DISPATCH_A8SVE" >> $@) -endif +$(eval $(call dispatcher_cpu_rule,$(ONEAPI.dispatcher_cpu),$(USECPUS))) # Create file with include paths ONEAPI.include_options := $(addprefix -I, $(ONEAPI.incdirs.common)) \ @@ -792,14 +656,8 @@ $(ONEAPI.objs_a): COPT += $(-fPIC) $(-cxx17) $(-Zl) $(-DEBC) $(-EHsc) $(pedantic -D__TBB_NO_IMPLICIT_LINKAGE \ -DTBB_USE_ASSERT=0 \ @$(ONEAPI.tmpdir_a)/inc_a_folders.txt -ifeq ($(ARCH_is_32e),yes) - $(call containing,_nrh, $(ONEAPI.objs_a)): COPT += $(p4_OPT) $(ONEAPI.dispatcher_tag.nrh) - $(call containing,_neh, $(ONEAPI.objs_a)): COPT += $(mc3_OPT) $(ONEAPI.dispatcher_tag.neh) - $(call containing,_hsw, $(ONEAPI.objs_a)): COPT += $(avx2_OPT) $(ONEAPI.dispatcher_tag.hsw) - $(call containing,_skx, $(ONEAPI.objs_a)): COPT += $(skx_OPT) $(ONEAPI.dispatcher_tag.skx) -else - $(call containing,_a8sve, $(ONEAPI.objs_a)): COPT += $(a8sve_OPT) $(ONEAPI.dispatcher_tag.a8sve) -endif + +$(eval $(call update_copt_from_dispatcher_tag,$(ONEAPI.objs_a))) $(ONEAPI.objs_a.dpc): $(ONEAPI.dispatcher_cpu) $(ONEAPI.tmpdir_a.dpc)/inc_a_folders.txt $(ONEAPI.objs_a.dpc): COPT += $(-fPIC) $(-cxx17) $(-DEBC) $(-EHsc) $(pedantic.opts.dpcpp) \ @@ -811,14 +669,8 @@ $(ONEAPI.objs_a.dpc): COPT += $(-fPIC) $(-cxx17) $(-DEBC) $(-EHsc) $(pedantic.op -D_ENABLE_ATOMIC_ALIGNMENT_FIX \ -DTBB_USE_ASSERT=0 \ @$(ONEAPI.tmpdir_a.dpc)/inc_a_folders.txt -ifeq ($(ARCH_is_32e),yes) - $(call containing,_nrh, $(ONEAPI.objs_a.dpc)): COPT += $(p4_OPT.dpcpp) $(ONEAPI.dispatcher_tag.nrh) - $(call containing,_neh, $(ONEAPI.objs_a.dpc)): COPT += $(mc3_OPT.dpcpp) $(ONEAPI.dispatcher_tag.neh) - $(call containing,_hsw, $(ONEAPI.objs_a.dpc)): COPT += $(avx2_OPT.dpcpp) $(ONEAPI.dispatcher_tag.hsw) - $(call containing,_skx, $(ONEAPI.objs_a.dpc)): COPT += $(skx_OPT.dpcpp) $(ONEAPI.dispatcher_tag.skx) -else - $(call containing,_a8sve, $(ONEAPI.objs_a.dpc)): COPT += $(a8sve_OPT.dpcpp) $(ONEAPI.dispatcher_tag.a8sve) -endif + +$(eval $(call update_copt_from_dispatcher_tag,$(ONEAPI.objs_a.dpc),.dpcpp)) # Set compilation options to the object files which are part of DYNAMIC lib $(ONEAPI.objs_y): $(ONEAPI.dispatcher_cpu) $(ONEAPI.tmpdir_y)/inc_y_folders.txt @@ -831,14 +683,8 @@ $(ONEAPI.objs_y): COPT += $(-fPIC) $(-cxx17) $(-Zl) $(-DEBC) $(-EHsc) $(pedantic -D__TBB_NO_IMPLICIT_LINKAGE \ -DTBB_USE_ASSERT=0 \ @$(ONEAPI.tmpdir_y)/inc_y_folders.txt -ifeq ($(ARCH_is_32e),yes) - $(call containing,_nrh, $(ONEAPI.objs_y)): COPT += $(p4_OPT) $(ONEAPI.dispatcher_tag.nrh) - $(call containing,_neh, $(ONEAPI.objs_y)): COPT += $(mc3_OPT) $(ONEAPI.dispatcher_tag.neh) - $(call containing,_hsw, $(ONEAPI.objs_y)): COPT += $(avx2_OPT) $(ONEAPI.dispatcher_tag.hsw) - $(call containing,_skx, $(ONEAPI.objs_y)): COPT += $(skx_OPT) $(ONEAPI.dispatcher_tag.skx) -else - $(call containing,_a8sve, $(ONEAPI.objs_y)): COPT += $(a8sve_OPT) $(ONEAPI.dispatcher_tag.a8sve) -endif + +$(eval $(call update_copt_from_dispatcher_tag,$(ONEAPI.objs_y))) $(ONEAPI.objs_y.dpc): $(ONEAPI.dispatcher_cpu) $(ONEAPI.tmpdir_y.dpc)/inc_y_folders.txt $(ONEAPI.objs_y.dpc): COPT += $(-fPIC) $(-cxx17) $(-DEBC) $(-EHsc) $(pedantic.opts.dpcpp) \ @@ -852,14 +698,8 @@ $(ONEAPI.objs_y.dpc): COPT += $(-fPIC) $(-cxx17) $(-DEBC) $(-EHsc) $(pedantic.op -D__TBB_NO_IMPLICIT_LINKAGE \ -DTBB_USE_ASSERT=0 \ @$(ONEAPI.tmpdir_y.dpc)/inc_y_folders.txt -ifeq ($(ARCH_is_32e),yes) - $(call containing,_nrh, $(ONEAPI.objs_y.dpc)): COPT += $(p4_OPT.dpcpp) $(ONEAPI.dispatcher_tag.nrh) - $(call containing,_neh, $(ONEAPI.objs_y.dpc)): COPT += $(mc3_OPT.dpcpp) $(ONEAPI.dispatcher_tag.neh) - $(call containing,_hsw, $(ONEAPI.objs_y.dpc)): COPT += $(avx2_OPT.dpcpp) $(ONEAPI.dispatcher_tag.hsw) - $(call containing,_skx, $(ONEAPI.objs_y.dpc)): COPT += $(skx_OPT.dpcpp) $(ONEAPI.dispatcher_tag.skx) -else - $(call containing,_a8sve, $(ONEAPI.objs_y.dpc)): COPT += $(a8sve_OPT.dpcpp) $(ONEAPI.dispatcher_tag.a8sve) -endif + +$(eval $(call update_copt_from_dispatcher_tag,$(ONEAPI.objs_y.dpc),.dpcpp)) # Filtering parameter files PARAMETERS.objs_a.filtered := $(filter %parameters.$(o),$(ONEAPI.objs_a)) @@ -1229,12 +1069,6 @@ $(foreach t,$(releasetbb.LIBS_Y),$(eval $(call .release.t,$t,$(RELEASEDIR.tbb.so $(foreach t,$(releasetbb.LIBS_A),$(eval $(call .release.t,$t,$(RELEASEDIR.tbb.libia)))) #----- cmake configs generation -ARCH_DIR_ONEDAL= -ifeq ($(ARCH),32e) - ARCH_DIR_ONEDAL=intel64 -else - ARCH_DIR_ONEDAL=arm -endif _release_cmake_configs: $(if $(shell bash -c "command -v cmake"),cmake -DINSTALL_DIR=$(RELEASEDIR.lib)/cmake/oneDAL -DARCH_DIR_ONEDAL=$(ARCH_DIR_ONEDAL) -P cmake/scripts/generate_config.cmake,echo 'cmake configs generation skipped')