-
Notifications
You must be signed in to change notification settings - Fork 38
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
Automatically wrapping with Clang.jl
#149
base: main
Are you sure you want to change the base?
Conversation
Doesn't work with everything yet but you can call initialize and finalize. |
Input: # For some reason you need to initialize MPI before using multiple libraries.
# Need to debug this
using MPI
MPI.Initialized() || MPI.Init()
using PETSc
for petsclib in PETSc.LibPETSc.petsclibs
println(splitpath(petsclib.petsc_library)[end])
@show PETSc.initialized(petsclib)
@show PETSc.initialize(petsclib)
@show PETSc.initialized(petsclib)
@show PETSc.finalized(petsclib)
@show PETSc.finalize(petsclib)
@show PETSc.initialized(petsclib)
@show PETSc.finalized(petsclib)
println()
end Output: libpetsc_double_real_Int64.dylib
PETSc.initialized(petsclib) = false
PETSc.initialize(petsclib) = nothing
PETSc.initialized(petsclib) = true
PETSc.finalized(petsclib) = false
PETSc.finalize(petsclib) = nothing
PETSc.initialized(petsclib) = false
PETSc.finalized(petsclib) = true
libpetsc_single_real_Int64.dylib
PETSc.initialized(petsclib) = false
PETSc.initialize(petsclib) = nothing
PETSc.initialized(petsclib) = true
PETSc.finalized(petsclib) = false
PETSc.finalize(petsclib) = nothing
PETSc.initialized(petsclib) = false
PETSc.finalized(petsclib) = true
libpetsc_double_complex_Int64.dylib
PETSc.initialized(petsclib) = false
PETSc.initialize(petsclib) = nothing
PETSc.initialized(petsclib) = true
PETSc.finalized(petsclib) = false
PETSc.finalize(petsclib) = nothing
PETSc.initialized(petsclib) = false
PETSc.finalized(petsclib) = true
libpetsc_single_complex_Int64.dylib
PETSc.initialized(petsclib) = false
PETSc.initialize(petsclib) = nothing
PETSc.initialized(petsclib) = true
PETSc.finalized(petsclib) = false
PETSc.finalize(petsclib) = nothing
PETSc.initialized(petsclib) = false
PETSc.finalized(petsclib) = true |
I guess I still need to sort out the types (But I think it should be possible with more walking of the syntax tree). |
1e39b30
to
97e39a4
Compare
16b5f8e
to
fe80c8f
Compare
Lazy question, but what's the high-level procedure here? What is now automatic and what still has to be maintained "by hand"? Are the specific things here related to various PETSc components all of the "by hand" flavor, or are those things that have been generated automatically and are then checked in? |
I think everything in |
As @vchuravy said, the file in There is a bunch of stuff we do not currently wrap (look at There probably some gotchas left in there with respect to system / build dependent types that will need to be sorted out, but right now it does support multiple PETSc builds living side-by-side in Julia. @psanan shoot me an email if you'd like to VTC to chat about what I am doing, I'd be more than happy to have feedback. |
53fc7ab
to
aa8e660
Compare
afbe26f
to
0f22d51
Compare
3e3e0f9
to
1850ac4
Compare
Docs suggestion, re our chat our yesterday. Perhaps somewhere like here one could add language like "PETSc.jl's high-level, easy-to-use interface exposes only some of the functionality of PETSc. However, PETSc.jl includes an automatically-generated wrapper layer which directly exposes more of the PETSc API, which may be of use to existing expert users. See (link to minimal example/test of using the wrappers, directly) for an example". |
Thanks for the recommendation. I've put it as part of the PR task list. |
I'm going to try to just get this branch working without worrying about rebasing. I am already able to generate the full I don't think major changes have happened since this branch was created and now. |
fine with me; ideally we would change the existing tests that are currently in |
We don't have to strictly follow what was done before, since If I simplify
It essentially compiles the whole library with a few exceptions: julia> include("generator.jl")
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscbag.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscsys.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscconf.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscconf_poison.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscfix.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscmacros.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscversion.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petsc/private/petscadvancedmacros.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscsystypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscmath.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscerror.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscviewertypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscoptions.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petsclog.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petsctime.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscbt.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscstring.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petsclogtypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petsclogdeprecated.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscmatlab.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdraw.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdrawtypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdevice.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdevicetypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscsf.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscsftypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscvec.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscis.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscsectiontypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscistypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscviewer.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscsection.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmda.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdm.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscmat.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscmatcoarsen.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmtypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscfetypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdstypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmlabel.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdt.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmdatypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscpf.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscao.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscfe.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscspace.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdualspace.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmcomposite.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmpatch.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmplex.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscpartitioner.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmplextypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscfv.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscfvtypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmfield.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmplextransform.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmplextransformtypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmredundant.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmshell.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmsliced.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmswarm.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmstag.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscdmproduct.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscds.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petsccharacteristic.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscts.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscsnes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscksp.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscpc.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscpctypes.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscconvest.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petsctao.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petsctaolinesearch.h
[ Info: Found dependent header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petsctao_deprecations.h
[ Info: Parsing headers...
/Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petscsys.h:98:6: error: "PETSc was configured with Open MPI but now appears to be compiling using a non-Open MPI mpi.h"
[ Info: Processing header: /Users/kausb/.julia/artifacts/a69b8f699a39f274f95752394759a3e9973e02b0/lib/petsc/double_real_Int64/include/petsc.h
[ Info: Building the DAG...
┌ Warning: [CollectDependentSystemNode]: found symbols in the system headers: [:MPI_Info, :MPI_Op, :MPI_Status, :MPI_Status, :MPI_Datatype, :off_t, :__darwin_off_t, :MPI_Comm, :MPI_Aint, :MPI_File, :ADIOI_FileD, :MPI_Request, :MPI_Group, :MPI_Offset, :MPI_Win]
└ @ Clang.Generators ~/.julia/packages/Clang/uJQ2L/src/generator/passes.jl:95
[ Info: Emit Julia expressions...
┌ Error: missing implementation for ExprNode{Clang.Generators.FunctionDefault, Clang.CLFunctionDecl}(:SNESObjectiveComputeFunctionDefaultFD, Clang.Generators.FunctionDefault(), CLCursor (Clang.CLFunctionDecl) SNESObjectiveComputeFunctionDefaultFD(SNES, Vec, Vec, void *), Expr[], Expr[], Int64[]), please file an issue to Clang.jl.
└ @ Clang.Generators ~/.julia/packages/Clang/uJQ2L/src/generator/codegen.jl:716
┌ Error: missing implementation for ExprNode{Clang.Generators.FunctionDefault, Clang.CLFunctionDecl}(:SNESComputeJacobianDefault, Clang.Generators.FunctionDefault(), CLCursor (Clang.CLFunctionDecl) SNESComputeJacobianDefault(SNES, Vec, Mat, Mat, void *), Expr[], Expr[], Int64[]), please file an issue to Clang.jl.
└ @ Clang.Generators ~/.julia/packages/Clang/uJQ2L/src/generator/codegen.jl:716
┌ Error: missing implementation for ExprNode{Clang.Generators.FunctionDefault, Clang.CLFunctionDecl}(:SNESComputeJacobianDefaultColor, Clang.Generators.FunctionDefault(), CLCursor (Clang.CLFunctionDecl) SNESComputeJacobianDefaultColor(SNES, Vec, Mat, Mat, void *), Expr[], Expr[], Int64[]), please file an issue to Clang.jl.
└ @ Clang.Generators ~/.julia/packages/Clang/uJQ2L/src/generator/codegen.jl:716
┌ Error: missing implementation for ExprNode{Clang.Generators.FunctionDefault, Clang.CLFunctionDecl}(:SNESPicardComputeFunction, Clang.Generators.FunctionDefault(), CLCursor (Clang.CLFunctionDecl) SNESPicardComputeFunction(SNES, Vec, Vec, void *), Expr[], Expr[], Int64[]), please file an issue to Clang.jl.
└ @ Clang.Generators ~/.julia/packages/Clang/uJQ2L/src/generator/codegen.jl:716
┌ Error: missing implementation for ExprNode{Clang.Generators.FunctionDefault, Clang.CLFunctionDecl}(:SNESPicardComputeMFFunction, Clang.Generators.FunctionDefault(), CLCursor (Clang.CLFunctionDecl) SNESPicardComputeMFFunction(SNES, Vec, Vec, void *), Expr[], Expr[], Int64[]), please file an issue to Clang.jl.
└ @ Clang.Generators ~/.julia/packages/Clang/uJQ2L/src/generator/codegen.jl:716
┌ Error: missing implementation for ExprNode{Clang.Generators.FunctionDefault, Clang.CLFunctionDecl}(:SNESPicardComputeJacobian, Clang.Generators.FunctionDefault(), CLCursor (Clang.CLFunctionDecl) SNESPicardComputeJacobian(SNES, Vec, Mat, Mat, void *), Expr[], Expr[], Int64[]), please file an issue to Clang.jl.
└ @ Clang.Generators ~/.julia/packages/Clang/uJQ2L/src/generator/codegen.jl:716
┌ Error: missing implementation for ExprNode{Clang.Generators.FunctionDefault, Clang.CLFunctionDecl}(:TSComputeRHSFunctionLinear, Clang.Generators.FunctionDefault(), CLCursor (Clang.CLFunctionDecl) TSComputeRHSFunctionLinear(TS, PetscReal, Vec, Vec, void *), Expr[], Expr[], Int64[]), please file an issue to Clang.jl.
└ @ Clang.Generators ~/.julia/packages/Clang/uJQ2L/src/generator/codegen.jl:716
┌ Error: missing implementation for ExprNode{Clang.Generators.FunctionDefault, Clang.CLFunctionDecl}(:TSComputeRHSJacobianConstant, Clang.Generators.FunctionDefault(), CLCursor (Clang.CLFunctionDecl) TSComputeRHSJacobianConstant(TS, PetscReal, Vec, Mat, Mat, void *), Expr[], Expr[], Int64[]), please file an issue to Clang.jl.
└ @ Clang.Generators ~/.julia/packages/Clang/uJQ2L/src/generator/codegen.jl:716
[ Info: [ProloguePrinter]: print to /Users/kausb/.julia/dev/PETSc.jl/gen/../lib/petsc_library.jl
[ Info: [GeneralPrinter]: print to /Users/kausb/.julia/dev/PETSc.jl/gen/../lib/petsc_library.jl
[ Info: [EpiloguePrinter]: print to /Users/kausb/.julia/dev/PETSc.jl/gen/../lib/petsc_library.jl
[ Info: Done!
"/Users/kausb/.julia/dev/PETSc.jl/gen/../lib/petsc_library.jl" |
@ViralBShah Also, this PR is very large. Perhaps it is simpler to start a new one from main? |
Yes, the simpler thing would be to start the generator on a new PR in main, and just get that running first. And then piecemeal port things over to the new generated API. But not being a user of PETSc, that is where I will start running into my limitations here. Let's push one step forward at least. I do feel that on main, it would be nice to fix all the FIXME things first so that everything that was working in the past is working again now, and tagged - giving a solid baseline for the new stuff. |
I’m a PETSc user (well at least of part of the library). Yet I’m only a beginner when it comes to using clang to port it all. If you leave out the functions that have ccalls in the current main, there are only a limited number of additional functions remaining that are mainly there to make using petsc more julia-like. Those ones could be gradually expanded to include more functionally, but as long as we call autowrapped routines throughout it will be much easier to maintain this. |
So with your generated library, did you try doing I see what you are saying about the auto-generated comments for the wrappers. Wouldn't we still need the docs that are in the Julian interface as it stands right now - or are you thinking those could be completely replaced with this auto-generated stuff? |
I didn’t manage to load it just now; I was using a simpler generator.toml shown in one of the comments
I think it can be replaced with autogenerated stuff. Multiple dispatch will take care of the rest. |
One of the reasons for the wrapper file to be rather complex is that the different versions of the PETSc libraries have different definitions of Yet, this doesn't work for structures, which are instead defined as: mutable struct DMSTAGSTENCIL{PetscInt}
loc::DMStagStencilLocation
i::PetscInt
j::PetscInt
k::PetscInt
c::PetscInt
end At the time the initial wrapping was done, it wasn't possible to automatically wrap C structures to give something like above. Instead mutable struct DMStagStencil
loc::DMStagStencilLocation
i::PetscInt
j::PetscInt
k::PetscInt
c::PetscInt
DMStagStencil() = new()
end Question: do you know whether there is a way to automatically add types to the structures using EDIT: @albert-de-montserrat pointed out that this is actually done already in wrap.jl. The disadvantage is that it has to be specified manually for every (x, s) -> add_struct_type(x, s, ("MatStencil",), ("PetscInt",)), |
@ViralBShah it now loads again and some of the tests work. Quite a bit of work remains to automatically wrap the |
In principle yes, `structs` do get wrapped automatically with `Clang`,
Yet, I had to deactivate a large number of them to get the package to load (plus all functions that call unwrapped `structs`).
I suppose that this is what was done before as well. Having a way to automatize this process would certainly help.
|
Perhaps @Gnimuc can chime in, if they have the time to look at this. |
This adds an auto-wrapping tool that creates more julia-friendly functions for the PETSc functions created by the Clang.jl. It is tested on the DMSTAG routines where most of the routines defined in the petscdmstag.h header file are now translated, including their doc strings. There is still some stuff that needs manual work, but that is mostly indicated by "TODO" comments. Tests are also provided for most routines Since functions rarely change between different PETSc versions, it is unlikely that much needs to be re-wrapped between different PETSc releases. I expect that the "wrap_functions.jl" routine will also be helpful in many of the other petsc header files, but have not tested this yet.
took a bit of time but I now added a (mostly) automatic wrapper tool that creates Julia-friendly functions of the functions generated by |
When I looked at this last, it felt like redoing this on top of master picemeal may be easier than trying to rebase this PR to master (which at least for me felt really complex). |
Not sure I understand what you mean. I am trying to port the tests from main into this branch bit by bit, so we can ensure that we have at least the same functionality |
Ah - I suppose the merge conflicts will then get resolved when all tests are migrated. |
Experimenting to play with #147
Todo
Clang.jl
#149 (comment))test/dmda.jl
failure...examples/laplacian.jl
failure...