tisztamo / FunctionWranglers.jl

Fast, inlined execution of arrays of functions
Other
8 stars 0 forks source link

Wrangler trees #3

Open mschauer opened 3 years ago

mschauer commented 3 years ago

The linear effort in issue #1 suggests that there is a use case for FunctionWranglers which have a FunctionWrangler as op in

struct FunctionWrangler{TOp, TNext}
    op::TOp
    next::TNext
end

together with a binary descent version of sindex selecting the function of interest by a sequence of bits choosing either op or next in each step.

mschauer commented 3 years ago

That would also allow to choose a list of functions from a list of functions in smap! etc.

tisztamo commented 3 years ago

Interesting idea!

I thought of index building to speed it up yesterday, and what you suggest can also be the base of the index, if ever needed.

Do you see a concrete use case of such trees? Would you mind contributing?

(There is also an @assert in sindex at the time, I plan to replace it with proper bounds checking, hopefully gaining ~1ns)

mschauer commented 3 years ago

Yes, of course. Just want to be careful not to reinvent Lisp here :-)

mschauer commented 3 years ago

Apropos @assert, https://github.com/tisztamo/FunctionWranglers.jl/blob/c4ae2ce03f465ad762205438fea0e47ccc0c12da/src/FunctionWranglers.jl#L71 looks wrong/superfluous.

tisztamo commented 3 years ago

That's a copypaste artifact, thanks!

I was not able to quickly replace the assert with proper bounds checking that reacts to @inbounds (never did that before, maybe my understanding is not deep enough), so I ended up removing it altogether.