요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
DRM 기반과 GPU 구분
introduction.rst:43-73DRM core를 재사용하면서 major 261과 accel 전용 char device·sysfs·debugfs 경로로 graphics stack과 분리합니다.
Driver 통합 절차
introduction.rst:74-110CONFIG_DRM_ACCEL, DRIVER_COMPUTE_ACCEL과 accel_open()을 적용하고 DRM의 contribution 규칙을 따릅니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
============
Introduction
============
The Linux compute accelerators subsystem is designed to expose compute
accelerators in a common way to user-space and provide a common set of
functionality.
These devices can be either stand-alone ASICs or IP blocks inside an SoC/GPU.
Although these devices are typically designed to accelerate
Machine-Learning (ML) and/or Deep-Learning (DL) computations, the accel layer
is not limited to handling these types of accelerators.
Typically, a compute accelerator will belong to one of the following
categories:
- Edge AI - doing inference at an edge device. It can be an embedded ASIC/FPGA,
or an IP inside a SoC (e.g. laptop web camera). These devices
are typically configured using registers and can work with or without DMA.
- Inference data-center - single/multi user devices in a large server. This
type of device can be stand-alone or an IP inside a SoC or a GPU. It will
have on-board DRAM (to hold the DL topology), DMA engines and
command submission queues (either kernel or user-space queues).
It might also have an MMU to manage multiple users and might also enable
virtualization (SR-IOV) to support multiple VMs on the same device. In
addition, these devices will usually have some tools, such as profiler and
debugger.
- Training data-center - Similar to Inference data-center cards, but typically
have more computational power and memory b/w (e.g. HBM) and will likely have
a method of scaling-up/out, i.e. connecting to other training cards inside
the server or in other servers, respectively.
All these devices typically have different runtime user-space software stacks,
that are tailored-made to their h/w. In addition, they will also probably
include a compiler to generate programs to their custom-made computational
engines. Typically, the common layer in user-space will be the DL frameworks,
such as PyTorch and TensorFlow.
Sharing code with DRM
=====================
Because this type of devices can be an IP inside GPUs or have similar
characteristics as those of GPUs, the accel subsystem will use the
DRM subsystem's code and functionality. i.e. the accel core code will
be part of the DRM subsystem and an accel device will be a new type of DRM
device.
This will allow us to leverage the extensive DRM code-base and
collaborate with DRM developers that have experience with this type of
devices. In addition, new features that will be added for the accelerator
drivers can be of use to GPU drivers as well.
Differentiation from GPUs
=========================
Because we want to prevent the extensive user-space graphic software stack
from trying to use an accelerator as a GPU, the compute accelerators will be
differentiated from GPUs by using a new major number and new device char files.
Furthermore, the drivers will be located in a separate place in the kernel
tree - drivers/accel/.
The accelerator devices will be exposed to the user space with the dedicated
261 major number and will have the following convention:
- device char files - /dev/accel/accel\*
- sysfs - /sys/class/accel/accel\*/
- debugfs - /sys/kernel/debug/accel/\*/
Getting Started
===============
First, read the DRM documentation at Documentation/gpu/index.rst.
Not only it will explain how to write a new DRM driver but it will also
contain all the information on how to contribute, the Code Of Conduct and
what is the coding style/documentation. All of that is the same for the
accel subsystem.
Second, make sure the kernel is configured with CONFIG_DRM_ACCEL.
To expose your device as an accelerator, two changes are needed to
be done in your driver (as opposed to a standard DRM driver):
- Add the DRIVER_COMPUTE_ACCEL feature flag in your drm_driver's
driver_features field. It is important to note that this driver feature is
mutually exclusive with DRIVER_RENDER and DRIVER_MODESET. Devices that want
to expose both graphics and compute device char files should be handled by
two drivers that are connected using the auxiliary bus framework.
- Change the open callback in your driver fops structure to accel_open().
Alternatively, your driver can use DEFINE_DRM_ACCEL_FOPS macro to easily
set the correct function operations pointers structure.
External References
===================
email threads
-------------
* `Initial discussion on the New subsystem for acceleration devices <https://lore.kernel.org/lkml/CAFCwf11=9qpNAepL7NL+YAV_QO=Wv6pnWPhKHKAepK3fNn+2Dg@mail.gmail.com/>`_ - Oded Gabbay (2022)
* `patch-set to add the new subsystem <https://lore.kernel.org/lkml/[email protected]/>`_ - Oded Gabbay (2022)
Conference talks
----------------
* `LPC 2022 Accelerators BOF outcomes summary <https://airlied.blogspot.com/2022/09/accelerators-bof-outcomes-summary.html>`_ - Dave Airlie (2022)
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Accelerator subsystem의 범위
1-42`GPL-2.0`로 배포되는 Linux compute accelerators subsystem은 compute accelerator를 userspace에 공통 방식으로 노출하고 공통 기능 집합을 제공합니다. Device는 standalone ASIC일 수도 있고 SoC/GPU 내부 IP block일 수도 있습니다. 일반적으로 ML 또는 DL 연산 가속용이지만 accel layer는 이런 accelerator만 처리하도록 제한되지 않습니다.
Edge AI는 edge device에서 inference를 수행하며 embedded ASIC/FPGA 또는 laptop web camera 같은 SoC 내부 IP일 수 있습니다. 보통 register로 구성하고 DMA가 있거나 없어도 동작합니다. Inference data-center device는 large server의 single/multi-user device로 standalone 또는 SoC/GPU 내부 IP일 수 있습니다. DL topology를 담는 onboard DRAM, DMA engine, kernel 또는 userspace command submission queue를 갖습니다. Multi-user MMU와 여러 VM을 위한 SR-IOV virtualization, profiler와 debugger 같은 tool도 제공할 수 있습니다.
Training data-center card는 inference card와 비슷하지만 대개 compute power와 HBM 같은 memory bandwidth가 더 크고, server 내부 다른 training card와 연결하는 scale-up 또는 다른 server의 card와 연결하는 scale-out 방법을 제공합니다. 이 device들은 hardware에 맞춘 서로 다른 runtime userspace stack과 custom compute engine program을 생성하는 compiler를 보통 포함합니다. Userspace의 공통 layer는 PyTorch, TensorFlow 같은 DL framework입니다.
Deployment 위치와 전형적인 hardware/runtime 기능을 비교합니다.
DRM code 공유
43-56Accelerator가 GPU 내부 IP이거나 GPU와 유사한 특성을 가질 수 있으므로 accel subsystem은 DRM subsystem의 code와 기능을 사용합니다. Accel core code는 DRM subsystem의 일부이고 accel device는 새로운 DRM device type입니다.
이를 통해 방대한 DRM codebase와 이러한 device 경험이 있는 DRM developer의 지식을 활용할 수 있습니다. Accelerator driver에 추가되는 새 기능도 GPU driver에 유용할 수 있습니다.
새 device type을 두되 공통 core와 개발 경험을 공유합니다.
GPU와의 구분
57-73광범위한 userspace graphics stack이 accelerator를 GPU로 사용하려 들지 않게 compute accelerator는 새 major number와 새 character device file로 GPU와 구분합니다. Driver는 kernel tree의 별도 위치인 `drivers/accel/`에 둡니다.
Accelerator device는 전용 major number `261`로 userspace에 노출합니다. Character device는 `/dev/accel/accel*`, sysfs는 `/sys/class/accel/accel*/`, debugfs는 `/sys/kernel/debug/accel/*/` 규칙을 사용합니다.
GPU graphics node와 구분하는 dedicated major와 path conventions입니다.
Driver 작성 시작하기
74-97먼저 `Documentation/gpu/index.rst`의 DRM 문서를 읽어야 합니다. 새 DRM driver 작성법뿐 아니라 contribution, Code Of Conduct, coding style과 documentation 정보가 있고 accel subsystem에도 같은 규칙이 적용됩니다. Kernel은 `CONFIG_DRM_ACCEL`로 구성해야 합니다.
Standard DRM driver와 비교해 accelerator로 device를 노출하려면 두 가지를 바꿉니다. 첫째, `drm_driver`의 `driver_features` field에 `DRIVER_COMPUTE_ACCEL` feature flag를 추가합니다. 이 feature는 `DRIVER_RENDER`, `DRIVER_MODESET`과 상호 배타적입니다. Graphics와 compute character device를 모두 노출하려면 auxiliary bus framework로 연결한 driver 두 개가 처리해야 합니다.
둘째, driver `fops` structure의 open callback을 `accel_open()`으로 바꿉니다. 또는 `DEFINE_DRM_ACCEL_FOPS` macro를 사용해 올바른 file operation pointer structure를 간단히 설정할 수 있습니다.
공통 DRM 지식을 바탕으로 accelerator-specific identity를 설정합니다.
외부 논의와 발표
98-110외부 참고 자료는 Oded Gabbay가 2022년에 시작한 acceleration device 신규 subsystem 논의와 subsystem 추가 patch set, Dave Airlie의 LPC 2022 Accelerators BOF 결과 요약입니다.
- Initial discussion on the New subsystem for acceleration devices
https://lore.kernel.org/lkml/CAFCwf11=9qpNAepL7NL+YAV_QO=Wv6pnWPhKHKAepK3fNn+2Dg@mail.gmail.com/ - Patch-set to add the new subsystem
https://lore.kernel.org/lkml/[email protected]/ - LPC 2022 Accelerators BOF outcomes summary
https://airlied.blogspot.com/2022/09/accelerators-bof-outcomes-summary.html
Device 범위와 유형
introduction.rst:1-42Edge inference, data-center inference와 training accelerator를 공통 userspace interface로 노출합니다.