Changeset 3279 in CLRX


Ignore:
Timestamp:
Sep 1, 2017, 3:10:28 PM (16 months ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmGallium?: Make Kernel states vector as container of pointers (for safety behaviour).

Location:
CLRadeonExtender/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/CLRX/amdasm/AsmFormats.h

    r3278 r3279  
    404404        void initializeAmdHsaKernelConfig();
    405405    };
    406     std::vector<Kernel> kernelStates;
     406    std::vector<Kernel*> kernelStates;
    407407    std::vector<Section> sections;
    408408    std::vector<cxuint> kcodeSelection; // kcode
     
    429429    explicit AsmGalliumHandler(Assembler& assembler);
    430430    /// destructor
    431     ~AsmGalliumHandler() = default;
     431    ~AsmGalliumHandler();
    432432   
    433433    cxuint addKernel(const char* kernelName);
  • CLRadeonExtender/trunk/amdasm/AsmGalliumFormat.cpp

    r3278 r3279  
    110110}
    111111
     112AsmGalliumHandler::~AsmGalliumHandler()
     113{
     114    for (Kernel* kernel: kernelStates)
     115        delete kernel;
     116}
     117
    112118cxuint AsmGalliumHandler::determineLLVMVersion() const
    113119{
     
    133139    /// add kernel config section
    134140    sections.push_back({ thisKernel, AsmSectionType::CONFIG, ELFSECTID_UNDEF, nullptr });
    135     kernelStates.push_back({ thisSection, nullptr, false, 0 });
     141    kernelStates.push_back(new Kernel{ thisSection, nullptr, false, 0 });
    136142   
    137143    if (assembler.currentKernel == ASMKERN_GLOBAL)
     
    223229    assembler.currentKernel = kernel;
    224230    if (kernel != ASMKERN_GLOBAL)
    225         assembler.currentSection = kernelStates[kernel].defaultSection;
     231        assembler.currentSection = kernelStates[kernel]->defaultSection;
    226232    else // default main section
    227233        assembler.currentSection = savedSection;
     
    289295    if (currentKcodeKernel != ASMKERN_GLOBAL)
    290296    {
    291         Kernel& newKernel = kernelStates[currentKcodeKernel];
     297        Kernel& newKernel = *kernelStates[currentKcodeKernel];
    292298        assembler.isaAssembler->setAllocatedRegisters(newKernel.allocRegs,
    293299                            newKernel.allocRegFlags);
     
    300306    {   // save other state
    301307        size_t regTypesNum;
    302         Kernel& oldKernel = kernelStates[currentKcodeKernel];
     308        Kernel& oldKernel = *kernelStates[currentKcodeKernel];
    303309        const cxuint* regs = assembler.isaAssembler->getAllocatedRegisters(
    304310                            regTypesNum, oldKernel.allocRegFlags);
     
    397403        return;
    398404    }
    399     if (handler.kernelStates[asmr.currentKernel].hasProgInfo)
     405    if (handler.kernelStates[asmr.currentKernel]->hasProgInfo)
    400406    {
    401407        asmr.printError(pseudoOpPlace,
     
    410416    handler.output.kernels[asmr.currentKernel].useConfig = true;
    411417    if (handler.determineLLVMVersion() >= 40000U) // HSA since LLVM 4.0
    412         handler.kernelStates[asmr.currentKernel].initializeAmdHsaKernelConfig();
     418        handler.kernelStates[asmr.currentKernel]->initializeAmdHsaKernelConfig();
    413419}
    414420
     
    944950   
    945951    handler.inside = AsmGalliumHandler::Inside::PROGINFO;
    946     handler.kernelStates[asmr.currentKernel].hasProgInfo = true;
     952    handler.kernelStates[asmr.currentKernel]->hasProgInfo = true;
    947953}
    948954
     
    988994   
    989995    // do operation
    990     AsmGalliumHandler::Kernel& kstate = handler.kernelStates[asmr.currentKernel];
     996    AsmGalliumHandler::Kernel& kstate = *handler.kernelStates[asmr.currentKernel];
    991997    kstate.hasProgInfo = true;
    992998    const cxuint llvmVersion = handler.determineLLVMVersion();
     
    10211027                               curAllocRegFlags);
    10221028        cxuint newAllocRegs[MAX_REGTYPES_NUM];
    1023         AsmGalliumHandler::Kernel& kernel = handler.kernelStates[*it];
     1029        AsmGalliumHandler::Kernel& kernel = *handler.kernelStates[*it];
    10241030        for (size_t i = 0; i < regTypesNum; i++)
    10251031            newAllocRegs[i] = std::max(curAllocRegs[i], kernel.allocRegs[i]);
     
    13891395        {
    13901396            config.usedSGPRsNum = std::min(
    1391                 std::max(minRegsNum[0], kernelStates[i].allocRegs[0]) +
     1397                std::max(minRegsNum[0], kernelStates[i]->allocRegs[0]) +
    13921398                    getGPUExtraRegsNum(arch, REGTYPE_SGPR,
    1393                         kernelStates[i].allocRegFlags|GCN_VCC),
     1399                        kernelStates[i]->allocRegFlags|GCN_VCC),
    13941400                    maxSGPRsNum); // include all extra sgprs
    13951401        }
    13961402        if (config.usedVGPRsNum==BINGEN_DEFAULT)
    1397             config.usedVGPRsNum = std::max(minRegsNum[1], kernelStates[i].allocRegs[1]);
     1403            config.usedVGPRsNum = std::max(minRegsNum[1], kernelStates[i]->allocRegs[1]);
    13981404    }
    13991405   
Note: See TracChangeset for help on using the changeset viewer.