Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize the memory pool #19

Merged
merged 3 commits into from
May 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
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ GPUCompiler = "61eb1bfa-7361-4325-ad38-22787b887f55"
LLVM = "929cbde3-209d-540e-8aea-75f648917ca0"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand Down
1 change: 0 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ coverage:
patch: false
project: false
changes: false
comment: false
2 changes: 2 additions & 0 deletions src/initialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ function __init__()

initializer(prepare_cuda_call)

__init_memory__()

@require ForwardDiff="f6369f11-7733-5829-9624-2563aa707210" include("forwarddiff.jl")
end

Expand Down
8 changes: 6 additions & 2 deletions src/memory.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# GPU memory management and pooling

using Printf
using Logging
using TimerOutputs

using Base: @lock
Expand Down Expand Up @@ -515,10 +516,13 @@ function __init_memory__()

# the user hand-picked an allocator, so be a little verbose
atexit(()->begin
Core.println("""
old_logger = global_logger()
global_logger(Logging.ConsoleLogger(Core.stderr, old_logger.min_level))
@debug """
CUDA.jl $(nameof(pool[])) statistics:
- $(alloc_stats.pool_nalloc) pool allocations: $(Base.format_bytes(alloc_stats.pool_alloc)) in $(Base.round(alloc_stats.pool_time; digits=2))s
- $(alloc_stats.actual_nalloc) CUDA allocations: $(Base.format_bytes(alloc_stats.actual_alloc)) in $(Base.round(alloc_stats.actual_time; digits=2))s""")
- $(alloc_stats.actual_nalloc) CUDA allocations: $(Base.format_bytes(alloc_stats.actual_alloc)) in $(Base.round(alloc_stats.actual_time; digits=2))s"""
global_logger(old_logger)
end)
end

Expand Down