[799] | 1 | /*************************************************************************/ |
---|
| 2 | /* */ |
---|
| 3 | /* Copyright (c) 1994 Stanford University */ |
---|
| 4 | /* */ |
---|
| 5 | /* All rights reserved. */ |
---|
| 6 | /* */ |
---|
| 7 | /* Permission is given to use, copy, and modify this software for any */ |
---|
| 8 | /* non-commercial purpose as long as this copyright notice is not */ |
---|
| 9 | /* removed. All other uses, including redistribution in whole or in */ |
---|
| 10 | /* part, are forbidden without prior written permission. */ |
---|
| 11 | /* */ |
---|
| 12 | /* This software is provided with absolutely no warranty and no */ |
---|
| 13 | /* support. */ |
---|
| 14 | /* */ |
---|
| 15 | /*************************************************************************/ |
---|
| 16 | |
---|
| 17 | #include <math.h> |
---|
| 18 | |
---|
| 19 | #include "decs.h" |
---|
| 20 | |
---|
| 21 | /////////////// |
---|
| 22 | void subblock() |
---|
| 23 | { |
---|
| 24 | long i; |
---|
| 25 | long j; |
---|
| 26 | long k; |
---|
| 27 | long xportion; |
---|
| 28 | long yportion; |
---|
| 29 | long my_num; |
---|
| 30 | |
---|
| 31 | /* Determine starting coord and number of points to process in */ |
---|
| 32 | /* each direction : i in numlev / j in xprocs / k in yprocs */ |
---|
| 33 | |
---|
| 34 | for (i = 0; i < numlev; i++) |
---|
| 35 | { |
---|
| 36 | xportion = (jmx[i] - 2) / xprocs; |
---|
| 37 | for (j = 0; j < xprocs; j++) |
---|
| 38 | { |
---|
| 39 | for (k = 0; k < yprocs; k++) |
---|
| 40 | { |
---|
| 41 | gps[k * xprocs + j]->rel_num_x[i] = xportion; |
---|
| 42 | } |
---|
| 43 | } |
---|
| 44 | yportion = (imx[i] - 2) / yprocs; |
---|
| 45 | for (j = 0; j < yprocs; j++) |
---|
| 46 | { |
---|
| 47 | for (k = 0; k < xprocs; k++) |
---|
| 48 | { |
---|
| 49 | gps[j * xprocs + k]->rel_num_y[i] = yportion; |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | for (my_num = 0; my_num < nprocs; my_num++) |
---|
| 55 | { |
---|
| 56 | for (i = 0; i < numlev; i++) |
---|
| 57 | { |
---|
| 58 | gps[my_num]->rlist[i] = 1; |
---|
| 59 | gps[my_num]->rljst[i] = 1; |
---|
| 60 | gps[my_num]->rlien[i] = gps[my_num]->rlist[i] + gps[my_num]->rel_num_y[i]; |
---|
| 61 | gps[my_num]->rljen[i] = gps[my_num]->rljst[i] + gps[my_num]->rel_num_x[i]; |
---|
| 62 | gps[my_num]->eist[i] = gps[my_num]->rlist[i] + 1; |
---|
| 63 | gps[my_num]->oist[i] = gps[my_num]->rlist[i]; |
---|
| 64 | gps[my_num]->ejst[i] = gps[my_num]->rljst[i] + 1; |
---|
| 65 | gps[my_num]->ojst[i] = gps[my_num]->rljst[i]; |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | for (i = 0; i < nprocs; i++) |
---|
| 70 | { |
---|
| 71 | gps[i]->neighbors[LEFT] = -1; |
---|
| 72 | gps[i]->neighbors[RIGHT] = -1; |
---|
| 73 | gps[i]->neighbors[UP] = -1; |
---|
| 74 | gps[i]->neighbors[DOWN] = -1; |
---|
| 75 | gps[i]->neighbors[UPLEFT] = -1; |
---|
| 76 | gps[i]->neighbors[UPRIGHT] = -1; |
---|
| 77 | gps[i]->neighbors[DOWNLEFT] = -1; |
---|
| 78 | gps[i]->neighbors[DOWNRIGHT] = -1; |
---|
| 79 | |
---|
| 80 | if (i >= xprocs) |
---|
| 81 | { |
---|
| 82 | gps[i]->neighbors[UP] = i - xprocs; |
---|
| 83 | } |
---|
| 84 | if (i < nprocs - xprocs) |
---|
| 85 | { |
---|
| 86 | gps[i]->neighbors[DOWN] = i + xprocs; |
---|
| 87 | } |
---|
| 88 | if ((i % xprocs) > 0) |
---|
| 89 | { |
---|
| 90 | gps[i]->neighbors[LEFT] = i - 1; |
---|
| 91 | } |
---|
| 92 | if ((i % xprocs) < (xprocs - 1)) |
---|
| 93 | { |
---|
| 94 | gps[i]->neighbors[RIGHT] = i + 1; |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | j = gps[i]->neighbors[UP]; |
---|
| 98 | |
---|
| 99 | if (j != -1) |
---|
| 100 | { |
---|
| 101 | if ((j % xprocs) > 0) |
---|
| 102 | { |
---|
| 103 | gps[i]->neighbors[UPLEFT] = j - 1; |
---|
| 104 | } |
---|
| 105 | if ((j % xprocs) < (xprocs - 1)) |
---|
| 106 | { |
---|
| 107 | gps[i]->neighbors[UPRIGHT] = j + 1; |
---|
| 108 | } |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | j = gps[i]->neighbors[DOWN]; |
---|
| 112 | |
---|
| 113 | if (j != -1) |
---|
| 114 | { |
---|
| 115 | if ((j % xprocs) > 0) |
---|
| 116 | { |
---|
| 117 | gps[i]->neighbors[DOWNLEFT] = j - 1; |
---|
| 118 | } |
---|
| 119 | if ((j % xprocs) < (xprocs - 1)) |
---|
| 120 | { |
---|
| 121 | gps[i]->neighbors[DOWNRIGHT] = j + 1; |
---|
| 122 | } |
---|
| 123 | } |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | for (i = 0; i < nprocs; i++) |
---|
| 127 | { |
---|
| 128 | gps[i]->rownum = i / xprocs; |
---|
| 129 | gps[i]->colnum = i % xprocs; |
---|
| 130 | } |
---|
| 131 | } // end subblock() |
---|