← Documents Documentation/arch/arm/nwfpe/todo.rst GitHub 원문 ↗

Linux 6.18.37 · Architecture

NWFPE TODO List

미구현 transcendental instruction의 table·CORDIC 접근과 FPCR 기반 rounding-mode override의 호환성 문제를 정리합니다.

Source pathDocumentation/arch/arm/nwfpe/todo.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

todo.rst:1-72

TODO는 두 축입니다. POW·LOG·SIN 같은 transcendental operation을 정확하고 빠르게 구현하는 일, 그리고 instruction-local rounding이라는 FPA11 규칙을 깨지 않으면서 global rounding mode를 제공할지 결정하는 일입니다.

NWFPE 향후 작업
transcendental opstable method or CORDICaccuracy / speed
rounding overrideFPCR + kernel callportability risk

수학 구현과 rounding control은 각각 성능·정확도와 ABI·hardware 호환성을 저울질합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 TODO LIST
2 =========
3
4 ::
5
6 POW{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - power
7 RPW{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - reverse power
8 POL{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - polar angle (arctan2)
9
10 LOG{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - logarithm to base 10
11 LGN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - logarithm to base e
12 EXP{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - exponent
13 SIN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - sine
14 COS{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - cosine
15 TAN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - tangent
16 ASN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - arcsine
17 ACS{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - arccosine
18 ATN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - arctangent
19
20 These are not implemented. They are not currently issued by the compiler,
21 and are handled by routines in libc. These are not implemented by the FPA11
22 hardware, but are handled by the floating point support code. They should
23 be implemented in future versions.
24
25 There are a couple of ways to approach the implementation of these. One
26 method would be to use accurate table methods for these routines. I have
27 a couple of papers by S. Gal from IBM's research labs in Haifa, Israel that
28 seem to promise extreme accuracy (in the order of 99.8%) and reasonable speed.
29 These methods are used in GLIBC for some of the transcendental functions.
30
31 Another approach, which I know little about is CORDIC. This stands for
32 Coordinate Rotation Digital Computer, and is a method of computing
33 transcendental functions using mostly shifts and adds and a few
34 multiplications and divisions. The ARM excels at shifts and adds,
35 so such a method could be promising, but requires more research to
36 determine if it is feasible.
37
38 Rounding Methods
39 ----------------
40
41 The IEEE standard defines 4 rounding modes. Round to nearest is the
42 default, but rounding to + or - infinity or round to zero are also allowed.
43 Many architectures allow the rounding mode to be specified by modifying bits
44 in a control register. Not so with the ARM FPA11 architecture. To change
45 the rounding mode one must specify it with each instruction.
46
47 This has made porting some benchmarks difficult. It is possible to
48 introduce such a capability into the emulator. The FPCR contains
49 bits describing the rounding mode. The emulator could be altered to
50 examine a flag, which if set forced it to ignore the rounding mode in
51 the instruction, and use the mode specified in the bits in the FPCR.
52
53 This would require a method of getting/setting the flag, and the bits
54 in the FPCR. This requires a kernel call in ArmLinux, as WFC/RFC are
55 supervisor only instructions. If anyone has any ideas or comments I
56 would like to hear them.
57
58 NOTE:
59 pulled out from some docs on ARM floating point, specifically
60 for the Acorn FPE, but not limited to it:
61
62 The floating point control register (FPCR) may only be present in some
63 implementations: it is there to control the hardware in an implementation-
64 specific manner, for example to disable the floating point system. The user
65 mode of the ARM is not permitted to use this register (since the right is
66 reserved to alter it between implementations) and the WFC and RFC
67 instructions will trap if tried in user mode.
68
69 Hence, the answer is yes, you could do this, but then you will run a high
70 risk of becoming isolated if and when hardware FP emulation comes out
71
72 -- Russell.
73

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

TODO LIST

1-23

아직 구현되지 않은 transcendental library-call instruction은 다음과 같습니다.

POW{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - power
RPW{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - reverse power
POL{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - polar angle (arctan2)

LOG{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - logarithm to base 10
LGN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - logarithm to base e
EXP{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - exponent
SIN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - sine
COS{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - cosine
TAN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - tangent
ASN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - arcsine
ACS{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - arccosine
ATN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - arctangent

compiler가 현재 이 instruction을 emit하지 않고 libc routine이 처리합니다. FPA11 hardware에도 구현되지 않고 floating-point support code가 처리하지만 향후 emulator version에서 구현할 대상으로 남아 있습니다.

Implementation approaches

24-37

첫 번째 접근은 정확한 table method입니다. IBM Haifa research lab의 S. Gal 논문은 약 99.8% 수준의 높은 정확도와 합리적인 속도를 제시하며 GLIBC도 일부 transcendental function에 이 방식을 사용합니다.

다른 접근은 CORDIC(Coordinate Rotation Digital Computer)입니다. shift와 add를 주로 쓰고 소수의 multiply/divide로 transcendental function을 계산합니다. ARM은 shift와 add에 강하므로 유망할 수 있지만 실제 적용 가능성은 더 연구해야 합니다.

Rounding Methods

38-57

IEEE standard에는 4개 rounding mode가 있습니다. nearest가 기본이고 +infinity, -infinity, zero 방향도 허용됩니다.

rounding mode설명
nearest기본값
+infinity양의 무한대 방향
-infinity음의 무한대 방향
zero0 방향

많은 architecture는 control register bit로 mode를 정하지만 ARM FPA11은 각 instruction에 mode를 지정해야 합니다. 이 차이는 benchmark port를 어렵게 만들었습니다.

emulator의 `FPCR`에는 rounding mode bit가 있으므로 flag를 추가해 instruction의 mode를 무시하고 FPCR mode를 강제할 수 있습니다. 다만 flag와 FPCR bit를 get/set할 방법이 필요하고 `WFC`/`RFC`가 supervisor-only이므로 ArmLinux kernel call이 필요합니다.

FPCR portability note

58-72

Acorn FPE를 비롯한 ARM floating-point 문서에서 가져온 note입니다. `FPCR`은 일부 구현에만 있을 수 있고 floating-point system disable 같은 implementation-specific hardware control에 사용됩니다.

ARM user mode는 구현마다 달라질 수 있는 이 register를 사용할 수 없습니다. user mode에서 `WFC`나 `RFC`를 시도하면 trap이 발생합니다.

Russell의 결론은 기술적으로 해당 기능을 넣을 수는 있지만 hardware FP emulation이 등장할 때 다른 구현과 고립될 위험이 크다는 것입니다.