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

Fix issues with A_mul_Bc and Ac_mul_B for CholmodSparse (#9160). #9189

Merged
merged 2 commits into from
Dec 12, 2014

Conversation

acroy
Copy link
Contributor

@acroy acroy commented Nov 28, 2014

As described in the title. Is there any test for Cholmod related functions?

@andreasnoack
Copy link
Member

Thanks. Could you add some tests for the cases you described in #9160?

@tkelman
Copy link
Contributor

tkelman commented Nov 28, 2014

https://github.com/JuliaLang/julia/blob/master/test/sparse.jl is as good a place to put them as any, a little easier than making a new file under test/linalg/. If you could label the tests with a comment that refers to the issue number that would be awesome. More test coverage is always welcome, especially for sparse functionality where the current tests can miss a few problems as you've seen.

@andreasnoack
Copy link
Member

I'd prefer if they would be places in a test/linalg/cholmod.jl file. I think it would be easier to track test coverage if the tests are put in a file of the same name of the source.

@tkelman
Copy link
Contributor

tkelman commented Nov 28, 2014

That could work as long as it's added to the linalg list in test/runtests.jl, though currently the tests under the linalg folder are a little harder to run individually - you can do make test-sparse, or make test-linalg to run all of the linalg group, but not for the individual files under test/linalg/. Maybe it could work by adding another complicated $(subst .jl,,$(wildcard *.jl)) thing in test/Makefile.

@acroy
Copy link
Contributor Author

acroy commented Nov 28, 2014

Sure. I will add some tests in test/linalg/cholmod.jl and then we can see how it works out.

@acroy
Copy link
Contributor Author

acroy commented Nov 28, 2014

I put them in test/linalg/cholmod.jl and added this to the linalg tests in test/runtests.jl. Should we test Float64 and Float32 elements?

@andreasnoack
Copy link
Member

Great. Preferably, we should test all four data types supported by CHOLMOD.

@acroy
Copy link
Contributor Author

acroy commented Nov 28, 2014

I will have a look at the trailing whitespace. I got a similar error on my Mac if I try to use Float32s. Looking closer at this I get "CHOLMOD ERROR: sparse: float unsupported" if I try to create CholmodSparse. I am not sure what is going on ... Even worse for complex entries I get a segfault even for the normal *. I will have to look at the docs again ...

@acroy
Copy link
Contributor Author

acroy commented Nov 28, 2014

Ok the docs for cholmod_ssmult says

Only pattern and real matrices are supported. Complex and zomplex matrices are supported only when the numerical values are not computed (values is FALSE).

So complex matrices shouldn't be allowed for *.

@andreasnoack
Copy link
Member

It appears that the new tests are very useful.

@acroy
Copy link
Contributor Author

acroy commented Nov 28, 2014

Seems that the Float32 issue depends on the platform. On my Mac I can't construct CholmodSparse with Float32 entries, while it works on another Linux machine. I modified the tests. Hopefully travis and/or appveyor give us some clues.

@tkelman
Copy link
Contributor

tkelman commented Nov 28, 2014

Evidently suitesparse is a mess. Looks like there was already a https://github.com/JuliaLang/julia/blob/master/test/suitesparse.jl file that these would be better for IMO. Or we move and/or split up the contents that are in that file into smaller files in linalg.

@andreasnoack
Copy link
Member

Yes. If any of the tests in suitesparse.jl are actually tests of the definitions in base/linalg/cholmod.jl, I think they should just be moved to the new file.

@acroy
Copy link
Contributor Author

acroy commented Nov 28, 2014

Looking into the future and since the linalg tests are already so heavy, what about having a directory test\sparse similar to test\linalg? There we could put cholmod.jl and umfpack.jl etc.

@tkelman : Do you have a good guess what the errors on windows are about?

@andreasnoack
Copy link
Member

As mentioned, I think that we should work towards a structure where the test files corresponds to the files in base. Some of the confusion with the sparse stuff is that we both have the base/sparse directory and the base/linalg/sparse.jl, -unfpack.jl and -cholmod.jl files. I'd be okay with collecting all sparse definitions to the sparse directory. We should also hear what @ViralBShah has to say here.

@tkelman
Copy link
Contributor

tkelman commented Nov 28, 2014

@acroy no idea. I get the same CHOLMOD error: F is too small on win32 for the very first call to CholmodSparse(A), with Ti = Int64; elty = Float64.

@acroy
Copy link
Contributor Author

acroy commented Nov 28, 2014

What the F is F? It seems this error is generated in cholmod_transpose.c. Very mysterious.

@ViralBShah
Copy link
Member

I am OK with having all sparse stuff in one directory, including linear algebra.

@acroy
Copy link
Contributor Author

acroy commented Nov 30, 2014

For some reason Cholmod on my Mac doesn't support Float32s. The Travis build is apparently fine though. [EDIT: I have to take that back. There was a typo in my test. Cholmod with Float32 doesn't work.]

