static void randroutine(const void *const arg) { const idargument *const ia = (idargument *)arg; const workset *const ws = ia->tp->extra; const runconfig *const rc = ia->tp->rc; const unsigned id = ia->id; const unsigned sz = rc->size; const unsigned l = sz; const unsigned m = sz; const unsigned n = sz; const unsigned tr = tilerows; const unsigned tc = tilecols; const joblayout al = definejob(rc, id, l, m, tr, tc); const joblayout bl = definejob(rc, id, m, n, tc, tr); eltype *const a = ws->a + al.baseoffset / sizeof(eltype); eltype *const b = ws->b + bl.baseoffset / sizeof(eltype); matfill(id, al.absolutebaserow, a, al.baserow, al.nrows, m, tc, elrand); matfill(id * 5, bl.absolutebaserow, b, bl.baserow, bl.nrows, n, tr, elrand); printf("rand %03u with %u rows is done on core %d\n", id, al.nrows, sched_getcpu()); }
static void randroutine(const void *const arg) { const idargument *const ia = (idargument *)arg; const workset *const ws = ia->tp->extra; const runconfig *const rc = ia->tp->rc; const unsigned id = ia->id; const unsigned sz = rc->size; const unsigned l = sz; const unsigned m = sz; const unsigned n = sz; const unsigned tr = tilerows; const unsigned tc = tilecols; const joblayout al = definejob(rc, id, l, m, tr, tc); const joblayout bl = definejob(rc, id, m, n, tc, tr); const unsigned adiff = (al.baseoffset - al.mapoffset) / sizeof(eltype); eltype *const a = (eltype *)peekmap(rc, ws->fda, al.mapoffset, al.maplength, pmwrite | pmshared) + adiff; const unsigned bdiff = (bl.baseoffset - bl.mapoffset) / sizeof(eltype); eltype *const b = (eltype *)peekmap(rc, ws->fdb, bl.mapoffset, bl.maplength, pmwrite | pmshared) + bdiff; matfill(id, al.absolutebaserow, a, al.baserow, al.nrows, m, tc, elrand); matfill(id * 5, bl.absolutebaserow, b, bl.baserow, bl.nrows, n, tr, elrand); printf("rand %03u with a:%u b:%u rows is done on core %d\n", id, al.nrows, bl.nrows, sched_getcpu()); }
GEN shallowmatconcat(GEN v) { long i, j, h, l = lg(v), L = 0, H = 0; GEN M, maxh, maxl; if (l == 1) return cgetg(1,t_MAT); switch(typ(v)) { case t_VEC: for (i = 1; i < l; i++) { GEN c = gel(v,i); GEN s = _matsize(c); H = maxss(H, s[1]); L += s[2]; } M = zeromatcopy(H, L); L = 0; for (i = 1; i < l; i++) { GEN c = gel(v,i); GEN s = _matsize(c); matfill(M, c, 0, L, 1); L += s[2]; } return M; case t_COL: for (i = 1; i < l; i++) { GEN c = gel(v,i); GEN s = _matsize(c); H += s[1]; L = maxss(L, s[2]); } M = zeromatcopy(H, L); H = 0; for (i = 1; i < l; i++) { GEN c = gel(v,i); GEN s = _matsize(c); matfill(M, c, H, 0, 1); H += s[1]; } return M; case t_MAT: h = lgcols(v); maxh = zero_zv(h-1); maxl = zero_zv(l-1); for (j = 1; j < l; j++) for (i = 1; i < h; i++) { GEN c = gcoeff(v,i,j); GEN s = _matsize(c); if (s[1] > maxh[i]) maxh[i] = s[1]; if (s[2] > maxl[j]) maxl[j] = s[2]; } for (i = 1, H = 0; i < h; i++) H += maxh[i]; for (j = 1, L = 0; j < l; j++) L += maxl[j]; M = zeromatcopy(H, L); for (j = 1, L = 0; j < l; j++) { for (i = 1, H = 0; i < h; i++) { GEN c = gcoeff(v,i,j); matfill(M, c, H, L, minss(maxh[i], maxl[j])); H += maxh[i]; } L += maxl[j]; } return M; default: pari_err_TYPE("shallowmatconcat", v); return NULL; } }