void MarkLoops(Var * proc) { InstrBlock * blk; NumberBlocks(proc->instr); for(blk = proc->instr; blk != NULL; blk = blk->next) { blk->jump_type = JUMP_IF; } // Test for each block, if it is end of an loop for(blk = proc->instr; blk != NULL; blk = blk->next) { if (blk->cond_to != NULL) { // We jump to some previous spot in the sequence if (blk->cond_to->seq_no <= blk->seq_no) { blk->jump_type = JUMP_LOOP; //->cond_to->loop_end = blk; } } if (blk->to != NULL) { if (blk->to->seq_no <= blk->seq_no) { blk->jump_type = JUMP_LOOP; //to->loop_end = blk; } } } }
void Reduction<VoxelType>::Max(VoxelType * inputs, VoxelType * output, int numInputs, cudaStream_t stream) { int blockSize = NumberThreadsPerBlockThatBestFit(numInputs, OPTIMAL_BLOCK_SIZE_REDUCTION); if (numInputs > SIZE_SMALL_CUDA_VECTOR) { int blocks = NumberBlocks(numInputs, blockSize); if (temporaryBuffer->Length() < blocks) temporaryBuffer->ResizeWithoutPreservingData(blocks); KernelMax<VoxelType>(stream, blocks, blockSize, inputs, temporaryBuffer->Pointer(), numInputs); inputs = temporaryBuffer->Pointer(); numInputs = blocks; blockSize = NumberThreadsPerBlockThatBestFit(numInputs); } KernelMax<VoxelType>(stream, 1, blockSize, inputs, output, numInputs); }
void Reduction<VoxelType>::MinIndex(VoxelType * inputs, VoxelType * output, int * minIndex, int numInputs, cudaStream_t stream) { int blockSize = NumberThreadsPerBlockThatBestFit(numInputs, OPTIMAL_BLOCK_SIZE_REDUCTION); int * indexes = nullptr; if (numInputs > SIZE_SMALL_CUDA_VECTOR) { int blocks = NumberBlocks(numInputs, blockSize); int minSizeBuffer = blocks + (int) ceil(blocks * (sizeof(int) / (float) sizeof(float))); if (temporaryBuffer->Length() < minSizeBuffer) temporaryBuffer->ResizeWithoutPreservingData(minSizeBuffer); indexes = (int *)(temporaryBuffer->Pointer() + blocks); KernelMinIndexes<VoxelType>(stream, blocks, blockSize, inputs, temporaryBuffer->Pointer(), indexes, numInputs, nullptr); inputs = temporaryBuffer->Pointer(); numInputs = blocks; blockSize = NumberThreadsPerBlockThatBestFit(numInputs); } KernelMinIndexes<VoxelType>(stream, 1, blockSize, inputs, output, minIndex, numInputs, indexes); }