@ViralBShah : This should concern cholmod.jl, cholmod_h.jl, umfpack.jl, umfpack_h.jl and spqr_h.jl (the latter seems to be unused) in linalg/. But it might be better to move them in a separate PR?

@acroy
Copy link
Contributor Author

acroy commented Nov 30, 2014

I am a bit confused, but maybe this is as simple as that: in the documentation (section 8, first paragraph) it says

CHOLMOD supports both int and long integers. CHOLMOD routines with the prefix `cholmod_`
use `int` integers, `cholmod_l_` routines use `long`. All floating-point values are `double`.

Although there is a constant (CHOLMOD_SINGLE) for dtype which suggests also floats are allowed, in cholmod_core.h there is a comment (just below the constant definition) saying

 FUTURE WORK: the float case is not supported yet.

So I guess that means that we have to remove Float32 from the list of supported types?

@ViralBShah
Copy link
Member

Interesting. I did not know that. We should remove Float32 support then, I guess.

@ViralBShah ViralBShah added sparse Sparse arrays linear algebra Linear algebra labels Dec 1, 2014
@acroy
Copy link
Contributor Author

acroy commented Dec 1, 2014

The tests on windows are still failing. The Travis linux build fails for linalg/pinv. Is that unrelated?

@andreasnoack
Copy link
Member

The pinv error must be unrelated. I think F is the result array when transposing. I don't know how it is allocated and why it is Windows specific.

@tkelman
Copy link
Contributor

tkelman commented Dec 1, 2014

I think the pinv tolerances are a little too tight, that's an intermittent failure I've seen once in a while.

Not sure exactly where the failure is happening, but maybe we can try to create a standalone C reproduction case to see if it's an upstream bug? I don't know if SuiteSparse has a mailing list or issue tracker of any kind though.

@andreasnoack
Copy link
Member

@tkelman Yes, Iagree. The tolerance should be adjusted a bit, but it shouldn't be a concern for this PR.

@acroy
Copy link
Contributor Author

acroy commented Dec 1, 2014

@tkelman Maybe the demos in deps/SuitSparse-4.x.x/CHOLMOD/Demo would work?

@tkelman
Copy link
Contributor

tkelman commented Dec 1, 2014

I meant a reproduction of how we're triggering this error. Here's a better backtrace on release-0.3 https://gist.github.com/tkelman/18b8226652251afc7bee showing that it seems this was already broken and untested, your changes don't appear to have made anything worse at least.

else
const CholmodIndexTypes = (:Int32, :Int64)
end
typealias CHMITypes Union([eval(Ti) for Ti in CholmodIndexTypes]...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to do this without eval? Put it inside the if perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can put the typealias inside the if. symbol(::Type{T}) would be really handy.

@tkelman
Copy link
Contributor

tkelman commented Dec 8, 2014

This worked for me on win32 and win64 without the changes to deps/Makefile. I'd rather avoid tweaking it if it's not necessary.

@andreasnoack and @dmbates could you look over the changes to base/linalg/cholmod.jl?

…ndex types based on size of SuitSparse_long. Test adjusted.
# check the size of SuiteSparse_long
if int(ccall((:jl_cholmod_sizeof_long,:libsuitesparse_wrapper),Csize_t,())) == 4
const CholmodIndexTypes = (:Int32, )
typealias CHMITypes Union(Int32)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks odd. Why the Union?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for symmetry reasons :-) I can remove the Unions if you want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it look odd, but I don't think it matters.

