Skip to content

CPU_BASELINE=FP16 doesn't get enabled on Armv7 + GCC 6 #14957

@tomoaki0705

Description

@tomoaki0705
System information (version)
  • OpenCV => current 3.4/master branch
  • Operating System / Platform => Armv7 platform (Raspberry-pi, Tinker Board etc.)
  • Compiler => GCC 6.3.0
Detailed description

When passing -DCPU_BASELINE=FP16 on Armv7 platform, it results in FAILURE

-- Performing Test HAVE_CXX_MFPU_NEON_FP16 (check file: cmake/checks/cpu_fp16.cpp)
-- Performing Test HAVE_CXX_MFPU_NEON_FP16 - Failed
-- FP16 is not supported by C++ compiler
-- Optimization FP16 is not available, skipped
(snip)
--   CPU/HW features:
--     Baseline:                    NEON
--       requested:                 FP16
--       required:                  NEON
--       disabled:                  VFPV3

GCC 6.3.0 requires -mfp16-format option to use float16 SIMD types.

#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE)
typedef __fp16 float16_t;
typedef __simd64_float16_t float16x4_t;
#endif

The current implementation on OpenCV matches for GCC 4.x and 5.x series, but not for GCC 6 series.

To make things compatible for various GCC, we should pass both -mfpu=neon-fp16 and -mfp16-format=ieee to cpu_fp16.cpp during cmake

Steps to reproduce
cmake -DCPU_BASELINE=FP16 ..

on Armv7 platform and GCC 6 or later.

I'll send a patch later

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions