Changeset 3841 in CLRX


Ignore:
Timestamp:
Feb 23, 2018, 4:53:06 PM (14 months ago)
Author:
matszpk
Message:

CLRadeonExtender: SimpleCache?: Optimize updating sortedEntries after increasing element usage (add fast path).
Fixed updating maxWeight if weight of the element is greater.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdasm/AsmRegAlloc.cpp

    r3840 r3841  
    465465    void updateInSortedEntries(EntryMapIt it)
    466466    {
    467         // update after increasing usage, just swap entries if needed
     467        const size_t curPos = it->second.sortedPos;
     468        if (curPos == 0)
     469            return; // first position
     470        if (sortedEntries[curPos-1]->second.usage < it->second.usage &&
     471            (curPos==1 || sortedEntries[curPos-2]->second.usage >= it->second.usage))
     472        {
     473            //std::cout << "fast path" << std::endl;
     474            std::swap(sortedEntries[curPos-1]->second.sortedPos, it->second.sortedPos);
     475            std::swap(sortedEntries[curPos-1], sortedEntries[curPos]);
     476            return;
     477        }
     478        //std::cout << "slow path" << std::endl;
    468479        auto fit = std::upper_bound(sortedEntries.begin(),
    469480            sortedEntries.begin()+it->second.sortedPos, it,
     
    522533        const size_t elemWeight = value.weight();
    523534       
     535        // correct max weight if element have greater weight
     536        maxWeight = std::max(elemWeight, maxWeight);
     537       
    524538        while (totalWeight+elemWeight > maxWeight)
    525539        {
     
    534548       
    535549        totalWeight += elemWeight;
    536         // correct max weight if element have greater weight
    537         maxWeight = std::max(elemWeight, maxWeight);
    538550    }
    539551};
Note: See TracChangeset for help on using the changeset viewer.