@andreasnoack
Copy link
Member

As far as I can see, the changes are good.

@andreasnoack
Copy link
Member

Is this ready for merging?

@tkelman
Copy link
Contributor

tkelman commented Dec 12, 2014

I think so. It will break AppVeyor for as long as it takes to rebuild a new nightly with updated suitesparse wrapper. We might need to manually clear out the buildbot's copy.

@andreasnoack
Copy link
Member

@tkelman Is there a way to avoid that? If not then let's go ahead and merge.

@tkelman
Copy link
Contributor

tkelman commented Dec 12, 2014

We can ask @staticfloat to manually build a nightly from this branch and make sure it gets pushed to status.julialang.org first? I do have a login to the buildbot but I'm not sure how I would go about doing that yet.

@staticfloat
Copy link
Member

It should take about 45 minutes to an hour for your merge here to result in a new build available on status.julialang.org, so I say go ahead and just merge it. If you need to clean the deps, you can do so by logging in to the buildbot and using the new "clean arpack/openblas/suitesparse" force builds available from this page. So just run that right before you merge this, and you should be good to go.

@tkelman
Copy link
Contributor

tkelman commented Dec 12, 2014

Awesome, thanks for adding the cleaners. Based on some local testing, I think the usual make cleanall that should be happening already will be good enough to catch this one. Let's merge and see.

tkelman added a commit that referenced this pull request Dec 12, 2014
Fix issues with A_mul_Bc and Ac_mul_B for CholmodSparse (#9160).
@tkelman tkelman merged commit d5fdf90 into JuliaLang:master Dec 12, 2014
@acroy acroy deleted the cholmod branch December 12, 2014 06:16
@acroy
Copy link
Contributor Author

acroy commented Dec 12, 2014

Thanks everyone! Do you think that this is worth to be back ported to 0.3?

@tkelman
Copy link
Contributor

tkelman commented Dec 12, 2014

I think so, since it was pretty buggy before. @JuliaBackports @ivarne what's your opinion?

I suspect since the linalg tests have been rearranged on master it won't be a clean cherry-pick, could you prepare it as a new PR against release-0.3? And since the buildbots don't make new binaries off of the release branch all that often, I'll probably want to tweak appveyor to recompile just the suitesparse wrapper.

@tkelman
Copy link
Contributor

tkelman commented Dec 12, 2014

@staticfloat the ubuntu and centos builders look stuck in a "Retry exception slave lost" death loop? Funny how I previously wanted to make sure release-0.3 manual builds wouldn't get uploaded as nightly, now I do want a manually-triggered nightly...

@ivarne
Copy link
Member

ivarne commented Dec 12, 2014

git cherry-pick -x -e won't be able to help you much in the process of backporting this (unless you are using some crazy tricks). The Uint->UInt rename will be an effective blocker for quite a few lines. If a PR shows up (without UInts), I'm generally in favor of backporting as much as possible, while keeping the BC promise. Sparse linear algebra is not the area where you should listen to me though.

@tkelman
Copy link
Contributor

tkelman commented Dec 12, 2014

Sometimes you can do curl https://github.com/JuliaLang/julia/pull/9189.patch | sed 's/UInt/Uint/g' | git apply, but that won't quite work here. It'll need to be done manually.

tkelman referenced this pull request Dec 12, 2014
with a hack so the rest of suitesparse doesn't rebuild
@tkelman
Copy link
Contributor

tkelman commented Dec 15, 2014

backported in c5158b8, pretty sure I resolved the conflicts right (passed tests on linux32 and win64, checking appveyor and travis now for the rest)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra sparse Sparse arrays
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants