-
Notifications
You must be signed in to change notification settings - Fork 251
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
Wrapping nfloat
in Arblib.jl
#2184
Comments
|
I don't think there should be any issue with actually wrapping the underlying types. For mutable struct nfloat_struct{P,F}
head::NTuple{NFLOAT_HEADER_LIMBS,UInt}
d::NTuple{P,UInt} # FIXME: Should be different for 32 bit systems
end Where the The issue with
and lets say we have the (higher level) types What would be useful for the wrapper is to have some distinction between scalars and vectors in the type names in C, even if all of them are just typedefs for void pointers in the end. In some sense similar to how Flint differentiates between How is it for the Note that our current approach already has some issues related the interpretation of pointers, but it only occurs in a few places for now. For example the wrapper of the function
maps the |
I started an attempt of wrapping the new
nfloat
module in Arblib.jl. I thought I would create this issue to collect some of the issues and decisions encountered along the way. I'm creating the issue here on the Flint page instead of the Arblib.jl page since the discussions could be relevant for Flint itself.It is relevant to know that the way Arblib.jl works is that it parses the Flint documentation and automatically generates the low level wrapping of the functions. In particular this means that having enough information in the function signatures to automatically generate the wrappers is important, otherwise a lot of manual work is required.
So far I have two comments:
nfloat_ctx_set_real_prec
andnfloat_ctx_set_real_prec
have different names in the documentation and the code. In the code they have a leading underscore. I'm not sure which one is the intended one?arb
) have a_t
-suffix version that is used for scalar values and the_ptr
and_srcptr
-suffix version that is used for vectors of that type (e.g.arb_t
,arb_ptr
andarb_srcptr
). In Arblib.jl the_t
version is mapped to the scalar type and the_ptr
and_srcptr
versions are mapped to vectors of that type (arb_t
is mapped toArb
, andarb_ptr
andarb_srcptr
are mapped toArbVector
). I don't think this approach is used in all of Flint, but at least for the types coming from Arb it is mostly followed. Fornfloat
this approach is not followed, it usesnfloat_ptr
andnfloat_srcptr
for everything. This is problematic for the automatic wrapping because we don't have enough information to determine if the argument is a scalar or a vector. My understanding is that the reason for this is thatnfloat
is not actually a single type, but each precision is technically its own type, is that correct? One possible solution to this issue (from the point of view of Arblib.jl) could maybe be to definetypedef void * nfloat_t
(which is exactly the same definition as fornfloat_ptr
) and use that type whenever a scalar value is intended. Would this be technically possible? I'm however not so fond of forcing Flint to structure it's code in a certain way just to make the life for Arblib.jl easier (though of course it could also help any other attempt of automatically generating wrappers). In this case it could however maybe be beneficial in terms of the Flint documentation as well, the type signaturenfloat_ptr
doesn't tell the user if the function expects a scalar value or a vector so usingnfloat_t
for scalar values could be helpful for that reason. The could be some other reason for the choice to usenfloat_ptr
instead ofnfloat_t
that I'm missing though?If I encounter any more issues in my wrapping attempt I'll update you!
The text was updated successfully, but these errors were encountered: