diff options
author | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2019-01-16 15:40:25 +0000 |
---|---|---|
committer | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2019-01-18 10:43:04 +0000 |
commit | 90313eb8f72cf9ba17cbf7b84382a609e927a1fe (patch) | |
tree | 0cb5868280821e263a5def166bd98676d1e36f3d /src/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.cpp | |
parent | 13a2080f9e88dacf0b96744ecf60a5e9debf9010 (diff) | |
download | ComputeLibrary-90313eb8f72cf9ba17cbf7b84382a609e927a1fe.tar.gz |
COMPMID-1687: Optimize CLGEMMMatrixMultiplyKernel
Change-Id: I040478ff7aa04f0523ed6e302129b829442cb194
Reviewed-on: https://review.mlplatform.org/534
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
Diffstat (limited to 'src/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.cpp')
-rw-r--r-- | src/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.cpp | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/src/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.cpp b/src/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.cpp new file mode 100644 index 0000000000..079a52e61c --- /dev/null +++ b/src/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.cpp @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2019 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.h" + +#include "arm_compute/core/GPUTarget.h" +#include "arm_compute/runtime/CL/CLScheduler.h" + +#include <utility> + +namespace arm_compute +{ +namespace cl_gemm +{ +std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedConfigurationBifrost::configure(unsigned int m, unsigned int n, unsigned int k, unsigned int b, DataType data_type) +{ + ARM_COMPUTE_ERROR_ON(data_type != DataType::F32); + ARM_COMPUTE_UNUSED(data_type); + + const GPUTarget gpu_target = CLScheduler::get().target(); + switch(gpu_target) + { + case GPUTarget::G76: + return configure_G76_f32(m, n, k, b); + default: + return configure_G7x_f32(m, n, k, b); + } +} + +std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedConfigurationBifrost::configure_G7x_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b) +{ + ARM_COMPUTE_UNUSED(k); + ARM_COMPUTE_UNUSED(b); + + GEMMLHSMatrixInfo lhs_info; + GEMMRHSMatrixInfo rhs_info; + + if(n <= 4) + { + // Configure GEMMLHSMatrixInfo + lhs_info.m0 = 4; + lhs_info.k0 = 8; + lhs_info.v0 = lhs_info.m0 * 16 < m ? 2 : 16; + lhs_info.interleave = true; + lhs_info.transpose = false; + + // Configure GEMMRHSMatrixInfo + rhs_info.n0 = 2; + rhs_info.k0 = lhs_info.k0; + rhs_info.h0 = rhs_info.n0 * 16 < n ? 2 : 16; + rhs_info.interleave = false; + rhs_info.transpose = true; + } + else + { + // Configure GEMMLHSMatrixInfo + lhs_info.m0 = 5; + lhs_info.k0 = 4; + lhs_info.v0 = lhs_info.m0 * 2 < m ? 1 : 2; + lhs_info.interleave = false; + lhs_info.transpose = false; + + // Configure GEMMRHSMatrixInfo + rhs_info.n0 = 4; + rhs_info.k0 = lhs_info.k0; + rhs_info.h0 = rhs_info.n0 * 16 < n ? 2 : 16; + rhs_info.interleave = true; + rhs_info.transpose = true; + } + + return std::make_pair(lhs_info, rhs_info); +} + +std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedConfigurationBifrost::configure_G76_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b) +{ + ARM_COMPUTE_UNUSED(k); + ARM_COMPUTE_UNUSED(b); + + GEMMLHSMatrixInfo lhs_info; + GEMMRHSMatrixInfo rhs_info; + + if(n <= 4) + { + // Configure GEMMLHSMatrixInfo + lhs_info.m0 = 4; + lhs_info.k0 = 8; + lhs_info.v0 = lhs_info.m0 * 16 < m ? 2 : 16; + lhs_info.interleave = true; + lhs_info.transpose = false; + + // Configure GEMMRHSMatrixInfo + rhs_info.n0 = 2; + rhs_info.k0 = lhs_info.k0; + rhs_info.h0 = rhs_info.n0 * 16 < n ? 2 : 16; + rhs_info.interleave = false; + rhs_info.transpose = true; + } + else + { + // Configure GEMMLHSMatrixInfo + lhs_info.m0 = 4; + lhs_info.k0 = 2; + lhs_info.v0 = lhs_info.m0 * 8 < m ? 2 : 8; + lhs_info.interleave = false; + lhs_info.transpose = false; + + // Configure GEMMRHSMatrixInfo + rhs_info.n0 = 4; + rhs_info.k0 = lhs_info.k0; + rhs_info.h0 = rhs_info.n0 * 16 < n ? 2 : 16; + rhs_info.interleave = false; + rhs_info.transpose = true; + } + + return std::make_pair(lhs_info, rhs_info); +} +} // namespace cl_gemm +} // namespace arm_compute
\ No newline at end of file |