[libomptarget] [amdgpu] Change default number of teams per computation unit
authorDhruva Chakrabarti <Dhruva.Chakrabarti@amd.com>
Tue, 29 Jun 2021 22:07:57 +0000 (15:07 -0700)
committerDhruva Chakrabarti <Dhruva.Chakrabarti@amd.com>
Tue, 29 Jun 2021 22:34:35 +0000 (15:34 -0700)
This patch is related to https://reviews.llvm.org/D98832. Based on discussions there, I decided to separate out the teams default as this patch. This change is to increase the number of teams per computation unit so as to provide more wavefronts for hiding latency. This change improves performance for some programs, including 20-50% for some Stream benchmarks.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D99003

openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

index aaa6812..be64ed2 100644 (file)
@@ -70,6 +70,10 @@ hostrpc_assign_buffer(hsa_agent_t, hsa_queue_t *, uint32_t device_id) {
 }
 }
 
+// Heuristic parameters used for kernel launch
+// Number of teams per CU to allow scheduling flexibility
+static const unsigned DefaultTeamsPerCU = 4;
+
 int print_kernel_trace;
 
 #ifdef OMPTARGET_DEBUG
@@ -1083,7 +1087,7 @@ int32_t __tgt_rtl_init_device(int device_id) {
        DeviceInfo.EnvNumTeams);
   } else {
     char *TeamsPerCUEnvStr = getenv("OMP_TARGET_TEAMS_PER_PROC");
-    int TeamsPerCU = 1; // default number of teams per CU is 1
+    int TeamsPerCU = DefaultTeamsPerCU;
     if (TeamsPerCUEnvStr) {
       TeamsPerCU = std::stoi(TeamsPerCUEnvStr);
     }