Changeset 598 for soft/giet_vm/applications/ocean/linkup.C
- Timestamp:
- Jul 9, 2015, 2:11:17 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/ocean/linkup.C
r589 r598 1 #line 115 "/Users/alain/soc/giet_vm/applications/ocean/null_macros/c.m4.null.GIET" 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 /*************************************************************************/ 2 16 17 /* Set all the pointers to the proper locations for the q_multi and 18 rhs_multi data structures */ 19 20 EXTERN_ENV 21 22 #include "decs.h" 23 24 void link_all() 25 { 26 long i; 27 long j; 28 29 for (j = 0; j < nprocs; j++) { 30 linkup(psium[j]); 31 linkup(psilm[j]); 32 linkup(psib[j]); 33 linkup(ga[j]); 34 linkup(gb[j]); 35 linkup(work2[j]); 36 linkup(work3[j]); 37 linkup(work6[j]); 38 linkup(tauz[j]); 39 linkup(oldga[j]); 40 linkup(oldgb[j]); 41 for (i = 0; i <= 1; i++) { 42 linkup(psi[j][i]); 43 linkup(psim[j][i]); 44 linkup(work1[j][i]); 45 linkup(work4[j][i]); 46 linkup(work5[j][i]); 47 linkup(work7[j][i]); 48 linkup(temparray[j][i]); 49 } 50 } 51 link_multi(); 52 } 53 54 void linkup(double **row_ptr) 55 { 56 long i; 57 double *a; 58 double **row; 59 double **y; 60 long x_part; 61 long y_part; 62 63 x_part = (jm - 2) / xprocs + 2; 64 y_part = (im - 2) / yprocs + 2; 65 row = row_ptr; 66 y = row + y_part; 67 a = (double *) y; 68 for (i = 0; i < y_part; i++) { 69 *row = (double *) a; 70 row++; 71 a += x_part; 72 } 73 } 74 75 void link_multi() 76 { 77 long i; 78 long j; 79 long l; 80 double *a; 81 double **row; 82 double **y; 83 unsigned long z; 84 unsigned long zz; 85 long x_part; 86 long y_part; 87 unsigned long d_size; 88 89 z = ((unsigned long) q_multi + nprocs * sizeof(double ***)); 90 91 if (nprocs % 2 == 1) { /* To make sure that the actual data 92 starts double word aligned, add an extra 93 pointer */ 94 z += sizeof(double ***); 95 } 96 97 d_size = numlev * sizeof(double **); 98 if (numlev % 2 == 1) { /* To make sure that the actual data 99 starts double word aligned, add an extra 100 pointer */ 101 d_size += sizeof(double **); 102 } 103 for (i = 0; i < numlev; i++) { 104 d_size += ((imx[i] - 2) / yprocs + 2) * ((jmx[i] - 2) / xprocs + 2) * sizeof(double) + ((imx[i] - 2) / yprocs + 2) * sizeof(double *); 105 } 106 for (i = 0; i < nprocs; i++) { 107 q_multi[i] = (double ***) z; 108 z += d_size; 109 } 110 for (j = 0; j < nprocs; j++) { 111 zz = (unsigned long) q_multi[j]; 112 zz += numlev * sizeof(double **); 113 if (numlev % 2 == 1) { /* To make sure that the actual data 114 starts double word aligned, add an extra 115 pointer */ 116 zz += sizeof(double **); 117 } 118 for (i = 0; i < numlev; i++) { 119 d_size = ((imx[i] - 2) / yprocs + 2) * ((jmx[i] - 2) / xprocs + 2) * sizeof(double) + ((imx[i] - 2) / yprocs + 2) * sizeof(double *); 120 q_multi[j][i] = (double **) zz; 121 zz += d_size; 122 } 123 } 124 125 for (l = 0; l < numlev; l++) { 126 x_part = (jmx[l] - 2) / xprocs + 2; 127 y_part = (imx[l] - 2) / yprocs + 2; 128 for (j = 0; j < nprocs; j++) { 129 row = q_multi[j][l]; 130 y = row + y_part; 131 a = (double *) y; 132 for (i = 0; i < y_part; i++) { 133 *row = (double *) a; 134 row++; 135 a += x_part; 136 } 137 } 138 } 139 140 z = ((unsigned long) rhs_multi + nprocs * sizeof(double ***)); 141 if (nprocs % 2 == 1) { /* To make sure that the actual data 142 starts double word aligned, add an extra 143 pointer */ 144 z += sizeof(double ***); 145 } 146 147 d_size = numlev * sizeof(double **); 148 if (numlev % 2 == 1) { /* To make sure that the actual data 149 starts double word aligned, add an extra 150 pointer */ 151 d_size += sizeof(double **); 152 } 153 for (i = 0; i < numlev; i++) { 154 d_size += ((imx[i] - 2) / yprocs + 2) * ((jmx[i] - 2) / xprocs + 2) * sizeof(double) + ((imx[i] - 2) / yprocs + 2) * sizeof(double *); 155 } 156 for (i = 0; i < nprocs; i++) { 157 rhs_multi[i] = (double ***) z; 158 z += d_size; 159 } 160 for (j = 0; j < nprocs; j++) { 161 zz = (unsigned long) rhs_multi[j]; 162 zz += numlev * sizeof(double **); 163 if (numlev % 2 == 1) { /* To make sure that the actual data 164 starts double word aligned, add an extra 165 pointer */ 166 zz += sizeof(double **); 167 } 168 for (i = 0; i < numlev; i++) { 169 d_size = ((imx[i] - 2) / yprocs + 2) * ((jmx[i] - 2) / xprocs + 2) * sizeof(double) + ((imx[i] - 2) / yprocs + 2) * sizeof(double *); 170 rhs_multi[j][i] = (double **) zz; 171 zz += d_size; 172 } 173 } 174 175 for (l = 0; l < numlev; l++) { 176 x_part = (jmx[l] - 2) / xprocs + 2; 177 y_part = (imx[l] - 2) / yprocs + 2; 178 for (j = 0; j < nprocs; j++) { 179 row = rhs_multi[j][l]; 180 y = row + y_part; 181 a = (double *) y; 182 for (i = 0; i < y_part; i++) { 183 *row = (double *) a; 184 row++; 185 a += x_part; 186 } 187 } 188 } 189 190 }
Note: See TracChangeset
for help on using the changeset viewer.