Skip to content

With testsuite, Level 1m function fails for matrix sizes 5000 and above #323

Closed

Description

@kirannd28

Level 1m function fails for single real and single complex datatype. (sc)
Steps to reproduce the issue:

  1. Build blis library
  2. do below changes in testsuite/input.general file
    6000 # Problem size: first to test
    6000 # Problem size: maximum to test
    1000 # Problem size: increment between experiments
  3. and enable only level 1m functions in testsuite/input.operations
  4. make checkblis

**% blis_

m n gflops resid result
blis_ssubm_n_cc 6000 3000 2.38 2.93e+02 FAILURE
blis_ssubm_c_cc 6000 3000 2.38 2.93e+02 FAILURE
blis_ssubm_t_cc 6000 3000 0.24 2.93e+02 FAILURE
blis_ssubm_h_cc 6000 3000 0.24 2.93e+02 FAILURE

% blis_

m n gflops resid result
blis_csubm_n_cc 6000 3000 2.42 3.81e+03 FAILURE
blis_csubm_c_cc 6000 3000 2.43 2.59e+03 FAILURE
blis_csubm_t_cc 6000 3000 0.36 3.81e+03 FAILURE
blis_csubm_h_cc 6000 3000 0.36 2.59e+03 FAILURE**

output.log
Attached output log

Activity

  1. fgvanzee commented on Jul 16, 2019

    @fgvanzee
    Member

    @kirannd28 Thanks for this report.

    I've looked into this a bit, and I'm pretty sure that this is a "false positive" failure. That is, the testsuite is reporting failure when the implementation is actually fine. The reason for the failure, according to my theory, is nuanced and related to the rather rudimentary way that the subm test module is attempting to detect failure.

    Let's leave this issue open. I'll have to think about if there is a better way to test for failure in these large cases.

  2. kirannd28 commented on Jul 17, 2019

    @kirannd28
    Author

    @fgvanzee Thanks for the reply.

    Adding more info about the problem.

    • addm
    • subm
    • normfm
    • dotxaxpyf

    Test cases fail for the above 4 functions, for single real and single complex datatype.
    Hope the above reply holds good for all four functions.

  3. fgvanzee commented on Jul 17, 2019

    @fgvanzee
    Member

    @kirannd28 Other test modules use similar correctness checking methods to that of subm, including those for the addm and normfm operations.

    I looked into dotxaxpyf, and the failures there are actually being produced by another phenomenon. It appears that the #pragma omp simd directive that we use to try to get the compiler to better optimize reference kernels is causing the compiler to emit code that is more prone to accumulating error in dot products.

    @devinamatthews Any ideas why #pragma omp simd might be having this effect? (I determined specifically that it was the dotxv product component of the dotxaxpyftest that is the culprit; the axpyv component has negligible impact on the outcome.)

    Worse case, of course, is that we disable the #pragma omp simd by default.

  4. fgvanzee commented on Jul 17, 2019

    @fgvanzee
    Member

    An update.

    I spoke to @rvdg, and he pointed out that it's important to always remember what we're comparing against. The testsuite module for dotxaxpyf uses loops over dotxv (and axpyv) to compute the solution that we assume is correct and that we compare the dotxaxpyf solution to. The current implementation of dotxv on Haswell- and Zen-like architectures is one that accumulates dot products via AVX vectors (ie: accumulates the ith vector element into the (i mod 4)th vector slot), with a horizontal add at the very end to collapse the four intermediate results (or eight for single-precision real) down to a single value. This implementation, which effectively accumulates once per four elements, would likely give you better numerical accuracy than one that accumulated once per element.

    So it would appear that the compiler-generated code is perhaps fine as-is, but the "check/test" code based on axpyv and dotxv (AVX intrinsics) is slightly better. Which would explain residuals such as:

    blis_ddotxaxpyf_nnnn_ccccc        6000     4     6.71   1.20e-13   FAILURE
    blis_ddotxaxpyf_nnnc_ccccc        6000     4     6.84   4.21e-14   MARGINAL
    blis_ddotxaxpyf_nncn_ccccc        6000     4     6.89   8.18e-14   MARGINAL
    blis_ddotxaxpyf_nncc_ccccc        6000     4     6.92   1.07e-13   FAILURE
    

    That is, they are not WAY off, but just a little off. These residuals might simply be representing the relative improvement in accuracy one observes by using dot product code that accumulates as described above.

    Also, note that when we switch to a problem where at least one vector is non-contiguous, the BLIS implementation of dotxaxpyf falls back to a simpler code branch that relies only on loops over axpyv and dotxv, in which case the residuals disappear completely:

    blis_ddotxaxpyf_nnnn_ccccj        6000     4     1.11   0.00e+00   PASS
    blis_ddotxaxpyf_nnnc_ccccj        6000     4     1.11   0.00e+00   PASS
    blis_ddotxaxpyf_nncn_ccccj        6000     4     1.12   0.00e+00   PASS
    blis_ddotxaxpyf_nncc_ccccj        6000     4     1.11   0.00e+00   PASS
    
  5. devinamatthews commented on Aug 6, 2020

    @devinamatthews
    Member

    I have similar problems often in TBLIS, but when trying to compare a vectorized and a non-vectorized implementation some error is to be expected. In fact the best remedy for this is to only test smaller sizes...

    I think this can be safely closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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