Repository navigation
core: POWER/VSX Improvements - #9907
Conversation
|
Looks good to me +1 |
954a1f5 to
7edf732
Compare
|
@alalek I implemented the new universal intrinsics and I think it's ready for merge |
7edf732 to
faa5a82
Compare
|
Thank you very much @seiko2plus . I really appreciate your kind help offer. looking in your PR, it seems you already implemented this new version of I'm sorry but to say this, but could you follow my modification, please ? Again, nice work and sorry for disturbing because of my mistake. |
- changed behavior of vec_ctf, vec_ctu, vec_cts in gcc and clang to make them compatible with XLC - implemented most of missing conversion intrinsics in gcc and clang - implemented conversions intrinsics of odd-numbered elements - ignored gcc bug warning that caused by -Wunused-but-set-variable in rare cases - replaced right shift with algebraic right shift for signed vectors to shift in the sign bit. - added new universal intrinsics v_matmuladd, v_rotate_left/right - avoid using floating multiply-add in RNG
faa5a82 to
2dc76d5
Compare
|
@tomoaki0705 It's alright, I removed the accumulate version of v_dotprod and I kept v_matmuladd, v_rotate_left/right. |
|
@alalek I changed my mind, please leave this PR open until I finish the implementation of universal intrinsics (exp, log, sin, cos) for VSX and @tomoaki0705 finishes #9753 in case if he is gonna need any new intrinsics. |
|
I've been able to build OpenCV using toolchain provided by Ubuntu 17.10. Config: FROM ubuntu:17.10
RUN apt-get update && apt-get install -y \
curl git python3 cmake ninja-build \
gcc-7-powerpc64le-linux-gnu \
g++-7-powerpc64le-linux-gnu \
binutils-powerpc64le-linux-gnu \
libc6-ppc64-powerpc-cross \
pkg-config-powerpc64le-linux-gnuToolchain file: set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR powerpc64le)
set(CMAKE_C_COMPILER /usr/bin/powerpc64le-linux-gnu-gcc-7)
set(CMAKE_CXX_COMPILER /usr/bin/powerpc64le-linux-gnu-g++-7)
set(CMAKE_FIND_ROOT_PATH /usr/powerpc64le-linux-gnu)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
|
I tried to run the core test in same container (need to install qemu-ppc64le -L /usr/powerpc64le-linux-gnu -E OPENCV_TEST_DATA_PATH=/testdata /build/bin/opencv_test_coreNote: options Unfortunately the hal_intrin.int8x16 test crashes (added $ qemu-ppc64le -L /usr/powerpc64le-linux-gnu -E OPENCV_TEST_DATA_PATH=/testdata /build/bin/opencv_test_core
--gtest_filter=*intrin*
CTEST_FULL_OUTPUT
OpenCV version: 3.3.1-dev
OpenCV VCS version: unknown
Build type: debug
Parallel framework: pthreads
CPU features: VSX
OpenCL is disabled
Note: Google Test filter = *intrin*
[==========] Running 11 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 11 tests from hal_intrin
[ RUN ] hal_intrin.uint8x16
[ OK ] hal_intrin.uint8x16 (8 ms)
[ RUN ] hal_intrin.int8x16
Segmentation fault (core dumped) |
|
@mshabunin Add "-cpu POWER9" option to QEMU (it is "Illegal instruction" fault). |
|
@mshabunin Did you used this current patch during tests? if not, please use this current patch for the following reasons when we use one of these VSX instructions that truncate double-precision to fixed-point word or Qemu instruction emulation return: PowerKVM/QEMU return: even and odd numbered elements contains conversion result I didn't notice this issue because all my previous tests was only on PowerKVM. |
|
This says about
|
|
@alalek , yes, @seiko2plus , I used this patch + #10078 + master |
That was my thought before and ISA2.07 docs confirms the same. but it seems that gcc and clang have different behavior than xlc. I'm launching a full investigation into VSX conversions, please wait for my next reply. @mshabunin old versions of qemu use power7 as default cpu and newest versions use power8 as default cpu.
Anyway I prefer to use IBM Advance toolchain which I support in this patch, Did you try using it? |
|
@seiko2plus , thanks for clarification. I did not try IBM Advance toolchain, the way with standard Ubuntu packages looks easier and works well enough, probably we will use it for testing on the buildbot. As IBM documentation says:
|
|
Results of VSX conversion instructions are affected by endianness:
On the other hand, xlc(little-endian) prefer the compatibility with big-endian I ended up with implemented conversions intrinsics of odd-numbered elements which it maps directly to VSX instructions, note: |
|
@seiko2plus , I thought we want to support only LE platforms: |
|
@mshabunin Sorry for not being clear enough, you misunderstood me |
POWER/VSX Improvements
Improvements are related to #7207
VSX compatibility in vsx_utils.hpp among compilers gcc, clang, xlc becomes more mature and organized.
As result of supporting IBM Advance toolchain, now we can build and test Opencv for powerpc in x86_64,
For more information about IBM Advance toolchain and how to install it checkout this link.
Options that are provided by toolchain
AT_PATH : Advance Toolchain directory, i.e. -DAT_PATH=/opt/at11.0
AT_RPATH : Add new directories to runtime search path, i.e. -DAT_RPATH=/path/to/opencv/lib,/path/to/opencl/runtime.
Note:
AT_HOST_LINK: instead of testing opencv on the target machine,
you can turn this option ON to link against host advance toolchain runtime
so you can perform tests directly in the host using QEMU user emulation.
i.e. -DAT_HOST_LINK=ON , qemu-ppc64le ./bin/opencv_test_core
AT_NO_AUTOVEC: For some kind of reasons QEMU instruction emulation
fails to load unaligend addresses correctly especially with floating-point if vectorization optimization is enabled.
Vectorization in GCC is enabled by the flag -ftree-vectorize and by default at -O3,
so you should enable this option if you going to build opencv in release mode.
Note: Auto vectorization optimization works without any issues in PowerKVM/QEMU.
Current issues:
I'm willing to fix them later but I still have no intention to support vsx on it.