Skip to content
This repository was archived by the owner on Mar 12, 2021. It is now read-only.

Don't depwarn if new env vars are used. #648

Merged
merged 1 commit into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions src/memory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -413,38 +413,43 @@ enable_timings() = (TimerOutputs.enable_debug_timings(CuArrays); return)
disable_timings() = (TimerOutputs.disable_debug_timings(CuArrays); return)

function __init_memory__()
if haskey(ENV, "CUARRAYS_MEMORY_LIMIT")
# memory limit configuration
memory_limit_str = if haskey(ENV, "JULIA_CUDA_MEMORY_LIMIT")
ENV["JULIA_CUDA_MEMORY_LIMIT"]
elseif haskey(ENV, "CUARRAYS_MEMORY_LIMIT")
Base.depwarn("The CUARRAYS_MEMORY_LIMIT environment flag is deprecated, please use JULIA_CUDA_MEMORY_LIMIT instead.", :__init_memory__)
ENV["JULIA_CUDA_MEMORY_LIMIT"] = ENV["CUARRAYS_MEMORY_LIMIT"]
ENV["CUARRAYS_MEMORY_LIMIT"]
else
nothing
end

if haskey(ENV, "JULIA_CUDA_MEMORY_LIMIT")
usage_limit[] = parse(Int, ENV["JULIA_CUDA_MEMORY_LIMIT"])
if memory_limit_str !== nothing
usage_limit[] = parse(Int, memory_limit_str)
end

if haskey(ENV, "CUARRAYS_MEMORY_POOL")
# memory pool configuration
memory_pool_str = if haskey(ENV, "JULIA_CUDA_MEMORY_POOL")
ENV["JULIA_CUDA_MEMORY_POOL"]
elseif haskey(ENV, "CUARRAYS_MEMORY_POOL")
Base.depwarn("The CUARRAYS_MEMORY_POOL environment flag is deprecated, please use JULIA_CUDA_MEMORY_POOL instead.", :__init_memory__)
ENV["JULIA_CUDA_MEMORY_POOL"] = ENV["CUARRAYS_MEMORY_POOL"]
ENV["CUARRAYS_MEMORY_POOL"]
else
nothing
end

if haskey(ENV, "JULIA_CUDA_MEMORY_POOL")
if memory_pool_str !== nothing
pool[] =
if ENV["JULIA_CUDA_MEMORY_POOL"] == "binned"
if memory_pool_str == "binned"
BinnedPool
elseif ENV["JULIA_CUDA_MEMORY_POOL"] == "simple"
elseif memory_pool_str == "simple"
SimplePool
elseif ENV["JULIA_CUDA_MEMORY_POOL"] == "split"
elseif memory_pool_str == "split"
SplittingPool
elseif ENV["JULIA_CUDA_MEMORY_POOL"] == "none"
elseif memory_pool_str == "none"
DummyPool
else
error("Invalid allocator selected")
end
end
pool[].init()

# if the user hand-picked an allocator, be a little verbose
if haskey(ENV, "JULIA_CUDA_MEMORY_POOL")
# the user hand-picked an allocator, so be a little verbose
atexit(()->begin
Core.println("""
CuArrays.jl $(nameof(pool[])) statistics:
Expand All @@ -453,6 +458,8 @@ function __init_memory__()
end)
end

# initialization
pool[].init()
reset_timers!()
end

Expand Down
12 changes: 8 additions & 4 deletions src/memory/binned.jl
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,16 @@ const allocated = Dict{CuPtr{Nothing},Block}()
function init()
create_pools(30) # up to 512 MiB

if haskey(ENV, "CUARRAYS_MANAGED_POOL")
Base.depwarn("The CUARRAYS_MANAGED_POOL environment flag is deprecated, please use JULIA_CUDA_MEMORY_POOL instead.", :__init_memory__)
ENV["JULIA_CUDA_MEMORY_POOL_MANAGED"] = ENV["CUARRAYS_MANAGED_POOL"]
managed_str = if haskey(ENV, "JULIA_CUDA_MEMORY_POOL_MANAGED")
ENV["JULIA_CUDA_MEMORY_POOL_MANAGED"]
elseif haskey(ENV, "CUARRAYS_MANAGED_POOL")
Base.depwarn("The CUARRAYS_MANAGED_POOL environment flag is deprecated, please use JULIA_CUDA_MEMORY_POOL_MANAGED instead.", :__init_memory__)
ENV["CUARRAYS_MANAGED_POOL"]
else
nothing
end

managed = parse(Bool, get(ENV, "JULIA_CUDA_MEMORY_POOL_MANAGED", "true"))
managed = parse(Bool, something(managed_str, "true"))
if managed
delay = MIN_DELAY
@async begin
Expand Down