Alexandru Duțu has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/42217 )

Change subject: configs, gpu-compute: Add option to specify gfx version
......................................................................

configs, gpu-compute: Add option to specify gfx version

Currently uses gfx801, gfx803, gfx900 for Carrizo, Fiji,
and Vega respectively

Change-Id: I62758914b6a60f16dd4f2141a23c0a9141a4e1a0
---
M configs/example/apu_se.py
M src/gpu-compute/GPU.py
M src/gpu-compute/gpu_compute_driver.cc
M src/gpu-compute/gpu_compute_driver.hh
4 files changed, 63 insertions(+), 10 deletions(-)



diff --git a/configs/example/apu_se.py b/configs/example/apu_se.py
index fd9b386..5466c4d 100644
--- a/configs/example/apu_se.py
+++ b/configs/example/apu_se.py
@@ -204,6 +204,9 @@
                   "driver on a per-page basis.  Valid values are between "
                   "0-7")

+parser.add_option("--gfx-version", type="string", default='gfx801',
+                  help="Gfx version for gpu: gfx801, gfx803, gfx900")
+
 Ruby.define_options(parser)

 #add TLB options to the parser
@@ -446,6 +449,7 @@

 # HSA kernel mode driver
 gpu_driver = GPUComputeDriver(filename = "kfd", isdGPU = options.dgpu,
+                              gfxVersion = options.gfx_version,
                               dGPUPoolID = 1, m_type = options.m_type)

 # Creating the GPU kernel launching components: that is the HSA
@@ -683,8 +687,15 @@
# Create the /sys/devices filesystem for the simulator so that the HSA Runtime
 # knows what type of GPU hardware we are simulating
 if options.dgpu:
-    hsaTopology.createFijiTopology(options)
+    assert (options.gfx_version in ['gfx803', 'gfx900']),\
+            "Incorrect gfx version for dGPU"
+    if options.gfx_version == 'gfx803':
+        hsaTopology.createFijiTopology(options)
+    elif options.gfx_version == 'gfx900':
+        hsaTopology.createVegaTopology(options)
 else:
+    assert (options.gfx_version in ['gfx801']),\
+            "Incorrect gfx version for APU"
     hsaTopology.createCarrizoTopology(options)

 m5.ticks.setGlobalFrequency('1THz')
diff --git a/src/gpu-compute/GPU.py b/src/gpu-compute/GPU.py
index 091fdde..53bece9 100644
--- a/src/gpu-compute/GPU.py
+++ b/src/gpu-compute/GPU.py
@@ -50,6 +50,12 @@
     'PF_END',
     ]

+class GfxVersion(ScopedEnum): vals = [
+    'gfx801',
+    'gfx803',
+    'gfx900',
+    ]
+
 class PoolManager(SimObject):
     type = 'PoolManager'
     abstract = True
@@ -237,6 +243,7 @@
     type = 'GPUComputeDriver'
     cxx_header = 'gpu-compute/gpu_compute_driver.hh'
     isdGPU = Param.Bool(False, 'Driver is for a dGPU')
+    gfxVersion = Param.GfxVersion('gfx801', 'ISA of gpu to model')
     dGPUPoolID = Param.Int(False, 'Pool ID for dGPU.')
     # Default Mtype for caches
     #--     1   1   1   C_RW_S  (Cached-ReadWrite-Shared)
diff --git a/src/gpu-compute/gpu_compute_driver.cc b/src/gpu-compute/gpu_compute_driver.cc
index 9873e29..dedbba8 100644
--- a/src/gpu-compute/gpu_compute_driver.cc
+++ b/src/gpu-compute/gpu_compute_driver.cc
@@ -47,7 +47,8 @@
 #include "sim/syscall_emul_buf.hh"

 GPUComputeDriver::GPUComputeDriver(const Params &p)
-    : HSADriver(p), isdGPU(p.isdGPU)
+    : HSADriver(p), isdGPU(p.isdGPU), gfxVersion(p.gfxVersion),
+      dGPUPoolID(p.dGPUPoolID)
 {
     device->attachDriver(this);
     DPRINTF(GPUDriver, "Constructing KFD: device\n");
@@ -175,10 +176,26 @@
                     gpuVmApeLimit(args->process_apertures[i].gpuvm_base);

                 // NOTE: Must match ID populated by hsaTopology.py
-                if (isdGPU)
-                    args->process_apertures[i].gpu_id = 50156;
-                else
-                    args->process_apertures[i].gpu_id = 2765;
+                if (isdGPU) {
+                    switch (gfxVersion) {
+                      case GfxVersion::gfx803:
+                        args->process_apertures[i].gpu_id = 50156;
+                        break;
+                      case GfxVersion::gfx900:
+                        args->process_apertures[i].gpu_id = 22124;
+                        break;
+                      default:
+                        fatal("Invalid gfx version for dGPU\n");
+                    }
+                } else {
+                    switch (gfxVersion) {
+                      case GfxVersion::gfx801:
+                        args->process_apertures[i].gpu_id = 2765;
+                        break;
+                      default:
+                        fatal("Invalid gfx version for APU\n");
+                    }
+                }

                 DPRINTF(GPUDriver, "GPUVM base for node[%i] = %#x\n", i,
                         args->process_apertures[i].gpuvm_base);
@@ -610,10 +627,26 @@
ape_args->gpuvm_limit = gpuVmApeLimit(ape_args->gpuvm_base);

                 // NOTE: Must match ID populated by hsaTopology.py
-                if (isdGPU)
-                    ape_args->gpu_id = 50156;
-                else
-                    ape_args->gpu_id = 2765;
+                if (isdGPU) {
+                    switch (gfxVersion) {
+                      case GfxVersion::gfx803:
+                        ape_args->gpu_id = 50156;
+                        break;
+                      case GfxVersion::gfx900:
+                        ape_args->gpu_id = 22124;
+                        break;
+                      default:
+                        fatal("Invalid gfx version for dGPU\n");
+                    }
+                } else {
+                    switch (gfxVersion) {
+                      case GfxVersion::gfx801:
+                        ape_args->gpu_id = 2765;
+                        break;
+                      default:
+                        fatal("Invalid gfx version for APU\n");
+                    }
+                }

assert(bits<Addr>(ape_args->scratch_base, 63, 47) != 0x1ffff);
                 assert(bits<Addr>(ape_args->scratch_base, 63, 47) != 0);
diff --git a/src/gpu-compute/gpu_compute_driver.hh b/src/gpu-compute/gpu_compute_driver.hh
index 7f94acc..7f13461 100644
--- a/src/gpu-compute/gpu_compute_driver.hh
+++ b/src/gpu-compute/gpu_compute_driver.hh
@@ -44,6 +44,7 @@

 #include "base/addr_range_map.hh"
 #include "dev/hsa/hsa_driver.hh"
+#include "enums/GfxVersion.hh"
 #include "mem/request.hh"

 struct GPUComputeDriverParams;
@@ -68,6 +69,7 @@

   private:
     bool isdGPU;
+    GfxVersion gfxVersion;
     int dGPUPoolID;

     /**

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/42217
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I62758914b6a60f16dd4f2141a23c0a9141a4e1a0
Gerrit-Change-Number: 42217
Gerrit-PatchSet: 1
Gerrit-Owner: Alexandru Duțu <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to