libxmp/libxmpf in Omni Compiler  1.3.4
xmp_pack_vector.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <omp.h>
#include <complex.h>
#include "xmp_internal.h"
Include dependency graph for xmp_pack_vector.c:

Macros

#define _XMP_SUM_VECTOR(_type)
 

Functions

void _XMP_pack_vector (char *restrict dst, char *restrict src, int count, int blocklength, long stride)
 
void _XMP_pack_vector2 (char *restrict dst, char *restrict src, int count, int blocklength, int nnodes, int type_size, int src_block_dim)
 
void _XMP_unpack_vector (char *restrict dst, char *restrict src, int count, int blocklength, long stride)
 
void _XMPF_unpack_transpose_vector (char *restrict dst, char *restrict src, int dst_stride, int src_stride, int type_size, int dst_block_dim)
 
void _XMP_sum_vector (int type, char *restrict dst, char *restrict src, int count, int blocklength, long stride)
 
void _XMP_check_reflect_type (void)
 

Variables

int _xmp_omp_num_procs = 1
 
int _xmp_reflect_pack_flag = 0
 

Macro Definition Documentation

◆ _XMP_SUM_VECTOR

#define _XMP_SUM_VECTOR (   _type)
Value:
for (long i = 0; i < count; i++){ \
for (long j = 0; j < blocklength; j++){ \
((_type *)dst)[i * stride + j] += ((_type *)src)[i * blocklength + j]; \
} \
}

Function Documentation

◆ _XMP_check_reflect_type()

void _XMP_check_reflect_type ( void  )
301 {
302  char *reflect_type = getenv("XMP_REFLECT_TYPE");
303  _xmp_omp_num_procs = omp_get_num_procs();
304 
305  if (reflect_type){
306 
307  if (strcmp(reflect_type, "REFLECT_NOPACK") == 0){
309  //xmpf_dbg_printf("REFLECT_NOPACK\n");
310  return;
311  }
312  else if (strcmp(reflect_type, "REFLECT_PACK") == 0){
314  //xmpf_dbg_printf("REFLECT_PACK\n");
315  return;
316  }
317 
318  }
319 
320  // not specified or a wrong value
321  if (_xmp_omp_num_procs > 1){
323  //xmpf_dbg_printf("not specified and REFLECT_PACK\n");
324  }
325  else {
327  //xmpf_dbg_printf("not specified and REFLECT_NOPACK\n");
328  }
329 
330 }

◆ _XMP_pack_vector()

void _XMP_pack_vector ( char *restrict  dst,
char *restrict  src,
int  count,
int  blocklength,
long  stride 
)
10  {
11  long i;
12  if (_xmp_omp_num_procs > 1 && count > 8 * _xmp_omp_num_procs){
13 #pragma omp parallel for private(i)
14  for (i = 0; i < count; i++){
15  memcpy(dst + i * blocklength, src + i * stride, blocklength);
16  }
17  }
18  else {
19  for (i = 0; i < count; i++){
20  memcpy(dst + i * blocklength, src + i * stride, blocklength);
21  }
22  }
23 
24 }
Here is the caller graph for this function:

◆ _XMP_pack_vector2()

void _XMP_pack_vector2 ( char *restrict  dst,
char *restrict  src,
int  count,
int  blocklength,
int  nnodes,
int  type_size,
int  src_block_dim 
)
28  {
29  long j,k;
30  if (src_block_dim == 1){
31 #pragma omp parallel for private(j,k)
32  for (j = 0; j < count; j++){
33  for (k = 0; k < nnodes; k++){
34  memcpy(dst + ((k * count +j ) * blocklength ) * type_size,
35  src + ((k + j * nnodes) * blocklength ) * type_size,
36  blocklength * type_size);
37  }
38  }
39  }
40 }

◆ _XMP_sum_vector()

