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

Macros

#define MPI_PORTABLE_PLATFORM_H
 
#define min(x, y)   ((x) < (y) ? (x) : (y))
 

Functions

_XMP_template_t_XMP_create_template_desc (int dim, _Bool is_fixed)
 
void _XMP_calc_template_size (_XMP_template_t *t)
 
int _XMP_check_template_ref_inclusion (int ref_lower, int ref_upper, int ref_stride, _XMP_template_t *t, int index)
 
void _XMP_init_template_FIXED (_XMP_template_t **template, int dim,...)
 
void _XMP_init_template_UNFIXED (_XMP_template_t **template, int dim)
 
void _XMP_set_template_size (_XMP_template_t *t, int dim,...)
 
void _XMP_init_template_chunk (_XMP_template_t *template, _XMP_nodes_t *nodes)
 
void _XMP_finalize_template (_XMP_template_t *template)
 
void _XMP_dist_template_DUPLICATION (_XMP_template_t *template, int template_index)
 
void _XMP_dist_template_BLOCK (_XMP_template_t *template, int template_index, int nodes_index)
 
void _XMP_dist_template_CYCLIC (_XMP_template_t *template, int template_index, int nodes_index)
 
void _XMP_dist_template_BLOCK_CYCLIC (_XMP_template_t *template, int template_index, int nodes_index, unsigned long long width)
 
void _XMP_dist_template_GBLOCK (_XMP_template_t *template, int template_index, int nodes_index, int *mapping_array, int *temp0)
 
_XMP_nodes_t_XMP_create_nodes_by_template_ref (_XMP_template_t *ref_template, int *shrink, long long *ref_lower, long long *ref_upper, long long *ref_stride)
 
int _XMP_exec_task_TEMPLATE_PART (_XMP_task_desc_t **task_desc, _XMP_template_t *ref_template,...)
 
_Bool union_triplet (int lb0, int ub0, int st0, int lb1, int ub1, int st1)
 
int _XMP_exec_task_TEMPLATE_PART_nocomm (_XMP_template_t *ref_template,...)
 
int _XMP_calc_template_owner_SCALAR (_XMP_template_t *template, int dim_index, long long ref_index)
 
int _XMP_calc_template_par_triplet (_XMP_template_t *template, int template_index, int nodes_rank, int *template_lower, int *template_upper, int *template_stride)
 
int xmpc_ltog (int local_idx, _XMP_template_t *template, int dim, int offset)
 

Macro Definition Documentation

◆ min

#define min (   x,
 
)    ((x) < (y) ? (x) : (y))

◆ MPI_PORTABLE_PLATFORM_H

#define MPI_PORTABLE_PLATFORM_H

Function Documentation

◆ _XMP_calc_template_owner_SCALAR()

