147 Int templateheight, blockheight;
148 templateheight = p * nbrow;
149 if (m % templateheight != 0) {
150 if ((m % templateheight) > (nbrow * myprow)) {
154 if ((m % templateheight) >= (nbrow * (myprow + 1))) {
157 blockheight = (m / templateheight) * nbrow + nbrow;
159 blockheight = (m / templateheight) * nbrow + (m % nbrow);
163 blockheight = (m / templateheight) * nbrow;
206 Int p2, q2, myprow, mypcol;
221 if (myprow >= p2 || mypcol >= q2)
222 myprow = mypcol = -1;
223 if ((myprow >= 0 || mypcol >= 0) && (p2 != p && q2 != q)) {
224 fprintf(stderr,
"??MR2D:incoherent p,q parameters\n");
227 assert(myprow < p && mypcol < q);
229 fprintf(stderr,
"??MR2D:Bad first processor coordinates\n");
232 if (i < 0 || j < 0 || i + m > a->
m || j + n > a->
n) {
233 fprintf(stderr,
"??MR2D:Bad submatrix:i=%d,j=%d,\
234m=%d,n=%d,M=%d,N=%d\n",
235 i, j, m, n, a->
m, a->
n);
238 if ((myprow >= 0 || mypcol >= 0) &&
240 fprintf(stderr,
"??MR2D:bad lda arg:row=%d,m=%d,p=%d,\
241nbrow=%d,lda=%d,sprow=%d\n",
252 Int tempheight, firstblock, firsttemp;
255 firsttemp = i / tempheight;
256 firstblock = (i / bs) % p;
257 *newsp = (sp + firstblock) % p;
259 *decal = firsttemp * bs + (
SHIFT(myp, sp, p) < firstblock ? bs : 0);
271 Int vtemp, htemp, vsubtemp, hsubtemp, il, jl;
272 assert(ig >= 0 && ig < a->m && jg >= 0 && jg < a->n);
276 vtemp = ig / templateheight;
277 htemp = jg / templatewidth;
280 vsubtemp = ig % a->
nbrow;
281 hsubtemp = jg % a->
nbcol;
283 il = a->
nbrow * vtemp + vsubtemp;
284 jl = a->
nbcol * htemp + hsubtemp;
288 Int pr, pc, p, q, lp, lq;
290 p = templateheight / a->
nbrow;
291 q = templatewidth / a->
nbcol;
292 lp = ig % templateheight / a->
nbrow;
293 lq = jg % templatewidth / a->
nbcol;
298 return (jl * a->
lda + il);