aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/CL/gemm/CLGEMMKernelSelectionValhall.cpp
diff options
context:
space:
mode:
authorGian Marco Iodice <gianmarco.iodice@arm.com>2020-11-02 15:43:57 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2020-11-03 12:55:19 +0000
commit491f30c0fff416007d97f4a5a043923861ef7b64 (patch)
tree62fa694cf1f4936380288bbf5b606a7e93b9bd9e /src/runtime/CL/gemm/CLGEMMKernelSelectionValhall.cpp
parent488f508056a2ce971cec201ebda1c7b5b11bf253 (diff)
downloadComputeLibrary-491f30c0fff416007d97f4a5a043923861ef7b64.tar.gz
COMPMID-3939: Update GEMM heuristic Mali-G77
- Update heuristic for GEMM reshaped RHS only - Fix left-over block size in CLGEMMMatrixMultiplyReshapedOlyRHSKernel Change-Id: I34c738821ed2e4a537da4a15058eec164cb6b61f Signed-off-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4305 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime/CL/gemm/CLGEMMKernelSelectionValhall.cpp')
-rw-r--r--src/runtime/CL/gemm/CLGEMMKernelSelectionValhall.cpp136
1 files changed, 130 insertions, 6 deletions
diff --git a/src/runtime/CL/gemm/CLGEMMKernelSelectionValhall.cpp b/src/runtime/CL/gemm/CLGEMMKernelSelectionValhall.cpp
index acae0e7565..da41859b87 100644
--- a/src/runtime/CL/gemm/CLGEMMKernelSelectionValhall.cpp
+++ b/src/runtime/CL/gemm/CLGEMMKernelSelectionValhall.cpp
@@ -46,8 +46,8 @@ CLGEMMKernelType CLGEMMKernelSelectionValhall::select_kernel(const CLGEMMKernelS
using FunctionExecutorPtr = CLGEMMKernelType (CLGEMMKernelSelectionValhall::*)(unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant);
- // Configurations for Valhall architectures
- static std::map<DataType, FunctionExecutorPtr> gemm_configs =
+ // Default configurations for Valhall architectures
+ static std::map<DataType, FunctionExecutorPtr> gemm_default_configs =
{
{ DataType::F32, &CLGEMMKernelSelectionValhall::default_f32 },
{ DataType::F16, &CLGEMMKernelSelectionValhall::default_f16 },
@@ -57,14 +57,34 @@ CLGEMMKernelType CLGEMMKernelSelectionValhall::select_kernel(const CLGEMMKernelS
{ DataType::QSYMM8_PER_CHANNEL, &CLGEMMKernelSelectionValhall::default_q8 }
};
+ // Mali-G77 configurations
+ static std::map<DataType, FunctionExecutorPtr> gemm_g77_configs =
+ {
+ { DataType::F32, &CLGEMMKernelSelectionValhall::default_f32 },
+ { DataType::F16, &CLGEMMKernelSelectionValhall::g77_f16 },
+ { DataType::QASYMM8, &CLGEMMKernelSelectionValhall::default_q8 },
+ { DataType::QASYMM8_SIGNED, &CLGEMMKernelSelectionValhall::default_q8 },
+ { DataType::QSYMM8, &CLGEMMKernelSelectionValhall::default_q8 },
+ { DataType::QSYMM8_PER_CHANNEL, &CLGEMMKernelSelectionValhall::default_q8 }
+ };
+
const DataType data_type = params.data_type;
- if(gemm_configs.find(data_type) != gemm_configs.end())
+ switch(_target)
{
- return (this->*gemm_configs[data_type])(params.m, params.n, params.k, params.b, params.is_rhs_constant);
+ case GPUTarget::G77:
+ if(gemm_g77_configs.find(data_type) != gemm_g77_configs.end())
+ {
+ return (this->*gemm_g77_configs[data_type])(params.m, params.n, params.k, params.b, params.is_rhs_constant);
+ }
+ ARM_COMPUTE_ERROR("Not supported data type");
+ default:
+ if(gemm_default_configs.find(data_type) != gemm_default_configs.end())
+ {
+ return (this->*gemm_default_configs[data_type])(params.m, params.n, params.k, params.b, params.is_rhs_constant);
+ }
+ ARM_COMPUTE_ERROR("Not supported data type");
}
-
- ARM_COMPUTE_ERROR("Not supported data type");
}
CLGEMMKernelType CLGEMMKernelSelectionValhall::default_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant)
@@ -81,6 +101,110 @@ CLGEMMKernelType CLGEMMKernelSelectionValhall::default_f16(unsigned int m, unsig
return is_rhs_constant ? CLGEMMKernelType::RESHAPED_ONLY_RHS : CLGEMMKernelType::NATIVE_V1;
}
+CLGEMMKernelType CLGEMMKernelSelectionValhall::g77_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant)
+{
+ if (!is_rhs_constant)
+ {
+ return CLGEMMKernelType::NATIVE_V1;
+ }
+
+ if (m == 1)
+ {
+ return CLGEMMKernelType::RESHAPED_ONLY_RHS;
+ }
+
+ const float r_mn = static_cast<float>(m) / static_cast<float>(n);
+ const float r_mk = static_cast<float>(m) / static_cast<float>(k);
+ const float r_nk = static_cast<float>(n) / static_cast<float>(k);
+ const float workload = (static_cast<float>(m) * static_cast<float>(n) * static_cast<float>(b)) / 20.0f;
+
+ if(r_mk <= 0.6817956566810608)
+ {
+ if(workload <= 801.6000061035156)
+ {
+ return CLGEMMKernelType::RESHAPED_ONLY_RHS;
+ }
+ else
+ {
+ if(r_mn <= 0.0839829258620739)
+ {
+ return CLGEMMKernelType::RESHAPED_ONLY_RHS;
+ }
+ else
+ {
+ if(r_mk <= 0.24917218834161758)
+ {
+ return CLGEMMKernelType::RESHAPED;
+ }
+ else
+ {
+ if(workload <= 2551.75)
+ {
+ return CLGEMMKernelType::RESHAPED_ONLY_RHS;
+ }
+ else
+ {
+ if(workload <= 5061.574951171875)
+ {
+ return CLGEMMKernelType::RESHAPED_ONLY_RHS;
+ }
+ else
+ {
+ return CLGEMMKernelType::RESHAPED;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ if(r_mk <= 4.849947690963745)
+ {
+ if(workload <= 17618.4501953125)
+ {
+ if(workload <= 5224.699951171875)
+ {
+ return CLGEMMKernelType::RESHAPED_ONLY_RHS;
+ }
+ else
+ {
+ if(r_nk <= 0.7933054566383362)
+ {
+ return CLGEMMKernelType::RESHAPED;
+ }
+ else
+ {
+ return CLGEMMKernelType::RESHAPED_ONLY_RHS;
+ }
+ }
+ }
+ else
+ {
+ if(workload <= 20275.2001953125)
+ {
+ return CLGEMMKernelType::RESHAPED;
+ }
+ else
+ {
+ if(r_mk <= 3.07421875)
+ {
+ return CLGEMMKernelType::RESHAPED_ONLY_RHS;
+ }
+ else
+ {
+ return CLGEMMKernelType::RESHAPED;
+ }
+ }
+ }
+ }
+ else
+ {
+ return CLGEMMKernelType::RESHAPED_ONLY_RHS;
+ }
+ }
+}
+
CLGEMMKernelType CLGEMMKernelSelectionValhall::default_q8(unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant)
{
ARM_COMPUTE_UNUSED(m, n, k, b);