diff --git a/src/devices/numa/impl.jl b/src/devices/numa/impl.jl index 43e556b..01ac8cd 100644 --- a/src/devices/numa/impl.jl +++ b/src/devices/numa/impl.jl @@ -67,18 +67,30 @@ end """ gen_access_expr(device::NumaNode, symbol::Symbol) -Generate code to access the variable designated by `symbol` using the [`LocalVariables`](@ref) [`CacheStrategy`](@ref) on a [`NumaNode`](@ref). +Generate code to access the variable designated by `symbol` on a [`NumaNode`](@ref), using the [`CacheStrategy`](@ref) set in the device. """ function gen_access_expr(device::NumaNode, symbol::Symbol) - if typeof(device.cacheStrategy) <: LocalVariables - s = Symbol("data_$symbol") - quoteNode = Meta.parse(":($s)") - return quoteNode - elseif typeof(device.cacheStrategy) <: Dictionary - accessStr = ":(cache_$(to_var_name(device.id))[:$symbol])" - quoteNode = Meta.parse(accessStr) - return quoteNode - end - - return error("Unimplemented cache strategy \"$(device.cacheStrategy)\" for device \"$(device)\"") + return _gen_access_expr(device, device.cacheStrategy, symbol) +end + +""" + _gen_access_expr(device::NumaNode, ::LocalVariables, symbol::Symbol) + +Internal function for dispatch, used in [`gen_access_expr`](@ref). +""" +function _gen_access_expr(device::NumaNode, ::LocalVariables, symbol::Symbol) + s = Symbol("data_$symbol") + quoteNode = Meta.parse(":($s)") + return quoteNode +end + +""" + _gen_access_expr(device::NumaNode, ::Dictionary, symbol::Symbol) + +Internal function for dispatch, used in [`gen_access_expr`](@ref). +""" +function _gen_access_expr(device::NumaNode, ::Dictionary, symbol::Symbol) + accessStr = ":(cache_$(to_var_name(device.id))[:$symbol])" + quoteNode = Meta.parse(accessStr) + return quoteNode end