#include #include int **starts, **ends; const int NUM_BLOCKS = 9, THREADS_PER_BLOCK = 10; const std::string input = "assign4input1"; // figures out the start and end position for every thread and puts them in 2D arrays. void calculateStarts(int textLength, int patternLength) { int majorChunkSize = textLength / NUM_BLOCKS; int minorChunkSize = majorChunkSize / THREADS_PER_BLOCK; int chunkStart = 0; starts = new int*[NUM_BLOCKS]; ends = new int*[NUM_BLOCKS]; for (int i = 0; i textLength... the matching algorithm will only check to textLength-1! ends[i][j] = starts[i][j] + minorChunkSize + patternLength - 1; } // remainders are added to the end of the last chunk int remainingForChunk = majorChunkSize % THREADS_PER_BLOCK; ends[i][THREADS_PER_BLOCK-1] += remainingForChunk; } int remainingForWhole = textLength%NUM_BLOCKS; ends[NUM_BLOCKS - 1][THREADS_PER_BLOCK - 1] += remainingForWhole; } int main() { calculateStarts(1000, 20); return 0; }