1 /*
2 * Copyright (c) 2017, 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 #include "stdioInterf.h"
19 #include "fioMacros.h"
20
21 extern struct cgrp *__fort_genlist();
22 extern struct chdr *__fort_allchn();
23
24 /* compute the recv/send order for a binary broadcast */
25
__fort_bcstchn(struct chdr * c,int scpu,int ncpus,int * cpus)26 void __fort_bcstchn(struct chdr *c,
27 int scpu, /* sending cpu */
28 int ncpus,/* number of receiving cpus */
29 int *cpus)
30 {
31 int lcpu;
32 int n;
33 char buf[80];
34
35 lcpu = __fort_myprocnum();
36
37 if (lcpu != scpu) {
38 c->cp[c->cn].op = CPU_RECV;
39 c->cp[c->cn].cpu = scpu;
40 c->cp[c->cn].rp = &(c->rp[0]);
41 c->cn++;
42 return;
43 }
44
45 for (n = 0; n < ncpus; n++) {
46 c->cp[c->cn].op = CPU_SEND;
47 c->cp[c->cn].cpu = cpus[n];
48 c->cp[c->cn].sp = &(c->sp[0]);
49 c->cn++;
50 }
51 }
52