Changeset 5397 for icGREP/icgrep-devel


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

Avoiding MRemap for Mac OS X

Location:
icGREP/icgrep-devel/icgrep
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.cpp

    r5389 r5397  
    1717#include <errno.h>
    1818#include <llvm/Support/raw_ostream.h>
     19
    1920
    2021using namespace llvm;
     
    169170}
    170171
     172#ifdef __APPLE__
     173#define MAP_ANONYMOUS MAP_ANON
     174#endif
     175
    171176Value * CBuilder::CreateAnonymousMMap(Value * size) {
    172177    PointerType * const voidPtrTy = getVoidPtrTy();
     
    212217}
    213218
     219#ifndef __APPLE__
    214220Value * CBuilder::CreateMRemap(Value * addr, Value * oldSize, Value * newSize, const bool mayMove) {
    215221    DataLayout DL(mMod);
     
    230236    return ptr;
    231237}
     238#endif
    232239
    233240Value * CBuilder::CreateMUnmap(Value * addr, Value * size) {
  • 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.