omlins/ParallelStencil.jl

ParallelStencil on 1.10

Closed this issue · 6 comments

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

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

Can we prioritise this

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

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

The root cause for it is this bug in Julia 1.10: JuliaLang/julia#52531

omlins commented

This issue was solved here: JuliaLang/julia#52531