Fable.jl icon indicating copy to clipboard operation
Fable.jl copied to clipboard

generator redesign

Open leios opened this issue 1 year ago • 2 comments

Right now, Fable is reliant on a lot of fractally concepts (Chaos game, Fractal Flame method, etc). This does not need to be the case, and it is better to move all the fractally things out so we can create the FableObjects with other generation functions, so...

  • [x] Remove the Global array of points from FableLayer
  • [ ] Combine color and pt functions that mutate a point struct with a color already associated with it. That way, there is no return on @fums and we can @splat whenever in the @fum
  • [ ] Create an AbstractGenerator, where one of them is RandomGenerator (1)
  • [ ] FractalObjects now define generators
    • [x] Also define -> create
  • [ ] Remove num_particles and num_iterations (2)
  • [ ] Remove random iteration option and instead find a way to properly iterate (possibly with a stack for recursion?)
    • [ ] No moure double-loop structure
    • [ ] Still loop over number of generators for multiple objects per kernel run
    • [ ] No longer call it fractal_flame (this method is still possible as a generator)
  • [ ] H_post -> transformations
  • [ ] Performance test to main
  • [ ] combine kwargs for final launch, send error if two identical kwargs don't match
  • [ ] Document!
  1. Something like:
abstract type AbstractGenerator end;

struct ChaosGenerator{F, A, I}
    f::F
    args::A
    iterations::I
end

# All generators should create a run function to be called from the kernel
pt = run(gen::AbstractGenerator)  = gen.f(tid, gen.args...)

function ChaosGame(tid, bounds, random_function, f_set, dims, n)
    pt = randon_function(seed(tid), bounds, dims...)
    
    # now do Chaos Game for n iterations
end

gen = ChaosGenerator(ChaosGame, (bounds, random_function, f_set...), 1000)
  1. These parameters are not necessary. num_particles is really just limiting the scope of our kernel and causing unnecessary trips to global memory. num_iterations should now be set by the generator and iterated on as an ndrange

leios avatar Jul 12 '24 14:07 leios

Thinking on this more, I think...

  1. All primitivs are still FableOperators
  2. the generator should create a specific @generated template to follow, so we can still do chaos game for as many steps as we want
  3. multiple Fable objects still compose into an executable by following the generator templates

leios avatar Jul 15 '24 14:07 leios

Ok, jotting down some more notes here. The generators should be <: FableOperator. Because we want to minimize the number of @generated functions, we should @generate based on each operator and then loop over them in the main kernel (note that this might need another @generated function at the fee level).

Also, we might as well add in the first part of https://github.com/leios/Fable.jl/pull/99 here (remember to color 1st and then move!).

leios avatar Jul 15 '24 18:07 leios