Neuer Compiler GCC 6 mit HSA- und Zen-Support

Der schon län­ger ange­kün­dig­te Com­pi­ler GCC in der Ver­si­on 6 steht offen­bar kurz vor der Ver­öf­fent­li­chung. GCC ist der Stan­dard-Com­pi­ler unter Linux, mit dem die C‑Quellcodes in aus­führ­ba­re Maschi­nen­spra­che über­setzt werden.

Neu in der Ver­si­on 6 ist die Unter­stüt­zung für AMDs kom­men­de CPU-Archi­tek­tur Zen sowie für HSA, also der zur Lösung einer Auf­ga­be gemein­sam von CPU und GPU genutz­te Spei­cher, erst­mals unter­stützt in AMDs Kaveri-APUs, voll in Carrizo.

Hier die für die x86-Welt rele­van­te Fea­ture­lis­te von GCC 6:

Hete­ro­ge­neous Sys­tems Architecture

GCC can now gene­ra­te HSAIL (Hete­ro­ge­neous Sys­tem Archi­tec­tu­re Inter­me­dia­te Lan­guage) for simp­le OpenMP device con­s­tructs if con­fi­gu­red with –enable-offload-targets=hsa. A new libgomp plug­in then runs the HSA GPU ker­nels imple­men­ting the­se con­s­tructs on HSA capa­ble GPUs via a stan­dard HSA run time.

If the HSA com­pi­la­ti­on back end deter­mi­nes it can­not out­put HSAIL for a par­ti­cu­lar input, it gives a war­ning by default. The­se war­nings can be sup­pres­sed with ‑Wno-hsa. To give a few examp­les, the HSA back end does not imple­ment com­pi­la­ti­on of code using func­tion poin­ters, auto­ma­tic allo­ca­ti­on of varia­ble sized arrays, func­tions with varia­dic argu­ments as well as a num­ber of other less com­mon pro­gramming constructs.

When com­pi­la­ti­on for HSA is enab­led, the com­pi­ler attempts to com­pi­le com­po­si­te OpenMP constructs
#prag­ma omp tar­get teams dis­tri­bu­te par­al­lel for
into par­al­lel HSA GPU kernels.

IA-32/x86-64

GCC now sup­ports the Intel CPU named Sky­la­ke with AVX-512 exten­si­ons through ‑march=skylake-avx512. The switch enables the fol­lo­wing ISA exten­si­ons: AVX-512F, AVX512VL, AVX-512CD, AVX-512BW, AVX-512DQ.

Sup­port for new AMD ins­truc­tions moni­torx and mwaitx has been added. This includes new intrin­sic and built-in sup­port. It is enab­led through opti­on ‑mmwaitx. The ins­truc­tions moni­torx and mwaitx imple­ment the same func­tion­a­li­ty as the old moni­tor and mwait ins­truc­tions. In addi­ti­on mwaitx adds a con­fi­gura­ble timer. The timer value is recei­ved as third argu­ment and stored in regis­ter %ebx.

x86-64 tar­gets now allow stack rea­lignment from a word-ali­gned stack poin­ter using the com­mand-line opti­on ‑mstack­rea­lign or __attribute__ ((force_align_arg_pointer)). This allows func­tions com­pi­led with a vec­tor-ali­gned stack to be invo­ked from objects that keep only word-alignment.

Sup­port for address spaces __seg_fs, __seg_gs, and __seg_tls. The­se can be used to access data via the %fs and %gs seg­ments wit­hout having to resort to inline assem­bly. Plea­se refer to the docu­men­ta­ti­on for usa­ge instructions.

Sup­port for AMD Zen (fami­ly 17h) pro­ces­sors is now available through the ‑march=znver1 and ‑mtune=znver1 options.

Lei­der wer­den die meis­ten Dis­tri­bu­tio­nen und Anwen­dun­gen nicht auto­ma­tisch in den Genuss der Opti­mie­run­gen kom­men, da die Pake­te in der Regel vor­kom­pi­liert aus Repo­si­to­rys gela­den wer­den. Wer opti­mier­ten Code möch­te, muss eine Dis­tri­bu­ti­on wäh­len, die aus Quell­code kom­pi­liert wird oder sich wenigs­tens die rele­van­ten Anwen­dun­gen selbst aus dem Quell­code kom­pi­lie­ren, was bei Open-Source-Soft­ware zumin­dest theo­re­tisch mach­bar ist – die ent­spre­chen­den Fähig­kei­ten vorausgesetzt.

Wie­viel opti­mier­ter Code brin­gen kann, sieht man an den GCC-Kom­pi­la­ten mit ver­schie­de­nen CPU-Flags, die wir vor eini­ger Zeit für die Bull­do­zer-Archi­tek­tur ver­öf­fent­licht haben. Hier ein Kom­men­tar dazu aus dem dama­li­gen Artikel:

Wenig über­ra­schend dau­ert das Encoden einer WAV ins MP3-For­mat weni­ger lang, je stär­ker das Kom­pi­lat auf die CPU-Archi­tek­tur opti­miert ist. Die Unter­schie­de inner­halb der Kom­pi­la­te jedoch lie­gen immer auf ähn­li­chem Niveau. Steam­rol­ler ist ~5 % schnel­ler als Piledri­ver und Excava­tor legt noch mal 10 Pro­zent­punk­te drauf. So lie­gen zwi­schen dem Enco­die­ren mit dem Stan­dard-Kom­pi­lat auf Piledri­ver und dem des maxi­mal opti­mier­ten auf Excava­tor immer­hin 65 % Per­for­mance-Gewinn für die­sel­be WAV bei iden­ti­scher Kon­fi­gu­ra­ti­on und iden­ti­schem Takt. Hal­lo Soft­ware-Ent­wick­ler! Hier schlum­mert Poten­zi­al, das ein­fach per Com­pi­ler-Flag akti­viert wer­den kann!

Quel­le: GCC 6 Release Series Chan­ges, New Fea­tures, and Fixes