Address multiple-parent :lincomb in C code generation#77
Conversation
+ is_trivial_left + is_trivial_right + has_identity_lincomb + has_trivial_nodes
+ has_lincomb_with_identity + has_identity_lincomb
+ Full support for OpenBLAS + Support for real types for MKL
+ Support for complex types for MKL
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #77 +/- ##
==========================================
+ Coverage 92.41% 94.29% +1.87%
==========================================
Files 30 30
Lines 2546 2560 +14
==========================================
+ Hits 2353 2414 +61
+ Misses 193 146 -47 ☔ View full report in Codecov by Sentry. |
|
Julia code: C-code bash: I think the julia and c output are not consistent. Should be 9 instead of 3. Right? |
|
Generated code Should it really be |
|
Thank you for spotting that bug! Your diagnosis is correct. I introduced that bug when switching to |
|
Shouldn't there be a |
|
For me, the generated main for complex numbers does not work. |
Currently, I'm using as index the position of the matrix as parent in the
I don't think this has ever worked for complex types with |
+ Use consecutive indices starting from 0 for non-identity nodes + Do not generate code for combinations with coefficient 0
|
Good idea to try to use the opportunity to fix the generated main-file for complex numbers. Here is another small test that almost works. Maybe I got something wrong in MKL types... Julia: C-code: bash: Real parts are "okay". Imaginary parts different but not super different? |
|
It looks like a bug – I'll try to debug it more carefully. One unrelated comment is that the matrices should be contiguous by columns rather than by row (the BLAS and LAPACK routines use |
|
Found the bug. The two functions: should really be because Fixed in my latest commit. |
|
Nice work! When I export with It could be my openblas installation, which I know is a bit funny. |
|
GraphMatFun.jl/src/code_gen/gen_c_code.jl Lines 623 to 626 in fac0e48 As far as I understand, there is no way for a user to influence kwarg A. An end-user anyway shouldn't directly call The alternative is to expose it to the user through a parameter in the This is actually already present before this PR, but when we are anyway messing with this code... |
It works with both |
Indeed I was a bit puzzled by the kwarg that cannot be used – there must have been a way at some point in the past, but I don't remember how we did it. I've removed |
|
Great! LGTM 👍 |
|
One other thing I noticed by looking at the generated code is that we now have a number of new trivial which should really be or which is just a copy and should be removed. In fact, nodes of the form |
Great! I'll create an issue from my last comment and let's discuss it there. |
I actually think we this type of code optimization should not be done in the code generation. A user can always run |
No description provided.