Kyle Roarty has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/46244 )
Change subject: configs,gpu-compute: Add render driver needed for ROCm 4
......................................................................
configs,gpu-compute: Add render driver needed for ROCm 4
ROCm 4 utilizes the render driver located at /dev/dri/renderDXXX. This
patch implements a very simple driver that just returns a file
descriptor when opened, as testing has shown that's all that's needed
Change-Id: I65602346cbf17b2dc80e114046ebf5c9830a1507
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/46244
Tested-by: kokoro <noreply+kok...@google.com>
Reviewed-by: Jason Lowe-Power <power...@gmail.com>
Reviewed-by: Matt Sinclair <mattdsincl...@gmail.com>
Maintainer: Jason Lowe-Power <power...@gmail.com>
Maintainer: Matt Sinclair <mattdsincl...@gmail.com>
---
M configs/example/apu_se.py
M configs/example/hsaTopology.py
M src/gpu-compute/GPU.py
M src/gpu-compute/SConscript
A src/gpu-compute/gpu_render_driver.cc
A src/gpu-compute/gpu_render_driver.hh
6 files changed, 124 insertions(+), 2 deletions(-)
Approvals:
Jason Lowe-Power: Looks good to me, but someone else must approve; Looks
good to me, approved
Matt Sinclair: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/configs/example/apu_se.py b/configs/example/apu_se.py
index f779df3..98a1e19 100644
--- a/configs/example/apu_se.py
+++ b/configs/example/apu_se.py
@@ -436,6 +436,9 @@
gfxVersion = args.gfx_version,
dGPUPoolID = 1, m_type = args.m_type)
+renderDriNum = 128
+render_driver = GPURenderDriver(filename = f'dri/renderD{renderDriNum}')
+
# Creating the GPU kernel launching components: that is the HSA
# packet processor (HSAPP), GPU command processor (CP), and the
# dispatcher.
@@ -498,7 +501,8 @@
"HSA_ENABLE_SDMA=0"]
process = Process(executable = executable, cmd = [args.cmd]
- + args.options.split(), drivers = [gpu_driver], env =
env)
+ + args.options.split(),
+ drivers = [gpu_driver, render_driver], env = env)
for cpu in cpu_list:
cpu.createThreads()
diff --git a/configs/example/hsaTopology.py b/configs/example/hsaTopology.py
index 78fe1f7..78193e0 100644
--- a/configs/example/hsaTopology.py
+++ b/configs/example/hsaTopology.py
@@ -156,6 +156,9 @@
file_append((node_dir, 'gpu_id'), 22124)
file_append((node_dir, 'name'), 'Vega\n')
+ # Should be the same as the render driver filename
(dri/renderD<drm_num>)
+ drm_num = 128
+
# 96 in real Vega
# Random comment for comparison purposes
caches = 0
@@ -200,7 +203,7 @@
'vendor_id 4098\n' + \
'device_id 26720\n' + \
'location_id 1024\n' + \
- 'drm_render_minor 128\n' + \
+ 'drm_render_minor %s\n' % drm_num + \
'hive_id 0\n' + \
'num_sdma_engines 2\n' + \
'num_sdma_xgmi_engines 0\n' + \
@@ -329,6 +332,9 @@
file_append((node_dir, 'gpu_id'), 50156)
file_append((node_dir, 'name'), 'Fiji\n')
+ # Should be the same as the render driver filename
(dri/renderD<drm_num>)
+ drm_num = 128
+
# Real Fiji shows 96, but building that topology is complex and doesn't
# appear to be required for anything.
caches = 0
@@ -373,6 +379,7 @@
'vendor_id
4098\n' + \
'device_id
29440\n' + \
'location_id
512\n' + \
+ 'drm_render_minor %s\n' %
drm_num + \
'max_engine_clk_fcompute %s\n'
\
% int(toFrequency(options.gpu_clock) /
1e6) + \
'local_mem_size
4294967296\n' + \
@@ -424,6 +431,9 @@
mem_banks_cnt = 1
+ # Should be the same as the render driver filename
(dri/renderD<drm_num>)
+ drm_num = 128
+
# populate global node properties
# NOTE: SIMD count triggers a valid GPU agent creation
node_prop = 'cpu_cores_count %s\n' %
options.num_cpus + \
@@ -446,6 +456,7 @@
'vendor_id
4098\n' + \
'device_id
39028\n' + \
'location_id
8\n' + \
+ 'drm_render_minor %s\n' %
drm_num + \
'max_engine_clk_fcompute %s\n'
\
% int(toFrequency(options.gpu_clock) /
1e6) + \
'local_mem_size
0\n' + \
diff --git a/src/gpu-compute/GPU.py b/src/gpu-compute/GPU.py
index 579c84b..ace83a5 100644
--- a/src/gpu-compute/GPU.py
+++ b/src/gpu-compute/GPU.py
@@ -254,6 +254,10 @@
# default value: 5/C_RO_S (only allow caching in GL2 for read. Shared)
m_type = Param.Int("Default MTYPE for cache. Valid values between
0-7");
+class GPURenderDriver(EmulatedDriver):
+ type = 'GPURenderDriver'
+ cxx_header = 'gpu-compute/gpu_render_driver.hh'
+
class GPUDispatcher(SimObject):
type = 'GPUDispatcher'
cxx_header = 'gpu-compute/dispatcher.hh'
diff --git a/src/gpu-compute/SConscript b/src/gpu-compute/SConscript
index adb9b0e..ae0bfab 100644
--- a/src/gpu-compute/SConscript
+++ b/src/gpu-compute/SConscript
@@ -52,6 +52,7 @@
Source('gpu_compute_driver.cc')
Source('gpu_dyn_inst.cc')
Source('gpu_exec_context.cc')
+Source('gpu_render_driver.cc')
Source('gpu_static_inst.cc')
Source('gpu_tlb.cc')
Source('lds_state.cc')
diff --git a/src/gpu-compute/gpu_render_driver.cc
b/src/gpu-compute/gpu_render_driver.cc
new file mode 100644
index 0000000..1af83cb
--- /dev/null
+++ b/src/gpu-compute/gpu_render_driver.cc
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2021 Kyle Roarty
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "gpu-compute/gpu_render_driver.hh"
+
+#include "params/GPURenderDriver.hh"
+#include "sim/fd_entry.hh"
+
+GPURenderDriver::GPURenderDriver(const GPURenderDriverParams &p)
+ : EmulatedDriver(p)
+{
+}
+
+/* ROCm 4 utilizes the render driver located at /dev/dri/renderDXXX. This
+ * patch implements a very simple driver that just returns a file
+ * descriptor when opened, as testing has shown that's all that's needed
+ */
+int
+GPURenderDriver::open(ThreadContext *tc, int mode, int flags)
+{
+ auto process = tc->getProcessPtr();
+ auto device_fd_entry = std::make_shared<DeviceFDEntry>(this, filename);
+ int tgt_fd = process->fds->allocFD(device_fd_entry);
+ return tgt_fd;
+}
diff --git a/src/gpu-compute/gpu_render_driver.hh
b/src/gpu-compute/gpu_render_driver.hh
new file mode 100644
index 0000000..d070668
--- /dev/null
+++ b/src/gpu-compute/gpu_render_driver.hh
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2021 Kyle Roarty
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __GPU_COMPUTE_GPU_RENDER_DRIVER_HH__
+#define __GPU_COMPUTE_GPU_RENDER_DRIVER_HH__
+
+#include "cpu/thread_context.hh"
+#include "sim/emul_driver.hh"
+#include "sim/process.hh"
+
+struct GPURenderDriverParams;
+
+class GPURenderDriver final : public EmulatedDriver
+{
+ public:
+ GPURenderDriver(const GPURenderDriverParams &p);
+
+ int open(ThreadContext *tc, int mode, int flags) override;
+
+ int
+ ioctl(ThreadContext *tc, unsigned req, Addr buf)
+ {
+ return -EBADF;
+ }
+};
+
+#endif
4 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the
submitted one.
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/46244
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: I65602346cbf17b2dc80e114046ebf5c9830a1507
Gerrit-Change-Number: 46244
Gerrit-PatchSet: 6
Gerrit-Owner: Kyle Roarty <kyleroarty1...@gmail.com>
Gerrit-Reviewer: Alex Dutu <alexandru.d...@amd.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: Kyle Roarty <kyleroarty1...@gmail.com>
Gerrit-Reviewer: Matt Sinclair <mattdsincl...@gmail.com>
Gerrit-Reviewer: Matthew Poremba <matthew.pore...@amd.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s