Skip to content

ddot, memory alignment and reproducibility #317

Closed

Description

@pmarguinaud

Hi all,

I have noticed that the result of ddot depends on memory alignment of its arguments. Is this expected ? Do some other routines of OpenBlas share the same feature ?

I use xianyi-OpenBLAS-v0.2.4-0-g3a26470.tar.gz with the Intel compiler 13.1.4.183 (I expect it would be the same with gcc, since ddt is written in assembly).

I can provide a test case if it is desired.

Regards,

Philippe Marguinaud

Activity

  1. xianyi commented on Nov 14, 2013

    @xianyi
    Collaborator

    Hi @pmarguinaud ,

    Thank you for the report. It might be a bug.
    Please provide the test case.

    Xianyi

  2. pmarguinaud commented on Nov 15, 2013

    @pmarguinaud
    Author

    Hello Zhang,

    Here is the code

    PROGRAM MAIN
    IMPLICIT NONE
    DOUBLE PRECISION DDOT
    EXTERNAL DDOT

    INTEGER, PARAMETER :: N = 5, LDA = 5, J = 5

    REAL (8) :: A (LDA_N), AJJ, X (LDA_N*2)

    A = (/ &
    & 0.1772004544267360204302E+01_8, &
    & 0.0000000000000000000000E+00_8, &
    & 0.0000000000000000000000E+00_8, &
    & 0.0000000000000000000000E+00_8, &
    & 0.0000000000000000000000E+00_8, &
    & 0.9593654956366169661575E-01_8, &
    & 0.8836267311005768787524E+00_8, &
    & 0.0000000000000000000000E+00_8, &
    & 0.0000000000000000000000E+00_8, &
    & 0.0000000000000000000000E+00_8, &
    & -0.5078993612458535533705E+00_8, &
    & 0.9944539528130179606435E+00_8, &
    & 0.1811932610333222948285E+01_8, &
    & 0.0000000000000000000000E+00_8, &
    & 0.0000000000000000000000E+00_8, &
    & 0.9311488401630136912956E+00_8, &
    & -0.8367007889097397566047E+00_8, &
    & -0.1321798463159503889131E+01_8, &
    & 0.1416242430430413312692E+01_8, &
    & 0.0000000000000000000000E+00_8, &
    & -0.4063195159061600558736E+00_8, &
    & 0.3609905431122589214432E+00_8, &
    & 0.5710157887908507978736E+00_8, &
    & 0.4600399202697713629817E-01_8, &
    & 0.1980000019073486328125E+01_8 &
    /)

    X = 0
    X (1:LDA_N) = A
    AJJ = DDOT( J-1, X( 1 + LDA * (J-1) ), 1, X( 1 + LDA * (J-1) ), 1 )
    WRITE (_, '(E30.22)') AJJ

    X = 0
    X (2:LDA_N+1) = A
    AJJ = DDOT( J-1, X( 1 + LDA * (J-1) + 1 ), 1, X( 1 + LDA * (J-1) + 1 ), 1 )
    WRITE (_, '(E30.22)') AJJ

    END

    I get two slighly different results

    0.6235851195535556668048E+00
    0.6235851195535555557825E+00

    Regards,

    Philippe

  3. xianyi commented on Nov 25, 2013

    @xianyi
    Collaborator

    Hi Philippe,

    I checked ddot assembly kernel. This difference is expected.

    The dot need sum the x*y result. We want to use SIMD instructions, e.g. aligned load, packed add, packed multiply. However, the different alignment results in the different addition order. Thus, you can get two different results.

    Xianyi

  4. pmarguinaud commented on Nov 26, 2013

    @pmarguinaud
    Author

    Hello Xianyi

    Thank you for looking at this. Note, that for the application I am working on, we will have to go back to regular blas/lapack from netlib, since bit-wise reproducibility is a big concern.

    Best regards,

    Philippe

    Date: Mon, 25 Nov 2013 07:08:54 -0800
    From: notifications@github.com
    To: OpenBLAS@noreply.github.com
    CC: pmarguinaud@hotmail.com
    Subject: Re: [OpenBLAS] ddot, memory alignment and reproducibility (#317)

    Hi Philippe,

    I checked ddot assembly kernel. This difference is expected.

    The dot need sum the x*y result. We want to use SIMD instructions, e.g. aligned load, packed add, packed multiply. However, the different alignment results in the different addition order. Thus, you can get two different results.

    Xianyi

    —
    Reply to this email directly or view it on GitHub.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions