HSA Programmer's Reference Manual: HSAIL Virtual ISA And
Total Page:16
File Type:pdf, Size:1020Kb
HSA Foundation Proprietary HSA Programmer’s Reference Manual: HSAIL Virtual ISA and Programming Model, Compiler Writer’s Guide, and Object Format (BRIG) Publication #: 49828 ∙ Rev: Version 0.95 ∙ Issue Date: 1 May 2013 HSA Foundation Proprietary HSA Programmer’s Reference Manual: HSAIL Virtual ISA and Programming PID: 49828 ∙ Rev: Version 0.95 ∙ 1 May 2013 Model, Compiler Writer’s Guide, and Object Format (BRIG) © 2013 HSA Foundation. All rights reserved. The contents of this document are provided in connection with the HSA Foundation specifications. This specification is protected by copyright laws and contains material proprietary to the HSA Foundation. It or any components may not be reproduced, republished, distributed, transmitted, displayed, broadcast or otherwise exploited in any manner without the express prior written permission of HSA Foundation. You may use this specification for implementing the functionality therein, without altering or removing any trademark, copyright or other notice from the specification, but the receipt or possession of this specification does not convey any rights to reproduce, disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, in whole or in part. HSA Foundation grants express permission to any current Founder, Promoter, Supporter Contributor, Academic or Associate member of HSA Foundation to copy and redistribute UNMODIFIED versions of this specification in any fashion, provided that NO CHARGE is made for the specification and the latest available update of the specification for any version of the API is used whenever possible. Such distributed specification may be re-formatted AS LONG AS the contents of the specification are not changed in any way. The specification may be incorporated into a product that is sold as long as such product includes significant independent work developed by the seller. A link to the current version of this specification on the HSA Foundation web-site should be included whenever possible with specification distributions. HSA Foundation makes no, and expressly disclaims any, representations or warranties, express or implied, regarding this specification, including, without limitation, any implied warranties of merchantability or fitness for a particular purpose or non-infringement of any intellectual property. HSA Foundation makes no, and expressly disclaims any, warranties, express or implied, regarding the correctness, accuracy, completeness, timeliness, and reliability of the specification. Under no circumstances will the HSA Foundation, or any of its Founders, Promoters, Supporters, Academic, Contributors, and Associates members or their respective partners, officers, directors, employees, agents or representatives be liable for any damages, whether direct, indirect, special or consequential damages for lost revenues, lost profits, or otherwise, arising from or in connection with these materials. ii HSA Foundation Proprietary PID: 49828 ∙ Rev: Version 0.95 ∙ 1 May 2013 HSA Programmer’s Reference Manual: HSAIL Virtual ISA and Programming Model, Compiler Writer’s Guide, and Object Format (BRIG) Acknowledgements The HSAIL specification is the result of the contributions of many people. Here is a partial list of the contributors, including the company that they represented at the time of their contribution: • Paul Blinzer AMD • Mark Fowler AMD • Mike Houston AMD • Lee Howes AMD • Roy Ju AMD • Bill Licea-Kane AMD • Leonid Lobachev AMD • Mike Mantor AMD • Vicki Meagher AMD • Dmitry Preobrazhensky AMD • Phil Rogers AMD • Norm Rubin AMD • Benjamin Sander AMD • Elizabeth Sanville AMD • Oleg Semenov AMD • Brian Sumner AMD • Yaki Tebeka AMD • Tony Tye AMD • Micah Villmow AMD • Jem Davies ARM • Ian Devereux ARM • Robert Elliott ARM • Alexander Galazin ARM • Rune Holm ARM • Kurt Shuler Arteris • Greg Stoner HSA Foundation • Theo Drane Imagination Technologies • Yoong-Chert Foo Imagination Technologies Acknowledgements iii HSA Foundation Proprietary HSA Programmer’s Reference Manual: HSAIL Virtual ISA and Programming PID: 49828 ∙ Rev: Version 0.95 ∙ 1 May 2013 Model, Compiler Writer’s Guide, and Object Format (BRIG) • John Howson Imagination Technologies • Georg Kolling Imagination Technologies • James McCarthy Imagination Technologies • Jason Meridith Imagination Technologies • Mark Rankilor Imagination Technologies • Chien-Ping Lu MediaTek Inc. • Thomas Jablin MulticoreWare Inc. • Chuang Na MulticoreWare Inc. • Greg Bellows Qualcomm • P.J. Bostley Qualcomm • Alex Bourd Qualcomm • Ken Dockser Qualcomm • Jamie Esliger Qualcomm • Ben Gaster Qualcomm • Andrew Gruber Qualcomm • Wilson Kwan Qualcomm • Bob Rychlik Qualcomm • Ignacio Llamas Samsung Electronics Co, Ltd • Soojung Ryu Samsung Electronics Co, Ltd • Matthew Locke Texas Instruments • Chelsi Odegaard VTM Group iv Acknowledgements HSA Foundation Proprietary PID: 49828 ∙ Rev: Version 0.95 ∙ 1 May 2013 HSA Programmer’s Reference Manual: HSAIL Virtual ISA and Programming Model, Compiler Writer’s Guide, and Object Format (BRIG) About the HSA Programmer's Reference Manual This document describes the Heterogeneous System Architecture Intermediate Language (HSAIL), which is a virtual machine and an intermediate language. This document serves as the specification for the HSAIL language for HSA implementers. Note that there are a wide variety of methods for implementing these requirements. Audience This document is written for developers involved in developing an HSA implementation. Terminology This document shows new terms in italics. See Appendix C Glossary of HSAIL Terms (p. 327) for their definitions. HSA Information Sources • HSA Programmer's Reference Manual - publication # 49828 • HSA Software System Architecture Specification - publication # 51958 • HSA Hardware System Architecture Specification - publication # 50830 • The OpenCL™ Specification: http://www.khronos.org/registry/cl/specs/ opencl-1.2.pdf About the HSA Programmer's Reference Manual v HSA Foundation Proprietary HSA Programmer’s Reference Manual: HSAIL Virtual ISA and Programming PID: 49828 ∙ Rev: Version 0.95 ∙ 1 May 2013 Model, Compiler Writer’s Guide, and Object Format (BRIG) vi About the HSA Programmer's Reference Manual HSA Foundation Proprietary PID: 49828 ∙ Rev: Version 0.95 ∙ 1 May 2013 HSA Programmer’s Reference Manual: HSAIL Virtual ISA and Programming Model, Compiler Writer’s Guide, and Object Format (BRIG) Contents Chapter 1 Overview . 1 1.1 What Is HSAIL? . 1 1.2 HSAIL Virtual Language . 2 Chapter 2 HSAIL Programming Model . 5 2.1 Overview of Grids, Work-Groups, and Work-Items . 5 2.2 Work-Groups . .7 2.2.1 Work-Group ID . 7 2.2.2 Work-Group Flattened ID . 8 2.3 Work-Items . 8 2.3.1 Work-Item ID . 8 2.3.2 Work-Item Flattened ID . 9 2.3.3 Work-Item Absolute ID . 9 2.3.4 Work-Item Flattened Absolute ID . .9 2.4 Scalable Data-Parallel Computing . 10 2.5 Active Work-Groups and Active Work-Items . 10 2.6 Wavefronts, Lanes, and Wavefront Sizes . .11 2.6.1 Example of Contents of a Wavefront . 11 2.6.2 Wavefront Size . 12 2.7 Types of Memory . 13 2.8 Segments . 13 2.8.1 Types of Segments . 14 2.8.2 Shared Virtual Memory . 16 2.8.3 Addressing for Segments . 17 2.9 Flat Memory and Agents . ..