libxmp/libxmpf in Omni Compiler
1.3.4
|
#include <stdarg.h>
#include "mpi.h"
#include "xmp_internal.h"
#include "xmp_math_function.h"
|
_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) |
|
◆ min
#define min |
( |
|
x, |
|
|
|
y |
|
) |
| ((x) < (y) ? (x) : (y)) |
◆ MPI_PORTABLE_PLATFORM_H
#define MPI_PORTABLE_PLATFORM_H |
◆ _XMP_calc_template_owner_SCALAR()
int _XMP_calc_template_owner_SCALAR |
( |
_XMP_template_t * |
template, |
|
|
int |
dim_index, |
|
|
long long |
ref_index |
|
) |
| |
654 for (
int i = 0; i < np; i++){
655 if (m[i] <= ref_index && ref_index < m[i+1]){
◆ _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 |
|
) |
| |
671 int par_lower = 0, par_upper = 0, par_stride = 0;
685 par_lower = ser_lower;
686 par_upper = ser_upper;
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) {
699 par_upper = par_lower + par_chunk_width - 1;
710 int nodes_size = ni->
size;
713 if (template_size < nodes_size) {
714 if (nodes_rank < template_size) {
715 int par_index = ser_lower + (nodes_rank * par_width);
717 par_lower = par_index;
718 par_upper = par_index;
723 int div = template_size / nodes_size;
724 int mod = template_size % nodes_size;
729 if(nodes_rank >= mod) {
736 par_lower = ser_lower + (nodes_rank * par_width);
737 par_upper = par_lower + (nodes_size * (par_size - 1) * par_width);
740 par_stride = nodes_size * par_width;
747 *template_lower = par_lower;
748 *template_upper = par_upper;
749 *template_stride = par_stride;
◆ _XMP_calc_template_size()
40 for(
int i=0;i<dim;i++){
44 if(ser_lower > ser_upper)
45 _XMP_fatal(
"the lower bound of template should be less than or equal to the upper bound");
◆ _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 |
|
) |
| |
248 _XMP_validate_template_ref(&ref_lower, &ref_upper, &ref_stride, info->
ser_lower, info->
ser_upper);
255 return _XMP_check_template_ref_inclusion_width_1(ref_lower, ref_upper, ref_stride,
258 return _XMP_check_template_ref_inclusion_width_N(ref_lower, ref_upper, ref_stride, t, index);
◆ _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 |
|
) |
| |
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];
472 for(
int i=0;i<onto_nodes_dim;i++)
473 onto_nodes_shrink[i] = 1;
475 int new_nodes_dim = 0;
477 int acc_dim_size = 1;
478 int ref_template_dim = ref_template->
dim;
480 for(
int i=0;i<ref_template_dim;i++){
488 onto_nodes_shrink[onto_nodes_index] = 0;
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;
498 new_nodes_dim_size[new_nodes_dim] = 1;
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;
505 new_nodes_dim_size[new_nodes_dim] = size;
512 if (new_nodes_dim > 0)
514 onto_nodes_ref_lower, onto_nodes_ref_upper,
◆ _XMP_create_template_desc()
◆ _XMP_dist_template_BLOCK()
void _XMP_dist_template_BLOCK |
( |
_XMP_template_t * |
template, |
|
|
int |
template_index, |
|
|
int |
nodes_index |
|
) |
| |
357 unsigned long long nodes_size = ni->
size;
363 unsigned long long nodes_rank = ni->
rank;
367 if(nodes_rank == (owner_nodes_size - 1)){
370 else if (nodes_rank >= owner_nodes_size){
371 template->is_owner =
false;
383 if((ti->
ser_size % nodes_size) == 0){
◆ _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 |
|
) |
| |
401 _XMP_dist_template_CYCLIC_WIDTH(
template, template_index, nodes_index, width);
◆ _XMP_dist_template_CYCLIC()
void _XMP_dist_template_CYCLIC |
( |
_XMP_template_t * |
template, |
|
|
int |
template_index, |
|
|
int |
nodes_index |
|
) |
| |
396 _XMP_dist_template_CYCLIC_WIDTH(
template, template_index, nodes_index, 1);
◆ _XMP_dist_template_DUPLICATION()
void _XMP_dist_template_DUPLICATION |
( |
_XMP_template_t * |
template, |
|
|
int |
template_index |
|
) |
| |
◆ _XMP_dist_template_GBLOCK()
void _XMP_dist_template_GBLOCK |
( |
_XMP_template_t * |
template, |
|
|
int |
template_index, |
|
|
int |
nodes_index, |
|
|
int * |
mapping_array, |
|
|
int * |
temp0 |
|
) |
| |
420 long long *rsum_array =
_XMP_alloc(
sizeof(
long long) * (ni->
size + 1));
422 for (
int i = 1; i <= ni->
size; i++){
423 rsum_array[i] = rsum_array[i-1] + (
long long)mapping_array[i-1];
428 _XMP_fatal(
"The size of the template exceeds the sum of the mapping array.");
431 _XMP_warning(
"The sum of the mapping array exceeds the size of the template.");
433 template->is_owner =
false;
438 template->is_owner =
true;
447 template->is_fixed =
false;
◆ _XMP_exec_task_TEMPLATE_PART()
520 int ref_dim = ref_template->
dim;
522 long long lower[ref_dim], upper[ref_dim], stride[ref_dim];
525 va_start(args, ref_template);
526 for (
int i = 0; i < ref_dim; i++) {
527 shrink[i] = va_arg(args,
int);
529 lower[i] = va_arg(args,
long long);
530 upper[i] = va_arg(args,
long long);
531 stride[i] = va_arg(args,
long long);
537 if (*task_desc == NULL) {
542 if (_XMP_compare_task_exec_cond(desc, ref_template, lower, upper, stride)) {
550 if (desc->
nodes != NULL) {
557 _XMP_set_task_desc(desc, n, n->
is_member, ref_template, lower, upper, stride);
◆ _XMP_exec_task_TEMPLATE_PART_nocomm()
int _XMP_exec_task_TEMPLATE_PART_nocomm |
( |
_XMP_template_t * |
ref_template, |
|
|
|
... |
|
) |
| |
572 int ref_dim = ref_template->
dim;
575 long long lower[ref_dim], upper[ref_dim], stride[ref_dim];
578 va_start(args, ref_template);
580 for (
int i = 0; i < ref_dim; i++) {
581 shrink[i] = va_arg(args,
int);
583 lower[i] = va_arg(args,
long long);
584 upper[i] = va_arg(args,
long long);
585 stride[i] = va_arg(args,
long long);
591 for (
int i = 0; i < ref_dim; i++){
593 if (shrink[i])
continue;
611 if (
union_triplet(lower[i], upper[i], stride[i], plb, pub, pst))
break;
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;
622 _XMP_fatal(
"_XMP_exec_task_TEMPLATE_PART_nocomm: unknown dist_manner");
◆ _XMP_finalize_template()
315 for (
int i = 0; i <
template->dim; i++){
◆ _XMP_init_template_chunk()
307 template->is_distributed =
true;
309 template->onto_nodes = nodes;
◆ _XMP_init_template_FIXED()
void _XMP_init_template_FIXED |
( |
_XMP_template_t ** |
template, |
|
|
int |
dim, |
|
|
|
... |
|
) |
| |
273 for(
int i=0;i<dim;i++){
◆ _XMP_init_template_UNFIXED()
◆ _XMP_set_template_size()
294 for (
int i = 0; i < dim; i++) {
◆ union_triplet()
_Bool union_triplet |
( |
int |
lb0, |
|
|
int |
ub0, |
|
|
int |
st0, |
|
|
int |
lb1, |
|
|
int |
ub1, |
|
|
int |
st1 |
|
) |
| |
64 if (ub0 < lb0 || ub1 < lb0)
return false;
82 ub2 = (ub0 > ub1)? ub1 : ub0;
84 for(
int i=lb2;i<= ub2;i+=st2)
85 if((i-lb3) % st3 == 0)
◆ xmpc_ltog()
int xmpc_ltog |
( |
int |
local_idx, |
|
|
_XMP_template_t * |
template, |
|
|
int |
dim, |
|
|
int |
offset |
|
) |
| |
757 int global_index = 0;
760 long long base =
template->info[dim].ser_lower;
764 global_index = local_idx;
770 global_index = base + n_info->
rank + n_info->
size * local_idx;
775 global_index = base + n_info->
rank * w
776 + (local_idx/w) * w * n_info->
size + local_idx%w;
782 _XMP_fatal(
"_XMP_: unknown chunk dist_manner");
785 return global_index - offset;
long long par_upper
Definition: xmp_data_struct.h:81
int size
Definition: xmp_data_struct.h:32
_XMP_nodes_info_t info[1]
Definition: xmp_data_struct.h:60
Definition: xmp_data_struct.h:31
_XMP_template_info_t info[1]
Definition: xmp_data_struct.h:115
unsigned long long ser_size
Definition: xmp_data_struct.h:74
Definition: xmp_data_struct.h:316
#define _XMP_N_DIST_BLOCK
Definition: xmp_constant.h:29
long long ser_lower
Definition: xmp_data_struct.h:72
#define _XMP_M_CEILi(a_, b_)
Definition: xmp_gpu_func.hpp:22
int is_member
Definition: xmp_data_struct.h:46
void * _XMP_alloc(size_t size)
Definition: xmp_util.c:21
#define _XMP_N_NO_ONTO_NODES
Definition: xmp_constant.h:24
void _XMP_finalize_nodes(void *nodes)
_XMP_template_chunk_t * chunk
Definition: xmp_data_struct.h:112
_Bool is_regular_chunk
Definition: xmp_data_struct.h:89
long long par_lower
Definition: xmp_data_struct.h:80
#define min(x, y)
Definition: xmp_template.c:404
_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_nodes_info_t * onto_nodes_info
Definition: xmp_data_struct.h:94
_Bool is_fixed
Definition: xmp_data_struct.h:104
Definition: xmp_data_struct.h:70
int dim
Definition: xmp_data_struct.h:108
unsigned long long par_chunk_width
Definition: xmp_data_struct.h:86
int _XMP_calc_template_owner_SCALAR(_XMP_template_t *template, int dim_index, long long ref_index)
Definition: xmp_template.c:632
_XMP_nodes_t * onto_nodes
Definition: xmp_data_struct.h:111
int desc_kind
Definition: xmp_data_struct.h:100
_Bool union_triplet(int lb0, int ub0, int st0, int lb1, int ub1, int st1)
Definition: xmp_util.c:62
void _XMP_calc_template_size(_XMP_template_t *t)
Definition: xmp_template.c:30
void _XMP_warning(char *msg)
Definition: xmp_util.c:58
#define _XMP_N_INT_FALSE
Definition: xmp_constant.h:5
#define _XMP_N_DIST_CYCLIC
Definition: xmp_constant.h:30
Definition: xmp_data_struct.h:98
_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
Definition: xmp_data_struct.h:78
_XMP_nodes_t * nodes
Definition: xmp_data_struct.h:317
long long ser_upper
Definition: xmp_data_struct.h:73
int onto_nodes_index
Definition: xmp_data_struct.h:92
#define _XMP_N_DIST_BLOCK_CYCLIC
Definition: xmp_constant.h:31
#define _XMP_N_DIST_GBLOCK
Definition: xmp_constant.h:32
#define _XMP_N_DIST_DUPLICATION
Definition: xmp_constant.h:28
int par_stride
Definition: xmp_data_struct.h:85
int rank
Definition: xmp_data_struct.h:35
#define _XMP_N_INVALID_RANK
Definition: xmp_constant.h:21
int dist_manner
Definition: xmp_data_struct.h:87
void _XMP_free(void *p)
Definition: xmp_util.c:37
#define _XMP_ASSERT(_flag)
Definition: xmp_internal.h:34
#define _XMP_DESC_TEMPLATE
Definition: xmp_constant.h:132
void _XMP_fatal(char *msg)
Definition: xmp_util.c:42
#define _XMP_M_COUNTi(a_, b_)
Definition: xmp_math_function.h:15
unsigned long long par_width
Definition: xmp_data_struct.h:82
void _XMP_push_nodes(void *nodes)
_Bool is_distributed
Definition: xmp_data_struct.h:105
_XMP_template_t * _XMP_create_template_desc(int dim, _Bool is_fixed)
Definition: xmp_template.c:10
int dim
Definition: xmp_data_struct.h:47
Definition: xmp_data_struct.h:40
#define _XMP_M_COUNT_TRIPLETi(l_, u_, s_)
Definition: xmp_gpu_func.hpp:25
unsigned long long _XMP_get_on_ref_id(void)
Definition: xmp_util.c:13
#define _XMP_N_MAX_DIM
Definition: xmp_constant.h:6
#define _XMP_N_INT_TRUE
Definition: xmp_constant.h:4
long long * mapping_array
Definition: xmp_data_struct.h:88
int execute
Definition: xmp_data_struct.h:318
unsigned long long on_ref_id
Definition: xmp_data_struct.h:102
_Bool is_owner
Definition: xmp_data_struct.h:106