Skip to content

openjpeg fails test suite with fused-multiply-add instructions enabled #1017

@ghost

Description

Hi

The test suite of OpenJPEG fails in the following cases:

         26 - NR-C1P0-p0_04.j2k-compare2base (Failed)                     
         29 - NR-C1P0-p0_05.j2k-compare2base (Failed)            
         32 - NR-C1P0-p0_06.j2k-compare2base (Failed)            
         68 - NR-C1P1-p1_02.j2k-compare2base (Failed)              
         71 - NR-C1P1-p1_03.j2k-compare2base (Failed)            
         74 - NR-C1P1-p1_04.j2k-compare2base (Failed)                                           
         77 - NR-C1P1-p1_05.j2k-compare2base (Failed)               
         89 - NR-JP2-file2.jp2-compare2base (Failed)                                     
        176 - NR-RIC-subsampling_1.jp2-compare2base (Failed)                                                                  
        179 - NR-RIC-subsampling_2.jp2-compare2base (Failed)                                                       
        182 - NR-RIC-zoo1.jp2-compare2base (Failed)                                              
        185 - NR-RIC-zoo2.jp2-compare2base (Failed)                                   
        929 - NR-DEC-_00042.j2k-2-decode-md5 (Failed)                           
        939 - NR-DEC-buxI.j2k-9-decode-md5 (Failed)                                      
        947 - NR-DEC-CT_Phillips_JPEG2K_Decompr_Problem.j2k-13-decode-md5 (Failed)
        957 - NR-DEC-Marrin.jp2-18-decode-md5 (Failed)                           
        983 - NR-DEC-kodak_2layers_lrcp.j2c-31-decode-md5 (Failed)    
        985 - NR-DEC-kodak_2layers_lrcp.j2c-32-decode-md5 (Failed)                              
        987 - NR-DEC-issue104_jpxstream.jp2-33-decode-md5 (Failed)                             
        996 - NR-DEC-file409752.jp2-40-decode-md5 (Failed)                                                     
        998 - NR-DEC-issue188_beach_64bitsbox.jp2-41-decode-md5 (Failed)                                                 
        1000 - NR-DEC-issue206_image-000.jp2-42-decode-md5 (Failed)                                        
        1002 - NR-DEC-issue205.jp2-43-decode-md5 (Failed)                                              
        1020 - NR-DEC-issue228.j2k-60-decode-md5 (Failed)                 
        1028 - NR-DEC-issue142.j2k-66-decode-md5 (Failed)           
        1030 - NR-DEC-issue134.jp2-67-decode-md5 (Failed)
        1032 - NR-DEC-issue135.j2k-68-decode-md5 (Failed)
        1034 - NR-DEC-issue208.jp2-69-decode-md5 (Failed)
        1036 - NR-DEC-issue211.jp2-70-decode-md5 (Failed)
        1040 - NR-DEC-broken.jpc-73-decode (Failed)
        1041 - NR-DEC-issue226.j2k-74-decode (Failed)
        1042 - NR-DEC-issue226.j2k-74-decode-md5 (Failed)
        1101 - NR-DEC-p1_04.j2k-124-decode-md5 (Failed)
        1103 - NR-DEC-p1_04.j2k-125-decode-md5 (Failed)
        1105 - NR-DEC-p1_04.j2k-126-decode-md5 (Failed)
        1107 - NR-DEC-p1_04.j2k-127-decode-md5 (Failed)
        1109 - NR-DEC-p1_04.j2k-128-decode-md5 (Failed)
        1111 - NR-DEC-p1_04.j2k-129-decode-md5 (Failed)
        1115 - NR-DEC-p1_04.j2k-131-decode-md5 (Failed)
        1129 - NR-DEC-p1_04.j2k-138-decode-md5 (Failed)
        1133 - NR-DEC-p1_04.j2k-140-decode-md5 (Failed)
        1164 - NR-DEC-p1_06.j2k-156-decode (Failed)
        1165 - NR-DEC-p1_06.j2k-156-decode-md5 (Failed)
        1180 - NR-DEC-p1_06.j2k-164-decode (Failed)
        1181 - NR-DEC-p1_06.j2k-164-decode-md5 (Failed)
        1185 - NR-DEC-p0_04.j2k-166-decode-md5 (Failed)
        1187 - NR-DEC-p0_04.j2k-167-decode-md5 (Failed)
        1189 - NR-DEC-p0_04.j2k-168-decode-md5 (Failed)
        1197 - NR-DEC-p0_04.j2k-172-decode-md5 (Failed)
        1358 - NR-DEC-issue205.jp2-253-decode-md5 (Failed)
        1360 - NR-DEC-issue236-ESYCC-CDEF.jp2-254-decode-md5 (Failed)
        1362 - NR-DEC-issue559-eci-090-CIELab.jp2-255-decode-md5 (Failed)
        1364 - NR-DEC-issue559-eci-091-CIELab.jp2-256-decode-md5 (Failed)

These failures seems to be related to the usage of fused-multiply-add (FMA)
instructions in the compiled code. Using the compiler flags

-O2 -march=broadwell

triggers above failures. The flags

-O2 -march=broadwell -ffp-contract=off

(which is disabling FMA) lets all test succeed except for two which are listed
in the known-to-fail file of Travis CI.

The GCC compiler enables FMA if -O2 is given and the/all target architectures
support FMA (if you have a different processor than broadwell, try -march=native
or change broadwell to the architecture you are using). The reason that these
tests fail seems to be in the changed floating point precision of a FMA
instruction (which is a*b + c) in contrast to the normal a*b + c (with
standard plus and multiply). Though I'm not an expert on that, so I might be
wrong.

I don't know if this directly counts as bug/issue since it is essential "the
hardware does not calculate correctly". However, it might be worth documenting
this and maybe also emit a warning in the configuration phase if FMA usage is
detected -- or maybe even disable it "-tfp-contract" is supported by GCC and clang
not sure about other compilers.

Alternatively but far more cumbersome and laborious, adapt the test suite to
be lenient to different floating point precisions.

oedipus

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions