static void apply_buf(const plan *ego_, R *IO) { const P *ego = (const P *) ego_; plan_rdft *cld0 = (plan_rdft *) ego->cld0; plan_rdft *cldm = (plan_rdft *) ego->cldm; INT i, j, m = ego->m, v = ego->v, r = ego->r; INT mb = ego->mb, me = ego->me, ms = ego->ms; INT batchsz = compute_batchsize(r); R *buf; size_t bufsz = r * batchsz * 2 * sizeof(R); BUF_ALLOC(R *, buf, bufsz); for (i = 0; i < v; ++i, IO += ego->vs) { R *IOp = IO; R *IOm = IO + m * ms; cld0->apply((plan *) cld0, IO, IO); for (j = mb; j + batchsz < me; j += batchsz) dobatch(ego, IOp, IOm, j, j + batchsz, buf); dobatch(ego, IOp, IOm, j, me, buf); cldm->apply((plan *) cldm, IO + ms * (m/2), IO + ms * (m/2)); } BUF_FREE(buf, bufsz); }
static void apply_buf(const plan *ego_, R *cr, R *ci) { const P *ego = (const P *) ego_; plan_rdft2 *cld0 = (plan_rdft2 *) ego->cld0; plan_rdft2 *cldm = (plan_rdft2 *) ego->cldm; INT i, j, ms = ego->ms, v = ego->v; INT batchsz = compute_batchsize(ego->r); R *buf; INT mb = 1, me = (ego->m+1) / 2; STACK_MALLOC(R *, buf, ego->r * batchsz * 2 * sizeof(R)); for (i = 0; i < v; ++i, cr += ego->vs, ci += ego->vs) { R *Rp = cr; R *Ip = ci; R *Rm = cr + ego->m * ms; R *Im = ci + ego->m * ms; cld0->apply((plan *) cld0, Rp, Ip, Rp, Ip); for (j = mb; j + batchsz < me; j += batchsz) dobatch(ego, Rp, Ip, Rm, Im, j, j + batchsz, 0, buf); dobatch(ego, Rp, Ip, Rm, Im, j, me, ego->extra_iter, buf); cldm->apply((plan *) cldm, Rp + me * ms, Ip + me * ms, Rp + me * ms, Ip + me * ms); } STACK_FREE(buf); }
// but best way is as whole vector as this implies that we want to // execute now too - no need for commit. int ipbatch(std::vector<std::string> &arg) { unsigned int i; std::string::size_type pos; int rval = 0; size_t len; for(i = 0; i < arg.size(); i++) { // first is it empty const std::string & s = arg[i]; // ignore any leading space pos = s.find_first_not_of(" \t\n"); if(pos == std::string::npos) continue; // only whitespace if(s[pos] == '#') continue; // a comment if(s.find("commit", pos) == pos) { syslog(LOG_WARNING, "commit\n"); rval = dobatch(batchstore); batchstoreidx = 0; batchstore[batchstoreidx] = 0; } else { // maybe some sanity checking here? // ================================================== // check if we will exceed the buffer with this line // if it will exceed the buffer, flush and reset the // pointers then add this line and continue. --slp // ================================================== len = strlen(s.c_str()); if(batchstoreidx + len + 2 >= BATCHSTORE_SIZE) { rval = (dobatch(batchstore) || rval); syslog(LOG_WARNING, "ipbatch buffer flushed, more to follow"); batchstoreidx = 0; batchstore[batchstoreidx] = 0; } syslog(LOG_WARNING, "batchline %s\n", s.c_str()); strncpy(&(batchstore[batchstoreidx]), s.c_str(), len); batchstoreidx += len; if(batchstore[batchstoreidx-1] != '\n') batchstore[batchstoreidx++] = '\n'; batchstore[batchstoreidx] = 0; // next string overwrites, but last must be null } } if(batchstoreidx > 0) rval = (dobatch(batchstore) || rval); return rval; }
static void apply_buf(const plan *ego_, R *ri, R *ii, R *ro, R *io) { const P *ego = (const P *) ego_; R *buf; INT vl = ego->vl, n = ego->n, batchsz = compute_batchsize(n); INT i; size_t bufsz = n * batchsz * 2 * sizeof(R); BUF_ALLOC(R *, buf, bufsz); for (i = 0; i < vl - batchsz; i += batchsz) { dobatch(ego, ri, ii, ro, io, buf, batchsz); ri += batchsz * ego->ivs; ii += batchsz * ego->ivs; ro += batchsz * ego->ovs; io += batchsz * ego->ovs; } dobatch(ego, ri, ii, ro, io, buf, vl - i); BUF_FREE(buf, bufsz); }
static void apply_buf(const plan *ego_, R *rio, R *iio) { const P *ego = (const P *) ego_; INT i, j, v = ego->v, r = ego->r; INT batchsz = compute_batchsize(r); R *buf; INT mb = ego->mb, me = ego->me; size_t bufsz = r * batchsz * 2 * sizeof(R); BUF_ALLOC(R *, buf, bufsz); for (i = 0; i < v; ++i, rio += ego->vs, iio += ego->vs) { for (j = mb; j + batchsz < me; j += batchsz) dobatch(ego, rio, iio, j, j + batchsz, buf); dobatch(ego, rio, iio, j, me, buf); } BUF_FREE(buf, bufsz); }
static void iterate(const P *ego, R *I, R *O, void (*dobatch)(const P *ego, R *I, R *O, R *buf, INT batchsz)) { R *buf; INT vl = ego->vl; INT n = ego->n; INT i; INT batchsz = compute_batchsize(n); size_t bufsz = n * batchsz * sizeof(R); BUF_ALLOC(R *, buf, bufsz); for (i = 0; i < vl - batchsz; i += batchsz) { dobatch(ego, I, O, buf, batchsz); I += batchsz * ego->ivs; O += batchsz * ego->ovs; } dobatch(ego, I, O, buf, vl - i); BUF_FREE(buf, bufsz); }