Changeset 6021


Ignore:
Timestamp:
May 7, 2018, 3:10:38 PM (3 months ago)
Author:
xwa163
Message:

Add percentage for cycle counter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/toolchain/pipeline.cpp

    r6008 r6021  
    290290        b->CreatePThreadJoinCall(threadId, status);
    291291    }
    292    
     292
    293293    if (LLVM_UNLIKELY(DebugOptionIsSet(codegen::EnableCycleCounter))) {
     294        Value* FP_100 = ConstantFP::get(b->getDoubleTy(), 100.0);
     295        Value* totalCycles = b->getSize(0);
     296        for (const Kernel * kernel : kernels) {
     297            b->setKernel(kernel);
     298            Value * cycles = b->CreateLoad(b->getCycleCountPtr());
     299            totalCycles = b->CreateAdd(totalCycles, cycles);
     300        }
     301        Value* fTotalCycle = b->CreateUIToFP(totalCycles, b->getDoubleTy());
     302
    294303        for (const Kernel * kernel : kernels) {
    295304            b->setKernel(kernel);
     
    305314            Value * cycles = b->CreateLoad(b->getCycleCountPtr());
    306315            Value * fCycles = b->CreateUIToFP(cycles, b->getDoubleTy());
    307             const auto formatString = kernel->getName() + ": %7.2e items processed; %7.2e CPU cycles,  %6.2f cycles per item.\n";
     316            Value * percentage = b->CreateFDiv(b->CreateFMul(fCycles, FP_100), fTotalCycle);
     317
     318            const auto formatString = kernel->getName() + ": %7.2e items processed; %7.2e CPU cycles,  %6.2f cycles per item,  %2.2f%% of Total CPU Cycles. \n ";
    308319            Value * stringPtr = b->CreatePointerCast(b->GetString(formatString), b->getInt8PtrTy());
    309             b->CreateCall(b->GetDprintf(), {b->getInt32(2), stringPtr, fItems, fCycles, b->CreateFDiv(fCycles, fItems)});
     320            b->CreateCall(b->GetDprintf(), {b->getInt32(2), stringPtr, fItems, fCycles, b->CreateFDiv(fCycles, fItems), percentage});
    310321        }
    311322    }
     
    360371
    361372    b->SetInsertPoint(pipelineExit);
     373
    362374    if (LLVM_UNLIKELY(DebugOptionIsSet(codegen::EnableCycleCounter))) {
    363         for (unsigned k = 0; k < kernels.size(); k++) {
    364             auto & kernel = kernels[k];
     375        Value* FP_100 = ConstantFP::get(b->getDoubleTy(), 100.0);
     376        Value* totalCycles = b->getSize(0);
     377        for (const Kernel * kernel : kernels) {
     378            b->setKernel(kernel);
     379            Value * cycles = b->CreateLoad(b->getCycleCountPtr());
     380            totalCycles = b->CreateAdd(totalCycles, cycles);
     381        }
     382        Value* fTotalCycle = b->CreateUIToFP(totalCycles, b->getDoubleTy());
     383
     384        for (const Kernel * kernel : kernels) {
    365385            b->setKernel(kernel);
    366386            const auto & inputs = kernel->getStreamInputs();
     
    375395            Value * cycles = b->CreateLoad(b->getCycleCountPtr());
    376396            Value * fCycles = b->CreateUIToFP(cycles, b->getDoubleTy());
    377             const auto formatString = kernel->getName() + ": %7.2e items processed; %7.2e CPU cycles,  %6.2f cycles per item.\n";
     397            Value * percentage = b->CreateFDiv(b->CreateFMul(fCycles, FP_100), fTotalCycle);
     398
     399            const auto formatString = kernel->getName() + ": %7.2e items processed; %7.2e CPU cycles,  %6.2f cycles per item,  %2.2f%% of Total CPU Cycles. \n ";
    378400            Value * stringPtr = b->CreatePointerCast(b->GetString(formatString), b->getInt8PtrTy());
    379             b->CreateCall(b->GetDprintf(), {b->getInt32(2), stringPtr, fItems, fCycles, b->CreateFDiv(fCycles, fItems)});
     401            b->CreateCall(b->GetDprintf(), {b->getInt32(2), stringPtr, fItems, fCycles, b->CreateFDiv(fCycles, fItems), percentage});
    380402        }
    381403    }
Note: See TracChangeset for help on using the changeset viewer.