Changeset 5528


Ignore:
Timestamp:
Jun 22, 2017, 1:55:52 PM (20 months ago)
Author:
lindanl
Message:

editd: number of groups is now defined by number of pattern segments.

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/editd/EditdCudaDriver.h

    r5514 r5528  
    66#include <unistd.h>
    77#include <cassert>
     8#include <toolchain/toolchain.h>
    89#include "cuda.h"
    910
    1011#define GROUPTHREADS 64
    11 #define GROUPBLOCKS 64
    1212
    1313void checkCudaErrors(CUresult err) {
     
    7474  CUdeviceptr devStrides;
    7575
     76  const unsigned numOfGroups = codegen::GroupNum;
    7677  int strideSize = GROUPTHREADS * sizeof(ulong) * 4;
    7778  int strides = filesize/(strideSize * 2) + 1;
    7879  int bufferSize = strides * strideSize;
    79   int outputSize = sizeof(ulong) * GROUPTHREADS * strides * (dist + 1) * GROUPBLOCKS;
     80  int outputSize = sizeof(ulong) * GROUPTHREADS * strides * (dist + 1) * numOfGroups;
    8081
    8182  checkCudaErrors(cuMemAlloc(&devBufferInput, bufferSize));
     
    9697  unsigned blockSizeY = 1;
    9798  unsigned blockSizeZ = 1;
    98   unsigned gridSizeX  = GROUPBLOCKS;
     99  unsigned gridSizeX  = numOfGroups;
    99100  unsigned gridSizeY  = 1;
    100101  unsigned gridSizeZ  = 1;
     
    134135  // Retrieve device data
    135136  ulong * matchRslt;
    136   if (posix_memalign((void**)&matchRslt, 32, outputSize/GROUPBLOCKS)) {
     137  if (posix_memalign((void**)&matchRslt, 32, outputSize/numOfGroups)) {
    137138    std::cerr << "Cannot allocate memory for output.\n";
    138139    exit(-1);
    139140  }
    140141 
    141   checkCudaErrors(cuMemcpyDtoH(matchRslt, devBufferOutput, outputSize/GROUPBLOCKS));
     142  checkCudaErrors(cuMemcpyDtoH(matchRslt, devBufferOutput, outputSize/numOfGroups));
    142143
    143144  // Clean-up
  • icGREP/icgrep-devel/icgrep/editd/editd.cpp

    r5523 r5528  
    149149            pattFile.close();
    150150        }
     151        codegen::GroupNum = pattVector.size();
    151152    }
    152153
     
    384385
    385386#define GROUPTHREADS 64
    386 #define GROUPBLOCKS 64
    387387
    388388void editdGPUCodeGen(unsigned patternLen){
     
    501501    Value * myResultStreamPtr = iBuilder->CreateGEP(resultStreamPtr, {iBuilder->CreateMul(strideBlocks, strideNo)});
    502502    Value * myResultStream = iBuilder->CreateLoad(iBuilder->CreateGEP(myResultStreamPtr, {iBuilder->getInt32(0), bid}));
    503     for (unsigned i=1; i<GROUPBLOCKS; i++){
     503    for (int i=1; i<codegen::GroupNum; i++){
    504504        Value * nextStreamPtr = iBuilder->CreateGEP(myResultStreamPtr, {iBuilder->CreateMul(outputBlocks, iBuilder->getInt32(i)), bid});
    505505        myResultStream = iBuilder->CreateOr(myResultStream, iBuilder->CreateLoad(nextStreamPtr));
     
    582582        std::string patterns((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
    583583
    584         editdGPUCodeGen(patterns.length()/GROUPTHREADS - 1);
     584        editdGPUCodeGen(patterns.length()/codegen::GroupNum - 1);
    585585        mergeGPUCodeGen();
    586586        ulong * rslt = RunPTX(PTXFilename, chStream, size, patterns.c_str(), patterns.length(), editDistance);
Note: See TracChangeset for help on using the changeset viewer.