Changeset 3442 in CLRX


Ignore:
Timestamp:
Sep 27, 2017, 3:32:27 PM (17 months ago)
Author:
matszpk
Message:

CLRadeonExtender: Update GPUId test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/tests/utils/GPUId.cpp

    r3441 r3442  
    2323#include <cstring>
    2424#include <cstdio>
     25#include <utility>
    2526#include <initializer_list>
    2627#include <CLRX/utils/GPUId.h>
     
    110111{
    111112    char descBuf[60];
     113    // checking device type names
    112114    for (cxuint i = 0; i < gpuDeviceEntryTableSize; i++)
    113115    {
     
    164166{
    165167    char descBuf[60];
     168    // checking architecture names
    166169    for (cxuint i = 0; i < gpuArchitectureEntryTableSize; i++)
    167170    {
     
    182185}
    183186
     187struct GPUMaxRegTestCase
     188{
     189    GPUArchitecture arch;
     190    cxuint regType;
     191    Flags flags;
     192    cxuint regsNum;
     193};
     194
     195// getGPUMaxRegistersNum testcase table
     196static const GPUMaxRegTestCase gpuMaxRegTestTable[] =
     197{
     198    { GPUArchitecture::GCN1_0, REGTYPE_VGPR, 0, 256 },
     199    { GPUArchitecture::GCN1_1, REGTYPE_VGPR, 0, 256 },
     200    { GPUArchitecture::GCN1_2, REGTYPE_VGPR, 0, 256 },
     201    { GPUArchitecture::GCN1_4, REGTYPE_VGPR, 0, 256 },
     202    { GPUArchitecture::GCN1_0, REGTYPE_SGPR, 0, 104 },
     203    { GPUArchitecture::GCN1_1, REGTYPE_SGPR, 0, 104 },
     204    { GPUArchitecture::GCN1_2, REGTYPE_SGPR, 0, 102 },
     205    { GPUArchitecture::GCN1_4, REGTYPE_SGPR, 0, 102 },
     206    { GPUArchitecture::GCN1_0, REGTYPE_SGPR, REGCOUNT_NO_VCC, 102 },
     207    { GPUArchitecture::GCN1_1, REGTYPE_SGPR, REGCOUNT_NO_VCC, 102 },
     208    { GPUArchitecture::GCN1_2, REGTYPE_SGPR, REGCOUNT_NO_VCC, 100 },
     209    { GPUArchitecture::GCN1_4, REGTYPE_SGPR, REGCOUNT_NO_VCC, 100 },
     210    { GPUArchitecture::GCN1_1, REGTYPE_SGPR, REGCOUNT_NO_FLAT, 100 },
     211    { GPUArchitecture::GCN1_2, REGTYPE_SGPR, REGCOUNT_NO_FLAT, 96 },
     212    { GPUArchitecture::GCN1_4, REGTYPE_SGPR, REGCOUNT_NO_FLAT, 96 },
     213    { GPUArchitecture::GCN1_2, REGTYPE_SGPR, REGCOUNT_NO_XNACK, 98 },
     214    { GPUArchitecture::GCN1_4, REGTYPE_SGPR, REGCOUNT_NO_XNACK, 98 }
     215};
     216
     217static void testGetGPUMaxRegistersNum()
     218{
     219    char descBuf[60];
     220    // checking architecture names
     221    for (cxuint i = 0; i < sizeof gpuMaxRegTestTable/ sizeof(GPUMaxRegTestCase); i++)
     222    {
     223        const GPUMaxRegTestCase testCase = gpuMaxRegTestTable[i];
     224        snprintf(descBuf, sizeof descBuf, "Test %d", i);
     225        const cxuint result = getGPUMaxRegistersNum(testCase.arch, testCase.regType,
     226                                testCase.flags);
     227        assertValue("testGetGPUMaxRegistersNum", descBuf,
     228                    testCase.regsNum, result);
     229    }
     230}
     231
     232// getGPUExtraRegsNum testcase table
     233static const GPUMaxRegTestCase gpuExtraRegsTestTable[] =
     234{
     235    { GPUArchitecture::GCN1_0, REGTYPE_VGPR, 0, 0 },
     236    { GPUArchitecture::GCN1_1, REGTYPE_VGPR, 0, 0 },
     237    { GPUArchitecture::GCN1_2, REGTYPE_VGPR, 0, 0 },
     238    { GPUArchitecture::GCN1_4, REGTYPE_VGPR, 0, 0 },
     239    { GPUArchitecture::GCN1_0, REGTYPE_SGPR, 0, 0 },
     240    { GPUArchitecture::GCN1_1, REGTYPE_SGPR, 0, 0 },
     241    { GPUArchitecture::GCN1_2, REGTYPE_SGPR, 0, 0 },
     242    { GPUArchitecture::GCN1_4, REGTYPE_SGPR, 0, 0 },
     243    { GPUArchitecture::GCN1_0, REGTYPE_SGPR, GCN_VCC, 2 },
     244    { GPUArchitecture::GCN1_1, REGTYPE_SGPR, GCN_VCC, 2 },
     245    { GPUArchitecture::GCN1_2, REGTYPE_SGPR, GCN_VCC, 2 },
     246    { GPUArchitecture::GCN1_4, REGTYPE_SGPR, GCN_VCC, 2 },
     247    { GPUArchitecture::GCN1_1, REGTYPE_SGPR, GCN_FLAT, 4 },
     248    { GPUArchitecture::GCN1_2, REGTYPE_SGPR, GCN_FLAT, 6 },
     249    { GPUArchitecture::GCN1_4, REGTYPE_SGPR, GCN_FLAT, 6 },
     250    { GPUArchitecture::GCN1_2, REGTYPE_SGPR, GCN_XNACK, 4 },
     251    { GPUArchitecture::GCN1_4, REGTYPE_SGPR, GCN_XNACK, 4 }
     252};
     253
     254static void testGetGPUExtraRegsNum()
     255{
     256    char descBuf[60];
     257    // checking architecture names
     258    for (cxuint i = 0; i < sizeof gpuExtraRegsTestTable/ sizeof(GPUMaxRegTestCase); i++)
     259    {
     260        const GPUMaxRegTestCase testCase = gpuExtraRegsTestTable[i];
     261        snprintf(descBuf, sizeof descBuf, "Test %d", i);
     262        const cxuint result = getGPUExtraRegsNum(testCase.arch, testCase.regType,
     263                                testCase.flags);
     264        assertValue("testGetGPUExtraRegsNum", descBuf,
     265                    testCase.regsNum, result);
     266    }
     267}
     268
     269
    184270int main(int argc, const char** argv)
    185271{
     
    187273    retVal |= callTest(testGetGPUDeviceFromName);
    188274    retVal |= callTest(testGetGPUArchitectureFromName);
     275    retVal |= callTest(testGetGPUMaxRegistersNum);
     276    retVal |= callTest(testGetGPUExtraRegsNum);
    189277    return retVal;
    190278}
Note: See TracChangeset for help on using the changeset viewer.