Path: blob/21.2-virgl/src/amd/common/amd_kernel_code_t.h
7075 views
/*1* Copyright 2015,2016 Advanced Micro Devices, Inc.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* on the rights to use, copy, modify, merge, publish, distribute, sub7* license, and/or sell copies of the Software, and to permit persons to whom8* the Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20* USE OR OTHER DEALINGS IN THE SOFTWARE.21*22*/2324#ifndef AMDKERNELCODET_H25#define AMDKERNELCODET_H2627//---------------------------------------------------------------------------//28// AMD Kernel Code, and its dependencies //29//---------------------------------------------------------------------------//3031// Sets val bits for specified mask in specified dst packed instance.32#define AMD_HSA_BITS_SET(dst, mask, val) \33dst &= (~(1 << mask##_SHIFT) & ~mask); \34dst |= (((val) << mask##_SHIFT) & mask)3536// Gets bits for specified mask from specified src packed instance.37#define AMD_HSA_BITS_GET(src, mask) ((src & mask) >> mask##_SHIFT)3839/* Every amd_*_code_t has the following properties, which are composed of40* a number of bit fields. Every bit field has a mask (AMD_CODE_PROPERTY_*),41* bit width (AMD_CODE_PROPERTY_*_WIDTH, and bit shift amount42* (AMD_CODE_PROPERTY_*_SHIFT) for convenient access. Unused bits must be 0.43*44* (Note that bit fields cannot be used as their layout is45* implementation defined in the C standard and so cannot be used to46* specify an ABI)47*/48enum amd_code_property_mask_t49{5051/* Enable the setup of the SGPR user data registers52* (AMD_CODE_PROPERTY_ENABLE_SGPR_*), see documentation of amd_kernel_code_t53* for initial register state.54*55* The total number of SGPRuser data registers requested must not56* exceed 16. Any requests beyond 16 will be ignored.57*58* Used to set COMPUTE_PGM_RSRC2.USER_SGPR (set to total count of59* SGPR user data registers enabled up to 16).60*/6162AMD_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_BUFFER_SHIFT = 0,63AMD_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_BUFFER_WIDTH = 1,64AMD_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_BUFFER =65((1 << AMD_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_BUFFER_WIDTH) - 1)66<< AMD_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_BUFFER_SHIFT,6768AMD_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_PTR_SHIFT = 1,69AMD_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_PTR_WIDTH = 1,70AMD_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_PTR =71((1 << AMD_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_PTR_WIDTH) - 1)72<< AMD_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_PTR_SHIFT,7374AMD_CODE_PROPERTY_ENABLE_SGPR_QUEUE_PTR_SHIFT = 2,75AMD_CODE_PROPERTY_ENABLE_SGPR_QUEUE_PTR_WIDTH = 1,76AMD_CODE_PROPERTY_ENABLE_SGPR_QUEUE_PTR =77((1 << AMD_CODE_PROPERTY_ENABLE_SGPR_QUEUE_PTR_WIDTH) - 1)78<< AMD_CODE_PROPERTY_ENABLE_SGPR_QUEUE_PTR_SHIFT,7980AMD_CODE_PROPERTY_ENABLE_SGPR_KERNARG_SEGMENT_PTR_SHIFT = 3,81AMD_CODE_PROPERTY_ENABLE_SGPR_KERNARG_SEGMENT_PTR_WIDTH = 1,82AMD_CODE_PROPERTY_ENABLE_SGPR_KERNARG_SEGMENT_PTR =83((1 << AMD_CODE_PROPERTY_ENABLE_SGPR_KERNARG_SEGMENT_PTR_WIDTH) - 1)84<< AMD_CODE_PROPERTY_ENABLE_SGPR_KERNARG_SEGMENT_PTR_SHIFT,8586AMD_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_ID_SHIFT = 4,87AMD_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_ID_WIDTH = 1,88AMD_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_ID =89((1 << AMD_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_ID_WIDTH) - 1)90<< AMD_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_ID_SHIFT,9192AMD_CODE_PROPERTY_ENABLE_SGPR_FLAT_SCRATCH_INIT_SHIFT = 5,93AMD_CODE_PROPERTY_ENABLE_SGPR_FLAT_SCRATCH_INIT_WIDTH = 1,94AMD_CODE_PROPERTY_ENABLE_SGPR_FLAT_SCRATCH_INIT =95((1 << AMD_CODE_PROPERTY_ENABLE_SGPR_FLAT_SCRATCH_INIT_WIDTH) - 1)96<< AMD_CODE_PROPERTY_ENABLE_SGPR_FLAT_SCRATCH_INIT_SHIFT,9798AMD_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_SIZE_SHIFT = 6,99AMD_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_SIZE_WIDTH = 1,100AMD_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_SIZE =101((1 << AMD_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_SIZE_WIDTH) - 1)102<< AMD_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_SIZE_SHIFT,103104AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_X_SHIFT = 7,105AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_X_WIDTH = 1,106AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_X =107((1 << AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_X_WIDTH) - 1)108<< AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_X_SHIFT,109110AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_Y_SHIFT = 8,111AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_Y_WIDTH = 1,112AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_Y =113((1 << AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_Y_WIDTH) - 1)114<< AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_Y_SHIFT,115116AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_Z_SHIFT = 9,117AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_Z_WIDTH = 1,118AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_Z =119((1 << AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_Z_WIDTH) - 1)120<< AMD_CODE_PROPERTY_ENABLE_SGPR_GRID_WORKGROUP_COUNT_Z_SHIFT,121122AMD_CODE_PROPERTY_RESERVED1_SHIFT = 10,123AMD_CODE_PROPERTY_RESERVED1_WIDTH = 6,124AMD_CODE_PROPERTY_RESERVED1 = ((1 << AMD_CODE_PROPERTY_RESERVED1_WIDTH) - 1)125<< AMD_CODE_PROPERTY_RESERVED1_SHIFT,126127/* Control wave ID base counter for GDS ordered-append. Used to set128* COMPUTE_DISPATCH_INITIATOR.ORDERED_APPEND_ENBL. (Not sure if129* ORDERED_APPEND_MODE also needs to be settable)130*/131AMD_CODE_PROPERTY_ENABLE_ORDERED_APPEND_GDS_SHIFT = 16,132AMD_CODE_PROPERTY_ENABLE_ORDERED_APPEND_GDS_WIDTH = 1,133AMD_CODE_PROPERTY_ENABLE_ORDERED_APPEND_GDS =134((1 << AMD_CODE_PROPERTY_ENABLE_ORDERED_APPEND_GDS_WIDTH) - 1)135<< AMD_CODE_PROPERTY_ENABLE_ORDERED_APPEND_GDS_SHIFT,136137/* The interleave (swizzle) element size in bytes required by the138* code for private memory. This must be 2, 4, 8 or 16. This value139* is provided to the finalizer when it is invoked and is recorded140* here. The hardware will interleave the memory requests of each141* lane of a wavefront by this element size to ensure each142* work-item gets a distinct memory memory location. Therefore, the143* finalizer ensures that all load and store operations done to144* private memory do not exceed this size. For example, if the145* element size is 4 (32-bits or dword) and a 64-bit value must be146* loaded, the finalizer will generate two 32-bit loads. This147* ensures that the interleaving will get the work-item148* specific dword for both halves of the 64-bit value. If it just149* did a 64-bit load then it would get one dword which belonged to150* its own work-item, but the second dword would belong to the151* adjacent lane work-item since the interleaving is in dwords.152*153* The value used must match the value that the runtime configures154* the GPU flat scratch (SH_STATIC_MEM_CONFIG.ELEMENT_SIZE). This155* is generally DWORD.156*157* USE VALUES FROM THE AMD_ELEMENT_BYTE_SIZE_T ENUM.158*/159AMD_CODE_PROPERTY_PRIVATE_ELEMENT_SIZE_SHIFT = 17,160AMD_CODE_PROPERTY_PRIVATE_ELEMENT_SIZE_WIDTH = 2,161AMD_CODE_PROPERTY_PRIVATE_ELEMENT_SIZE =162((1 << AMD_CODE_PROPERTY_PRIVATE_ELEMENT_SIZE_WIDTH) - 1)163<< AMD_CODE_PROPERTY_PRIVATE_ELEMENT_SIZE_SHIFT,164165/* Are global memory addresses 64 bits. Must match166* amd_kernel_code_t.hsail_machine_model ==167* HSA_MACHINE_LARGE. Must also match168* SH_MEM_CONFIG.PTR32 (GFX6 (SI)/GFX7 (CI)),169* SH_MEM_CONFIG.ADDRESS_MODE (GFX8 (VI)+).170*/171AMD_CODE_PROPERTY_IS_PTR64_SHIFT = 19,172AMD_CODE_PROPERTY_IS_PTR64_WIDTH = 1,173AMD_CODE_PROPERTY_IS_PTR64 = ((1 << AMD_CODE_PROPERTY_IS_PTR64_WIDTH) - 1)174<< AMD_CODE_PROPERTY_IS_PTR64_SHIFT,175176/* Indicate if the generated ISA is using a dynamically sized call177* stack. This can happen if calls are implemented using a call178* stack and recursion, alloca or calls to indirect functions are179* present. In these cases the Finalizer cannot compute the total180* private segment size at compile time. In this case the181* workitem_private_segment_byte_size only specifies the statically182* know private segment size, and additional space must be added183* for the call stack.184*/185AMD_CODE_PROPERTY_IS_DYNAMIC_CALLSTACK_SHIFT = 20,186AMD_CODE_PROPERTY_IS_DYNAMIC_CALLSTACK_WIDTH = 1,187AMD_CODE_PROPERTY_IS_DYNAMIC_CALLSTACK =188((1 << AMD_CODE_PROPERTY_IS_DYNAMIC_CALLSTACK_WIDTH) - 1)189<< AMD_CODE_PROPERTY_IS_DYNAMIC_CALLSTACK_SHIFT,190191/* Indicate if code generated has support for debugging. */192AMD_CODE_PROPERTY_IS_DEBUG_SUPPORTED_SHIFT = 21,193AMD_CODE_PROPERTY_IS_DEBUG_SUPPORTED_WIDTH = 1,194AMD_CODE_PROPERTY_IS_DEBUG_SUPPORTED = ((1 << AMD_CODE_PROPERTY_IS_DEBUG_SUPPORTED_WIDTH) - 1)195<< AMD_CODE_PROPERTY_IS_DEBUG_SUPPORTED_SHIFT,196197AMD_CODE_PROPERTY_IS_XNACK_SUPPORTED_SHIFT = 22,198AMD_CODE_PROPERTY_IS_XNACK_SUPPORTED_WIDTH = 1,199AMD_CODE_PROPERTY_IS_XNACK_SUPPORTED = ((1 << AMD_CODE_PROPERTY_IS_XNACK_SUPPORTED_WIDTH) - 1)200<< AMD_CODE_PROPERTY_IS_XNACK_SUPPORTED_SHIFT,201202AMD_CODE_PROPERTY_RESERVED2_SHIFT = 23,203AMD_CODE_PROPERTY_RESERVED2_WIDTH = 9,204AMD_CODE_PROPERTY_RESERVED2 = ((1 << AMD_CODE_PROPERTY_RESERVED2_WIDTH) - 1)205<< AMD_CODE_PROPERTY_RESERVED2_SHIFT206};207208/* AMD Kernel Code Object (amd_kernel_code_t). GPU CP uses the AMD Kernel209* Code Object to set up the hardware to execute the kernel dispatch.210*211* Initial Kernel Register State.212*213* Initial kernel register state will be set up by CP/SPI prior to the start214* of execution of every wavefront. This is limited by the constraints of the215* current hardware.216*217* The order of the SGPR registers is defined, but the Finalizer can specify218* which ones are actually setup in the amd_kernel_code_t object using the219* enable_sgpr_* bit fields. The register numbers used for enabled registers220* are dense starting at SGPR0: the first enabled register is SGPR0, the next221* enabled register is SGPR1 etc.; disabled registers do not have an SGPR222* number.223*224* The initial SGPRs comprise up to 16 User SRGPs that are set up by CP and225* apply to all waves of the grid. It is possible to specify more than 16 User226* SGPRs using the enable_sgpr_* bit fields, in which case only the first 16227* are actually initialized. These are then immediately followed by the System228* SGPRs that are set up by ADC/SPI and can have different values for each wave229* of the grid dispatch.230*231* SGPR register initial state is defined as follows:232*233* Private Segment Buffer (enable_sgpr_private_segment_buffer):234* Number of User SGPR registers: 4. V# that can be used, together with235* Scratch Wave Offset as an offset, to access the Private/Spill/Arg236* segments using a segment address. It must be set as follows:237* - Base address: of the scratch memory area used by the dispatch. It238* does not include the scratch wave offset. It will be the per process239* SH_HIDDEN_PRIVATE_BASE_VMID plus any offset from this dispatch (for240* example there may be a per pipe offset, or per AQL Queue offset).241* - Stride + data_format: Element Size * Index Stride (???)242* - Cache swizzle: ???243* - Swizzle enable: SH_STATIC_MEM_CONFIG.SWIZZLE_ENABLE (must be 1 for244* scratch)245* - Num records: Flat Scratch Work Item Size / Element Size (???)246* - Dst_sel_*: ???247* - Num_format: ???248* - Element_size: SH_STATIC_MEM_CONFIG.ELEMENT_SIZE (will be DWORD, must249* agree with amd_kernel_code_t.privateElementSize)250* - Index_stride: SH_STATIC_MEM_CONFIG.INDEX_STRIDE (will be 64 as must251* be number of wavefront lanes for scratch, must agree with252* amd_kernel_code_t.wavefrontSize)253* - Add tid enable: 1254* - ATC: from SH_MEM_CONFIG.PRIVATE_ATC,255* - Hash_enable: ???256* - Heap: ???257* - Mtype: from SH_STATIC_MEM_CONFIG.PRIVATE_MTYPE258* - Type: 0 (a buffer) (???)259*260* Dispatch Ptr (enable_sgpr_dispatch_ptr):261* Number of User SGPR registers: 2. 64 bit address of AQL dispatch packet262* for kernel actually executing.263*264* Queue Ptr (enable_sgpr_queue_ptr):265* Number of User SGPR registers: 2. 64 bit address of AmdQueue object for266* AQL queue on which the dispatch packet was queued.267*268* Kernarg Segment Ptr (enable_sgpr_kernarg_segment_ptr):269* Number of User SGPR registers: 2. 64 bit address of Kernarg segment. This270* is directly copied from the kernargPtr in the dispatch packet. Having CP271* load it once avoids loading it at the beginning of every wavefront.272*273* Dispatch Id (enable_sgpr_dispatch_id):274* Number of User SGPR registers: 2. 64 bit Dispatch ID of the dispatch275* packet being executed.276*277* Flat Scratch Init (enable_sgpr_flat_scratch_init):278* Number of User SGPR registers: 2. This is 2 SGPRs.279*280* For CI/VI:281* The first SGPR is a 32 bit byte offset from SH_MEM_HIDDEN_PRIVATE_BASE282* to base of memory for scratch for this dispatch. This is the same offset283* used in computing the Scratch Segment Buffer base address. The value of284* Scratch Wave Offset must be added by the kernel code and moved to285* SGPRn-4 for use as the FLAT SCRATCH BASE in flat memory instructions.286*287* The second SGPR is 32 bit byte size of a single work-item's scratch288* memory usage. This is directly loaded from the dispatch packet Private289* Segment Byte Size and rounded up to a multiple of DWORD.290*291* \todo [Does CP need to round this to >4 byte alignment?]292*293* The kernel code must move to SGPRn-3 for use as the FLAT SCRATCH SIZE in294* flat memory instructions. Having CP load it once avoids loading it at295* the beginning of every wavefront.296*297* Private Segment Size (enable_sgpr_private_segment_size):298* Number of User SGPR registers: 1. The 32 bit byte size of a single299* work-item's scratch memory allocation. This is the value from the dispatch300* packet. Private Segment Byte Size rounded up by CP to a multiple of DWORD.301*302* \todo [Does CP need to round this to >4 byte alignment?]303*304* Having CP load it once avoids loading it at the beginning of every305* wavefront.306*307* \todo [This will not be used for CI/VI since it is the same value as308* the second SGPR of Flat Scratch Init.309*310* Grid Work-Group Count X (enable_sgpr_grid_workgroup_count_x):311* Number of User SGPR registers: 1. 32 bit count of the number of312* work-groups in the X dimension for the grid being executed. Computed from313* the fields in the HsaDispatchPacket as314* ((gridSize.x+workgroupSize.x-1)/workgroupSize.x).315*316* Grid Work-Group Count Y (enable_sgpr_grid_workgroup_count_y):317* Number of User SGPR registers: 1. 32 bit count of the number of318* work-groups in the Y dimension for the grid being executed. Computed from319* the fields in the HsaDispatchPacket as320* ((gridSize.y+workgroupSize.y-1)/workgroupSize.y).321*322* Only initialized if <16 previous SGPRs initialized.323*324* Grid Work-Group Count Z (enable_sgpr_grid_workgroup_count_z):325* Number of User SGPR registers: 1. 32 bit count of the number of326* work-groups in the Z dimension for the grid being executed. Computed327* from the fields in the HsaDispatchPacket as328* ((gridSize.z+workgroupSize.z-1)/workgroupSize.z).329*330* Only initialized if <16 previous SGPRs initialized.331*332* Work-Group Id X (enable_sgpr_workgroup_id_x):333* Number of System SGPR registers: 1. 32 bit work group id in X dimension334* of grid for wavefront. Always present.335*336* Work-Group Id Y (enable_sgpr_workgroup_id_y):337* Number of System SGPR registers: 1. 32 bit work group id in Y dimension338* of grid for wavefront.339*340* Work-Group Id Z (enable_sgpr_workgroup_id_z):341* Number of System SGPR registers: 1. 32 bit work group id in Z dimension342* of grid for wavefront. If present then Work-group Id Y will also be343* present344*345* Work-Group Info (enable_sgpr_workgroup_info):346* Number of System SGPR registers: 1. {first_wave, 14'b0000,347* ordered_append_term[10:0], threadgroup_size_in_waves[5:0]}348*349* Private Segment Wave Byte Offset350* (enable_sgpr_private_segment_wave_byte_offset):351* Number of System SGPR registers: 1. 32 bit byte offset from base of352* dispatch scratch base. Must be used as an offset with Private/Spill/Arg353* segment address when using Scratch Segment Buffer. It must be added to354* Flat Scratch Offset if setting up FLAT SCRATCH for flat addressing.355*356*357* The order of the VGPR registers is defined, but the Finalizer can specify358* which ones are actually setup in the amd_kernel_code_t object using the359* enableVgpr* bit fields. The register numbers used for enabled registers360* are dense starting at VGPR0: the first enabled register is VGPR0, the next361* enabled register is VGPR1 etc.; disabled registers do not have an VGPR362* number.363*364* VGPR register initial state is defined as follows:365*366* Work-Item Id X (always initialized):367* Number of registers: 1. 32 bit work item id in X dimension of work-group368* for wavefront lane.369*370* Work-Item Id X (enable_vgpr_workitem_id > 0):371* Number of registers: 1. 32 bit work item id in Y dimension of work-group372* for wavefront lane.373*374* Work-Item Id X (enable_vgpr_workitem_id > 0):375* Number of registers: 1. 32 bit work item id in Z dimension of work-group376* for wavefront lane.377*378*379* The setting of registers is being done by existing GPU hardware as follows:380* 1) SGPRs before the Work-Group Ids are set by CP using the 16 User Data381* registers.382* 2) Work-group Id registers X, Y, Z are set by SPI which supports any383* combination including none.384* 3) Scratch Wave Offset is also set by SPI which is why its value cannot385* be added into the value Flat Scratch Offset which would avoid the386* Finalizer generated prolog having to do the add.387* 4) The VGPRs are set by SPI which only supports specifying either (X),388* (X, Y) or (X, Y, Z).389*390* Flat Scratch Dispatch Offset and Flat Scratch Size are adjacent SGRRs so391* they can be moved as a 64 bit value to the hardware required SGPRn-3 and392* SGPRn-4 respectively using the Finalizer ?FLAT_SCRATCH? Register.393*394* The global segment can be accessed either using flat operations or buffer395* operations. If buffer operations are used then the Global Buffer used to396* access HSAIL Global/Readonly/Kernarg (which are combine) segments using a397* segment address is not passed into the kernel code by CP since its base398* address is always 0. Instead the Finalizer generates prolog code to399* initialize 4 SGPRs with a V# that has the following properties, and then400* uses that in the buffer instructions:401* - base address of 0402* - no swizzle403* - ATC=1404* - MTYPE set to support memory coherence specified in405* amd_kernel_code_t.globalMemoryCoherence406*407* When the Global Buffer is used to access the Kernarg segment, must add the408* dispatch packet kernArgPtr to a kernarg segment address before using this V#.409* Alternatively scalar loads can be used if the kernarg offset is uniform, as410* the kernarg segment is constant for the duration of the kernel execution.411*/412413typedef struct amd_kernel_code_s {414uint32_t amd_kernel_code_version_major;415uint32_t amd_kernel_code_version_minor;416uint16_t amd_machine_kind;417uint16_t amd_machine_version_major;418uint16_t amd_machine_version_minor;419uint16_t amd_machine_version_stepping;420421/* Byte offset (possibly negative) from start of amd_kernel_code_t422* object to kernel's entry point instruction. The actual code for423* the kernel is required to be 256 byte aligned to match hardware424* requirements (SQ cache line is 16). The code must be position425* independent code (PIC) for AMD devices to give runtime the426* option of copying code to discrete GPU memory or APU L2427* cache. The Finalizer should endeavour to allocate all kernel428* machine code in contiguous memory pages so that a device429* pre-fetcher will tend to only pre-fetch Kernel Code objects,430* improving cache performance.431*/432int64_t kernel_code_entry_byte_offset;433434/* Range of bytes to consider prefetching expressed as an offset435* and size. The offset is from the start (possibly negative) of436* amd_kernel_code_t object. Set both to 0 if no prefetch437* information is available.438*/439int64_t kernel_code_prefetch_byte_offset;440uint64_t kernel_code_prefetch_byte_size;441442/* Number of bytes of scratch backing memory required for full443* occupancy of target chip. This takes into account the number of444* bytes of scratch per work-item, the wavefront size, the maximum445* number of wavefronts per CU, and the number of CUs. This is an446* upper limit on scratch. If the grid being dispatched is small it447* may only need less than this. If the kernel uses no scratch, or448* the Finalizer has not computed this value, it must be 0.449*/450uint64_t max_scratch_backing_memory_byte_size;451452/* Shader program settings for CS. Contains COMPUTE_PGM_RSRC1 and453* COMPUTE_PGM_RSRC2 registers.454*/455uint64_t compute_pgm_resource_registers;456457/* Code properties. See amd_code_property_mask_t for a full list of458* properties.459*/460uint32_t code_properties;461462/* The amount of memory required for the combined private, spill463* and arg segments for a work-item in bytes. If464* is_dynamic_callstack is 1 then additional space must be added to465* this value for the call stack.466*/467uint32_t workitem_private_segment_byte_size;468469/* The amount of group segment memory required by a work-group in470* bytes. This does not include any dynamically allocated group471* segment memory that may be added when the kernel is472* dispatched.473*/474uint32_t workgroup_group_segment_byte_size;475476/* Number of byte of GDS required by kernel dispatch. Must be 0 if477* not using GDS.478*/479uint32_t gds_segment_byte_size;480481/* The size in bytes of the kernarg segment that holds the values482* of the arguments to the kernel. This could be used by CP to483* prefetch the kernarg segment pointed to by the dispatch packet.484*/485uint64_t kernarg_segment_byte_size;486487/* Number of fbarrier's used in the kernel and all functions it488* calls. If the implementation uses group memory to allocate the489* fbarriers then that amount must already be included in the490* workgroup_group_segment_byte_size total.491*/492uint32_t workgroup_fbarrier_count;493494/* Number of scalar registers used by a wavefront. This includes495* the special SGPRs for VCC, Flat Scratch Base, Flat Scratch Size496* and XNACK (for GFX8 (VI)). It does not include the 16 SGPR added if a497* trap handler is enabled. Used to set COMPUTE_PGM_RSRC1.SGPRS.498*/499uint16_t wavefront_sgpr_count;500501/* Number of vector registers used by each work-item. Used to set502* COMPUTE_PGM_RSRC1.VGPRS.503*/504uint16_t workitem_vgpr_count;505506/* If reserved_vgpr_count is 0 then must be 0. Otherwise, this is the507* first fixed VGPR number reserved.508*/509uint16_t reserved_vgpr_first;510511/* The number of consecutive VGPRs reserved by the client. If512* is_debug_supported then this count includes VGPRs reserved513* for debugger use.514*/515uint16_t reserved_vgpr_count;516517/* If reserved_sgpr_count is 0 then must be 0. Otherwise, this is the518* first fixed SGPR number reserved.519*/520uint16_t reserved_sgpr_first;521522/* The number of consecutive SGPRs reserved by the client. If523* is_debug_supported then this count includes SGPRs reserved524* for debugger use.525*/526uint16_t reserved_sgpr_count;527528/* If is_debug_supported is 0 then must be 0. Otherwise, this is the529* fixed SGPR number used to hold the wave scratch offset for the530* entire kernel execution, or uint16_t(-1) if the register is not531* used or not known.532*/533uint16_t debug_wavefront_private_segment_offset_sgpr;534535/* If is_debug_supported is 0 then must be 0. Otherwise, this is the536* fixed SGPR number of the first of 4 SGPRs used to hold the537* scratch V# used for the entire kernel execution, or uint16_t(-1)538* if the registers are not used or not known.539*/540uint16_t debug_private_segment_buffer_sgpr;541542/* The maximum byte alignment of variables used by the kernel in543* the specified memory segment. Expressed as a power of two. Must544* be at least HSA_POWERTWO_16.545*/546uint8_t kernarg_segment_alignment;547uint8_t group_segment_alignment;548uint8_t private_segment_alignment;549550/* Wavefront size expressed as a power of two. Must be a power of 2551* in range 1..64 inclusive. Used to support runtime query that552* obtains wavefront size, which may be used by application to553* allocated dynamic group memory and set the dispatch work-group554* size.555*/556uint8_t wavefront_size;557558int32_t call_convention;559uint8_t reserved3[12];560uint64_t runtime_loader_kernel_symbol;561uint64_t control_directives[16];562} amd_kernel_code_t;563564#endif // AMDKERNELCODET_H565566567