void _XMP_sum_vector ( int  type,
char *restrict  dst,
char *restrict  src,
int  count,
int  blocklength,
long  stride 
)
102  {
103 
104  if (_xmp_omp_num_procs > 1 && count > 8 * _xmp_omp_num_procs){
105 
106  switch (type){
107 
108  case _XMP_N_TYPE_SHORT:
109 #pragma omp parallel for
110  _XMP_SUM_VECTOR(short);
111  break;
112 
114 #pragma omp parallel for
115  _XMP_SUM_VECTOR(unsigned short);
116  break;
117 
118  case _XMP_N_TYPE_INT:
119 #pragma omp parallel for
120  _XMP_SUM_VECTOR(int);
121  break;
122 
124 #pragma omp parallel for
125  _XMP_SUM_VECTOR(unsigned int);
126  break;
127 
128  case _XMP_N_TYPE_LONG:
129 #pragma omp parallel for
130  _XMP_SUM_VECTOR(long);
131  break;
132 
134 #pragma omp parallel for
135  _XMP_SUM_VECTOR(unsigned long);
136  break;
137 
139 #pragma omp parallel for
140  _XMP_SUM_VECTOR(long long);
141  break;
142 
144 #pragma omp parallel for
145  _XMP_SUM_VECTOR(unsigned long long);
146  break;
147 
148  case _XMP_N_TYPE_FLOAT:
149 #pragma omp parallel for
150  _XMP_SUM_VECTOR(float);
151  break;
152 
153  case _XMP_N_TYPE_DOUBLE:
154 #pragma omp parallel for
155  _XMP_SUM_VECTOR(double);
156  break;
157 
159 #pragma omp parallel for
160  _XMP_SUM_VECTOR(long double);
161  break;
162 
163 #ifdef __STD_IEC_559_COMPLEX__
164 
165  case _XMP_N_TYPE_FLOAT_IMAGINARY:
166 #pragma omp parallel for
167  _XMP_SUM_VECTOR(float imaginary);
168  break;
169 
171 #pragma omp parallel for
172  _XMP_SUM_VECTOR(float complex);
173  break;
174 
175  case _XMP_N_TYPE_DOUBLE_IMAGINARY:
176 #pragma omp parallel for
177  _XMP_SUM_VECTOR(double imaginary);
178  break;
179 
181 #pragma omp parallel for
182  _XMP_SUM_VECTOR(double complex);
183  break;
184 
185  case _XMP_N_TYPE_LONG_DOUBLE_IMAGINARY:
186 #pragma omp parallel for
187  _XMP_SUM_VECTOR(long double imaginary);
188  break;
189 
191 #pragma omp parallel for
192  _XMP_SUM_VECTOR(long double complex);
193  break;
194 
195 #endif
196 
197  case _XMP_N_TYPE_BOOL:
198  case _XMP_N_TYPE_CHAR:
201  default:
202  _XMP_fatal("_XMP_sum_vector: array arguments must be of a numerical type");
203  break;
204  }
205 
206  }
207  else {
208 
209  switch (type){
210 
211  case _XMP_N_TYPE_SHORT:
212  _XMP_SUM_VECTOR(short);
213  break;
214 
216  _XMP_SUM_VECTOR(unsigned short);
217  break;
218 
219  case _XMP_N_TYPE_INT:
220  _XMP_SUM_VECTOR(int);
221  break;
222 
224  _XMP_SUM_VECTOR(unsigned int);
225  break;
226 
227  case _XMP_N_TYPE_LONG:
228  _XMP_SUM_VECTOR(long);
229  break;
230 
232  _XMP_SUM_VECTOR(unsigned long);
233  break;
234 
236  _XMP_SUM_VECTOR(long long);
237  break;
238 
240  _XMP_SUM_VECTOR(unsigned long long);
241  break;
242 
243  case _XMP_N_TYPE_FLOAT:
244  _XMP_SUM_VECTOR(float);
245  break;
246 
247  case _XMP_N_TYPE_DOUBLE:
248  _XMP_SUM_VECTOR(double);
249  break;
250 
252  _XMP_SUM_VECTOR(long double);
253  break;
254 
255 #ifdef __STD_IEC_559_COMPLEX__
256 
257  case _XMP_N_TYPE_FLOAT_IMAGINARY:
258  _XMP_SUM_VECTOR(float imaginary);
259  break;
260 
262  _XMP_SUM_VECTOR(float complex);
263  break;
264 
265  case _XMP_N_TYPE_DOUBLE_IMAGINARY:
266  _XMP_SUM_VECTOR(double imaginary);
267  break;
268 
270  _XMP_SUM_VECTOR(double complex);
271  break;
272 
273  case _XMP_N_TYPE_LONG_DOUBLE_IMAGINARY:
274  _XMP_SUM_VECTOR(long double imaginary);
275  break;
276 
278  _XMP_SUM_VECTOR(long double complex);
279  break;
280 
281 #endif
282 
283  case _XMP_N_TYPE_BOOL:
284  case _XMP_N_TYPE_CHAR:
287  default:
288  _XMP_fatal("_XMP_sum_vector: array arguments must be of a numerical type");
289  break;
290  }
291 
292  }
293 
294 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMP_unpack_vector()

void _XMP_unpack_vector ( char *restrict  dst,
char *restrict  src,
int  count,
int  blocklength,
long  stride 
)
43  {
44  long i;
45  if (_xmp_omp_num_procs > 1 && count > 8 * _xmp_omp_num_procs){
46 #pragma omp parallel for private(i)
47  for (i = 0; i < count; i++){
48  memcpy(dst + i * stride, src + i * blocklength, blocklength);
49  }
50  }
51  else {
52  for (i = 0; i < count; i++){
53  memcpy(dst + i * stride, src + i * blocklength, blocklength);
54  }
55  }
56 
57 }

◆ _XMPF_unpack_transpose_vector()

void _XMPF_unpack_transpose_vector ( char *restrict  dst,
char *restrict  src,
int  dst_stride,
int  src_stride,
int  type_size,
int  dst_block_dim 
)
61  {
62  long i,j;
63  if (dst_block_dim == 1){
64  if (type_size == 16){
65  long ii,jj,imin,jmin,nblk=16;
66  double _Complex *dst0 = (double _Complex *)dst;
67  double _Complex *src0 = (double _Complex *)src;
68  for (jj = 0; jj < src_stride; jj+=nblk){
69  jmin=((jj+nblk) < src_stride)? (jj+nblk):src_stride;
70 #pragma omp parallel for private(i,j,ii,imin)
71  for (ii = 0; ii < dst_stride; ii+=nblk){
72  imin=((ii+nblk) < dst_stride)? (ii+nblk):dst_stride;
73  for (j = jj; j < jmin; j++){
74  for (i = ii; i < imin; i++){
75  dst0[j * dst_stride + i] = src0[i * src_stride + j];
76  }
77  }
78  }
79  }
80  }
81  else {
82  for (j = 0; j < src_stride; j++){
83  for (i = 0; i < dst_stride; i++){
84  memcpy(dst + (j * dst_stride + i) * type_size,
85  src + (i * src_stride + j) * type_size, type_size);
86  }
87  }
88  }
89  }
90 }

Variable Documentation

◆ _xmp_omp_num_procs

int _xmp_omp_num_procs = 1

◆ _xmp_reflect_pack_flag

int _xmp_reflect_pack_flag = 0
_XMP_N_TYPE_BOOL
#define _XMP_N_TYPE_BOOL
Definition: xmp_constant.h:80
_XMP_N_TYPE_INT
#define _XMP_N_TYPE_INT
Definition: xmp_constant.h:85
_XMP_N_TYPE_DOUBLE
#define _XMP_N_TYPE_DOUBLE
Definition: xmp_constant.h:92
_XMP_N_TYPE_DOUBLE_COMPLEX
#define _XMP_N_TYPE_DOUBLE_COMPLEX
Definition: xmp_constant.h:102
_XMP_N_TYPE_LONG_DOUBLE
#define _XMP_N_TYPE_LONG_DOUBLE
Definition: xmp_constant.h:93
_xmp_reflect_pack_flag
int _xmp_reflect_pack_flag
Definition: xmp_pack_vector.c:298
_XMP_N_TYPE_NONBASIC
#define _XMP_N_TYPE_NONBASIC
Definition: xmp_constant.h:104
_xmp_omp_num_procs
int _xmp_omp_num_procs
Definition: xmp_pack_vector.c:7
_XMP_N_TYPE_UNSIGNED_LONGLONG
#define _XMP_N_TYPE_UNSIGNED_LONGLONG
Definition: xmp_constant.h:90
_XMP_N_TYPE_LONG
#define _XMP_N_TYPE_LONG
Definition: xmp_constant.h:87
_XMP_N_TYPE_SHORT
#define _XMP_N_TYPE_SHORT
Definition: xmp_constant.h:83
_XMP_N_TYPE_FLOAT_COMPLEX
#define _XMP_N_TYPE_FLOAT_COMPLEX
Definition: xmp_constant.h:101
_XMP_N_TYPE_FLOAT
#define _XMP_N_TYPE_FLOAT
Definition: xmp_constant.h:91
_XMP_N_TYPE_UNSIGNED_INT
#define _XMP_N_TYPE_UNSIGNED_INT
Definition: xmp_constant.h:86
_XMP_N_TYPE_UNSIGNED_LONG
#define _XMP_N_TYPE_UNSIGNED_LONG
Definition: xmp_constant.h:88
_XMP_N_TYPE_UNSIGNED_SHORT
#define _XMP_N_TYPE_UNSIGNED_SHORT
Definition: xmp_constant.h:84
_XMP_N_TYPE_CHAR
#define _XMP_N_TYPE_CHAR
Definition: xmp_constant.h:81
_XMP_N_TYPE_UNSIGNED_CHAR
#define _XMP_N_TYPE_UNSIGNED_CHAR
Definition: xmp_constant.h:82
_XMP_N_TYPE_LONG_DOUBLE_COMPLEX
#define _XMP_N_TYPE_LONG_DOUBLE_COMPLEX
Definition: xmp_constant.h:103
_XMP_fatal
void _XMP_fatal(char *msg)
Definition: xmp_util.c:42
_XMP_N_TYPE_LONGLONG
#define _XMP_N_TYPE_LONGLONG
Definition: xmp_constant.h:89
_XMP_SUM_VECTOR
#define _XMP_SUM_VECTOR(_type)
Definition: xmp_pack_vector.c:94