Changeset 3443 in CLRX


Ignore:
Timestamp:
Sep 28, 2017, 12:06:39 PM (19 months ago)
Author:
matszpk
Message:

CLRadeonExtender: Move tables with arch values (arch versions) to GPUId.

Location:
CLRadeonExtender/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/CLRX/utils/GPUId.h

    r3349 r3443  
    158158
    159159/// calculate PGMRSRC1 register value
    160 uint32_t calculatePgmRSrc1(GPUArchitecture arch, cxuint vgprsNum, cxuint sgprsNum,
     160extern uint32_t calculatePgmRSrc1(GPUArchitecture arch, cxuint vgprsNum, cxuint sgprsNum,
    161161            cxuint priority, cxuint floatMode, bool privMode, bool dx10clamp,
    162162            bool debugMode, bool ieeeMode);
    163163
    164164/// calculate PGMRSRC2 register value
    165 uint32_t calculatePgmRSrc2(GPUArchitecture arch, bool scratchEn, cxuint userDataNum,
     165extern uint32_t calculatePgmRSrc2(GPUArchitecture arch, bool scratchEn, cxuint userDataNum,
    166166            bool trapPresent, cxuint dimMask, cxuint defDimValues, bool tgSizeEn,
    167167            cxuint ldsSize, cxuint exceptions);
     168
     169
     170/// ADMGPUArchValues table type
     171enum class GPUArchValuesTable: cxuint
     172{
     173    AMDCL2 = 0, ///< AMD OpenCL 2.0 driver
     174    OPENSOURCE ///< ROCm and Gallium
     175};
     176
     177/// get AMD GPU architecture values (version) for specific device type and driver
     178extern AMDGPUArchValues getGPUArchValues(GPUDeviceType deviceType,
     179                        GPUArchValuesTable table);
     180
     181// get GPU device type from Architecture values (version)
     182extern GPUDeviceType getGPUDeviceTypeFromArchValues(cxuint archMajor, cxuint archMinor,
     183                            cxuint archStepping);
    168184
    169185};
  • CLRadeonExtender/trunk/amdasm/AsmGalliumFormat.cpp

    r3427 r3443  
    16351635}
    16361636
    1637 // AMD GPU architecture for Gallium
    1638 static const AMDGPUArchValues galliumAmdGpuArchValuesTbl[] =
    1639 {
    1640     { 0, 0, 0 }, // GPUDeviceType::CAPE_VERDE
    1641     { 0, 0, 0 }, // GPUDeviceType::PITCAIRN
    1642     { 0, 0, 0 }, // GPUDeviceType::TAHITI
    1643     { 0, 0, 0 }, // GPUDeviceType::OLAND
    1644     { 7, 0, 0 }, // GPUDeviceType::BONAIRE
    1645     { 7, 0, 0 }, // GPUDeviceType::SPECTRE
    1646     { 7, 0, 0 }, // GPUDeviceType::SPOOKY
    1647     { 7, 0, 0 }, // GPUDeviceType::KALINDI
    1648     { 0, 0, 0 }, // GPUDeviceType::HAINAN
    1649     { 7, 0, 1 }, // GPUDeviceType::HAWAII
    1650     { 8, 0, 0 }, // GPUDeviceType::ICELAND
    1651     { 8, 0, 0 }, // GPUDeviceType::TONGA
    1652     { 7, 0, 0 }, // GPUDeviceType::MULLINS
    1653     { 8, 0, 3 }, // GPUDeviceType::FIJI
    1654     { 8, 0, 1 }, // GPUDeviceType::CARRIZO
    1655     { 0, 0, 0 }, // GPUDeviceType::DUMMY
    1656     { 0, 0, 0 }, // GPUDeviceType::GOOSE
    1657     { 0, 0, 0 }, // GPUDeviceType::HORSE
    1658     { 8, 0, 1 }, // GPUDeviceType::STONEY
    1659     { 8, 0, 4 }, // GPUDeviceType::ELLESMERE
    1660     { 8, 0, 4 }, // GPUDeviceType::BAFFIN
    1661     { 8, 0, 4 }, // GPUDeviceType::GFX804
    1662     { 9, 0, 0 }, // GPUDeviceType::GFX900
    1663     { 9, 0, 1 }  // GPUDeviceType::GFX901
    1664 };
    1665 
    16661637bool AsmGalliumHandler::prepareBinary()
    16671638{
     
    18531824   
    18541825    // setup amd GPU arch values (for LLVM 4.0 HSA config)
    1855     AMDGPUArchValues amdGpuArchValues = galliumAmdGpuArchValuesTbl[
    1856                     cxuint(assembler.deviceType)];
     1826    AMDGPUArchValues amdGpuArchValues = getGPUArchValues(assembler.deviceType,
     1827                                GPUArchValuesTable::OPENSOURCE);
    18571828    // replace arch minor and stepping by user defined values (if set)
    18581829    if (archMinor != BINGEN_DEFAULT)
  • CLRadeonExtender/trunk/amdasm/AsmROCmFormat.cpp

    r3426 r3443  
    13351335    return true;
    13361336}
    1337 
    1338 // AMD GPU architecture for Gallium
    1339 static const AMDGPUArchValues rocmAmdGpuArchValuesTbl[] =
    1340 {
    1341     { 0, 0, 0 }, // GPUDeviceType::CAPE_VERDE
    1342     { 0, 0, 0 }, // GPUDeviceType::PITCAIRN
    1343     { 0, 0, 0 }, // GPUDeviceType::TAHITI
    1344     { 0, 0, 0 }, // GPUDeviceType::OLAND
    1345     { 7, 0, 0 }, // GPUDeviceType::BONAIRE
    1346     { 7, 0, 0 }, // GPUDeviceType::SPECTRE
    1347     { 7, 0, 0 }, // GPUDeviceType::SPOOKY
    1348     { 7, 0, 0 }, // GPUDeviceType::KALINDI
    1349     { 0, 0, 0 }, // GPUDeviceType::HAINAN
    1350     { 7, 0, 1 }, // GPUDeviceType::HAWAII
    1351     { 8, 0, 0 }, // GPUDeviceType::ICELAND
    1352     { 8, 0, 0 }, // GPUDeviceType::TONGA
    1353     { 7, 0, 0 }, // GPUDeviceType::MULLINS
    1354     { 8, 0, 3 }, // GPUDeviceType::FIJI
    1355     { 8, 0, 1 }, // GPUDeviceType::CARRIZO
    1356     { 0, 0, 0 }, // GPUDeviceType::DUMMY
    1357     { 0, 0, 0 }, // GPUDeviceType::GOOSE
    1358     { 0, 0, 0 }, // GPUDeviceType::HORSE
    1359     { 8, 0, 1 }, // GPUDeviceType::STONEY
    1360     { 8, 0, 4 }, // GPUDeviceType::ELLESMERE
    1361     { 8, 0, 4 }, // GPUDeviceType::BAFFIN
    1362     { 8, 0, 4 }, // GPUDeviceType::GFX804
    1363     { 9, 0, 0 }, // GPUDeviceType::GFX900
    1364     { 9, 0, 1 }  // GPUDeviceType::GFX901
    1365 };
    13661337
    13671338bool AsmROCmHandler::prepareBinary()
     
    14401411    cxuint maxSGPRsNum = getGPUMaxRegistersNum(arch, REGTYPE_SGPR, 0);
    14411412   
    1442     AMDGPUArchValues amdGpuArchValues = rocmAmdGpuArchValuesTbl[
    1443                     cxuint(assembler.deviceType)];
     1413    AMDGPUArchValues amdGpuArchValues = getGPUArchValues(assembler.deviceType,
     1414                                GPUArchValuesTable::OPENSOURCE);
    14441415    // replace arch minor and stepping by user defined values (if set)
    14451416    if (output.archMinor!=UINT32_MAX)
  • CLRadeonExtender/trunk/amdbin/AmdCL2BinGen.cpp

    r3420 r3443  
    19171917    '-', 'h', 's', 'a', '-', 'g', 'l', 'o', 'b', 'a' };
    19181918
    1919 // AMDGPU architecture values for specific GPU device type for AMDOCL 2.0
    1920 static const AMDGPUArchValues amdGpuArchValuesTbl[] =
    1921 {
    1922     { 0, 0, 0 }, // GPUDeviceType::CAPE_VERDE
    1923     { 0, 0, 0 }, // GPUDeviceType::PITCAIRN
    1924     { 0, 0, 0 }, // GPUDeviceType::TAHITI
    1925     { 0, 0, 0 }, // GPUDeviceType::OLAND
    1926     { 7, 0, 0 }, // GPUDeviceType::BONAIRE
    1927     { 7, 0, 0 }, // GPUDeviceType::SPECTRE
    1928     { 7, 0, 0 }, // GPUDeviceType::SPOOKY
    1929     { 7, 0, 0 }, // GPUDeviceType::KALINDI
    1930     { 0, 0, 0 }, // GPUDeviceType::HAINAN
    1931     { 7, 0, 1 }, // GPUDeviceType::HAWAII
    1932     { 8, 0, 0 }, // GPUDeviceType::ICELAND
    1933     { 8, 0, 0 }, // GPUDeviceType::TONGA
    1934     { 7, 0, 0 }, // GPUDeviceType::MULLINS
    1935     { 8, 0, 4 }, // GPUDeviceType::FIJI
    1936     { 8, 0, 1 }, // GPUDeviceType::CARRIZO
    1937     { 8, 0, 1 }, // GPUDeviceType::DUMMY
    1938     { 8, 0, 4 }, // GPUDeviceType::GOOSE
    1939     { 8, 0, 4 }, // GPUDeviceType::HORSE
    1940     { 8, 1, 0 }, // GPUDeviceType::STONEY
    1941     { 8, 0, 4 }, // GPUDeviceType::ELLESMERE
    1942     { 8, 0, 4 }, // GPUDeviceType::BAFFIN
    1943     { 8, 0, 4 }, // GPUDeviceType::GFX804
    1944     { 9, 0, 0 }, // GPUDeviceType::GFX900
    1945     { 9, 0, 1 }  // GPUDeviceType::GFX901
    1946 };
    1947 
    19481919// helper to construct name for fixing allocation/deallocation bug ??
    19491920static CString constructName(size_t prefixSize, const char* prefix, const CString& name,
     
    20882059   
    20892060    const bool is16_3Ver = (input->driverVersion>=200406);
    2090     AMDGPUArchValues amdGpuArchValues = amdGpuArchValuesTbl[cxuint(input->deviceType)];
     2061    AMDGPUArchValues amdGpuArchValues = getGPUArchValues(input->deviceType,
     2062                                GPUArchValuesTable::AMDCL2);
    20912063    // fix for old drivers (1912.05)
    20922064    if (!is16_3Ver && input->deviceType==GPUDeviceType::FIJI)
  • CLRadeonExtender/trunk/amdbin/ROCmBinaries.cpp

    r3420 r3443  
    133133}
    134134
    135 struct AMDGPUArchValuesEntry
    136 {
    137     uint32_t major;
    138     uint32_t minor;
    139     uint32_t stepping;
    140     GPUDeviceType deviceType;
    141 };
    142 
    143 // list of AMDGPU arch entries for GPU devices
    144 static const AMDGPUArchValuesEntry amdGpuArchValuesTbl[] =
    145 {
    146     { 0, 0, 0, GPUDeviceType::CAPE_VERDE },
    147     { 7, 0, 0, GPUDeviceType::BONAIRE },
    148     { 7, 0, 1, GPUDeviceType::HAWAII },
    149     { 8, 0, 0, GPUDeviceType::ICELAND },
    150     { 8, 0, 1, GPUDeviceType::CARRIZO },
    151     { 8, 0, 2, GPUDeviceType::ICELAND },
    152     { 8, 0, 3, GPUDeviceType::FIJI },
    153     { 8, 0, 4, GPUDeviceType::FIJI },
    154     { 8, 1, 0, GPUDeviceType::STONEY },
    155     { 9, 0, 0, GPUDeviceType::GFX900 },
    156     { 9, 0, 1, GPUDeviceType::GFX901 }
    157 };
    158 
    159 static const size_t amdGpuArchValuesNum = sizeof(amdGpuArchValuesTbl) /
    160                 sizeof(AMDGPUArchValuesEntry);
    161 
    162 
    163135/// determint GPU device from ROCm notes
    164136GPUDeviceType ROCmBinary::determineGPUDeviceType(uint32_t& outArchMinor,
     
    196168    }
    197169    // determine device type
    198     GPUDeviceType deviceType = GPUDeviceType::CAPE_VERDE;
    199     // choose lowest GPU device by archMajor by default
    200     if (archMajor==0)
    201         deviceType = GPUDeviceType::CAPE_VERDE;
    202     else if (archMajor==7)
    203         deviceType = GPUDeviceType::BONAIRE;
    204     else if (archMajor==8)
    205         deviceType = GPUDeviceType::ICELAND;
    206     else if (archMajor==9)
    207         deviceType = GPUDeviceType::GFX900;
    208    
    209     // recognize device type by arch major, minor and stepping
    210     for (cxuint i = 0; i < amdGpuArchValuesNum; i++)
    211         if (amdGpuArchValuesTbl[i].major==archMajor &&
    212             amdGpuArchValuesTbl[i].minor==archMinor &&
    213             amdGpuArchValuesTbl[i].stepping==archStepping)
    214         {
    215             deviceType = amdGpuArchValuesTbl[i].deviceType;
    216             break;
    217         }
     170    GPUDeviceType deviceType = getGPUDeviceTypeFromArchValues(archMajor, archMinor,
     171                                    archStepping);
    218172    outArchMinor = archMinor;
    219173    outArchStepping = archStepping;
     
    315269};
    316270
    317 static const AMDGPUArchValues rocmAmdGpuArchValuesTbl[] =
    318 {
    319     { 0, 0, 0 }, // GPUDeviceType::CAPE_VERDE
    320     { 0, 0, 0 }, // GPUDeviceType::PITCAIRN
    321     { 0, 0, 0 }, // GPUDeviceType::TAHITI
    322     { 0, 0, 0 }, // GPUDeviceType::OLAND
    323     { 7, 0, 0 }, // GPUDeviceType::BONAIRE
    324     { 7, 0, 0 }, // GPUDeviceType::SPECTRE
    325     { 7, 0, 0 }, // GPUDeviceType::SPOOKY
    326     { 7, 0, 0 }, // GPUDeviceType::KALINDI
    327     { 0, 0, 0 }, // GPUDeviceType::HAINAN
    328     { 7, 0, 1 }, // GPUDeviceType::HAWAII
    329     { 8, 0, 0 }, // GPUDeviceType::ICELAND
    330     { 8, 0, 0 }, // GPUDeviceType::TONGA
    331     { 7, 0, 0 }, // GPUDeviceType::MULLINS
    332     { 8, 0, 3 }, // GPUDeviceType::FIJI
    333     { 8, 0, 1 }, // GPUDeviceType::CARRIZO
    334     { 8, 0, 1 }, // GPUDeviceType::DUMMY
    335     { 8, 0, 4 }, // GPUDeviceType::GOOSE
    336     { 8, 0, 4 }, // GPUDeviceType::HORSE
    337     { 8, 0, 1 }, // GPUDeviceType::STONEY
    338     { 8, 0, 4 }, // GPUDeviceType::ELLESMERE
    339     { 8, 0, 4 }, // GPUDeviceType::BAFFIN
    340     { 8, 0, 4 }, // GPUDeviceType::GFX804
    341     { 9, 0, 0 }, // GPUDeviceType::GFX900
    342     { 9, 0, 1 }  // GPUDeviceType::GFX901
    343 };
    344 
    345271void ROCmBinGenerator::generateInternal(std::ostream* osPtr, std::vector<char>* vPtr,
    346272             Array<cxbyte>* aPtr) const
    347273{
    348     AMDGPUArchValues amdGpuArchValues = rocmAmdGpuArchValuesTbl[cxuint(input->deviceType)];
     274    AMDGPUArchValues amdGpuArchValues = getGPUArchValues(input->deviceType,
     275                GPUArchValuesTable::OPENSOURCE);
    349276    if (input->archMinor!=UINT32_MAX)
    350277        amdGpuArchValues.minor = input->archMinor;
  • CLRadeonExtender/trunk/utils/GPUId.cpp

    r3439 r3443  
    299299}
    300300
     301// AMD GPU architecture for Gallium and ROCm
     302static const AMDGPUArchValues galliumGpuArchValuesTbl[] =
     303{
     304    { 0, 0, 0 }, // GPUDeviceType::CAPE_VERDE
     305    { 0, 0, 0 }, // GPUDeviceType::PITCAIRN
     306    { 0, 0, 0 }, // GPUDeviceType::TAHITI
     307    { 0, 0, 0 }, // GPUDeviceType::OLAND
     308    { 7, 0, 0 }, // GPUDeviceType::BONAIRE
     309    { 7, 0, 0 }, // GPUDeviceType::SPECTRE
     310    { 7, 0, 0 }, // GPUDeviceType::SPOOKY
     311    { 7, 0, 0 }, // GPUDeviceType::KALINDI
     312    { 0, 0, 0 }, // GPUDeviceType::HAINAN
     313    { 7, 0, 1 }, // GPUDeviceType::HAWAII
     314    { 8, 0, 0 }, // GPUDeviceType::ICELAND
     315    { 8, 0, 0 }, // GPUDeviceType::TONGA
     316    { 7, 0, 0 }, // GPUDeviceType::MULLINS
     317    { 8, 0, 3 }, // GPUDeviceType::FIJI
     318    { 8, 0, 1 }, // GPUDeviceType::CARRIZO
     319    { 0, 0, 0 }, // GPUDeviceType::DUMMY
     320    { 0, 0, 0 }, // GPUDeviceType::GOOSE
     321    { 0, 0, 0 }, // GPUDeviceType::HORSE
     322    { 8, 0, 1 }, // GPUDeviceType::STONEY
     323    { 8, 0, 4 }, // GPUDeviceType::ELLESMERE
     324    { 8, 0, 4 }, // GPUDeviceType::BAFFIN
     325    { 8, 0, 4 }, // GPUDeviceType::GFX804
     326    { 9, 0, 0 }, // GPUDeviceType::GFX900
     327    { 9, 0, 1 }  // GPUDeviceType::GFX901
     328};
     329
     330// AMDGPU architecture values for specific GPU device type for AMDOCL 2.0
     331static const AMDGPUArchValues amdCL2GpuArchValuesTbl[] =
     332{
     333    { 0, 0, 0 }, // GPUDeviceType::CAPE_VERDE
     334    { 0, 0, 0 }, // GPUDeviceType::PITCAIRN
     335    { 0, 0, 0 }, // GPUDeviceType::TAHITI
     336    { 0, 0, 0 }, // GPUDeviceType::OLAND
     337    { 7, 0, 0 }, // GPUDeviceType::BONAIRE
     338    { 7, 0, 0 }, // GPUDeviceType::SPECTRE
     339    { 7, 0, 0 }, // GPUDeviceType::SPOOKY
     340    { 7, 0, 0 }, // GPUDeviceType::KALINDI
     341    { 0, 0, 0 }, // GPUDeviceType::HAINAN
     342    { 7, 0, 1 }, // GPUDeviceType::HAWAII
     343    { 8, 0, 0 }, // GPUDeviceType::ICELAND
     344    { 8, 0, 0 }, // GPUDeviceType::TONGA
     345    { 7, 0, 0 }, // GPUDeviceType::MULLINS
     346    { 8, 0, 4 }, // GPUDeviceType::FIJI
     347    { 8, 0, 1 }, // GPUDeviceType::CARRIZO
     348    { 8, 0, 1 }, // GPUDeviceType::DUMMY
     349    { 8, 0, 4 }, // GPUDeviceType::GOOSE
     350    { 8, 0, 4 }, // GPUDeviceType::HORSE
     351    { 8, 1, 0 }, // GPUDeviceType::STONEY
     352    { 8, 0, 4 }, // GPUDeviceType::ELLESMERE
     353    { 8, 0, 4 }, // GPUDeviceType::BAFFIN
     354    { 8, 0, 4 }, // GPUDeviceType::GFX804
     355    { 9, 0, 0 }, // GPUDeviceType::GFX900
     356    { 9, 0, 1 }  // GPUDeviceType::GFX901
     357};
     358
     359AMDGPUArchValues CLRX::getGPUArchValues(GPUDeviceType deviceType, GPUArchValuesTable table)
     360{
     361    if (deviceType > GPUDeviceType::GPUDEVICE_MAX)
     362        throw Exception("Unknown GPU device type");
     363    // choose correct GPU arch values table
     364    const AMDGPUArchValues* archValuesTable = (table == GPUArchValuesTable::AMDCL2) ?
     365            amdCL2GpuArchValuesTbl : galliumGpuArchValuesTbl;
     366    return archValuesTable[cxuint(deviceType)];
     367}
     368
     369// GPU arch values with device type
     370struct AMDGPUArchValuesEntry
     371{
     372    uint32_t major;
     373    uint32_t minor;
     374    uint32_t stepping;
     375    GPUDeviceType deviceType;
     376};
     377
     378// list of AMDGPU arch entries for GPU devices
     379static const AMDGPUArchValuesEntry amdGpuArchValueEntriesTbl[] =
     380{
     381    { 0, 0, 0, GPUDeviceType::CAPE_VERDE },
     382    { 7, 0, 0, GPUDeviceType::BONAIRE },
     383    { 7, 0, 1, GPUDeviceType::HAWAII },
     384    { 8, 0, 0, GPUDeviceType::ICELAND },
     385    { 8, 0, 1, GPUDeviceType::CARRIZO },
     386    { 8, 0, 2, GPUDeviceType::ICELAND },
     387    { 8, 0, 3, GPUDeviceType::FIJI },
     388    { 8, 0, 4, GPUDeviceType::FIJI },
     389    { 8, 1, 0, GPUDeviceType::STONEY },
     390    { 9, 0, 0, GPUDeviceType::GFX900 },
     391    { 9, 0, 1, GPUDeviceType::GFX901 }
     392};
     393
     394static const size_t amdGpuArchValueEntriesNum = sizeof(amdGpuArchValueEntriesTbl) /
     395                sizeof(AMDGPUArchValuesEntry);
     396
     397GPUDeviceType CLRX::getGPUDeviceTypeFromArchValues(cxuint archMajor, cxuint archMinor,
     398                            cxuint archStepping)
     399{
     400    // determine device type
     401    GPUDeviceType deviceType = GPUDeviceType::CAPE_VERDE;
     402    // choose lowest GPU device by archMajor by default
     403    if (archMajor==0)
     404        deviceType = GPUDeviceType::CAPE_VERDE;
     405    else if (archMajor==7)
     406        deviceType = GPUDeviceType::BONAIRE;
     407    else if (archMajor==8)
     408        deviceType = GPUDeviceType::ICELAND;
     409    else if (archMajor==9)
     410        deviceType = GPUDeviceType::GFX900;
     411   
     412    // recognize device type by arch major, minor and stepping
     413    for (cxuint i = 0; i < amdGpuArchValueEntriesNum; i++)
     414        if (amdGpuArchValueEntriesTbl[i].major==archMajor &&
     415            amdGpuArchValueEntriesTbl[i].minor==archMinor &&
     416            amdGpuArchValueEntriesTbl[i].stepping==archStepping)
     417        {
     418            deviceType = amdGpuArchValueEntriesTbl[i].deviceType;
     419            break;
     420        }
     421    return deviceType;
     422}
Note: See TracChangeset for help on using the changeset viewer.