Skip to content

Commit

Permalink
Julia: LibCEED.jl Julia interface
Browse files Browse the repository at this point in the history
  • Loading branch information
pazner committed Oct 25, 2020
1 parent fc164cf commit 44554ea
Show file tree
Hide file tree
Showing 23 changed files with 3,366 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Yohann Dudouit
Leila Ghaffari
Tzanio Kolev
David Medina
Will Pazner
Thilina Rathnayake
Jeremy L. Thompson
Stan Tomov
4 changes: 4 additions & 0 deletions julia/LibCEED.jl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Manifest.toml
deps/build.log
deps/deps.jl
docs/build
20 changes: 20 additions & 0 deletions julia/LibCEED.jl/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name = "LibCEED"
uuid = "2cd74e05-b976-4426-91fa-5f1011f8952b"
authors = ["Will Pazner <[email protected]>"]
version = "0.1.0"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Cassette = "7057c7e9-c182-5462-911a-8362d720325c"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
UnsafeArrays = "c4a57d5a-5b31-53a6-b365-19f8c011fbd6"
libCEED_jll = "762fde13-7596-547b-826d-8223c52d51c1"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
49 changes: 49 additions & 0 deletions julia/LibCEED.jl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# LibCEED.jl: Julia Interface for [libCEED](https://github.com/CEED/libCEED)

## Installation

When the LibCEED.jl package is built, it requires the environment variable
`JULIA_LIBCEED_LIB` to be set to the location of the compiled libCEED shared
library.

For example, the package can be installed by:
```julia
% JULIA_LIBCEED_LIB=/path/to/libceed.so julia
julia> # press ] to enter package manager

(@v1.5) pkg> add LibCEED
```
or, equivalently,
```julia
% julia

julia> withenv("JULIA_LIBCEED_LIB" => "/path/to/libceed.so") do
Pkg.add("LibCEED")
end
```


## Usage

This package provides both a low-level and high-level interface for libCEED.

### Low-Level Interface

The low-level interface (provided in the `LibCEED.C` module) is in one-to-one
correspondence with the C libCEED iterface, and is automatically generated (with
some minor manual modifications) using the Julia package Clang.jl. The script
used to generate bindings is available in `generate_bindings.jl`.

With the low-level interface, the user is responsible for freeing all allocated
memory (calling the appropriate `Ceed*Destroy` functions). This interface is
not type-safe, and calling functions with the wrong arguments can cause libCEED
to crash.

### High-Level Interface

The high-level interface provides a more idiomatic Julia interface to the
libCEED library. Objects allocated using the high-level interface will
automatically be destroyed by the garbage collector, so the user does not need
to manually manage memory.

See the documentation for more information.
18 changes: 18 additions & 0 deletions julia/LibCEED.jl/deps/build.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const libceed_envvar = "JULIA_LIBCEED_LIB"

if isfile("deps.jl")
rm("deps.jl")
end

if haskey(ENV, libceed_envvar)
ceedpath = ENV[libceed_envvar]
@info "Using libCEED library specified by $libceed_envvar at $ceedpath"
open("deps.jl", write=true) do f
println(f, "const libceed = \"$(escape_string(ceedpath))\"")
end
else
@info "Using prebuilt libCEED binaries provided by libCEED_jll"
open("deps.jl", write=true) do f
println(f, "using libCEED_jll")
end
end
Loading

0 comments on commit 44554ea

Please sign in to comment.