Skip to content

Commit

Permalink
Smaller compiler refactoring (#240)
Browse files Browse the repository at this point in the history
This setups the the compile code to be better refactored in the future.
  • Loading branch information
GeorgeR227 authored Jun 13, 2024
1 parent a09020c commit 7738216
Show file tree
Hide file tree
Showing 7 changed files with 736 additions and 210 deletions.
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 @@ -46,7 +47,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 @@ -61,7 +62,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)
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
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 @@ -72,12 +73,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 @@ -145,7 +146,7 @@ function dec_avg₀₁(sd::HasDeltaSet)
(avg_mat, x -> avg_mat * 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

0 comments on commit 7738216

Please sign in to comment.