omlins / ParallelStencil.jl

Package for writing high-level code for parallel high-performance stencil computations that can be deployed on both GPUs and CPUs
BSD 3-Clause "New" or "Revised" License
301 stars 31 forks source link

ParallelStencil on 1.10 #125

Closed albert-de-montserrat closed 6 months ago

albert-de-montserrat commented 8 months ago

I have been testing Julia 1.10 (betas and rc1), and ParallelStencil doesn't seem to work. The @init_parallel_stencil seems not to do anything.

omlins commented 8 months ago

Thanks for reporting, I have seen this issue and thought already about some ways to solve it. :)

luraess commented 7 months ago

Can we prioritise this

albert-de-montserrat commented 7 months ago

I haven't fully tested if it has any side effects, and probably not very elegant or ideal, but this seems to fix it

const __is_initialized = Ref{Bool}(false)
const _package         = Ref{Symbol}(PKG_NONE)
const _numbertype      = Ref{DataType}(NUMBERTYPE_NONE)
const _ndims           = Ref{Integer}(NDIMS_NONE)
const _inbounds        = Ref{Bool}(false)
const _memopt          = Ref{Bool}(false)

let
    global _is_initialized, set_initialized, set_package, get_package, set_numbertype, get_numbertype, set_ndims, get_ndims, set_inbounds, get_inbounds, set_memopt, get_memopt, check_initialized, check_already_initialized
    _is_initialized::Bool       = __is_initialized[]  
    set_initialized(flag::Bool) = (__is_initialized[] = flag)
    is_initialized()            = __is_initialized[]
    set_package(pkg::Symbol)    = (_package[] = pkg)
    get_package()               = _package[]
    set_numbertype(T::DataType) = (_numbertype[] = T)
    get_numbertype()            = _numbertype[]
    set_ndims(n::Integer)       = (_ndims[] = n)
    get_ndims()                 = _ndims[]
    set_inbounds(flag::Bool)    = (_inbounds[] = flag)
    get_inbounds()              = _inbounds[]
    set_memopt(flag::Bool)      = (_memopt[] = flag)
    get_memopt()                = _memopt[]
   # etc... everything else below remains the same
end
omlins commented 7 months ago

I haven't fully tested if it has any side effects, and probably not very elegant or ideal, but this seems to fix it

const __is_initialized = Ref{Bool}(false)
const _package         = Ref{Symbol}(PKG_NONE)
const _numbertype      = Ref{DataType}(NUMBERTYPE_NONE)
const _ndims           = Ref{Integer}(NDIMS_NONE)
const _inbounds        = Ref{Bool}(false)
const _memopt          = Ref{Bool}(false)

let
    global _is_initialized, set_initialized, set_package, get_package, set_numbertype, get_numbertype, set_ndims, get_ndims, set_inbounds, get_inbounds, set_memopt, get_memopt, check_initialized, check_already_initialized
    _is_initialized::Bool       = __is_initialized[]  
    set_initialized(flag::Bool) = (__is_initialized[] = flag)
    is_initialized()            = __is_initialized[]
    set_package(pkg::Symbol)    = (_package[] = pkg)
    get_package()               = _package[]
    set_numbertype(T::DataType) = (_numbertype[] = T)
    get_numbertype()            = _numbertype[]
    set_ndims(n::Integer)       = (_ndims[] = n)
    get_ndims()                 = _ndims[]
    set_inbounds(flag::Bool)    = (_inbounds[] = flag)
    get_inbounds()              = _inbounds[]
    set_memopt(flag::Bool)      = (_memopt[] = flag)
    get_memopt()                = _memopt[]
   # etc... everything else below remains the same
end

Thanks for your idea, @albert-de-montserrat ! I'm actually working on this issue and my idea would be to create a solution that relies on extensions and preferences. As soon as I have something for you to try, I will share it with you. My goal is also to solve all the packaging difficulties in the same go...

omlins commented 7 months ago

The root cause for it is this bug in Julia 1.10: https://github.com/JuliaLang/julia/issues/52531

omlins commented 6 months ago

This issue was solved here: https://github.com/JuliaLang/julia/issues/52531