From 6893f21a896e51989c40b0b6de5cb2512b8afc97 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Mon, 20 Sep 2021 05:11:09 -0700 Subject: [PATCH] Remove buffer pool for tiled GEMM (#42309) --- stdlib/LinearAlgebra/src/LinearAlgebra.jl | 3 --- stdlib/LinearAlgebra/src/matmul.jl | 12 +++--------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/stdlib/LinearAlgebra/src/LinearAlgebra.jl b/stdlib/LinearAlgebra/src/LinearAlgebra.jl index 8c48a9a757959..b9737bf36d0c5 100644 --- a/stdlib/LinearAlgebra/src/LinearAlgebra.jl +++ b/stdlib/LinearAlgebra/src/LinearAlgebra.jl @@ -586,9 +586,6 @@ function __init__() BLAS.lbt_forward(liblapack_path) end BLAS.check() - Threads.resize_nthreads!(Abuf) - Threads.resize_nthreads!(Bbuf) - Threads.resize_nthreads!(Cbuf) catch ex Base.showerror_nostdio(ex, "WARNING: Error during initialization of module LinearAlgebra") end diff --git a/stdlib/LinearAlgebra/src/matmul.jl b/stdlib/LinearAlgebra/src/matmul.jl index 2b315b0cf6080..0cbfeaf9ed3ea 100644 --- a/stdlib/LinearAlgebra/src/matmul.jl +++ b/stdlib/LinearAlgebra/src/matmul.jl @@ -726,10 +726,6 @@ function generic_matmatmul(tA, tB, A::AbstractVecOrMat{T}, B::AbstractMatrix{S}) end const tilebufsize = 10800 # Approximately 32k/3 -# per-thread arrays of buffers resized by __init__ if needed -const Abuf = [Vector{UInt8}(undef, tilebufsize)] -const Bbuf = [Vector{UInt8}(undef, tilebufsize)] -const Cbuf = [Vector{UInt8}(undef, tilebufsize)] function generic_matmatmul!(C::AbstractMatrix, tA, tB, A::AbstractMatrix, B::AbstractMatrix, _add::MulAddMul=MulAddMul()) @@ -775,9 +771,8 @@ function _generic_matmatmul!(C::AbstractVecOrMat{R}, tA, tB, A::AbstractVecOrMat @inbounds begin if tile_size > 0 sz = (tile_size, tile_size) - # FIXME: This code is completely invalid!!! - Atile = unsafe_wrap(Array, convert(Ptr{T}, pointer(Abuf[Threads.threadid()])), sz) - Btile = unsafe_wrap(Array, convert(Ptr{S}, pointer(Bbuf[Threads.threadid()])), sz) + Atile = Array{T}(undef, sz) + Btile = Array{S}(undef, sz) z1 = zero(A[1, 1]*B[1, 1] + A[1, 1]*B[1, 1]) z = convert(promote_type(typeof(z1), R), z1) @@ -797,8 +792,7 @@ function _generic_matmatmul!(C::AbstractVecOrMat{R}, tA, tB, A::AbstractVecOrMat end end else - # FIXME: This code is completely invalid!!! - Ctile = unsafe_wrap(Array, convert(Ptr{R}, pointer(Cbuf[Threads.threadid()])), sz) + Ctile = Array{R}(undef, sz) for jb = 1:tile_size:nB jlim = min(jb+tile_size-1,nB) jlen = jlim-jb+1