Skip to content

Commit

Permalink
added AQUA.jl to Decapodes (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
quffaro authored Jun 6, 2024
1 parent 4995bd1 commit d62d424
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 153 deletions.
31 changes: 10 additions & 21 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,15 @@ version = "0.5.3"

[deps]
ACSets = "227ef7b5-1206-438b-ac65-934d6da304b8"
Catlab = "134e5e36-593f-5add-ad60-77f754baafbe"
CombinatorialSpaces = "b1c52339-7909-45ad-8b6a-6e388f7c67f2"
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
DiagrammaticEquations = "6f00c28b-6bed-4403-80fa-30e0dc12f317"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[weakdeps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Expand All @@ -34,36 +23,36 @@ DecapodesCUDAExt = "CUDA"

[compat]
ACSets = "0.2"
Catlab = "0.15, 0.16"
Aqua = "0.8"
CUDA = "5.2"
CombinatorialSpaces = "0.6.3"
ComponentArrays = "0.15"
CUDA = "5.2"
DataStructures = "0.18.13"
DiagrammaticEquations = "0.1"
Distributions = "0.25"
FileIO = "1.16"
GeometryBasics = "0.4.2"
JLD2 = "0.4"
JSON = "0.21"
Krylov = "0.9.6"
LinearAlgebra = "1.9"
MLStyle = "0.4.17"
Markdown = "1.9"
OrdinaryDiffEq = "6.47"
PreallocationTools = "0.4"
Requires = "1.3"
Random = "1.9"
SparseArrays = "1.9"
StaticArrays = "1.7"
Unicode = "1.9"
Statistics = "1.9"
Test = "1.9"
julia = "1.9"

[extras]
AlgebraicPetri = "4f99eebe-17bf-4e98-b6a1-2c4f205a959b"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["AlgebraicPetri", "CUDA", "Distributions", "Test", "Random", "GeometryBasics", "Statistics"]
test = ["Aqua", "CUDA", "Distributions", "GeometryBasics", "JSON", "OrdinaryDiffEq", "Random", "Statistics", "Test"]
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ makedocs(
checkdocs = :none,
pagesonly = true,
linkcheck = true,
linkcheck_ignore = [r"agupubs.onlinelibrary.wiley.com"], # This gives a 403 Forbidden
linkcheck_ignore = [r"agupubs\.onlinelibrary\.wiley\.com", # This gives a 403 Forbidden
r"Decapodes\.jl/dev"], # 404, probably due to bad self-rerference
pages = Any[
"Decapodes.jl" => "index.md",
"Overview" => "overview/overview.md",
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/sw/pressure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function generate(sd, my_symbol; hodge=GeometricHodge())
return (args...) -> op(args...)
end

#include("coordinates.jl")
include("coordinates.jl")

radius = 6371+90

Expand Down
2 changes: 1 addition & 1 deletion examples/sw/sw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ddp = SummationDecapode(diffExpr)
gensim(expand_operators(ddp), [:C])
f = eval(gensim(expand_operators(ddp), [:C]))

#include("coordinates.jl")
include("coordinates.jl")

const RADIUS = 6371+90
#primal_earth, npi, spi = makeSphere(0, 180, 5, 0, 360, 5, RADIUS);
Expand Down
5 changes: 4 additions & 1 deletion ext/DecapodesCUDAExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module DecapodesCUDAExt
using CombinatorialSpaces
using LinearAlgebra
using Base.Iterators
using Catlab
using Krylov
using CUDA
using CUDA.CUSPARSE
Expand Down Expand Up @@ -109,6 +108,10 @@ function dec_cu_pair_wedge_product(::Type{Tuple{1,1}}, sd::HasDeltaSet2D)
(α, β) -> dec_c_wedge_product(Tuple{1,1}, α, β, val_pack, Val{:CUDA}))
end

function dec_pair_wedge_product(::Type{Tuple{0,0}}, sd::HasDeltaSet)
error("Replace me in compiled code with element-wise multiplication (.*)")
end

# TODO: These need to be converted into CuArrays/kernels
function dec_cu_sharp_p(sd::HasDeltaSet2D)
♯_m = ♯_mat(sd, AltPPSharp())
Expand Down
20 changes: 3 additions & 17 deletions src/Decapodes.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
module Decapodes

using Catlab
using Catlab.Theories
using Catlab.Programs
using Catlab.CategoricalAlgebra
using Catlab.WiringDiagrams
using Catlab.WiringDiagrams.DirectedWiringDiagrams
using Catlab.ACSetInterface
using MLStyle
using Base.Iterators
using SparseArrays
using PreallocationTools

using ACSets
using DiagrammaticEquations
using DiagrammaticEquations.Deca
using MLStyle

export
findname, flat_op,
gensim, evalsim, closest_point, findnode, compile, compile_env, PhysicsState, default_dec_matrix_generate, default_dec_cu_matrix_generate, default_dec_generate, VectorForm,
CartesianPoint, SpherePoint, r, theta, phi, TangentBasis, θhat, ϕhat,
gensim, evalsim, compile, compile_env, default_dec_matrix_generate, default_dec_cu_matrix_generate, default_dec_generate,
CPUTarget, CUDATarget

append_dot(s::Symbol) = Symbol(string(s)*'\U0307')

include("coordinates.jl")
include("operators.jl")
include("simulation.jl")

Expand Down
11 changes: 8 additions & 3 deletions src/operators.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Base.Iterators
using CombinatorialSpaces
using Krylov
using LinearAlgebra
using Base.Iterators
using Catlab
using SparseArrays

function default_dec_cu_matrix_generate() end;

function default_dec_matrix_generate(sd, my_symbol, hodge)
op = @match my_symbol begin

Expand Down Expand Up @@ -117,6 +118,10 @@ function dec_pair_wedge_product(::Type{Tuple{1,1}}, sd::HasDeltaSet2D)
(α, β) -> dec_c_wedge_product(Tuple{1,1}, α, β, val_pack))
end

function dec_pair_wedge_product(::Type{Tuple{0,0}}, sd::HasDeltaSet)
error("Replace me in compiled code with element-wise multiplication (.*)")
end

function dec_♯_p(sd::HasDeltaSet2D)
♯_m = ♯_mat(sd, AltPPSharp())
x -> ♯_m * x
Expand Down
32 changes: 14 additions & 18 deletions src/simulation.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
using Catlab
using Base.Iterators
using CombinatorialSpaces
using ComponentArrays
using OrdinaryDiffEq
using GeometryBasics
using LinearAlgebra
using Base.Iterators
using Catlab
using MLStyle
import Catlab.Programs.GenerateJuliaPrograms: compile
using PreallocationTools

const gensim_in_place_stub = Symbol("GenSim-M")

Expand All @@ -18,7 +14,7 @@ struct CUDATarget <: GenerationTarget end

abstract type AbstractCall end

struct UnaryCall <: AbstractCall
struct UnaryCall <: AbstractCall
operator
equality
input
Expand All @@ -44,7 +40,7 @@ Base.Expr(c::UnaryCall) = begin
end
end

struct BinaryCall <: AbstractCall
struct BinaryCall <: AbstractCall
operator
equality
input1
Expand All @@ -65,7 +61,7 @@ Base.Expr(c::BinaryCall) = begin
return Expr(c.equality, c.output, Expr(:call, c.operator, c.input1, c.input2))
end

struct VarargsCall <: AbstractCall
struct VarargsCall <: AbstractCall
operator
equality
inputs
Expand All @@ -79,7 +75,7 @@ Base.Expr(c::VarargsCall) = begin
return Expr(c.equality, c.output, Expr(:call, c.operator, c.inputs...))
end

struct AllocVecCall <: AbstractCall
struct AllocVecCall <: AbstractCall
name
form
dimension
Expand Down Expand Up @@ -141,7 +137,7 @@ end =#

function is_form(d::SummationDecapode, var_id::Int)
type = d[var_id, :type]
return (type == :Form0 || type == :Form1 || type == :Form2 ||
return (type == :Form0 || type == :Form1 || type == :Form2 ||
type == :DualForm0 || type == :DualForm1 || type == :DualForm2)
end

Expand Down Expand Up @@ -345,10 +341,10 @@ function compile(d::SummationDecapode, inputs::Vector, alloc_vectors::Vector{All
operator = promote_arithmetic_map[operator]
equality = promote_arithmetic_map[equality]
push!(alloc_vectors, AllocVecCall(rname, d[r, :type], dimension, stateeltype, code_target))

# TODO: Do we want to support the ability of a user to use the backslash operator?
elseif(operator == :(*) || operator == :(/) || operator == :.* || operator == :./)
# WARNING: This part may break if we add more compiler types that have different
# WARNING: This part may break if we add more compiler types that have different
# operations for basic and broadcast modes, e.g. matrix multiplication vs broadcast
if(!is_infer(d, arg1) && !is_infer(d, arg2))
operator = promote_arithmetic_map[operator]
Expand Down Expand Up @@ -547,7 +543,7 @@ function gensim(user_d::AbstractNamedDecapode, input_vars; dimension::Int=2, sta
infer_overload_compiler!(d′, dimension)

# This will generate all of the fundemental DEC operators present
optimizable_dec_operators = Set([:₀, :₁, :₂, :₀⁻¹, :₂⁻¹,
optimizable_dec_operators = Set([:₀, :₁, :₂, :₀⁻¹, :₂⁻¹,
:d₀, :d₁, :dual_d₀, :d̃₀, :dual_d₁, :d̃₁])
extra_dec_operators = Set([:₁⁻¹, :₀₁, :₁₀, :₁₁, :₀₂, :₂₀])

Expand Down Expand Up @@ -580,19 +576,19 @@ function gensim(user_d::AbstractNamedDecapode, input_vars; dimension::Int=2, sta
end
end

gensim(c::Collage; dimension::Int=2) =
gensim(c::Collage; dimension::Int=2) =
gensim(collate(c); dimension=dimension)

""" function gensim(d::AbstractNamedDecapode; dimension::Int=2)
Generate a simulation function from the given Decapode. The returned function can then be combined with a mesh and a function describing function mappings to return a simulator to be passed to `solve`.
"""
gensim(d::AbstractNamedDecapode; dimension::Int=2, stateeltype = Float64, code_target = CPUTarget()) =
gensim(d::AbstractNamedDecapode; dimension::Int=2, stateeltype = Float64, code_target = CPUTarget()) =
gensim(d, vcat(collect(infer_state_names(d)), d[incident(d, :Literal, :type), :name]), dimension=dimension, stateeltype=stateeltype, code_target=code_target)

evalsim(d::AbstractNamedDecapode; dimension::Int=2, stateeltype = Float64, code_target = CPUTarget()) =
evalsim(d::AbstractNamedDecapode; dimension::Int=2, stateeltype = Float64, code_target = CPUTarget()) =
eval(gensim(d, dimension=dimension, stateeltype=stateeltype, code_target=code_target))
evalsim(d::AbstractNamedDecapode, input_vars; dimension::Int=2, stateeltype = Float64, code_target = CPUTarget()) =
evalsim(d::AbstractNamedDecapode, input_vars; dimension::Int=2, stateeltype = Float64, code_target = CPUTarget()) =
eval(gensim(d, input_vars, dimension=dimension, stateeltype=stateeltype, code_target=code_target))

"""
Expand Down
7 changes: 7 additions & 0 deletions test/aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Aqua, Decapodes

Aqua.test_ambiguities(Decapodes)
Aqua.test_all(
Decapodes, ambiguities=false,
deps_compat=(ignore=[:Markdown, :Random, :Test],),
)
22 changes: 8 additions & 14 deletions test/componentarrays.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
using ComponentArrays
using OrdinaryDiffEq
using GeometryBasics
using JSON
using Distributions

using Catlab
using Catlab.CategoricalAlgebra
using ACSets
using CombinatorialSpaces

using DiagrammaticEquations
using DiagrammaticEquations.Deca
using ComponentArrays
using Decapodes
using Test
using MLStyle
using DiagrammaticEquations
using Distributions
using GeometryBasics: Point3
using LinearAlgebra
using MLStyle
using OrdinaryDiffEq
using Test

C = ones(Float64, 10)
V = ones(Float64, 100)
Expand Down Expand Up @@ -173,4 +168,3 @@ soln = solve(prob, Tsit5())
# record(fig, "diff_adv.gif", range(0.0, tₑ; length=150); framerate = 30) do t
# ob.color = findnode(soln(t), :C)[point_map]
# end

Loading

0 comments on commit d62d424

Please sign in to comment.