1 /*****************************************************************************
2 * *
3 * Copyright (c) 2003-2006 Intel Corporation. *
4 * All rights reserved. *
5 * *
6 *****************************************************************************
7
8 This code is covered by the Community Source License (CPL), version
9 1.0 as published by IBM and reproduced in the file "license.txt" in the
10 "license" subdirectory. Redistribution in source and binary form, with
11 or without modification, is permitted ONLY within the regulations
12 contained in above mentioned license.
13
14 Use of the name and trademark "Intel(R) MPI Benchmarks" is allowed ONLY
15 within the regulations of the "License for Use of "Intel(R) MPI
16 Benchmarks" Name and Trademark" as reproduced in the file
17 "use-of-trademark-license.txt" in the "license" subdirectory.
18
19 THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
20 CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
21 LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
22 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
23 solely responsible for determining the appropriateness of using and
24 distributing the Program and assumes all risks associated with its
25 exercise of rights under this Agreement, including but not limited to
26 the risks and costs of program errors, compliance with applicable
27 laws, damage to or loss of data, programs or equipment, and
28 unavailability or interruption of operations.
29
30 EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
31 ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
32 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
33 WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
34 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
36 DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
37 HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
38
39 EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
40 YOUR JURISDICTION. It is licensee's responsibility to comply with any
41 export regulations applicable in licensee's jurisdiction. Under
42 CURRENT U.S. export regulations this software is eligible for export
43 from the U.S. and can be downloaded by or otherwise exported or
44 reexported worldwide EXCEPT to U.S. embargoed destinations which
45 include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
46 Afghanistan and any other country to which the U.S. has embargoed
47 goods and services.
48
49 ***************************************************************************
50
51 For more documentation than found here, see
52
53 [1] doc/ReadMe_IMB.txt
54
55 [2] Intel (R) MPI Benchmarks
56 Users Guide and Methodology Description
57 In
58 doc/IMB_ug.pdf
59
60 File: IMB_reduce_scatter.c
61
62 Implemented functions:
63
64 IMB_reduce_scatter;
65
66 ***************************************************************************/
67
68
69
70
71
72 #include "IMB_declare.h"
73 #include "IMB_benchmark.h"
74
75 #include "IMB_prototypes.h"
76
77
78 /*******************************************************************************/
79
80
81
IMB_reduce_scatter(struct comm_info * c_info,int size,int n_sample,MODES RUN_MODE,double * time)82 void IMB_reduce_scatter(struct comm_info* c_info, int size, int n_sample,
83 MODES RUN_MODE, double* time)
84 /*
85
86
87 MPI-1 benchmark kernel
88 Benchmarks MPI_Reduce_scatter
89
90
91
92 Input variables:
93
94 -c_info (type struct comm_info*)
95 Collection of all base data for MPI;
96 see [1] for more information
97
98
99 -size (type int)
100 Basic message size in bytes
101
102 -n_sample (type int)
103 Number of repetitions (for timing accuracy)
104
105 -RUN_MODE (type MODES)
106 (only MPI-2 case: see [1])
107
108
109 Output variables:
110
111 -time (type double*)
112 Timing result per sample
113
114
115 */
116 {
117 double t1, t2;
118 int i,pos1,pos2;
119 #ifdef CHECK
120 int pos,Locsize;
121 #endif
122
123 Type_Size s_size;
124
125 #ifdef CHECK
126 defect=0.;
127 #endif
128 ierr = 0;
129
130 /* GET SIZE OF DATA TYPE */
131 MPI_Type_size(c_info->red_data_type,&s_size);
132
133 for (i=0;i<c_info->num_procs ;i++)
134 {
135 IMB_get_rank_portion(i, c_info->num_procs, size, s_size,
136 &pos1, &pos2);
137 c_info->reccnt[i] = (pos2-pos1+1)/s_size;
138 #ifdef CHECK
139 if( i==c_info->rank ) {pos=pos1; Locsize= s_size*c_info->reccnt[i];}
140 #endif
141 }
142
143 if(c_info->rank!=-1)
144 {
145 for(i=0; i<N_BARR; i++) MPI_Barrier(c_info->communicator);
146
147 t1 = MPI_Wtime();
148 for(i=0;i< n_sample;i++)
149 {
150 ierr = MPI_Reduce_scatter
151 (c_info->s_buffer,c_info->r_buffer,
152 c_info->reccnt,
153 c_info->red_data_type,c_info->op_type,
154 c_info->communicator);
155 MPI_ERRHAND(ierr);
156
157 CHK_DIFF("Reduce_scatter",c_info, c_info->r_buffer, pos,
158 Locsize, size, asize,
159 put, 0, n_sample, i,
160 -1, &defect);
161
162 }
163 t2 = MPI_Wtime();
164 *time=(t2 - t1)/n_sample;
165 }
166 else
167 {
168 *time = 0.;
169 }
170
171 }
172
173