Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing test (gbtest76) on Apple Silicon #90

Closed
szarnyasg opened this issue Jan 6, 2022 · 7 comments
Closed

Failing test (gbtest76) on Apple Silicon #90

szarnyasg opened this issue Jan 6, 2022 · 7 comments

Comments

@szarnyasg
Copy link
Contributor

szarnyasg commented Jan 6, 2022

I made some progress on porting the library to Apple Silicon (#84, #86). This issue documents how to build Octave v7 on macOS and run the test. Finally, it contains the output of a single failing test.

Building Octave

  1. Grab the brew formula:

    wget https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/octave.rb
  2. Edit octave.rb

    1. Add "disable-docs" to args (or ensure that you have a working texinfo installation).
    2. Edit Mercurial (hg) repository: switch from the default branch (containing code for Octave v8.0) to stable (v7.0).
  3. Run

    brew install --head ./octave.rb

    This takes about 10 minutes.

Building the tests (gbmake)

  1. Grab the OpenMP binaries as described at https://mac.r-project.org/openmp/:

    curl -O https://mac.r-project.org/openmp/openmp-13.0.0-darwin21-Release.tar.gz
    sudo tar fvxz openmp-13.0.0-darwin21-Release.tar.gz -C /
  2. Run

    sed -i.bkp 's/-fopenmp/-Xclang -fopenmp/g' @GrB/private/gbmake.m
  3. Run octave and follow the instructions in GraphBLAS/README.md, including gbmake:

    cd @GrB/private
    gbmake

Running the tests

Run the tests:

cd test
gbtest

Currently, all tests pass except one.

Failing test: gbtest76

gbtest76 fails on macOS / Apple Silicon. (I tried running it in both Octave 7 and 8 on macOS. It passes on Linux with Octave 8. I did not try it on Linux with Octave 7.)

The output of gbtest76 is the following:

> gbtest76

gbtest76: testing trig and special functions
single
double
single complex
double complex
error: assert (err == 0) failed
error: called from
    assert at line 107 column 11
    gbtest76>gbtest76b at line 432 column 5
    gbtest76 at line 47 column 13

Upon closer inspection, the only test case that fails is the following:

case { 'double complex' }
    A = rand (4) + 1i* rand (4) ;
    B = rand (4) + 1i* rand (4) ;
    tol = 1e-10 ;
    G = GrB (A) ;
    H = GrB (B) ;
    gbtest76b (A, B, G, H, tol) ;

I printed the output before the assertion in line 432:

C1 = A.^1 ;
C2 = G.^1 ;
err = norm (C1-C2, 1) ;
display (err)
assert (err == 0) ;

It indeed has a non-zero result:

double complex
err = 2.7497e-16
@szarnyasg
Copy link
Contributor Author

szarnyasg commented Jan 6, 2022

I removed the tests except the double complex ones and printed the variables A, B before calling gbtest76b, then A, G, C1, C2 before the failed assert: https://github.com/szarnyasg/GraphBLAS/blob/gbtest76/GraphBLAS/test/gbtest76.m

Output on Linux (passing):

A =

   0.8444 + 0.9097i   0.5113 + 0.3101i   0.4766 + 0.4721i   0.2818 + 0.9130i
   0.7580 + 0.9828i   0.4049 + 0.7298i   0.5834 + 0.1007i   0.7558 + 0.9666i
   0.4206 + 0.8102i   0.7838 + 0.8988i   0.9081 + 0.4342i   0.6184 + 0.4770i
   0.2589 + 0.9022i   0.3033 + 0.6840i   0.5047 + 0.6109i   0.2505 + 0.8653i

B =

   0.260492 + 0.238616i   0.719705 + 0.080446i   0.001143 + 0.109058i   0.325204 + 0.814467i
   0.805028 + 0.967540i   0.398824 + 0.320055i   0.493578 + 0.551267i   0.870471 + 0.540284i
   0.548699 + 0.803179i   0.824845 + 0.507941i   0.867603 + 0.706561i   0.191067 + 0.963839i
   0.014042 + 0.447970i   0.668153 + 0.932834i   0.243911 + 0.547441i   0.567511 + 0.603186i
A =

        0 +      0i   0.5113 + 0.3101i   0.4766 + 0.4721i   0.2818 + 0.9130i
   0.7580 + 0.9828i   0.4049 + 0.7298i   0.5834 + 0.1007i   0.7558 + 0.9666i
   0.4206 + 0.8102i   0.7838 + 0.8988i   0.9081 + 0.4342i   0.6184 + 0.4770i
   0.2589 + 0.9022i   0.3033 + 0.6840i   0.5047 + 0.6109i   0.2505 + 0.8653i

G =

  4x4 GraphBLAS double complex matrix, bitmap by col
  15 nonzeros, 15 entries, memory: 480 bytes

    (2,1)    0.757954 + 0.982785i
    (3,1)    0.420572 + 0.810217i
    (4,1)    0.258917 + 0.902166i
    (1,2)    0.511275 + 0.310148i
    (2,2)    0.404934 + 0.729832i
    (3,2)    0.783799 + 0.898838i
    (4,2)    0.303313 + 0.683984i
    (1,3)    0.476597 + 0.472143i
    (2,3)    0.583382 + 0.100701i
    (3,3)    0.908113 + 0.434172i
    (4,3)    0.504687 + 0.610887i
    (1,4)    0.281838 + 0.913011i
    (2,4)    0.755804 + 0.966606i
    (3,4)    0.618369 + 0.47701i
    (4,4)    0.250506 + 0.86531i
C1 =

        0 +      0i   0.5113 + 0.3101i   0.4766 + 0.4721i   0.2818 + 0.9130i
   0.7580 + 0.9828i   0.4049 + 0.7298i   0.5834 + 0.1007i   0.7558 + 0.9666i
   0.4206 + 0.8102i   0.7838 + 0.8988i   0.9081 + 0.4342i   0.6184 + 0.4770i
   0.2589 + 0.9022i   0.3033 + 0.6840i   0.5047 + 0.6109i   0.2505 + 0.8653i


C2 =

  4x4 GraphBLAS double complex matrix, bitmap by col
  15 nonzeros, 15 entries, memory: 480 bytes

    (2,1)    0.757954 + 0.982785i
    (3,1)    0.420572 + 0.810217i
    (4,1)    0.258917 + 0.902166i
    (1,2)    0.511275 + 0.310148i
    (2,2)    0.404934 + 0.729832i
    (3,2)    0.783799 + 0.898838i
    (4,2)    0.303313 + 0.683984i
    (1,3)    0.476597 + 0.472143i
    (2,3)    0.583382 + 0.100701i
    (3,3)    0.908113 + 0.434172i
    (4,3)    0.504687 + 0.610887i
    (1,4)    0.281838 + 0.913011i
    (2,4)    0.755804 + 0.966606i
    (3,4)    0.618369 + 0.47701i
    (4,4)    0.250506 + 0.86531i
4x4 GraphBLAS double complex matrix, full by col
  no nonzeros, 16 entries, memory: 464 bytes

    (1,1)    0 + 0i
    (2,1)    0 + 0i
    (3,1)    0 + 0i
    (4,1)    0 + 0i
    (1,2)    0 + 0i
    (2,2)    0 + 0i
    (3,2)    0 + 0i
    (4,2)    0 + 0i
    (1,3)    0 + 0i
    (2,3)    0 + 0i
    (3,3)    0 + 0i
    (4,3)    0 + 0i
    (1,4)    0 + 0i
    (2,4)    0 + 0i
    (3,4)    0 + 0i
    (4,4)    0 + 0i

Output on Mac (failing):

A =

   0.8444 + 0.9097i   0.5113 + 0.3101i   0.4766 + 0.4721i   0.2818 + 0.9130i
   0.7580 + 0.9828i   0.4049 + 0.7298i   0.5834 + 0.1007i   0.7558 + 0.9666i
   0.4206 + 0.8102i   0.7838 + 0.8988i   0.9081 + 0.4342i   0.6184 + 0.4770i
   0.2589 + 0.9022i   0.3033 + 0.6840i   0.5047 + 0.6109i   0.2505 + 0.8653i

B =

   0.260492 + 0.238616i   0.719705 + 0.080446i   0.001143 + 0.109058i   0.325204 + 0.814467i
   0.805028 + 0.967540i   0.398824 + 0.320055i   0.493578 + 0.551267i   0.870471 + 0.540284i
   0.548699 + 0.803179i   0.824845 + 0.507941i   0.867603 + 0.706561i   0.191067 + 0.963839i
   0.014042 + 0.447970i   0.668153 + 0.932834i   0.243911 + 0.547441i   0.567511 + 0.603186i
A =

        0 +      0i   0.5113 + 0.3101i   0.4766 + 0.4721i   0.2818 + 0.9130i
   0.7580 + 0.9828i   0.4049 + 0.7298i   0.5834 + 0.1007i   0.7558 + 0.9666i
   0.4206 + 0.8102i   0.7838 + 0.8988i   0.9081 + 0.4342i   0.6184 + 0.4770i
   0.2589 + 0.9022i   0.3033 + 0.6840i   0.5047 + 0.6109i   0.2505 + 0.8653i

G =

  4x4 GraphBLAS double complex matrix, bitmap by col
  15 nonzeros, 15 entries, memory: 480 bytes

    (2,1)    0.757954 + 0.982785i
    (3,1)    0.420572 + 0.810217i
    (4,1)    0.258917 + 0.902166i
    (1,2)    0.511275 + 0.310148i
    (2,2)    0.404934 + 0.729832i
    (3,2)    0.783799 + 0.898838i
    (4,2)    0.303313 + 0.683984i
    (1,3)    0.476597 + 0.472143i
    (2,3)    0.583382 + 0.100701i
    (3,3)    0.908113 + 0.434172i
    (4,3)    0.504687 + 0.610887i
    (1,4)    0.281838 + 0.913011i
    (2,4)    0.755804 + 0.966606i
    (3,4)    0.618369 + 0.47701i
    (4,4)    0.250506 + 0.86531i
C1 =

        0 +      0i   0.5113 + 0.3101i   0.4766 + 0.4721i   0.2818 + 0.9130i
   0.7580 + 0.9828i   0.4049 + 0.7298i   0.5834 + 0.1007i   0.7558 + 0.9666i
   0.4206 + 0.8102i   0.7838 + 0.8988i   0.9081 + 0.4342i   0.6184 + 0.4770i
   0.2589 + 0.9022i   0.3033 + 0.6840i   0.5047 + 0.6109i   0.2505 + 0.8653i


C2 =

  4x4 GraphBLAS double complex matrix, bitmap by col
  15 nonzeros, 15 entries, memory: 480 bytes

    (2,1)    0.757954 + 0.982785i
    (3,1)    0.420572 + 0.810217i
    (4,1)    0.258917 + 0.902166i
    (1,2)    0.511275 + 0.310148i
    (2,2)    0.404934 + 0.729832i
    (3,2)    0.783799 + 0.898838i
    (4,2)    0.303313 + 0.683984i
    (1,3)    0.476597 + 0.472143i
    (2,3)    0.583382 + 0.100701i
    (3,3)    0.908113 + 0.434172i
    (4,3)    0.504687 + 0.610887i
    (1,4)    0.281838 + 0.913011i
    (2,4)    0.755804 + 0.966606i
    (3,4)    0.618369 + 0.47701i
    (4,4)    0.250506 + 0.86531i
  4x4 GraphBLAS double complex matrix, full by col
  7 nonzeros, 16 entries, memory: 464 bytes

    (1,1)    0 + 0i
    (2,1)    0 - 1.11022e-16i
    (3,1)    -5.55112e-17 + 0i
    (4,1)    5.55112e-17 + 0i
    (1,2)    0 + 0i
    (2,2)    0 + 0i
    (3,2)    0 + 0i
    (4,2)    0 + 0i
    (1,3)    0 + 0i
    (2,3)    0 + 0i
    (3,3)    -1.11022e-16 - 5.55112e-17i
    (4,3)    0 + 0i
    (1,4)    1.11022e-16 + 0i
    (2,4)    0 + 0i
    (3,4)    1.11022e-16 + 0i
    (4,4)    0 + 1.11022e-16i
error: assert (err == 0) failed
error: called from
    assert at line 107 column 11
    gbtest76>gbtest76b at line 404 column 5
    gbtest76 at line 28 column 13

So the problem seems to be computing C1-C2.

@DrTimothyAldenDavis
Copy link
Owner

It's not an error at all. Those differences are just round-off error. The complex multiply/add/etc can differ slightly on different compilers. I use "assert(err==0)" if it seems appropriate, and if those fail with err of 1e-16, or so, I just replace it with "assert (err < 1e-12)" say.

@DrTimothyAldenDavis
Copy link
Owner

I do all my code updates on the master branch, not on the stable branch. The stable branches don't get git commits very often, except for the next stable release. Can you make your PR's go to that branch instead? That would be a lot easier. Thanks!

@DrTimothyAldenDavis
Copy link
Owner

I just revised this test ; see the gbtest76.m in the master branch.

@szarnyasg
Copy link
Contributor Author

szarnyasg commented Jan 6, 2022

I do all my code updates on the master branch, not on the stable branch. The stable branches don't get git commits very often, except for the next stable release. Can you make your PR's go to that branch instead? That would be a lot easier. Thanks!

Indeed, I should have targeted master and not stable -- sorry about that. I see that you performed the merge in a2ce979.

Thanks for revising the gbtest76 test case!

I now tried running the Octave tests on 2682a3c but it failed due to a hard-coded x87 dependency in GB_cpu_features.h file:

octave:1> cd @GrB/private
octave:2> gbmake
Note that this @GrB interface is under the GNU GPLv3 (or later).
Hit enter to confirm and agree; control-C to decline:
.In file included from /Users/szarnyasg/git/GraphBLAS/GraphBLAS/@GrB/private/util/gb_abort.c:10:
In file included from util/gb_interface.h:17:
In file included from ../../../Source/GB_helper.h:16:
In file included from ../../../Source/GB.h:17:
In file included from ../../../Source/GB_cpu_features.h:61:
../../../cpu_features/include/cpuinfo_x86.h:252:2: error: "Including cpuinfo_x86.h from a non-x86 target."
#error "Including cpuinfo_x86.h from a non-x86 target."
 ^
1 error generated.

Maybe GB_cpu_features.h is a work-in-progress so this is just an FYI.

@DrTimothyAldenDavis
Copy link
Owner

Oops. That #if was supposed to guard against it but I wrote it wrong. See the next push on master.

@szarnyasg
Copy link
Contributor Author

Thanks! It works now and the tests pass:

gbtest: all tests passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants