-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update PRIMA.jl for the updated artifact
- Loading branch information
1 parent
8808a82
commit 4dab2a9
Showing
6 changed files
with
146 additions
and
111 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[deps] | ||
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31" | ||
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" | ||
PRIMA_jll = "eead6e0c-2d5b-5641-a95c-b722de96d551" | ||
|
||
[compat] | ||
julia = "1.6" |
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,9 @@ | ||
# Wrapping headers | ||
|
||
This directory contains a script that can be used to automatically generate wrappers from the C headers provided by PRIMA. | ||
This is done using Clang.jl. | ||
|
||
# Usage | ||
|
||
Either run `julia wrapper.jl` directly, or include it and call the `main()` function. | ||
Be sure to activate the project environment in this folder (`julia --project`), which will install `Clang.jl` and `JuliaFormatter.jl`. |
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,13 @@ | ||
[general] | ||
use_julia_native_enum_type = true | ||
print_using_CEnum = false | ||
library_name = "libprimac" | ||
|
||
[codegen] | ||
use_julia_bool = true | ||
always_NUL_terminated_string = true | ||
use_ccall_macro = true | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" | ||
add_comment_for_skipped_macro = true |
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,30 @@ | ||
# Script to parse PRIMA headers and generate Julia wrappers. | ||
using PRIMA_jll | ||
using Clang | ||
using Clang.Generators | ||
using JuliaFormatter | ||
|
||
function main() | ||
|
||
cd(@__DIR__) | ||
include = joinpath(PRIMA_jll.artifact_dir, "include", "prima") | ||
headers = [joinpath(include, "prima.h")] | ||
|
||
options = load_options(joinpath(@__DIR__, "prima.toml")) | ||
options["general"]["output_file_path"] = joinpath("..", "src", "wrappers.jl") | ||
|
||
args = get_default_args() | ||
push!(args, "-I$include") | ||
|
||
ctx = create_context(headers, args, options) | ||
build!(ctx) | ||
|
||
path = options["general"]["output_file_path"] | ||
format_file(path, YASStyle()) | ||
return nothing | ||
end | ||
|
||
# If we want to use the file as a script with `julia wrapper.jl` | ||
if abspath(PROGRAM_FILE) == @__FILE__ | ||
main() | ||
end |
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,73 @@ | ||
@enum prima_message::UInt32 begin | ||
PRIMA_MSG_NONE = 0 | ||
PRIMA_MSG_EXIT = 1 | ||
PRIMA_MSG_RHO = 2 | ||
PRIMA_MSG_FEVL = 3 | ||
end | ||
|
||
@enum prima_rc::Int32 begin | ||
PRIMA_SMALL_TR_RADIUS = 0 | ||
PRIMA_FTARGET_ACHIEVED = 1 | ||
PRIMA_TRSUBP_FAILED = 2 | ||
PRIMA_MAXFUN_REACHED = 3 | ||
PRIMA_MAXTR_REACHED = 20 | ||
PRIMA_NAN_INF_X = -1 | ||
PRIMA_NAN_INF_F = -2 | ||
PRIMA_NAN_INF_MODEL = -3 | ||
PRIMA_NO_SPACE_BETWEEN_BOUNDS = 6 | ||
PRIMA_DAMAGING_ROUNDING = 7 | ||
PRIMA_ZERO_LINEAR_CONSTRAINT = 8 | ||
PRIMA_INVALID_INPUT = 100 | ||
PRIMA_ASSERTION_FAILS = 101 | ||
PRIMA_VALIDATION_FAILS = 102 | ||
PRIMA_MEMORY_ALLOCATION_FAILS = 103 | ||
end | ||
|
||
function prima_get_rc_string(rc) | ||
@ccall libprimac.prima_get_rc_string(rc::Cint)::Cstring | ||
end | ||
|
||
function prima_bobyqa(calfun, n, x, f, xl, xu, nf, rhobeg, rhoend, ftarget, maxfun, npt, | ||
iprint) | ||
@ccall libprimac.prima_bobyqa(calfun::Ptr{Cvoid}, n::Cint, x::Ptr{Cdouble}, | ||
f::Ptr{Cdouble}, xl::Ptr{Cdouble}, xu::Ptr{Cdouble}, | ||
nf::Ptr{Cint}, rhobeg::Cdouble, rhoend::Cdouble, | ||
ftarget::Cdouble, maxfun::Cint, npt::Cint, | ||
iprint::Cint)::Cint | ||
end | ||
|
||
function prima_newuoa(calfun, n, x, f, nf, rhobeg, rhoend, ftarget, maxfun, npt, iprint) | ||
@ccall libprimac.prima_newuoa(calfun::Ptr{Cvoid}, n::Cint, x::Ptr{Cdouble}, | ||
f::Ptr{Cdouble}, nf::Ptr{Cint}, rhobeg::Cdouble, | ||
rhoend::Cdouble, ftarget::Cdouble, maxfun::Cint, | ||
npt::Cint, iprint::Cint)::Cint | ||
end | ||
|
||
function prima_uobyqa(calfun, n, x, f, nf, rhobeg, rhoend, ftarget, maxfun, iprint) | ||
@ccall libprimac.prima_uobyqa(calfun::Ptr{Cvoid}, n::Cint, x::Ptr{Cdouble}, | ||
f::Ptr{Cdouble}, nf::Ptr{Cint}, rhobeg::Cdouble, | ||
rhoend::Cdouble, ftarget::Cdouble, maxfun::Cint, | ||
iprint::Cint)::Cint | ||
end | ||
|
||
function prima_cobyla(m_nlcon, calcfc, n, x, f, cstrv, nlconstr, m_ineq, Aineq, bineq, m_eq, | ||
Aeq, beq, xl, xu, nf, rhobeg, rhoend, ftarget, maxfun, iprint) | ||
@ccall libprimac.prima_cobyla(m_nlcon::Cint, calcfc::Ptr{Cvoid}, n::Cint, | ||
x::Ptr{Cdouble}, f::Ptr{Cdouble}, cstrv::Ptr{Cdouble}, | ||
nlconstr::Ptr{Cdouble}, m_ineq::Cint, Aineq::Ptr{Cdouble}, | ||
bineq::Ptr{Cdouble}, m_eq::Cint, Aeq::Ptr{Cdouble}, | ||
beq::Ptr{Cdouble}, xl::Ptr{Cdouble}, xu::Ptr{Cdouble}, | ||
nf::Ptr{Cint}, rhobeg::Cdouble, rhoend::Cdouble, | ||
ftarget::Cdouble, maxfun::Cint, iprint::Cint)::Cint | ||
end | ||
|
||
function prima_lincoa(calfun, n, x, f, cstrv, m_ineq, Aineq, bineq, m_eq, Aeq, beq, xl, xu, | ||
nf, rhobeg, rhoend, ftarget, maxfun, npt, iprint) | ||
@ccall libprimac.prima_lincoa(calfun::Ptr{Cvoid}, n::Cint, x::Ptr{Cdouble}, | ||
f::Ptr{Cdouble}, cstrv::Ptr{Cdouble}, m_ineq::Cint, | ||
Aineq::Ptr{Cdouble}, bineq::Ptr{Cdouble}, m_eq::Cint, | ||
Aeq::Ptr{Cdouble}, beq::Ptr{Cdouble}, xl::Ptr{Cdouble}, | ||
xu::Ptr{Cdouble}, nf::Ptr{Cint}, rhobeg::Cdouble, | ||
rhoend::Cdouble, ftarget::Cdouble, maxfun::Cint, | ||
npt::Cint, iprint::Cint)::Cint | ||
end |