Changeset 3678 in CLRX


Ignore:
Timestamp:
Jan 29, 2018, 5:37:17 PM (2 years ago)
Author:
matszpk
Message:

CLRadeonExtender: ROCmBin: Add metadatas structures and types and API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/CLRX/amdbin/ROCmBinaries.h

    r3671 r3678  
    4444enum : Flags {
    4545    ROCMBIN_CREATE_REGIONMAP = 0x10,    ///< create region map
     46    ROCMBIN_CREATE_KERNELINFOMAP = 0x20,    ///< create kernel metadata info map
    4647    ROCMBIN_CREATE_ALL = ELF_CREATE_ALL | 0xfff0 ///< all ROCm binaries flags
    4748};
     
    6263    size_t offset;     ///< data
    6364    ROCmRegionType type; ///< type
     65};
     66
     67/// ROCm Value kind
     68enum class ROCmValueKind : cxbyte
     69{
     70    BY_VALUE = 0,       ///< value is just value
     71    GLOBAL_BUFFER,      ///< passed in global buffer
     72    DYN_SHARED_PTR,     ///< passed as dynamic shared pointer
     73    SAMPLER,            ///< sampler
     74    IMAGE,              ///< image
     75    PIPE,               ///< OpenCL pipe
     76    QUEUE,              ///< OpenCL queue
     77    HIDDEN_GLOBAL_OFFSET_X, ///< OpenCL global offset X
     78    HIDDEN_GLOBAL_OFFSET_Y, ///< OpenCL global offset Y
     79    HIDDEN_GLOBAL_OFFSET_Z, ///< OpenCL global offset Z
     80    HIDDEN_NONE,            ///< none (not used)
     81    HIDDEN_PRINTF_BUFFER,   ///< buffer for printf calls
     82    HIDDEN_DEFAULT_QUEUE,   ///< OpenCL default queue
     83    HIDDEN_COMPLETION_ACTION    ///< ???
     84};
     85
     86/// ROCm argument's value type
     87enum class ROCmValueType : cxbyte
     88{
     89    STRUCTURE = 0,  ///< structure
     90    INT8,       ///< 8-bit signed integer
     91    UINT8,      ///< 8-bit unsigned integer
     92    INT16,      ///< 16-bit signed integer
     93    UINT16,     ///< 16-bit unsigned integer
     94    FLOAT16,    ///< half floating point
     95    INT32,      ///< 32-bit signed integer
     96    UINT32,     ///< 32-bit unsigned integer
     97    FLOAT32,    ///< single floating point
     98    INT64,      ///< 64-bit signed integer
     99    UINT64,     ///< 64-bit unsigned integer
     100    FLOAT64     ///< double floating point
     101};
     102
     103/// ROCm argument address space
     104enum class ROCmAddressSpace : cxbyte
     105{
     106    PRIVATE = 0,
     107    GLOBAL,
     108    CONSTANT,
     109    LOCAL,
     110    GENERIC,
     111    REGION
     112};
     113
     114/// ROCm access qualifier
     115enum class ROCmAccessQual: cxbyte
     116{
     117    READ_ONLY = 0,
     118    WRITE_ONLY,
     119    READ_WRITE,
     120    DEFAULT
     121};
     122
     123/// ROCm kernel argument
     124struct ROCmKernelArgInfo
     125{
     126    CString name;       ///< name
     127    CString typeName;   ///< type name
     128    uint64_t size;      ///< argument size in bytes
     129    uint64_t align;     ///< argument alignment in bytes
     130    uint64_t pointeeAlign;      ///< alignemnt of pointed data of pointer
     131    ROCmValueKind valueKind;    ///< value kind
     132    ROCmValueType valueType;    ///< value type
     133    ROCmAddressSpace addressSpace;  ///< pointer address space
     134    ROCmAccessQual accessQual;      ///< access qualifier (for images and values)
     135    ROCmAccessQual actualAccessQual;    ///< access qualifier to resource data
     136    bool isConst;       ///< is constant
     137    bool isRestrict;    ///< is restrict
     138    bool isVolatile;    ///< is volatile
     139    bool isPipe;        ///< is pipe
     140};
     141
     142/// ROCm kernel metadata
     143struct ROCmKernelMetadata
     144{
     145    CString name;       ///< kernel name
     146    CString symbolName; ///< symbol name
     147    Array<ROCmKernelArgInfo> argInfos;  ///< kernel arguments
     148    CString language;       ///< language
     149    cxuint langVersion[2];  ///< language version
     150    cxuint reqdWorkGroupSize[3];    ///< required work group size
     151    cxuint workGroupSizeHint[3];    ///< work group size hint
     152    CString vecTypeHint;    ///< vector type hint
     153    CString runtimeHandle;  ///< symbol of runtime handle
     154    uint64_t kernargSegmentSize;    ///< kernel argument segment size
     155    uint64_t groupSegmentFixedSize; ///< group segment size (fixed)
     156    uint64_t privateSegmentFixedSize;   ///< private segment size (fixed)
     157    uint64_t kernargSegmentAlign;       ///< alignment of kernel argument segment
     158    cxuint wavefrontSize;       ///< wavefront size
     159    cxuint sgprsNum;        ///< number of SGPRs
     160    cxuint vgprsNum;        ///< number of VGPRs
     161    uint64_t maxFlatWorkGroupSize;
     162    uint64_t fixedWorkGroupSize[3];
     163    cxuint spilledSgprs;    ///< number of spilled SGPRs
     164    cxuint spilledVgprs;    ///< number of spilled VGPRs
     165};
     166
     167/// ROCm printf call info
     168struct ROCmPrintfInfo
     169{
     170    uint32_t id;    /// unique id of call
     171    Array<uint32_t> argSizes;   ///< argument sizes
     172    CString format;     ///< printf format
     173};
     174
     175/// ROCm binary metadata
     176struct ROCmMetadata
     177{
     178    cxuint version[2];  ///< version
     179    Array<ROCmPrintfInfo> printfInfos;  ///< printf calls infos
     180    Array<ROCmKernelMetadata> kernels;  ///< kernel metadatas
    64181};
    65182
     
    84201    size_t metadataSize;
    85202    char* metadata;
     203    std::unique_ptr<ROCmMetadata> metadataInfo;
     204    RegionMap kernelInfosMap;
    86205    bool newBinFormat;
    87206public:
     
    138257    { return metadata; }
    139258   
     259    /// get metadata info
     260    bool hasMetadataInfo() const
     261    { return metadataInfo!=nullptr; }
     262   
     263    /// get metadata info
     264    const ROCmMetadata& getMetadataInfo() const
     265    { return *metadataInfo; }
     266   
     267    /// get kernel metadata infos number
     268    size_t getKernelInfosNum() const
     269    { return metadataInfo->kernels.size(); }
     270   
     271    /// get kernel metadata info
     272    const ROCmKernelMetadata& getKernelInfo(size_t index) const
     273    { return metadataInfo->kernels[index]; }
     274   
     275    /// get kernel metadata info by name
     276    const ROCmKernelMetadata& getKernelInfo(const char* name) const;
     277   
     278    /// get target
    140279    const CString& getTarget() const
    141280    { return target; }
     
    147286    /// returns true if kernel map exists
    148287    bool hasRegionMap() const
    149     { return (creationFlags & ROCMBIN_CREATE_REGIONMAP) != 0; };
     288    { return (creationFlags & ROCMBIN_CREATE_REGIONMAP) != 0; }
     289    /// returns true if object has kernel map
     290    bool hasKernelInfoMap() const
     291    { return (creationFlags & ROCMBIN_CREATE_KERNELINFOMAP) != 0; }
    150292};
    151293
Note: See TracChangeset for help on using the changeset viewer.