
#include "cg.h"

__kernel void makea_5(__global int *iv,
                      __global int *last_n,
                      __global int *g_ilow,
                      __global int *g_ihigh,
                      int n,
                      int nz)
{
  int myid = get_global_id(0);
  int num_threads = get_global_size(0);
  int ilow = g_ilow[myid];
  if (ilow >= n) return;
  int ihigh = g_ihigh[myid];

  int nzrow = 0;
  if (myid < num_threads) {
    for (int i = 0; i < myid; i++) {
      nzrow = nzrow + last_n[i];
    }
  }
  if (nzrow > 0) {
    __global int *nzloc = &iv[nz];
    for (int j = ilow; j < ihigh; j++) {
      nzloc[j] = nzloc[j] + nzrow;
    }
  }
}

