-
Notifications
You must be signed in to change notification settings - Fork 25
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
Julia interface #90
Draft
cadaverous-lives
wants to merge
14
commits into
master
Choose a base branch
from
julia-interface-pr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Julia interface #90
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7d2ba34
New branch for julia interface pull request
cadaverous-lives bd1f084
Added README for julia example directory
cadaverous-lives b984ff9
Moved braid_Warmup function from braid_test to util
cadaverous-lives 70a55ac
implemented adaptive theta method in julia
cadaverous-lives 35172ad
renaming status.jl to Status.jl
cadaverous-lives 83130d5
minor changes to build_function_sundials.jl
cadaverous-lives dd83362
Updates to makefiles, Julia example README, and Fortran interface
rfalgout 8bba2f3
Added makefile option to turn on/off fortran interface
cadaverous-lives c03e47a
Removed -undefined dynamic_lookup from SHAREDFLAGS
cadaverous-lives 281e5f6
Merge branch 'julia-interface-pr' into adaptive-theta-julia
cadaverous-lives 4fd15b8
Renamed examples/julia/ to examples/ex-01-julia/
cadaverous-lives 197026b
Added entry to examples readme
cadaverous-lives 407744f
Added kwargs to XBraid.Init
cadaverous-lives 94e6b84
Merge remote-tracking branch 'origin/master' into julia-interface-pr
cadaverous-lives File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module BraidUtils | ||
export libbraid, c_stdout, BlackHoleBuffer, malloc_null_double_ptr, stacktrace_warn | ||
|
||
libbraid = joinpath(dirname(@__DIR__), "libbraid.so") | ||
c_stdout = Libc.FILE(Libc.RawFD(1), "w") # corresponds to C standard output | ||
|
||
|
||
""" | ||
Allocates a valid pointer to a pointer of type T | ||
""" | ||
function malloc_null_double_ptr(T::Type) | ||
pp = Base.Libc.malloc(sizeof(Ptr{Cvoid})) | ||
pp = reinterpret(Ptr{Ptr{T}}, pp) | ||
return pp | ||
end | ||
|
||
""" | ||
Displays a caught error message, including stacktrace, without throwing | ||
""" | ||
function stacktrace_warn(msg::String, err) | ||
err_msg = sprint(showerror, err) | ||
trace = sprint((io,v) -> show(io, "text/plain", v), stacktrace(catch_backtrace())) | ||
@warn "$(msg):\n$(err_msg)\n$(trace)" | ||
end | ||
|
||
""" | ||
Where'd all my data go? | ||
This extends Base to include a buffer which throws away the data written to it | ||
(useful for measuring the serialized size of an object) | ||
""" | ||
mutable struct BlackHoleBuffer <: IO | ||
ptr::Int | ||
end | ||
BlackHoleBuffer() = BlackHoleBuffer(0) | ||
|
||
function Base.read(from::BlackHoleBuffer, T::Type{UInt8}) | ||
throw(ArgumentError("BlackHoleBuffer is not readable)")) | ||
end | ||
function Base.write(to::BlackHoleBuffer, x::UInt8) | ||
to.ptr += 1 | ||
return 1 | ||
end | ||
function Base.write(to::BlackHoleBuffer, x::Array{T}) where T | ||
to.ptr += sizeof(x) | ||
return sizeof(x) | ||
end | ||
|
||
end # module BraidUtils | ||
|
||
# helper functions | ||
isCPoint(i::Integer, cfactor::Integer)::Bool = ((i-1) % cfactor == 0) | ||
isFPoint(i::Integer, cfactor::Integer)::Bool = !isCPoint(i, cfactor) | ||
mapFineToCoarse(i::Integer, cfactor::Integer)::Integer = (i-1) ÷ cfactor + 1 | ||
mapCoarseToFine(i::Integer, cfactor::Integer)::Integer = (i-1) * cfactor + 1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a makefile mechanism instead?