コード例 #1
0
ファイル: ImageBlocker.cpp プロジェクト: tclarke/nitro
ImageBlocker::ImageBlocker(size_t numRows,
                           size_t numCols,
                           size_t numRowsPerBlock,
                           size_t numColsPerBlock) :
    mStartRow(1, 0),
    mNumRows(1, numRows),
    mTotalNumRows(numRows),
    mNumCols(numCols),
    mNumRowsPerBlock(numRowsPerBlock),
    mNumColsPerBlock(numColsPerBlock),
    mNumBlocksDownRows(1),
    mNumPadRowsInFinalBlock(1)
{
    if (numRowsPerBlock == 0 || numColsPerBlock == 0)
    {
        throw except::Exception(Ctxt("Dimensions per block must be positive"));
    }

    getBlockInfo(numRows, mNumRowsPerBlock,
                 mNumBlocksDownRows[0], mNumPadRowsInFinalBlock[0]);

    getBlockInfo(mNumCols, mNumColsPerBlock,
                 mNumBlocksAcrossCols, mNumPadColsInFinalBlock);
}
コード例 #2
0
ファイル: ftpclient.c プロジェクト: mathlover777/NetworksLab
void callClient(const char *fileInx){
  
  no_writen = 0;
  num_blks = 0;
  num_last_blk = 0;
  // gets(fileIn);
  strcpy(fileIn,fileInx);
  len = strlen(fileIn);
  printf("\nAttempting Download {%s}\n",fileIn);
  // DEBUG printf("\nLen = %d\n",len);
  while(setupConnection()==-1);
  reportFile();
  openfile();
  getBlockInfo();
  beginread();
  readpartial();
  fclose(fp);
  close(sockid);
  return;
}
コード例 #3
0
ShortestPathAnalysis::Weight ShortestPathAnalysis::
getWeight(SILBasicBlock *BB, Weight CallerWeight) {
  assert(BB->getParent() == F);

  SILLoop *Loop = LI->getLoopFor(BB);
  if (!Loop) {
    // We are not in a loop. So just account the length of our function scope
    // in to the length of the CallerWeight.
    return Weight(CallerWeight.ScopeLength + getScopeLength(BB, 0),
                  CallerWeight.LoopWeight);
  }
  int LoopDepth = Loop->getLoopDepth();
  // Deal with the corner case of having more than 4 nested loops.
  while (LoopDepth >= MaxNumLoopLevels) {
    --LoopDepth;
    Loop = Loop->getParentLoop();
  }
  Weight W(getScopeLength(BB, LoopDepth), SingleLoopWeight);

  // Add weights for all the loops BB is in.
  while (Loop) {
    assert(LoopDepth > 0);
    BlockInfo *HeaderInfo = getBlockInfo(Loop->getHeader());
    int InnerLoopLength = HeaderInfo->getScopeLength(LoopDepth) *
                            ShortestPathAnalysis::LoopCount;
    int OuterLoopWeight = SingleLoopWeight;
    int OuterScopeLength = HeaderInfo->getScopeLength(LoopDepth - 1);

    // Reaching the outermost loop, we use the CallerWeight to get the outer
    // length+loopweight.
    if (LoopDepth == 1) {
      // If the apply in the caller is not in a significant loop, just stop with
      // what we have now.
      if (CallerWeight.LoopWeight < 4)
        return W;

      // If this function is part of the caller's scope length take the caller's
      // scope length. Note: this is not the case e.g. if the apply is in a
      // then-branch of an if-then-else in the caller and the else-branch is
      // the short path.
      if (CallerWeight.ScopeLength > OuterScopeLength)
        OuterScopeLength = CallerWeight.ScopeLength;
      OuterLoopWeight = CallerWeight.LoopWeight;
    }
    assert(OuterScopeLength >= InnerLoopLength);

    // If the current loop is only a small part of its outer loop, we don't
    // take the outer loop that much into account. Only if the current loop is
    // actually the "main part" in the outer loop we add the full loop weight
    // for the outer loop.
    if (OuterScopeLength < InnerLoopLength * 2) {
      W.LoopWeight += OuterLoopWeight - 1;
    } else if (OuterScopeLength < InnerLoopLength * 3) {
      W.LoopWeight += OuterLoopWeight - 2;
    } else if (OuterScopeLength < InnerLoopLength * 4) {
      W.LoopWeight += OuterLoopWeight - 3;
    } else {
      return W;
    }
    --LoopDepth;
    Loop = Loop->getParentLoop();
  }
  assert(LoopDepth == 0);
  return W;
}