title: Size of divided string in Knuth-Morris-Pratt Algorithm
body: <pre><code>int num = 0;
  char tmp_string[32000];
  
  if(l_length * lsize &gt; 32000){
      if (l_length * lsize % 32000 == 0) {
          num = l_length * lsize / 32000;
      } else{
          num = l_length * lsize / 32000 + 1;
      }
      ...
      if ( (l_length * lsize) % num == 0) {
          size = l_length * lsize / num;
      } else{
          size = l_length * lsize / num + 1;
      }
  } else {
      num = 1;
      size = l_length * lsize;
  }
  
  for (y = 0; y &lt; num; y++) {
      if (size % lsize == 0) {
          tmp_size = size / lsize;
      } else {
          tmp_size = size / lsize + 1;
      }
      .....find the matched pattern code.....
  }
  .....find the matched pattern between divided string.....
  </code></pre>
  
  <p>This code is some part of finding matched pattern in string.(KMP algorithm)</p>
  
  <p>I want to use only 32000byte string at one time.</p>
  
  <p>So if the size of string is bigger than 32000, I split them and calculate the "num" which is the number of loop. (eg. when the size is 64000, I have to run the function twice to search the whole string)</p>
  
  <p>lsize is the thread number(using the openCL actually) and l_length is the size of divided string that each thread will search.</p>
  
  <p>Problem is some string must be not searched because the size is missed during the dividing function. (eg. size = l_length*lsize/num &amp;&amp; tmp_size = size/lsize)</p>
  
  <p>I tried to change the code but couldn't find the appropriate length of each thread. (Another code for finding the pattern between divided string already exist.)</p>
  
  <p>How can I solve it?</p>