math/onednn: Add options for SIMD optimization level; Use standard BUILD_TESTING cmake variable instead of BUILD_TESTS

This commit is contained in:
Yuri Victorovich 2020-11-06 18:51:36 +00:00
parent 68a6590ca3
commit 54c8cf842d
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=554310
3 changed files with 43 additions and 14 deletions

View File

@ -3,7 +3,7 @@
PORTNAME= onednn
DISTVERSIONPREFIX= v
DISTVERSION= 1.7
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= math # machine-learning
MAINTAINER= yuri@FreeBSD.org
@ -23,30 +23,39 @@ GH_ACCOUNT= oneapi-src
GH_PROJECT= oneDNN
USE_LDCONFIG= yes
CMAKE_OFF= BUILD_TESTING
OPTIONS_DEFINE= OPENMP
OPTIONS_DEFAULT= OPENMP
OPTIONS_DEFAULT= OPENMP SIMD_DEFAULT
OPTIONS_SINGLE= SIMD
OPTIONS_SINGLE_SIMD= SIMD_DEFAULT SIMD_NATIVE
OPENMP_CMAKE_BOOL= USE_OPENMP
OPENMP_BROKEN_OFF= still requires omp.h, see https://github.com/intel/mkl-dnn/issues/581
CXXFLAGS_amd64= -msse4.1
CXXFLAGS_i386= -msse4.1
SIMD_DEFAULT_DESC= Default, no non-default SIMD instructions are used
SIMD_NATIVE_DESC= Optimize for this CPU
SIMD_NATIVE_CXXFLAGS= -march=native
SIMD_SSE41_DESC= Use SSE4.1 instructions
SIMD_SSE41_CXXFLAGS= -msse4.1
ARCH_LOCAL!= /usr/bin/uname -p # because OPTIONS_SINGLE_SIMD doesn't support per-ARCH values OPTIONS_SINGLE_SIMD_{arch}, like OPTIONS_DEFINE_{arch}
.if ${ARCH_LOCAL} == i386 || ${ARCH_LOCAL} == amd64
OPTIONS_SINGLE_SIMD+= SIMD_SSE41
.endif
CXXFLAGS:= ${CXXFLAGS:S/-O2/-O3/} # clang writes wrong binary code when -O2 optimization is used and one testcase is failing, see https://github.com/oneapi-src/oneDNN/issues/873#issuecomment-722778910
.include <bsd.port.options.mk>
.if ${ARCH} != aarch64 && ${ARCH} != amd64 && ${ARCH} != powerpc64
CMAKE_ARGS+= -DDNNL_TARGET_ARCH:STRING="GENERIC"
.endif
post-install:
@${RM} -r ${STAGEDIR}${PREFIX}/share/doc
do-test: # some tests are known to fail: https://github.com/intel/mkl-dnn/issues/350 (the upstream failed to reproduce it and closed the report)
@${REINPLACE_CMD} 's| /bin/bash | ${LOCALBASE}/bin/bash |' ${WRKSRC}/tests/CMakeLists.txt
@cd ${BUILD_WRKSRC} && \
${SETENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} -DBUILD_TESTS=ON ${CMAKE_SOURCE_PATH} && \
${SETENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} -DBUILD_TESTING=ON ${CMAKE_SOURCE_PATH} && \
${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} ${ALL_TARGET} && \
${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} test

View File

@ -20,7 +20,7 @@
+if(BUILD_EXAMPLES)
+ add_subdirectory(examples)
+endif()
+if(BUILD_TESTS)
+if(BUILD_TESTING)
+ add_subdirectory(tests)
+endif()

View File

@ -27,8 +27,28 @@
set(DEF_ARCH_OPT_FLAGS "-msse4.1")
endif()
# Clang cannot vectorize some loops with #pragma omp simd and gets
@@ -203,7 +203,7 @@ elseif(UNIX OR MINGW)
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
@@ -186,24 +186,24 @@ elseif(UNIX OR MINGW)
if(DNNL_TARGET_ARCH STREQUAL "AARCH64")
set(DEF_ARCH_OPT_FLAGS "-O3")
# For native compilation tune for the host processor
- if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
+ if (FALSE AND CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
append(DEF_ARCH_OPT_FLAGS "-mcpu=native")
endif()
elseif(DNNL_TARGET_ARCH STREQUAL "PPC64")
set(DEF_ARCH_OPT_FLAGS "-O3")
# In GCC, -ftree-vectorize is turned on under -O3 since 2007.
# For native compilation tune for the host processor
- if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
+ if (FALSE AND CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
append(DEF_ARCH_OPT_FLAGS "-mcpu=native")
endif()
elseif(DNNL_TARGET_ARCH STREQUAL "S390X")
set(DEF_ARCH_OPT_FLAGS "-O3")
# In GCC, -ftree-vectorize is turned on under -O3 since 2007.
# For native compilation tune for the host processor
- if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
+ if (FALSE AND CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
append(DEF_ARCH_OPT_FLAGS "-march=native")
endif()
- elseif(DNNL_TARGET_ARCH STREQUAL "X64")