Changeset 5721 for icGREP/icgrep-devel


Ignore:
Timestamp:
Nov 2, 2017, 10:22:06 AM (19 months ago)
Author:
cameron
Message:

EnableAsserts? and EnableCycleCounter? are DebugOptions? (disable object caching)

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

Legend:

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

    r5706 r5721  
    340340    size = CreateZExtOrTrunc(size, sizeTy);
    341341    ConstantInt * const align = ConstantInt::get(sizeTy, alignment);
    342     if (codegen::EnableAsserts) {
     342    if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    343343        CreateAssertZero(CreateURem(size, align), "CreateAlignedMalloc: size must be an integral multiple of alignment.");
    344344    }
     
    364364        Value * handle = CreateAlloca(voidPtrTy);
    365365        CallInst * success = CreateCall(f, {handle, align, size});
    366         if (codegen::EnableAsserts) {
     366        if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    367367            CreateAssertZero(success, "CreateAlignedMalloc: posix_memalign reported bad allocation");
    368368        }
     
    448448    }
    449449    Value * ptr = CreateCall(fMMap, {addr, size, prot, flags, fd, offset});
    450     if (codegen::EnableAsserts) {
     450    if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    451451        DataLayout DL(m);
    452452        IntegerType * const intTy = getIntPtrTy(DL);
     
    538538        ConstantInt * const flags = ConstantInt::get(intTy, MREMAP_MAYMOVE);
    539539        ptr = CreateCall(fMRemap, {addr, oldSize, newSize, flags});
    540         if (codegen::EnableAsserts) {
     540        if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    541541            Value * success = CreateICmpNE(CreatePtrToInt(addr, intTy), ConstantInt::getAllOnesValue(intTy)); // MAP_FAILED = -1
    542542            CreateAssert(success, "CreateMRemap: mremap failed to allocate memory");
     
    560560    }
    561561    len = CreateZExtOrTrunc(len, sizeTy);
    562     if (codegen::EnableAsserts) {
     562    if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    563563        DataLayout DL(getModule());
    564564        IntegerType * const intPtrTy = getIntPtrTy(DL);
     
    858858
    859859void CBuilder::__CreateAssert(Value * const assertion, StringRef failureMessage) {
    860     if (LLVM_UNLIKELY(codegen::EnableAsserts)) {
     860    if (LLVM_UNLIKELY(codegen::DebugOptionIsSet(codegen::EnableAsserts))) {
    861861        Module * const m = getModule();
    862862        if (LLVM_UNLIKELY(isa<ConstantInt>(assertion))) {
     
    11151115
    11161116#define CHECK_ADDRESS(Ptr, Name) \
    1117 if (codegen::EnableAsserts) { \
     1117if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) { \
    11181118    CreateAssert(Ptr, Name " was given a null address"); \
    11191119    if (AllocaInst * Base = resolveStackAddress(Ptr)) { \
     
    11511151
    11521152inline bool CBuilder::hasAddressSanitizer() const {
    1153     return codegen::EnableAsserts && mDriver && mDriver->hasExternalFunction("__asan_region_is_poisoned");
     1153    return codegen::DebugOptionIsSet(codegen::EnableAsserts) && mDriver && mDriver->hasExternalFunction("__asan_region_is_poisoned");
    11541154}
    11551155
    11561156LoadInst * CBuilder::CreateAlignedLoad(Value * Ptr, unsigned Align, const char * Name) {
    1157     if (codegen::EnableAsserts) {
     1157    if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    11581158        DataLayout DL(getModule());
    11591159        IntegerType * const intPtrTy = cast<IntegerType>(DL.getIntPtrType(Ptr->getType()));
     
    11671167
    11681168LoadInst * CBuilder::CreateAlignedLoad(Value * Ptr, unsigned Align, const Twine & Name) {
    1169     if (codegen::EnableAsserts) {
     1169    if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    11701170        DataLayout DL(getModule());
    11711171        IntegerType * const intPtrTy = cast<IntegerType>(DL.getIntPtrType(Ptr->getType()));
     
    11791179
    11801180LoadInst * CBuilder::CreateAlignedLoad(Value * Ptr, unsigned Align, bool isVolatile, const Twine & Name) {
    1181     if (codegen::EnableAsserts) {
     1181    if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    11821182        DataLayout DL(getModule());
    11831183        IntegerType * const intPtrTy = cast<IntegerType>(DL.getIntPtrType(Ptr->getType()));
     
    11911191
    11921192StoreInst * CBuilder::CreateAlignedStore(Value * Val, Value * Ptr, unsigned Align, bool isVolatile) {
    1193     if (codegen::EnableAsserts) {
     1193    if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    11941194        DataLayout DL(getModule());
    11951195        IntegerType * const intPtrTy = cast<IntegerType>(DL.getIntPtrType(Ptr->getType()));
     
    12041204CallInst * CBuilder::CreateMemMove(Value * Dst, Value * Src, Value *Size, unsigned Align, bool isVolatile,
    12051205                                   MDNode *TBAATag, MDNode *ScopeTag, MDNode *NoAliasTag) {
    1206     if (codegen::EnableAsserts) {
     1206    if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    12071207        DataLayout DL(getModule());
    12081208        IntegerType * const intPtrTy = DL.getIntPtrType(getContext());
     
    12221222CallInst * CBuilder::CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align, bool isVolatile,
    12231223                                  MDNode *TBAATag, MDNode *TBAAStructTag, MDNode *ScopeTag, MDNode *NoAliasTag) {
    1224     if (codegen::EnableAsserts) {
     1224    if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    12251225        DataLayout DL(getModule());
    12261226        IntegerType * const intPtrTy = DL.getIntPtrType(getContext());
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5706 r5721  
    659659        baseInputBuffer[i] = kb->getInputStreamPtr(name, blockIndex);
    660660
    661         if (codegen::EnableAsserts) {
     661        if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    662662            kb->CreateAssert(kb->CreateICmpUGE(mAvailableItemCount[i], processedItemCount[i]),
    663663                             "Processed item count cannot exceed the available item count");
     
    14361436
    14371437static inline std::string annotateKernelNameWithDebugFlags(std::string && name) {
    1438     if (codegen::EnableAsserts) {
     1438    if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    14391439        name += "_EA";
    14401440    }
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5706 r5721  
    5151
    5252Value * StreamSetBuffer::getStreamBlockPtr(IDISA::IDISA_Builder * const iBuilder, Value * self, Value * addr, Value * streamIndex, const bool /* readOnly */) const {
    53     if (codegen::EnableAsserts) {
     53    if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    5454        Value * const count = getStreamSetCount(iBuilder, self);
    5555        Value * const index = iBuilder->CreateZExtOrTrunc(streamIndex, count->getType());
     
    6161
    6262Value * StreamSetBuffer::getStreamPackPtr(IDISA::IDISA_Builder * const iBuilder, Value * self, Value * addr, Value * streamIndex, Value * packIndex, const bool /* readOnly */) const {
    63     if (codegen::EnableAsserts) {
     63    if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    6464        Value * const count = getStreamSetCount(iBuilder, self);
    6565        Value * const index = iBuilder->CreateZExtOrTrunc(streamIndex, count->getType());
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r5716 r5721  
    429429        b->SetInsertPoint(resume);
    430430
    431         if (codegen::EnableAsserts) {
     431        if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    432432            b->CreateAssertZero(b->CreateOr(finalBorrow, finalCarry),
    433433                                       "CarryManager: loop post-condition violated: final borrow and carry must be zero!");
  • icGREP/icgrep-devel/icgrep/pablo/carrypack_manager.cpp

    r5713 r5721  
    452452        iBuilder->SetInsertPoint(resume);
    453453
    454         if (codegen::EnableAsserts) {
     454        if (codegen::DebugOptionIsSet(codegen::EnableAsserts)) {
    455455            iBuilder->CreateAssertZero(iBuilder->CreateOr(finalBorrow, finalCarry),
    456456                                       "CarryPackManager: loop post-condition violated: final borrow and carry must be zero!");
  • icGREP/icgrep-devel/icgrep/toolchain/pipeline.cpp

    r5706 r5721  
    9999    Value * cycleCountStart = nullptr;
    100100    Value * cycleCountEnd = nullptr;
    101     if (codegen::EnableCycleCounter) {
     101    if (DebugOptionIsSet(codegen::EnableCycleCounter)) {
    102102        cycleCountStart = iBuilder->CreateReadCycleCounter();
    103103    }
     
    174174            }
    175175        }
    176         if (codegen::EnableCycleCounter) {
     176        if (DebugOptionIsSet(codegen::EnableCycleCounter)) {
    177177            cycleCountEnd = iBuilder->CreateReadCycleCounter();
    178178            Value * counterPtr = iBuilder->getCycleCountPtr();
     
    271271    }
    272272   
    273     if (codegen::EnableCycleCounter) {
     273    if (DebugOptionIsSet(codegen::EnableCycleCounter)) {
    274274        for (unsigned k = 0; k < kernels.size(); k++) {
    275275            auto & kernel = kernels[k];
     
    516516    Value * cycleCountStart = nullptr;
    517517    Value * cycleCountEnd = nullptr;
    518     if (codegen::EnableCycleCounter) {
     518    if (DebugOptionIsSet(codegen::EnableCycleCounter)) {
    519519        cycleCountStart = iBuilder->CreateReadCycleCounter();
    520520    }
     
    563563            }
    564564        }
    565         if (codegen::EnableCycleCounter) {
     565        if (DebugOptionIsSet(codegen::EnableCycleCounter)) {
    566566            cycleCountEnd = iBuilder->CreateReadCycleCounter();
    567567            Value * counterPtr = iBuilder->getCycleCountPtr();
     
    596596    iBuilder->SetInsertPoint(pipelineExit);
    597597
    598     if (codegen::EnableCycleCounter) {
     598    if (DebugOptionIsSet(codegen::EnableCycleCounter)) {
    599599        for (unsigned k = 0; k < kernels.size(); k++) {
    600600            auto & kernel = kernels[k];
  • icGREP/icgrep-devel/icgrep/toolchain/toolchain.cpp

    r5656 r5721  
    3333                        clEnumVal(TraceCounts, "Show kernel processed and produced item counts."),
    3434                        clEnumVal(TraceDynamicBuffers, "Show dynamic buffer allocations and deallocations."),
     35                        clEnumVal(EnableAsserts, "Enable built-in Parabix framework asserts in generated IR."),
     36                        clEnumVal(EnableCycleCounter, "Count and report CPU cycles per kernel."),
    3537                        clEnumValEnd), cl::cat(CodeGenOptions));
    3638
     
    7173                                          cl::desc("Number of threads used for segment pipeline parallel"), cl::value_desc("positive integer"));
    7274
    73 
    74 static cl::opt<bool, true> EnableAssertsOption("ea", cl::location(EnableAsserts), cl::init(IN_DEBUG_MODE),
    75                                                cl::desc("Enable Asserts"), cl::cat(CodeGenOptions));
    76 
    77 static cl::opt<bool, true> EnableCycleCountOption("ShowKernelCycles", cl::location(EnableCycleCounter), cl::init(false),
    78                                              cl::desc("Count and report CPU cycles per kernel"), cl::cat(CodeGenOptions));
    7975
    8076static cl::opt<bool, true> pipelineParallelOption("enable-pipeline-parallel", cl::location(PipelineParallel), cl::init(false),
     
    110106int ThreadNum;
    111107
    112 bool EnableAsserts;
    113 
    114 bool EnableCycleCounter;
    115 
    116108bool EnableObjectCache;
    117109
     
    148140
    149141bool DebugOptionIsSet(const DebugFlags flag) {
     142    if (IN_DEBUG_MODE && (flag == EnableAsserts)) return true;
    150143    return DebugOptions.isSet(flag);
    151144}
  • icGREP/icgrep-devel/icgrep/toolchain/toolchain.h

    r5637 r5721  
    3333    SerializeThreads,
    3434    TraceCounts,
    35     TraceDynamicBuffers
     35    TraceDynamicBuffers,
     36    EnableAsserts,
     37    EnableCycleCounter,
     38    DebugFlagSentinel
    3639};
    3740
     
    5154extern int ThreadNum;
    5255extern bool EnableObjectCache;
    53 extern bool EnableAsserts;
    54 extern bool EnableCycleCounter;
    5556extern bool NVPTX;
    5657extern int GroupNum;
Note: See TracChangeset for help on using the changeset viewer.