Ignore:
Timestamp:
Apr 6, 2017, 10:21:36 PM (2 years ago)
Author:
cameron
Message:

Avoiding MRemap for Mac OS X

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5395 r5397  
    186186    iBuilder->SetInsertPoint(expand);
    187187    Value * const reservedSize = iBuilder->CreateShl(requiredSize, 1);
     188#ifdef __APPLE__
     189    Value * newAddr = iBuilder->CreateAlignedMalloc(reservedSize, iBuilder->getCacheAlignment());
     190    Value * const baseAddrPtr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), iBuilder->getInt32(1)});
     191    Value * const baseAddr = iBuilder->CreateLoad(baseAddrPtr);
     192    iBuilder->CreateMemCpy(newAddr, baseAddr, currentSize, iBuilder->getCacheAlignment());
     193    iBuilder->CreateAlignedFree(baseAddr);
     194    Value * const remainingSize = iBuilder->CreateSub(reservedSize, currentSize);
     195    iBuilder->CreateMemZero(iBuilder->CreateGEP(newAddr, currentSize), remainingSize, iBuilder->getBitBlockWidth() / 8);
     196    newAddr = iBuilder->CreatePointerCast(newAddr, baseAddr->getType());
     197#else
    188198    Value * const baseAddrPtr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), iBuilder->getInt32(1)});
    189199    Value * const baseAddr = iBuilder->CreateLoad(baseAddrPtr);
    190200    Value * newAddr = iBuilder->CreateMRemap(baseAddr, currentSize, reservedSize);
    191201    newAddr = iBuilder->CreatePointerCast(newAddr, baseAddr->getType());
     202#endif
    192203    iBuilder->CreateStore(reservedSize, capacityPtr);
    193204    iBuilder->CreateStore(newAddr, baseAddrPtr);
Note: See TracChangeset for help on using the changeset viewer.