#include "cg.h"

__kernel void makea_2(__global int *rowstr,
                      __global int *last_n,
                      __global int *ilow,
                      __global int *ihigh)
{
  int myid = get_global_id(0);
  int num_threads = get_global_size(0);

  int nzrow = 0;
  if (myid < num_threads) {
    for (int i = 0; i < myid; i++) {
      nzrow = nzrow + last_n[i];
    }
  }
  if (nzrow > 0) {
    int j1 = (myid == 0) ? 0 : (ilow[myid] + 1);
    int j2 = ihigh[myid] + 1;

    for (int j = j1; j < j2; j++) {
      rowstr[j] = rowstr[j] + nzrow;
    }
  }
}

