1 /*
2 * Copyright (c) 1995-2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18 /* common fio routines */
19
20 #include "fioMacros.h"
21 #include "descRW.h"
22 #include "global.h"
23
24 /* loop over local blocks in each array dimension, reducing to
25 one-dimensional strided transfers */
26
I8(__fortio_loop)27 void I8(__fortio_loop)(fio_parm *z, /* parameter struct */
28 int dim) /* dimension */
29 {
30 DECL_HDR_PTRS(ac);
31 DECL_DIM_PTRS(acd);
32 __INT_T *gb, *tempGB = 0; /* for traversing the gen_block when applicable*/
33 int direction, pshape;
34 __INT_T tExtent;
35
36 int blkno, i, k, pcoord;
37 __INT_T m, n, tl, tu;
38
39 ac = z->ac;
40 SET_DIM_PTRS(acd, ac, dim - 1);
41
42 z->index[dim - 1] = F90_DPTR_LBOUND_G(acd);
43 n = F90_DPTR_EXTENT_G(acd); /* extent */
44 if (n <= 0)
45 return;
46
47 /* handle unmapped dimension */
48
49 if (dim > 1) {
50 while (--n >= 0) {
51 I8(__fortio_loop)(z, dim - 1);
52 z->index[dim - 1]++;
53 }
54 } else {
55 z->cnt = n;
56 z->str = F90_DPTR_SSTRIDE_G(acd) * F90_DPTR_LSTRIDE_G(acd);
57 z->fio_rw(z);
58 }
59 return;
60 }
61
62 /*
63 * routines to broadcast status and io status
64 */
65
66 #if !defined(DESC_I8)
67
68 static __INT_T fio_bitv;
69 static __INT_T *fio_iostat;
70
71 /* init bitv and iostat */
72
__fort_status_init(bitv,iostat)73 void __fort_status_init(bitv, iostat) __INT_T *bitv;
74 __INT_T *iostat;
75 {
76 fio_bitv = *bitv;
77 fio_iostat = iostat;
78 }
79
80 /* status and iostat broadcast from i/o processor to others */
81
82 #undef DIST_STATUS_BCST
83 __INT_T
__fort_status_bcst(s)84 __fort_status_bcst(s) __INT_T s;
85 {
86 __INT_T msg[2];
87 int ioproc, lcpu;
88
89 if (((fio_bitv &
90 (FIO_BITV_IOSTAT | FIO_BITV_ERR | FIO_BITV_EOF | FIO_BITV_EOR)) == 0) ||
91 LOCAL_MODE) {
92 return (s);
93 }
94 ioproc = GET_DIST_IOPROC;
95 lcpu = GET_DIST_LCPU;
96 if (lcpu == ioproc) {/* i/o proc sets up data */
97 msg[0] = s;
98 if (fio_bitv & FIO_BITV_IOSTAT) {
99 msg[1] = *fio_iostat;
100 } else {
101 msg[1] = 0;
102 }
103 }
104 __fort_rbcst(ioproc, msg, 2, 1, __INT);
105 if (lcpu != ioproc) {/* others get data */
106 if (fio_bitv & FIO_BITV_IOSTAT) {
107 *fio_iostat = msg[1];
108 }
109 }
110 return (msg[0]);
111 }
112
113 /* initialize i/o condition handling bit vector and iostat address */
114
115 void
__fortio_stat_init(__INT_T * bitv,__INT_T * iostat)116 __fortio_stat_init(__INT_T *bitv, __INT_T *iostat)
117 {
118 fio_bitv = *bitv;
119 fio_iostat = iostat;
120 }
121
122 /* broadcast status and iostat from i/o processor to others */
123
124 int
__fortio_stat_bcst(int * stat)125 __fortio_stat_bcst(int *stat)
126 {
127 __INT_T msg[2];
128 int ioproc, lcpu;
129
130 if (!LOCAL_MODE &&
131 fio_bitv &
132 (FIO_BITV_IOSTAT | FIO_BITV_ERR | FIO_BITV_EOF | FIO_BITV_EOR)) {
133 ioproc = GET_DIST_IOPROC;
134 lcpu = GET_DIST_LCPU;
135 if (lcpu == ioproc) {
136 msg[0] = *stat;
137 msg[1] = (fio_bitv & FIO_BITV_IOSTAT) ? *fio_iostat : 0;
138 }
139 __fort_rbcstl(ioproc, msg, 2, 1, __INT, sizeof(__INT_T));
140 if (lcpu != ioproc) {
141 *stat = msg[0];
142 if (fio_bitv & FIO_BITV_IOSTAT)
143 *fio_iostat = msg[1];
144 }
145 }
146 return *stat;
147 }
148
149 #endif
150