Skip to content
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

Smaller compiler refactoring #240

Merged
merged 22 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ext/DecapodesCUDAExt.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module DecapodesCUDAExt
using CombinatorialSpaces
import CombinatorialSpaces.DiscreteExteriorCalculus: DiscreteHodge
using LinearAlgebra
using Base.Iterators
using Krylov
Expand All @@ -8,7 +9,7 @@ using CUDA.CUSPARSE
using MLStyle
import Decapodes: default_dec_cu_matrix_generate

function default_dec_cu_matrix_generate(sd, my_symbol, hodge)
function default_dec_cu_matrix_generate(sd::HasDeltaSet, my_symbol::Symbol, hodge::DiscreteHodge)
op = @match my_symbol begin

# Regular Hodge Stars
Expand Down Expand Up @@ -43,7 +44,7 @@ function default_dec_cu_matrix_generate(sd, my_symbol, hodge)
end

# TODO: Update this to better cast hodges
function dec_cu_mat_hodge(k, sd::HasDeltaSet, hodge)
function dec_cu_mat_hodge(k::Int, sd::HasDeltaSet, hodge::DiscreteHodge)
hodge = dec_hodge_star(k, sd, hodge, Val{:CUDA})
return (hodge, x -> hodge * x)
end
Expand All @@ -58,7 +59,7 @@ function dec_cu_mat_hodge(::Type{Val{1}}, sd::HasDeltaSet, hodge::GeometricHodge
return (hodge, x -> hodge * x)
end

function dec_cu_mat_inverse_hodge(k::Int, sd::HasDeltaSet, hodge)
function dec_cu_mat_inverse_hodge(k::Int, sd::HasDeltaSet, hodge::DiscreteHodge)
invhodge = dec_inv_hodge_star(k, sd, hodge, Val{:CUDA})
return (invhodge, x -> invhodge * x)
lukem12345 marked this conversation as resolved.
Show resolved Hide resolved
end
Expand Down
3 changes: 1 addition & 2 deletions src/Decapodes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ using MLStyle

export
gensim, evalsim, compile, compile_env, default_dec_matrix_generate, default_dec_cu_matrix_generate, default_dec_generate,
CPUTarget, CUDATarget

CPUBackend, CUDABackend, CPUTarget, CUDATarget

include("operators.jl")
include("simulation.jl")
Expand Down
9 changes: 5 additions & 4 deletions src/operators.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using Base.Iterators
using CombinatorialSpaces
import CombinatorialSpaces.DiscreteExteriorCalculus: DiscreteHodge
lukem12345 marked this conversation as resolved.
Show resolved Hide resolved
using Krylov
using LinearAlgebra
using SparseArrays

function default_dec_cu_matrix_generate() end;

function default_dec_matrix_generate(sd, my_symbol, hodge)
function default_dec_matrix_generate(sd::HasDeltaSet, my_symbol::Symbol, hodge::DiscreteHodge)
op = @match my_symbol begin

# Regular Hodge Stars
Expand Down Expand Up @@ -69,12 +70,12 @@ function default_dec_matrix_generate(sd, my_symbol, hodge)
return op
end

function dec_mat_hodge(k, sd::HasDeltaSet, hodge)
function dec_mat_hodge(k::Int, sd::HasDeltaSet, hodge::DiscreteHodge)
hodge = dec_hodge_star(k, sd, hodge=hodge)
return (hodge, x -> hodge * x)
end

function dec_mat_inverse_hodge(k::Int, sd::HasDeltaSet, hodge)
function dec_mat_inverse_hodge(k::Int, sd::HasDeltaSet, hodge::DiscreteHodge)
invhodge = dec_inv_hodge_star(k, sd, hodge=hodge)
return (invhodge, x -> invhodge * x)
end
Expand Down Expand Up @@ -137,7 +138,7 @@ function dec_♭(sd::HasDeltaSet2D)
x -> ♭_m * x
end

function default_dec_generate(sd, my_symbol, hodge=GeometricHodge())
function default_dec_generate(sd::HasDeltaSet, my_symbol::Symbol, hodge::DiscreteHodge=GeometricHodge())

op = @match my_symbol begin

Expand Down
Loading
Loading