WaterLily-jl / WaterLily.jl

Fast and simple fluid simulator in Julia
Other
630 stars 77 forks source link

Top-level statement has no effect on execution of user code? #167

Closed vchuravy closed 1 week ago

vchuravy commented 1 week ago

I just noticed these two lines:

https://github.com/WaterLily-jl/WaterLily.jl/blob/c4d35002961e617228fe8c4ff784bcf04dd92893/ext/WaterLilyCUDAExt.jl#L19

https://github.com/WaterLily-jl/WaterLily.jl/blob/c4d35002961e617228fe8c4ff784bcf04dd92893/ext/WaterLilyAMDGPUExt.jl#L19

Since precompilation executes top-level statements in isolated processes they have no effect?

Similarly the __init__ codes would break some use-cases, (like creating a docker container with a precompilation cache and loading it on a GPU enabled machine later)

b-fg commented 1 week ago

Ah, maybe we did not notice because these are the default options anyways? I have seen the scalar-indexing error correctly popping up when looping through a GPU array outside of a kernel. What would be better solution if these cannot be included in __init__? Since false is already the default flag, we could just delete them I guess?