You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello @certik . I did try some workarounds for this in the last couple of days .
The C code what we get through the above program is quite close to what we want
Which is actually close to what we want if you go through it , it's just how the types are named after this point , hence we have the following error from symengine .
(lf) anutosh491@spbhat68:~/lpython/lpython$ lpython --backend=c --enable-symengine examples/expr2.py
expr2__tmp__generated__.c: In function ‘main0’:
expr2__tmp__generated__.c:51:21: warning: passing argument 1 of ‘basic_new_stack’ from incompatible pointer type [-Wincompatible-pointer-types]
51 | basic_new_stack(lst);
| ^~~
| |
| struct xBasicStruct *
In file included from expr2__tmp__generated__.c:3:
/home/anutosh491/conda_root/envs/lf/include/symengine/cwrapper.h:100:28: note: expected ‘basic_struct *’ {aka ‘struct CRCPBasic_C *’} but argument is of type ‘struct xBasicStruct *’
100 | void basic_new_stack(basic s);
| ~~~~~~^
Essentially struct CRCPBasic_C * and struct xBasicStruct * are similar structures here !
I think from a binary compatibility point of view, I think basic is just a raw pointer. I think it would work in LLVM, but probably fail in the C backend due to a C compiler refusing to identify void* with basic.
So we need to figure out how to improve LPython to allow us to interface with basic.
Well yes , unlike getting a segmenation fault through the C backend , the LLVM backend does compile everything successfully.
Though the result returned might not reflect that
The LLVM code generated here looks correct to me and we are also using the basic_new_stack function so a valid memory address should have been assigned to x , so I am not sure where the garbage value is being generated from. Looking into it.
The pass has been correctly implemented through #2255 . Though the ASR pass doesn't support freeing of variables through the basic_free_stack function . I will try adding support for it and once that is done the issue can be closed.
Activity
certik commentedon Jul 5, 2023
As a first step, let's write Python code using existing LPython:
And make it work for the symbolics_01.py fully, by calling symengine manually like any other C library.
anutosh491 commentedon Jul 9, 2023
Hello @certik . I did try some workarounds for this in the last couple of days .
The C code what we get through the above program is quite close to what we want
If only we would have
basic x,basic y,basic zhere we would be done .As talking about SymEngine's basic type , what is it exactly
arraycontaining 1 element of typebasic_structbasic_structis nothing but a structure containing a void pointeranutosh491 commentedon Jul 9, 2023
So I thought of trying out a few things like
1)
But I think declaring a list with a non primitive user defined data type is prohibhited.
This generates the C code
Which is actually close to what we want if you go through it , it's just how the types are named after this point , hence we have the following error from symengine .
Essentially
struct CRCPBasic_C *andstruct xBasicStruct *are similar structures here !certik commentedon Jul 9, 2023
I think from a binary compatibility point of view, I think
basicis just a raw pointer. I think it would work in LLVM, but probably fail in the C backend due to a C compiler refusing to identifyvoid*withbasic.So we need to figure out how to improve LPython to allow us to interface with
basic.anutosh491 commentedon Jul 12, 2023
Well yes , unlike getting a
segmenation faultthrough the C backend , the LLVM backend does compile everything successfully.Though the result returned might not reflect that
The LLVM code generated here looks correct to me and we are also using the
basic_new_stackfunction so a valid memory address should have been assigned tox, so I am not sure where the garbage value is being generated from. Looking into it.anutosh491 commentedon Jul 12, 2023
We could implement a workaround for the basic type using this framework
anutosh491 commentedon Jul 14, 2023
ASR for
anutosh491 commentedon Aug 9, 2023
The pass has been correctly implemented through #2255 . Though the ASR pass doesn't support freeing of variables through the
basic_free_stackfunction . I will try adding support for it and once that is done the issue can be closed.certik commentedon Aug 9, 2023
I think this is implemented, I opened an #2262 for the rest.