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

Functions

void print_rsd (_XMP_rsd_t *rsd)
 
void print_bsd (_XMP_bsd_t *bsd)
 
void print_csd (_XMP_csd_t *csd)
 
void print_comm_set (_XMP_comm_set_t *comm_set0)
 
_XMP_rsd_tintersection_rsds (_XMP_rsd_t *_rsd1, _XMP_rsd_t *_rsd2)
 
_XMP_csd_tintersection_csds (_XMP_csd_t *csd1, _XMP_csd_t *csd2)
 
_XMP_csd_talloc_csd (int n)
 
void free_csd (_XMP_csd_t *csd)
 
_XMP_csd_tcopy_csd (_XMP_csd_t *csd)
 
int get_csd_size (_XMP_csd_t *csd)
 
void free_comm_set (_XMP_comm_set_t *comm_set)
 
_XMP_csd_trsd2csd (_XMP_rsd_t *rsd)
 
_XMP_csd_tbsd2csd (_XMP_bsd_t *bsd)
 
_XMP_comm_set_tcsd2comm_set (_XMP_csd_t *csd)
 
void reduce_csd (_XMP_csd_t *csd[_XMP_N_MAX_DIM], int ndims)
 

Function Documentation

◆ alloc_csd()

_XMP_csd_t* alloc_csd ( int  n)
164  {
165  _XMP_csd_t *csd = (_XMP_csd_t *)_XMP_alloc(sizeof(_XMP_csd_t));
166  csd->l = (int *)_XMP_alloc(sizeof(int) * n);
167  csd->u = (int *)_XMP_alloc(sizeof(int) * n);
168  csd->n = n;
169  return csd;
170 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bsd2csd()

_XMP_csd_t* bsd2csd ( _XMP_bsd_t bsd)
224  {
225 
226  if (!bsd) return NULL;
227 
228  _XMP_csd_t *csd = alloc_csd(bsd->b);
229  csd->n = bsd->b;
230 
231  for (int i = 0; i < bsd->b; i++){
232  csd->l[i] = bsd->l + i;
233  int t = (bsd->u - csd->l[i]) / bsd->c;
234  csd->u[i] = csd->l[i] + bsd->c * t;
235  }
236 
237  csd->s = bsd->c;
238 
239  return csd;
240 
241 }
Here is the call graph for this function:

◆ copy_csd()

_XMP_csd_t* copy_csd ( _XMP_csd_t csd)
182  {
183  _XMP_csd_t *new_csd = alloc_csd(csd->n);
184  for (int i = 0; i < csd->n; i++){
185  new_csd->l[i] = csd->l[i];
186  new_csd->u[i] = csd->u[i];
187  }
188  new_csd->s = csd->s;
189  return new_csd;
190 }
Here is the call graph for this function:

◆ csd2comm_set()

_XMP_comm_set_t* csd2comm_set ( _XMP_csd_t csd)
244  {
245 
246  if (!csd || csd->n == 0) return NULL;
247 
249 
250  _XMP_comm_set_t *comm_set = comm_set0;
251  comm_set->l = csd->l[0];
252  comm_set->u = csd->l[0];
253  comm_set->next = NULL;
254 
255  for (int j = 0; csd->l[0] + j <= csd->u[0]; j+= csd->s){
256 
257  for (int i = 0; i < csd->n; i++){
258 
259  int l = csd->l[i] + j;
260 
261  if (l > csd->u[i]) continue;
262 
263  if (l == comm_set->u + 1){
264  comm_set->u = l;
265  }
266  else if (l <= comm_set->u){
267  continue;
268  }
269  else {
270  comm_set->next = (_XMP_comm_set_t *)malloc(sizeof(_XMP_comm_set_t));
271  comm_set = comm_set->next;
272  comm_set->l = l;
273  comm_set->u = l;
274  comm_set->next = NULL;
275  }
276  }
277 
278  }
279 
280  return comm_set0;
281 
282 }
Here is the call graph for this function:

◆ free_comm_set()

void free_comm_set ( _XMP_comm_set_t comm_set)
202  {
203 
204  while (comm_set){
205  _XMP_comm_set_t *next = comm_set->next;
206  _XMP_free(comm_set);
207  comm_set = next;
208  }
209 
210 }
Here is the call graph for this function:

◆ free_csd()

void free_csd ( _XMP_csd_t csd)
173  {
174  if (csd){
175  _XMP_free(csd->l);
176  _XMP_free(csd->u);
177  _XMP_free(csd);
178  }
179 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_csd_size()

int get_csd_size ( _XMP_csd_t csd)
193  {
194  int size = 0;
195  for (int i = 0; i < csd->n; i++){
196  size += _XMP_M_COUNT_TRIPLETi(csd->l[i], csd->u[i], csd->s);
197  }
198  return size;
199 }

◆ intersection_csds()

_XMP_csd_t* intersection_csds ( _XMP_csd_t csd1,
_XMP_csd_t csd2 
)
116  {
117 
118  if (!csd1 || !csd2) return NULL;
119 
120  _XMP_csd_t *csd0 = alloc_csd(MAX(csd1->n, csd2->n));
121 
122  int k = 0;
123 
124  csd0->n = 0;
125 
126  for (int i = 0; i < csd1->n; i++){
127  for (int j = 0; j < csd2->n; j++){
128 
129  _XMP_rsd_t *tmp = NULL;
130  _XMP_rsd_t rsd1 = { csd1->l[i], csd1->u[i], csd1->s };
131  _XMP_rsd_t rsd2 = { csd2->l[j], csd2->u[j], csd2->s };
132 
133  tmp = intersection_rsds(&rsd1, &rsd2);
134 
135  if (tmp){
136 
137  csd0->l[k] = tmp->l;
138  csd0->u[k] = tmp->u;
139 
140  // bubble sort
141  int p = k;
142  while (csd0->l[p-1] > tmp->l && p > 0){
143  int s;
144  s = csd0->l[p-1]; csd0->l[p-1] = csd0->l[p]; csd0->l[p] = s;
145  s = csd0->u[p-1]; csd0->u[p-1] = csd0->u[p]; csd0->u[p] = s;
146  p--;
147  }
148 
149  csd0->n++;
150  csd0->s = tmp->s;
151  k++;
152 
153  _XMP_free(tmp);
154  }
155 
156  }
157  }
158 
159  return csd0;
160 
161 }
Here is the call graph for this function:

◆ intersection_rsds()

_XMP_rsd_t* intersection_rsds ( _XMP_rsd_t _rsd1,
_XMP_rsd_t _rsd2 
)
82  {
83 
84  _XMP_rsd_t *rsd1, *rsd2;
85 
86  if (!_rsd1 || !_rsd2) return NULL;
87 
88  if (_rsd1->l <= _rsd2->l){
89  rsd1 = _rsd1;
90  rsd2 = _rsd2;
91  }
92  else {
93  rsd1 = _rsd2;
94  rsd2 = _rsd1;
95  }
96 
97  if (rsd2->l <= rsd1->u){
98  int min_u = MIN(rsd1->u, rsd2->u);
99  for (int i = rsd2->l; i <= min_u; i += rsd2->s){
100  if ((i - rsd1->l) % rsd1->s == 0){
101  _XMP_rsd_t *rsd0 = (_XMP_rsd_t *)_XMP_alloc(sizeof(_XMP_rsd_t));
102  rsd0->l = i;
103  rsd0->s = _XMP_lcm(rsd1->s, rsd2->s);
104  int t = (min_u - rsd0->l) / rsd0->s;
105  rsd0->u = rsd0->l + rsd0->s * t;
106  return rsd0;
107  }
108  }
109  }
110 
111  return NULL;
112 
113 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_bsd()

void print_bsd ( _XMP_bsd_t bsd)
22  {
23  if (!bsd){
24  printf("()\n");
25  }
26  else {
27  printf("(%d : %d : %d : %d)\n", bsd->l, bsd->u, bsd->b, bsd->c);
28  }
29 }

◆ print_comm_set()

void print_comm_set ( _XMP_comm_set_t comm_set0)
62  {
63 
64  if (!comm_set0){
65  printf("()\n");
66  return;
67  }
68 
69  _XMP_comm_set_t *comm_set = comm_set0;
70 
71  printf("(%d : %d)", comm_set->l, comm_set->u);
72 
73  while ((comm_set = comm_set->next)){
74  printf(", (%d : %d)", comm_set->l, comm_set->u);
75  }
76 
77  printf("\n");
78 
79 }

◆ print_csd()

void print_csd ( _XMP_csd_t csd)
32  {
33 
34  if (!csd || csd->n == 0){
35  printf("()\n");
36  return;
37  }
38 
39  printf("(");
40 
41  printf("(%d", csd->l[0]);
42  for (int i = 1; i < csd->n; i++){
43  printf(", %d", csd->l[i]);
44  }
45  printf(")");
46 
47  printf(" : ");
48 
49  printf("(%d", csd->u[0]);
50  for (int i = 1; i < csd->n; i++){
51  printf(", %d", csd->u[i]);
52  }
53  printf(")");
54 
55  printf(" : ");
56 
57  printf("%d)\n", csd->s);
58 
59 }

◆ print_rsd()

void print_rsd ( _XMP_rsd_t rsd)
6  {
7 
8  if (!rsd){
9  printf("()\n");
10  return;
11  }
12 
13  if (rsd->s){
14  printf("(%d : %d : %d)\n", rsd->l, rsd->u, rsd->s);
15  }
16  else {
17  printf("()\n");
18  }
19 }

◆ reduce_csd()

void reduce_csd ( _XMP_csd_t csd[_XMP_N_MAX_DIM],
int  ndims 
)
285  {
286 
287  for (int i = 0; i < ndims; i++){
288  if (!csd[i] || csd[i]->n == 0){
289  for (int j = 0; j < ndims; j++){
290  free_csd(csd[j]);
291  csd[j] = NULL;
292  }
293  return;
294  }
295  }
296 
297 }
Here is the call graph for this function:

◆ rsd2csd()

_XMP_csd_t* rsd2csd ( _XMP_rsd_t rsd)
213  {
214  if (!rsd) return NULL;
215  _XMP_csd_t *csd = alloc_csd(1);
216  csd->l[0] = rsd->l;
217  csd->u[0] = rsd->u;
218  csd->n = 1;
219  csd->s = rsd->s;
220  return csd;
221 }
Here is the call graph for this function:
_XMP_rsd_type::u
int u
Definition: xmp_data_struct.h:411
_XMP_alloc
void * _XMP_alloc(size_t size)
Definition: xmp_util.c:21
_XMP_csd_type::n
int n
Definition: xmp_data_struct.h:433
_XMP_csd_type::u
int * u
Definition: xmp_data_struct.h:432
free_csd
void free_csd(_XMP_csd_t *csd)
Definition: xmp_section_desc.c:173
_XMP_bsd_type::u
int u
Definition: xmp_data_struct.h:421
MAX
#define MAX(a, b)
Definition: xmp_internal.h:16
_XMP_bsd_type::b
int b
Definition: xmp_data_struct.h:422
alloc_csd
_XMP_csd_t * alloc_csd(int n)
Definition: xmp_section_desc.c:164
_XMP_rsd_type::l
int l
Definition: xmp_data_struct.h:410
intersection_rsds
_XMP_rsd_t * intersection_rsds(_XMP_rsd_t *_rsd1, _XMP_rsd_t *_rsd2)
Definition: xmp_section_desc.c:82
_XMP_csd_type::s
int s
Definition: xmp_data_struct.h:434
_XMP_comm_set_type::u
int u
Definition: xmp_data_struct.h:441
_XMP_comm_set_type::next
struct _XMP_comm_set_type * next
Definition: xmp_data_struct.h:442
_XMP_free
void _XMP_free(void *p)
Definition: xmp_util.c:37
_XMP_csd_type::l
int * l
Definition: xmp_data_struct.h:431
_XMP_bsd_type::c
int c
Definition: xmp_data_struct.h:423
_XMP_lcm
int _XMP_lcm(int a, int b)
Definition: xmp_math_function.c:66
_XMP_csd_type
Definition: xmp_data_struct.h:430
_XMP_rsd_type
Definition: xmp_data_struct.h:409
_XMP_bsd_type::l
int l
Definition: xmp_data_struct.h:420
_XMP_M_COUNT_TRIPLETi
#define _XMP_M_COUNT_TRIPLETi(l_, u_, s_)
Definition: xmp_gpu_func.hpp:25
_XMP_rsd_type::s
int s
Definition: xmp_data_struct.h:412
_XMP_comm_set_type
Definition: xmp_data_struct.h:439
_XMP_comm_set_type::l
int l
Definition: xmp_data_struct.h:440
MIN
#define MIN(a, b)
Definition: xmp_internal.h:12