int _XMP_calc_template_owner_SCALAR ( _XMP_template_t template,
int  dim_index,
long long  ref_index 
)
632  {
633  _XMP_ASSERT(template->is_fixed);
634  _XMP_ASSERT(template->is_distributed);
635 
636  _XMP_template_info_t *info = &(template->info[dim_index]);
637  _XMP_template_chunk_t *chunk = &(template->chunk[dim_index]);
639 
640  switch (chunk->dist_manner) {
641  case _XMP_N_DIST_BLOCK:
642  return (ref_index - (info->ser_lower)) / (chunk->par_chunk_width);
643  case _XMP_N_DIST_CYCLIC:
644  return (ref_index - (info->ser_lower)) % (chunk->par_stride);
646  {
647  int width = chunk->par_width;
648  return ((ref_index - (info->ser_lower)) / width) % ((chunk->par_stride) / width);
649  }
650  case _XMP_N_DIST_GBLOCK:
651  {
652  long long *m = chunk->mapping_array;
653  int np = chunk->onto_nodes_info->size;
654  for (int i = 0; i < np; i++){
655  if (m[i] <= ref_index && ref_index < m[i+1]){
656  return i;
657  }
658  }
659  }
660  return _XMP_N_INVALID_RANK;
661  default:
662  _XMP_fatal("unknown distribute manner");
663  return _XMP_N_INVALID_RANK; // XXX dummy
664  }
665 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMP_calc_template_par_triplet()

int _XMP_calc_template_par_triplet ( _XMP_template_t template,
int  template_index,
int  nodes_rank,
int *  template_lower,
int *  template_upper,
int *  template_stride 
)
668  {
669  _XMP_ASSERT(template->is_distributed);
670 
671  int par_lower = 0, par_upper = 0, par_stride = 0;
672 
673  _XMP_template_info_t *ti = &(template->info[template_index]);
674  int ser_lower = ti->ser_lower;
675  int ser_upper = ti->ser_upper;
676  int ser_size = ti->ser_size;
677 
678  _XMP_template_chunk_t *tc = &(template->chunk[template_index]);
679  int par_width = tc->par_width;
680  int par_chunk_width = tc->par_chunk_width;
681 
682  switch (tc->dist_manner) {
684  {
685  par_lower = ser_lower;
686  par_upper = ser_upper;
687 
688  par_stride = 1;
689  } break;
690  case _XMP_N_DIST_BLOCK:
691  {
692  par_lower = nodes_rank * par_chunk_width + ser_lower;
693  int owner_nodes_size = _XMP_M_CEILi(ser_size, par_chunk_width);
694  if (nodes_rank == (owner_nodes_size - 1)) {
695  par_upper = ser_upper;
696  } else if (nodes_rank >= owner_nodes_size) {
697  return _XMP_N_INT_FALSE;
698  } else {
699  par_upper = par_lower + par_chunk_width - 1;
700  }
701 
702  par_stride = 1;
703  } break;
704  case _XMP_N_DIST_CYCLIC:
706  {
709 
710  int nodes_size = ni->size;
711  int template_size = _XMP_M_CEILi(ser_size, par_width);
712 
713  if (template_size < nodes_size) {
714  if (nodes_rank < template_size) {
715  int par_index = ser_lower + (nodes_rank * par_width);
716 
717  par_lower = par_index;
718  par_upper = par_index;
719  } else {
720  return _XMP_N_INT_FALSE;
721  }
722  } else {
723  int div = template_size / nodes_size;
724  int mod = template_size % nodes_size;
725  int par_size = 0;
726  if(mod == 0) {
727  par_size = div;
728  } else {
729  if(nodes_rank >= mod) {
730  par_size = div;
731  } else {
732  par_size = div + 1;
733  }
734  }
735 
736  par_lower = ser_lower + (nodes_rank * par_width);
737  par_upper = par_lower + (nodes_size * (par_size - 1) * par_width);
738  }
739 
740  par_stride = nodes_size * par_width;
741  } break;
742  default:
743  _XMP_fatal("unknown distribution manner");
744  }
745 
746  // return triplet
747  *template_lower = par_lower;
748  *template_upper = par_upper;
749  *template_stride = par_stride;
750 
751  return _XMP_N_INT_TRUE;
752 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMP_calc_template_size()

void _XMP_calc_template_size ( _XMP_template_t t)
31 {
32  int dim;
33  if(t->is_fixed){
34  dim = t->dim;
35  }
36  else{
37  dim = t->dim-1;
38  }
39 
40  for(int i=0;i<dim;i++){
41  int ser_lower = t->info[i].ser_lower;
42  int ser_upper = t->info[i].ser_upper;
43 
44  if(ser_lower > ser_upper)
45  _XMP_fatal("the lower bound of template should be less than or equal to the upper bound");
46 
47  t->info[i].ser_size = _XMP_M_COUNTi(ser_lower, ser_upper);
48  }
49 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMP_check_template_ref_inclusion()

int _XMP_check_template_ref_inclusion ( int  ref_lower,
int  ref_upper,
int  ref_stride,
_XMP_template_t t,
int  index 
)
244  {
245  _XMP_template_info_t *info = &(t->info[index]);
246  _XMP_template_chunk_t *chunk = &(t->chunk[index]);
247 
248  _XMP_validate_template_ref(&ref_lower, &ref_upper, &ref_stride, info->ser_lower, info->ser_upper);
249 
250  switch (chunk->dist_manner) {
252  return _XMP_N_INT_TRUE;
253  case _XMP_N_DIST_BLOCK:
254  case _XMP_N_DIST_CYCLIC:
255  return _XMP_check_template_ref_inclusion_width_1(ref_lower, ref_upper, ref_stride,
256  chunk->par_lower, chunk->par_upper, chunk->par_stride);
258  return _XMP_check_template_ref_inclusion_width_N(ref_lower, ref_upper, ref_stride, t, index);
259  default:
260  _XMP_fatal("unknown distribution manner");
261  return _XMP_N_INT_FALSE; // XXX dummy
262  }
263 }
Here is the caller graph for this function:

◆ _XMP_create_nodes_by_template_ref()

_XMP_nodes_t* _XMP_create_nodes_by_template_ref ( _XMP_template_t ref_template,
int *  shrink,
long long *  ref_lower,
long long *  ref_upper,
long long *  ref_stride 
)
461 {
462  _XMP_ASSERT(ref_template->is_fixed);
463  _XMP_ASSERT(ref_template->is_distributed);
464 
465  _XMP_nodes_t *onto_nodes = ref_template->onto_nodes;
466  int onto_nodes_dim = onto_nodes->dim;
467  int onto_nodes_shrink[onto_nodes_dim];
468  int onto_nodes_ref_lower[onto_nodes_dim];
469  int onto_nodes_ref_upper[onto_nodes_dim];
470  int onto_nodes_ref_stride[onto_nodes_dim];
471 
472  for(int i=0;i<onto_nodes_dim;i++)
473  onto_nodes_shrink[i] = 1;
474 
475  int new_nodes_dim = 0;
476  int new_nodes_dim_size[_XMP_N_MAX_DIM];
477  int acc_dim_size = 1;
478  int ref_template_dim = ref_template->dim;
479 
480  for(int i=0;i<ref_template_dim;i++){
481  if(shrink[i]){
482  continue;
483  }
484 
485  _XMP_template_chunk_t *chunk = &(ref_template->chunk[i]);
486  int onto_nodes_index = chunk->onto_nodes_index;
487  if (onto_nodes_index != _XMP_N_NO_ONTO_NODES) {
488  onto_nodes_shrink[onto_nodes_index] = 0;
489 
490  int size = (chunk->onto_nodes_info)->size;
491  // FIXME calc onto_nodes_ref_lower, onto_nodes_ref_upper, onto_nodes_ref_stride
492  if (_XMP_M_COUNT_TRIPLETi(ref_lower[i], ref_upper[i], ref_stride[i]) == 1) {
493  int j = _XMP_calc_template_owner_SCALAR(ref_template, i, ref_lower[i]) + 1;
494  onto_nodes_ref_lower[onto_nodes_index] = j;
495  onto_nodes_ref_upper[onto_nodes_index] = j;
496  onto_nodes_ref_stride[onto_nodes_index] = 1;
497 
498  new_nodes_dim_size[new_nodes_dim] = 1;
499  } else {
500  onto_nodes_ref_lower[onto_nodes_index] = 1;
501  onto_nodes_ref_upper[onto_nodes_index] = size;
502  onto_nodes_ref_stride[onto_nodes_index] = 1;
503  acc_dim_size *= _XMP_M_COUNT_TRIPLETi(1, size, 1);
504 
505  new_nodes_dim_size[new_nodes_dim] = size;
506  }
507 
508  new_nodes_dim++;
509  }
510  }
511 
512  if (new_nodes_dim > 0)
513  return _XMP_init_nodes_struct_NODES_NAMED(new_nodes_dim, onto_nodes, onto_nodes_shrink,
514  onto_nodes_ref_lower, onto_nodes_ref_upper,
515  onto_nodes_ref_stride, new_nodes_dim_size, _XMP_N_INT_TRUE);
516  else return NULL;
517 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMP_create_template_desc()

_XMP_template_t* _XMP_create_template_desc ( int  dim,
_Bool  is_fixed 
)
11 {
12  // alloc descriptor
14  sizeof(_XMP_template_info_t) * (dim - 1));
15 
16  // calc members
18 
20  t->is_fixed = is_fixed;
21  t->is_distributed = false;
22  t->is_owner = false;
23  t->dim = dim;
24  t->onto_nodes = NULL;
25  t->chunk = NULL;
26 
27  return t;
28 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMP_dist_template_BLOCK()

void _XMP_dist_template_BLOCK ( _XMP_template_t template,
int  template_index,
int  nodes_index 
)
348 {
349  _XMP_ASSERT(template->is_fixed);
350  _XMP_ASSERT(template->is_distributed);
351 
352  _XMP_nodes_t *nodes = template->onto_nodes;
353  _XMP_template_chunk_t *chunk = &(template->chunk[template_index]);
354  _XMP_template_info_t *ti = &(template->info[template_index]);
355  _XMP_nodes_info_t *ni = &(nodes->info[nodes_index]);
356 
357  unsigned long long nodes_size = ni->size;
358 
359  // calc parallel members
360  unsigned long long chunk_width = _XMP_M_CEILi(ti->ser_size, nodes_size);
361 
362  if(nodes->is_member){
363  unsigned long long nodes_rank = ni->rank;
364  unsigned long long owner_nodes_size = _XMP_M_CEILi(ti->ser_size, chunk_width);
365 
366  chunk->par_lower = nodes_rank * chunk_width + ti->ser_lower;
367  if(nodes_rank == (owner_nodes_size - 1)){
368  chunk->par_upper = ti->ser_upper;
369  }
370  else if (nodes_rank >= owner_nodes_size){
371  template->is_owner = false;
372  }
373  else{
374  chunk->par_upper = chunk->par_lower + chunk_width - 1;
375  }
376  }
377 
378  chunk->par_width = 1;
379  chunk->par_stride = 1;
380  chunk->par_chunk_width = chunk_width;
382 
383  if((ti->ser_size % nodes_size) == 0){
384  chunk->is_regular_chunk = true;
385  }
386  else{
387  chunk->is_regular_chunk = false;
388  }
389 
390  chunk->onto_nodes_index = nodes_index;
391  chunk->onto_nodes_info = ni;
392 }

◆ _XMP_dist_template_BLOCK_CYCLIC()

void _XMP_dist_template_BLOCK_CYCLIC ( _XMP_template_t template,
int  template_index,
int  nodes_index,
unsigned long long  width 
)
400 {
401  _XMP_dist_template_CYCLIC_WIDTH(template, template_index, nodes_index, width);
402 }

◆ _XMP_dist_template_CYCLIC()

void _XMP_dist_template_CYCLIC ( _XMP_template_t template,
int  template_index,
int  nodes_index 
)
395 {
396  _XMP_dist_template_CYCLIC_WIDTH(template, template_index, nodes_index, 1);
397 }

◆ _XMP_dist_template_DUPLICATION()

void _XMP_dist_template_DUPLICATION ( _XMP_template_t template,
int  template_index 
)
327  {
328  _XMP_ASSERT(template->is_fixed);
329  _XMP_ASSERT(template->is_distributed);
330 
331  _XMP_template_chunk_t *chunk = &(template->chunk[template_index]);
332  _XMP_template_info_t *ti = &(template->info[template_index]);
333 
334  chunk->par_lower = ti->ser_lower;
335  chunk->par_upper = ti->ser_upper;
336  chunk->par_width = 1;
337 
338  chunk->par_stride = 1;
339  chunk->par_chunk_width = ti->ser_size;
341  chunk->is_regular_chunk = true;
342 
344  chunk->onto_nodes_info = NULL;
345 }

◆ _XMP_dist_template_GBLOCK()

void _XMP_dist_template_GBLOCK ( _XMP_template_t template,
int  template_index,
int  nodes_index,
int *  mapping_array,
int *  temp0 
)
407  {
408 
409  _XMP_ASSERT(template->is_fixed);
410  _XMP_ASSERT(template->is_distributed);
411 
412  _XMP_nodes_t *nodes = template->onto_nodes;
413 
414  _XMP_template_chunk_t *chunk = &(template->chunk[template_index]);
415  _XMP_template_info_t *ti = &(template->info[template_index]);
416  _XMP_nodes_info_t *ni = &(nodes->info[nodes_index]);
417 
418  if (mapping_array){
419 
420  long long *rsum_array = _XMP_alloc(sizeof(long long) * (ni->size + 1));
421  rsum_array[0] = ti->ser_lower;
422  for (int i = 1; i <= ni->size; i++){
423  rsum_array[i] = rsum_array[i-1] + (long long)mapping_array[i-1];
424  }
425  chunk->mapping_array = rsum_array;
426 
427  if (ti->ser_upper >= rsum_array[ni->size])
428  _XMP_fatal("The size of the template exceeds the sum of the mapping array.");
429 
430  if (ti->ser_upper + 1 < rsum_array[ni->size])
431  _XMP_warning("The sum of the mapping array exceeds the size of the template.");
432 
433  template->is_owner = false;
434  if (nodes->is_member && rsum_array[ni->rank + 1] != rsum_array[ni->rank]) {
435  chunk->par_lower = rsum_array[ni->rank];
436  if (chunk->par_lower <= ti->ser_upper){
437  chunk->par_upper = min(ti->ser_upper, rsum_array[ni->rank + 1] - 1);
438  template->is_owner = true;
439  }
440  }
441 
442  chunk->par_width = 1;
443  chunk->par_stride = 1;
444  chunk->par_chunk_width = chunk->par_upper - chunk->par_lower + 1;
445  }
446  else {
447  template->is_fixed = false;
448  }
449 
451  chunk->is_regular_chunk = false;
452 
453  chunk->onto_nodes_index = nodes_index;
454  chunk->onto_nodes_info = ni;
455 
456  *temp0 = chunk->par_lower;
457 }
Here is the call graph for this function:

◆ _XMP_exec_task_TEMPLATE_PART()

int _XMP_exec_task_TEMPLATE_PART ( _XMP_task_desc_t **  task_desc,
_XMP_template_t ref_template,
  ... 
)
519  {
520  int ref_dim = ref_template->dim;
521  int shrink[ref_dim];
522  long long lower[ref_dim], upper[ref_dim], stride[ref_dim];
523 
524  va_list args;
525  va_start(args, ref_template);
526  for (int i = 0; i < ref_dim; i++) {
527  shrink[i] = va_arg(args, int);
528  if (!shrink[i]) {
529  lower[i] = va_arg(args, long long);
530  upper[i] = va_arg(args, long long);
531  stride[i] = va_arg(args, long long);
532  }
533  }
534  va_end(args);
535 
536  _XMP_task_desc_t *desc = NULL;
537  if (*task_desc == NULL) {
538  desc = (_XMP_task_desc_t *)_XMP_alloc(sizeof(_XMP_task_desc_t));
539  *task_desc = desc;
540  } else {
541  desc = *task_desc;
542  if (_XMP_compare_task_exec_cond(desc, ref_template, lower, upper, stride)) {
543  if (desc->execute) {
544  _XMP_push_nodes(desc->nodes);
545  return _XMP_N_INT_TRUE;
546  } else {
547  return _XMP_N_INT_FALSE;
548  }
549  } else {
550  if (desc->nodes != NULL) {
551  _XMP_finalize_nodes(desc->nodes);
552  }
553  }
554  }
555 
556  _XMP_nodes_t *n = _XMP_create_nodes_by_template_ref(ref_template, shrink, lower, upper, stride);
557  _XMP_set_task_desc(desc, n, n->is_member, ref_template, lower, upper, stride);
558  if (n->is_member) {
559  _XMP_push_nodes(n);
560  return _XMP_N_INT_TRUE;
561  } else {
562  return _XMP_N_INT_FALSE;
563  }
564 }
Here is the call graph for this function:

◆ _XMP_exec_task_TEMPLATE_PART_nocomm()

int _XMP_exec_task_TEMPLATE_PART_nocomm ( _XMP_template_t ref_template,
  ... 
)
568  {
569 
570  if (!ref_template->is_owner) return _XMP_N_INT_FALSE;
571 
572  int ref_dim = ref_template->dim;
573 
574  int shrink[ref_dim];
575  long long lower[ref_dim], upper[ref_dim], stride[ref_dim];
576 
577  va_list args;
578  va_start(args, ref_template);
579 
580  for (int i = 0; i < ref_dim; i++) {
581  shrink[i] = va_arg(args, int);
582  if (!shrink[i]) {
583  lower[i] = va_arg(args, long long);
584  upper[i] = va_arg(args, long long);
585  stride[i] = va_arg(args, long long);
586  }
587  }
588 
589  va_end(args);
590 
591  for (int i = 0; i < ref_dim; i++){
592 
593  if (shrink[i]) continue;
594 
595  _XMP_template_chunk_t *chunk = &ref_template->chunk[i];
596  long long plb = chunk->par_lower;
597  long long pub = chunk->par_upper;
598  int pst = chunk->par_stride;
599 
600  switch (chunk->dist_manner){
601 
603  break;
604 
605  case _XMP_N_DIST_BLOCK:
606  case _XMP_N_DIST_GBLOCK:
607  if (pub < lower[i] || upper[i] < plb) return _XMP_N_INT_FALSE;
608  break;
609 
610  case _XMP_N_DIST_CYCLIC:
611  if (union_triplet(lower[i], upper[i], stride[i], plb, pub, pst)) break;
612  return _XMP_N_INT_FALSE;
613 
615  for (int i = 0; i < chunk->par_width; i++){
616  if (union_triplet(lower[i], upper[i], stride[i], plb+i, pub, pst)) goto next;
617  }
618  return _XMP_N_INT_FALSE;
619  next:
620  break;
621  default:
622  _XMP_fatal("_XMP_exec_task_TEMPLATE_PART_nocomm: unknown dist_manner");
623  }
624 
625  }
626 
627  return _XMP_N_INT_TRUE;
628 
629 }
Here is the call graph for this function:

◆ _XMP_finalize_template()

void _XMP_finalize_template ( _XMP_template_t template)
313  {
314  if (template->is_distributed) {
315  for (int i = 0; i < template->dim; i++){
316  _XMP_template_chunk_t *chunk = &(template->chunk[i]);
317  if (chunk->dist_manner == _XMP_N_DIST_GBLOCK){
318  _XMP_free(chunk->mapping_array);
319  }
320  }
321  _XMP_free(template->chunk);
322  }
323 
324  _XMP_free(template);
325 }
Here is the call graph for this function:

◆ _XMP_init_template_chunk()

void _XMP_init_template_chunk ( _XMP_template_t template,
_XMP_nodes_t nodes 
)
306 {
307  template->is_distributed = true;
308  template->is_owner = nodes->is_member;
309  template->onto_nodes = nodes;
310  template->chunk = _XMP_alloc(sizeof(_XMP_template_chunk_t) * (template->dim));
311 }
Here is the call graph for this function:

◆ _XMP_init_template_FIXED()

void _XMP_init_template_FIXED ( _XMP_template_t **  template,
int  dim,
  ... 
)
266 {
267  // alloc descriptor
269 
270  // calc info
271  va_list args;
272  va_start(args, dim);
273  for(int i=0;i<dim;i++){
274  t->info[i].ser_lower = va_arg(args, long long);
275  t->info[i].ser_upper = va_arg(args, long long);
276  }
277  va_end(args);
278 
280 
281  *template = t;
282 }
Here is the call graph for this function:

◆ _XMP_init_template_UNFIXED()

void _XMP_init_template_UNFIXED ( _XMP_template_t **  template,
int  dim 
)
285 {
286  *template = _XMP_create_template_desc(dim, false);
287 }
Here is the call graph for this function:

◆ _XMP_set_template_size()

void _XMP_set_template_size ( _XMP_template_t t,
int  dim,
  ... 
)
289  {
290 
291  // calc info
292  va_list args;
293  va_start(args, dim);
294  for (int i = 0; i < dim; i++) {
295  t->info[i].ser_lower = va_arg(args, long long);
296  t->info[i].ser_upper = va_arg(args, long long);
297  }
298  va_end(args);
299 
300  t->is_fixed = true;
302 
303 }
Here is the call graph for this function:

◆ union_triplet()

_Bool union_triplet ( int  lb0,
int  ub0,
int  st0,
int  lb1,
int  ub1,
int  st1 
)
63 {
64  if (ub0 < lb0 || ub1 < lb0) return false;
65 
66  int lb2, ub2, st2;
67  int lb3, st3;
68 
69  if(lb0 > lb1){
70  lb2 = lb0;
71  lb3 = lb1;
72  st2 = st0;
73  st3 = st1;
74  }
75  else{
76  lb2 = lb1;
77  lb3 = lb0;
78  st2 = st1;
79  st3 = st0;
80  }
81 
82  ub2 = (ub0 > ub1)? ub1 : ub0;
83 
84  for(int i=lb2;i<= ub2;i+=st2)
85  if((i-lb3) % st3 == 0)
86  return true;
87 
88  return false;
89 }
Here is the caller graph for this function:

◆ xmpc_ltog()

int xmpc_ltog ( int  local_idx,
_XMP_template_t template,
int  dim,
int  offset 
)
756 {
757  /*long long*/ int global_index = 0;
758  _XMP_template_chunk_t *chunk = &(template->chunk[dim]);
759  _XMP_nodes_info_t *n_info = chunk->onto_nodes_info;
760  long long base = template->info[dim].ser_lower;
761 
762  switch(chunk->dist_manner){
764  global_index = local_idx;
765  break;
766  case _XMP_N_DIST_BLOCK:
767  global_index = base + n_info->rank * chunk->par_chunk_width + local_idx;
768  break;
769  case _XMP_N_DIST_CYCLIC:
770  global_index = base + n_info->rank + n_info->size * local_idx;
771  break;
773  {
774  int w = chunk->par_width;
775  global_index = base + n_info->rank * w
776  + (local_idx/w) * w * n_info->size + local_idx%w;
777  }
778  break;
779  case _XMP_N_DIST_GBLOCK:
780  global_index = local_idx + chunk->mapping_array[n_info->rank];
781  default:
782  _XMP_fatal("_XMP_: unknown chunk dist_manner");
783  }
784 
785  return global_index - offset;
786 
787 }
Here is the call graph for this function:
_XMP_template_chunk_type::par_upper
long long par_upper
Definition: xmp_data_struct.h:81
_XMP_nodes_info_type::size
int size
Definition: xmp_data_struct.h:32
_XMP_nodes_type::info
_XMP_nodes_info_t info[1]
Definition: xmp_data_struct.h:60
_XMP_nodes_info_type
Definition: xmp_data_struct.h:31
_XMP_template_type::info
_XMP_template_info_t info[1]
Definition: xmp_data_struct.h:115
_XMP_template_info_type::ser_size
unsigned long long ser_size
Definition: xmp_data_struct.h:74
_XMP_task_desc_type
Definition: xmp_data_struct.h:316
_XMP_N_DIST_BLOCK
#define _XMP_N_DIST_BLOCK
Definition: xmp_constant.h:29
_XMP_template_info_type::ser_lower
long long ser_lower
Definition: xmp_data_struct.h:72
_XMP_M_CEILi
#define _XMP_M_CEILi(a_, b_)
Definition: xmp_gpu_func.hpp:22
_XMP_nodes_type::is_member
int is_member
Definition: xmp_data_struct.h:46
_XMP_alloc
void * _XMP_alloc(size_t size)
Definition: xmp_util.c:21
_XMP_N_NO_ONTO_NODES
#define _XMP_N_NO_ONTO_NODES
Definition: xmp_constant.h:24
_XMP_finalize_nodes
void _XMP_finalize_nodes(void *nodes)
_XMP_template_type::chunk
_XMP_template_chunk_t * chunk
Definition: xmp_data_struct.h:112
_XMP_template_chunk_type::is_regular_chunk
_Bool is_regular_chunk
Definition: xmp_data_struct.h:89
_XMP_template_chunk_type::par_lower
long long par_lower
Definition: xmp_data_struct.h:80
min
#define min(x, y)
Definition: xmp_template.c:404
_XMP_init_nodes_struct_NODES_NAMED
_XMP_nodes_t * _XMP_init_nodes_struct_NODES_NAMED(int dim, _XMP_nodes_t *ref_nodes, int *shrink, int *ref_lower, int *ref_upper, int *ref_stride, int *dim_size, int is_static)
Definition: xmp_nodes.c:498
_XMP_template_chunk_type::onto_nodes_info
_XMP_nodes_info_t * onto_nodes_info
Definition: xmp_data_struct.h:94
_XMP_template_type::is_fixed
_Bool is_fixed
Definition: xmp_data_struct.h:104
_XMP_template_info_type
Definition: xmp_data_struct.h:70
_XMP_template_type::dim
int dim
Definition: xmp_data_struct.h:108
_XMP_template_chunk_type::par_chunk_width
unsigned long long par_chunk_width
Definition: xmp_data_struct.h:86
_XMP_calc_template_owner_SCALAR
int _XMP_calc_template_owner_SCALAR(_XMP_template_t *template, int dim_index, long long ref_index)
Definition: xmp_template.c:632
_XMP_template_type::onto_nodes
_XMP_nodes_t * onto_nodes
Definition: xmp_data_struct.h:111
_XMP_template_type::desc_kind
int desc_kind
Definition: xmp_data_struct.h:100
union_triplet
_Bool union_triplet(int lb0, int ub0, int st0, int lb1, int ub1, int st1)
Definition: xmp_util.c:62
_XMP_calc_template_size
void _XMP_calc_template_size(_XMP_template_t *t)
Definition: xmp_template.c:30
_XMP_warning
void _XMP_warning(char *msg)
Definition: xmp_util.c:58
_XMP_N_INT_FALSE
#define _XMP_N_INT_FALSE
Definition: xmp_constant.h:5
_XMP_N_DIST_CYCLIC
#define _XMP_N_DIST_CYCLIC
Definition: xmp_constant.h:30
_XMP_template_type
Definition: xmp_data_struct.h:98
_XMP_create_nodes_by_template_ref
_XMP_nodes_t * _XMP_create_nodes_by_template_ref(_XMP_template_t *ref_template, int *shrink, long long *ref_lower, long long *ref_upper, long long *ref_stride)
Definition: xmp_template.c:459
_XMP_template_chunk_type
Definition: xmp_data_struct.h:78
_XMP_task_desc_type::nodes
_XMP_nodes_t * nodes
Definition: xmp_data_struct.h:317
_XMP_template_info_type::ser_upper
long long ser_upper
Definition: xmp_data_struct.h:73
_XMP_template_chunk_type::onto_nodes_index
int onto_nodes_index
Definition: xmp_data_struct.h:92
_XMP_N_DIST_BLOCK_CYCLIC
#define _XMP_N_DIST_BLOCK_CYCLIC
Definition: xmp_constant.h:31
_XMP_N_DIST_GBLOCK
#define _XMP_N_DIST_GBLOCK
Definition: xmp_constant.h:32
_XMP_N_DIST_DUPLICATION
#define _XMP_N_DIST_DUPLICATION
Definition: xmp_constant.h:28
_XMP_template_chunk_type::par_stride
int par_stride
Definition: xmp_data_struct.h:85
_XMP_nodes_info_type::rank
int rank
Definition: xmp_data_struct.h:35
_XMP_N_INVALID_RANK
#define _XMP_N_INVALID_RANK
Definition: xmp_constant.h:21
_XMP_template_chunk_type::dist_manner
int dist_manner
Definition: xmp_data_struct.h:87
_XMP_free
void _XMP_free(void *p)
Definition: xmp_util.c:37
_XMP_ASSERT
#define _XMP_ASSERT(_flag)
Definition: xmp_internal.h:34
_XMP_DESC_TEMPLATE
#define _XMP_DESC_TEMPLATE
Definition: xmp_constant.h:132
_XMP_fatal
void _XMP_fatal(char *msg)
Definition: xmp_util.c:42
_XMP_M_COUNTi
#define _XMP_M_COUNTi(a_, b_)
Definition: xmp_math_function.h:15
_XMP_template_chunk_type::par_width
unsigned long long par_width
Definition: xmp_data_struct.h:82
_XMP_push_nodes
void _XMP_push_nodes(void *nodes)
_XMP_template_type::is_distributed
_Bool is_distributed
Definition: xmp_data_struct.h:105
_XMP_create_template_desc
_XMP_template_t * _XMP_create_template_desc(int dim, _Bool is_fixed)
Definition: xmp_template.c:10
_XMP_nodes_type::dim
int dim
Definition: xmp_data_struct.h:47
_XMP_nodes_type
Definition: xmp_data_struct.h:40
_XMP_M_COUNT_TRIPLETi
#define _XMP_M_COUNT_TRIPLETi(l_, u_, s_)
Definition: xmp_gpu_func.hpp:25
_XMP_get_on_ref_id
unsigned long long _XMP_get_on_ref_id(void)
Definition: xmp_util.c:13
_XMP_N_MAX_DIM
#define _XMP_N_MAX_DIM
Definition: xmp_constant.h:6
_XMP_N_INT_TRUE
#define _XMP_N_INT_TRUE
Definition: xmp_constant.h:4
_XMP_template_chunk_type::mapping_array
long long * mapping_array
Definition: xmp_data_struct.h:88
_XMP_task_desc_type::execute
int execute
Definition: xmp_data_struct.h:318
_XMP_template_type::on_ref_id
unsigned long long on_ref_id
Definition: xmp_data_struct.h:102
_XMP_template_type::is_owner
_Bool is_owner
Definition: xmp_data_struct.h:106