From 91706adb4a2832f8a33e14e8704796a72e204296 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) (cherry picked from commit 6893f21a896e51989c40b0b6de5cb2512b8afc97) --- 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 89ad60e275a59..c6979c069aff7 100644 --- a/stdlib/LinearAlgebra/src/LinearAlgebra.jl +++ b/stdlib/LinearAlgebra/src/LinearAlgebra.jl @@ -536,9 +536,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 82f44c8e559fc..716026b392a18 100644 --- a/stdlib/LinearAlgebra/src/matmul.jl +++ b/stdlib/LinearAlgebra/src/matmul.jl @@ -779,10 +779,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()) @@ -828,9 +824,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) @@ -850,8 +845,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