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

Data Structures

struct  _XACC_sendrecv_comm_type
 
struct  _XACC_gmv_comm_type
 

Macros

#define _XACC_NUM_COMM_CACHES   4
 
#define _XACC_MAX_NUM_SENDRECVS   4
 

Typedefs

typedef struct _XACC_sendrecv_comm_type _XACC_sendrecv_comm_t
 
typedef struct _XACC_gmv_comm_type _XACC_gmv_comm_t
 

Functions

void xmpc_gmv_g_alloc_acc (_XMP_gmv_desc_t **gmv_desc, _XMP_array_t *ap, void *dev_addr)
 
void xmpc_gmv_l_alloc_acc (_XMP_gmv_desc_t **gmv_desc, void *local_data, int n)
 
void _XMP_gmove_array_array_common_acc (_XMP_gmv_desc_t *gmv_desc_leftp, _XMP_gmv_desc_t *gmv_desc_rightp, int *dst_l, int *dst_u, int *dst_s, unsigned long long *dst_d, int *src_l, int *src_u, int *src_s, unsigned long long *src_d, int mode)
 
void _XMP_gmove_garray_garray_acc (_XMP_gmv_desc_t *gmv_desc_leftp, _XMP_gmv_desc_t *gmv_desc_rightp, int mode)
 
void xmpc_gmv_do_acc (_XMP_gmv_desc_t *gmv_desc_leftp, _XMP_gmv_desc_t *gmv_desc_rightp, int mode)
 

Macro Definition Documentation

◆ _XACC_MAX_NUM_SENDRECVS

#define _XACC_MAX_NUM_SENDRECVS   4

◆ _XACC_NUM_COMM_CACHES

#define _XACC_NUM_COMM_CACHES   4

Typedef Documentation

◆ _XACC_gmv_comm_t

◆ _XACC_sendrecv_comm_t

Function Documentation

◆ _XMP_gmove_array_array_common_acc()

void _XMP_gmove_array_array_common_acc ( _XMP_gmv_desc_t gmv_desc_leftp,
_XMP_gmv_desc_t gmv_desc_rightp,
int *  dst_l,
int *  dst_u,
int *  dst_s,
unsigned long long *  dst_d,
int *  src_l,
int *  src_u,
int *  src_s,
unsigned long long *  src_d,
int  mode 
)
627  {
628  // NOTE: asynchronous gmove always done by _XMP_gmove_1to1
629  if (!xmp_is_async() && gmv_desc_leftp->is_global && gmv_desc_rightp->is_global && mode == _XMP_N_GMOVE_NORMAL){
630  if (_XMP_gmove_garray_garray_acc_opt(gmv_desc_leftp, gmv_desc_rightp,
631  dst_l, dst_u, dst_s, dst_d,
632  src_l, src_u, src_s, src_d)) return;
633  // fall through
634  }
635 
636 // _XMP_gmove_1to1(gmv_desc_leftp, gmv_desc_rightp, mode);
637  _XMP_fatal("_XMP_gmove_1to1 for acc is not implemented");
638 
639  return;
640 
641 }
Here is the call graph for this function:

◆ _XMP_gmove_garray_garray_acc()

void _XMP_gmove_garray_garray_acc ( _XMP_gmv_desc_t gmv_desc_leftp,
_XMP_gmv_desc_t gmv_desc_rightp,
int  mode 
)
651 {
652  _XMP_array_t *dst_array = gmv_desc_leftp->a_desc;
653  _XMP_array_t *src_array = gmv_desc_rightp->a_desc;
654 
655  _XMP_ASSERT(src_array->type == type);
656  _XMP_ASSERT(src_array->type_size == dst_array->type_size);
657 
658  _XACC_gmv_comm_t *gmv_comm = find_gmv_comm(gmv_desc_leftp, gmv_desc_rightp);
659  if(gmv_comm != NULL){
660  //do cached comm
661  exec_gmv_comm(gmv_comm);
662  return;
663  }
664 
665  g_current_comm.num_recvs = 0;
666  g_current_comm.num_sends = 0;
667 
668  //unsigned long long gmove_total_elmts = 0;
669 
670  // get dst info
671  unsigned long long dst_total_elmts = 1;
672  int dst_dim = dst_array->dim;
673  int dst_l[dst_dim], dst_u[dst_dim], dst_s[dst_dim];
674  unsigned long long dst_d[dst_dim];
675  int dst_scalar_flag = 1;
676  for (int i = 0; i < dst_dim; i++) {
677  dst_l[i] = gmv_desc_leftp->lb[i];
678  dst_u[i] = gmv_desc_leftp->ub[i];
679  dst_s[i] = gmv_desc_leftp->st[i];
680  dst_d[i] = dst_array->info[i].dim_acc;
681  _XMP_normalize_array_section(gmv_desc_leftp, i, &(dst_l[i]), &(dst_u[i]), &(dst_s[i]));
682  if (dst_s[i] != 0) dst_total_elmts *= _XMP_M_COUNT_TRIPLETi(dst_l[i], dst_u[i], dst_s[i]);
683  dst_scalar_flag &= (dst_s[i] == 0);
684  }
685 
686  // get src info
687  unsigned long long src_total_elmts = 1;
688  int src_dim = src_array->dim;
689  int src_l[src_dim], src_u[src_dim], src_s[src_dim];
690  unsigned long long src_d[src_dim];
691  int src_scalar_flag = 1;
692  for (int i = 0; i < src_dim; i++) {
693  src_l[i] = gmv_desc_rightp->lb[i];
694  src_u[i] = gmv_desc_rightp->ub[i];
695  src_s[i] = gmv_desc_rightp->st[i];
696  src_d[i] = src_array->info[i].dim_acc;
697  _XMP_normalize_array_section(gmv_desc_rightp, i, &(src_l[i]), &(src_u[i]), &(src_s[i]));
698  if (src_s[i] != 0) src_total_elmts *= _XMP_M_COUNT_TRIPLETi(src_l[i], src_u[i], src_s[i]);
699  src_scalar_flag &= (src_s[i] == 0);
700  }
701 
702  if (dst_total_elmts != src_total_elmts && !src_scalar_flag){
703  _XMP_fatal("wrong assign statement for gmove");
704  }
705  else {
706  //gmove_total_elmts = dst_total_elmts;
707  }
708 
709  if (mode == _XMP_N_GMOVE_NORMAL){
710 
711  if (dst_scalar_flag && src_scalar_flag){
712 // void *dst_addr = (char *)dst_array->array_addr_p + _XMP_gtol_calc_offset(dst_array, dst_l);
713 // void *src_addr = (char *)src_array->array_addr_p + _XMP_gtol_calc_offset(src_array, src_l);
714 // _XMP_gmove_SENDRECV_GSCALAR(dst_addr, src_addr,
715 // dst_array, src_array,
716 // dst_l, src_l);
717  _XMP_fatal("_XMP_gmove_SENDRECV_GSCALAR() for acc is not implemented");
718  return;
719  }
720  else if (!dst_scalar_flag && src_scalar_flag){
721 // char *tmp = _XMP_alloc(src_array->type_size);
722 // _XMP_gmove_BCAST_GSCALAR(tmp, src_array, src_l);
723 // _XMP_gmove_gsection_scalar(dst_array, dst_l, dst_u, dst_s, tmp);
724 // _XMP_free(tmp);
725  _XMP_fatal("_XMP_gmove_BCAST_GSCALAR() and _XMP_gmove_gsection_scalar() for acc is not implemented");
726  return;
727  }
728  }
729 
730  _XMP_gmove_array_array_common_acc(gmv_desc_leftp, gmv_desc_rightp,
731  dst_l, dst_u, dst_s, dst_d,
732  src_l, src_u, src_s, src_d,
733  mode);
734 
735 //cache comm
736  if(g_current_comm.num_recvs <= _XACC_MAX_NUM_SENDRECVS && g_current_comm.num_sends <= _XACC_MAX_NUM_SENDRECVS){
737 // printf("cache comm\n");
738  gmv_comm = (_XACC_gmv_comm_t*)malloc(sizeof(_XACC_gmv_comm_t));
739  gmv_comm->desc_left = alloc_gmv_desc(gmv_desc_leftp);
740  gmv_comm->desc_right = alloc_gmv_desc(gmv_desc_rightp);
741  gmv_comm->num_recvs = g_current_comm.num_recvs;
742  gmv_comm->num_sends = g_current_comm.num_sends;
743 
744  for(int i = 0; i < g_current_comm.num_recvs; i++){
745  gmv_comm->recvs[i] = g_current_comm.recvs[i];
746  }
747  for(int i = 0; i < g_current_comm.num_sends; i++){
748  gmv_comm->sends[i] = g_current_comm.sends[i];
749  }
750  cache_comm(gmv_comm);
751  }
752 }
Here is the caller graph for this function:

◆ xmpc_gmv_do_acc()

void xmpc_gmv_do_acc ( _XMP_gmv_desc_t gmv_desc_leftp,
_XMP_gmv_desc_t gmv_desc_rightp,
int  mode 
)
757 {
758  if (gmv_desc_leftp->is_global && gmv_desc_rightp->is_global){
759  _XMP_gmove_garray_garray_acc(gmv_desc_leftp, gmv_desc_rightp, mode);
760  }
761  else {
762  _XMP_fatal("gmv_do_acc: currently both sides must be global.");
763  }
764 }
Here is the call graph for this function:

◆ xmpc_gmv_g_alloc_acc()

void xmpc_gmv_g_alloc_acc ( _XMP_gmv_desc_t **  gmv_desc,
_XMP_array_t ap,
void *  dev_addr 
)
187 {
188  _XMP_gmv_desc_t *gp;
189  int n = ap->dim;
190 
191  gp = (_XMP_gmv_desc_t *)_XMP_alloc(sizeof(_XMP_gmv_desc_t));
192 
193  gp->kind = (int *)_XMP_alloc(sizeof(int) * n);
194  gp->lb = (int *)_XMP_alloc(sizeof(int) * n);
195  gp->ub = (int *)_XMP_alloc(sizeof(int) * n);
196  gp->st = (int *)_XMP_alloc(sizeof(int) * n);
197 
198  if (!gp || !gp->kind || !gp->lb || !gp->st)
199  _XMP_fatal("gmv_g_alloc: cannot alloc memory");
200 
201  gp->is_global = true;
202  gp->ndims = n;
203  gp->a_desc = ap;
204 
205  gp->local_data = NULL;
206  gp->a_lb = NULL;
207  gp->a_ub = NULL;
208 
209  gp->a_dev = dev_addr;
210 
211  *gmv_desc = gp;
212 }
Here is the call graph for this function:

◆ xmpc_gmv_l_alloc_acc()

void xmpc_gmv_l_alloc_acc ( _XMP_gmv_desc_t **  gmv_desc,
void *  local_data,
int  n 
)
216 {
217  _XMP_gmv_desc_t *gp;
218 
219  gp = (_XMP_gmv_desc_t *)_XMP_alloc(sizeof(_XMP_gmv_desc_t));
220 
221  gp->kind = (int *)_XMP_alloc(sizeof(int) * n);
222  gp->lb = (int *)_XMP_alloc(sizeof(int) * n);
223  gp->ub = (int *)_XMP_alloc(sizeof(int) * n);
224  gp->st = (int *)_XMP_alloc(sizeof(int) * n);
225  gp->a_lb = (int *)_XMP_alloc(sizeof(int) * n);
226  gp->a_ub = (int *)_XMP_alloc(sizeof(int) * n);
227 
228  gp->is_global = false;
229  gp->ndims = n;
230  gp->a_desc = NULL;
231 
232  gp->local_data = NULL;
233 
234  gp->a_dev = local_data;
235 
236  *gmv_desc = gp;
237 }
Here is the call graph for this function:
_XACC_gmv_comm_type::num_recvs
int num_recvs
Definition: xmp_gmove_acc.c:23
_XMP_gmove_array_array_common_acc
void _XMP_gmove_array_array_common_acc(_XMP_gmv_desc_t *gmv_desc_leftp, _XMP_gmv_desc_t *gmv_desc_rightp, int *dst_l, int *dst_u, int *dst_s, unsigned long long *dst_d, int *src_l, int *src_u, int *src_s, unsigned long long *src_d, int mode)
Definition: xmp_gmove_acc.c:624
_XACC_gmv_comm_type
Definition: xmp_gmove_acc.c:20
xmp_is_async
_Bool xmp_is_async()
Definition: xmp_async.c:20
_XMP_alloc
void * _XMP_alloc(size_t size)
Definition: xmp_util.c:21
_XMP_gmv_desc_type::lb
int * lb
Definition: xmp_data_struct.h:398
_XMP_gmv_desc_type::st
int * st
Definition: xmp_data_struct.h:400
_XACC_gmv_comm_type::recvs
_XACC_sendrecv_comm_t recvs[_XACC_MAX_NUM_SENDRECVS]
Definition: xmp_gmove_acc.c:25
_XMP_N_GMOVE_NORMAL
#define _XMP_N_GMOVE_NORMAL
Definition: xmp_constant.h:69
_XMP_gmv_desc_type::ub
int * ub
Definition: xmp_data_struct.h:399
_XACC_MAX_NUM_SENDRECVS
#define _XACC_MAX_NUM_SENDRECVS
Definition: xmp_gmove_acc.c:10
_XMP_gmove_garray_garray_acc
void _XMP_gmove_garray_garray_acc(_XMP_gmv_desc_t *gmv_desc_leftp, _XMP_gmv_desc_t *gmv_desc_rightp, int mode)
Definition: xmp_gmove_acc.c:648
_XMP_gmv_desc_type
Definition: xmp_data_struct.h:386
_XMP_gmv_desc_type::a_ub
int * a_ub
Definition: xmp_data_struct.h:395
_XACC_gmv_comm_type::desc_left
_XMP_gmv_desc_t * desc_left
Definition: xmp_gmove_acc.c:21
_XACC_gmv_comm_type::sends
_XACC_sendrecv_comm_t sends[_XACC_MAX_NUM_SENDRECVS]
Definition: xmp_gmove_acc.c:26
_XMP_gmv_desc_type::kind
int * kind
Definition: xmp_data_struct.h:397
_XACC_gmv_comm_type::desc_right
_XMP_gmv_desc_t * desc_right
Definition: xmp_gmove_acc.c:22
_XMP_gmv_desc_type::local_data
void * local_data
Definition: xmp_data_struct.h:393
_XMP_array_type
Definition: xmp_data_struct.h:266
_XMP_gmv_desc_type::ndims
int ndims
Definition: xmp_data_struct.h:389
_XMP_array_type::type_size
size_t type_size
Definition: xmp_data_struct.h:274
_XMP_array_type::info
_XMP_array_info_t info[1]
Definition: xmp_data_struct.h:313
_XMP_ASSERT
#define _XMP_ASSERT(_flag)
Definition: xmp_internal.h:34
_XMP_gmv_desc_type::is_global
_Bool is_global
Definition: xmp_data_struct.h:388
_XMP_array_type::dim
int dim
Definition: xmp_data_struct.h:272
_XMP_fatal
void _XMP_fatal(char *msg)
Definition: xmp_util.c:42
_XMP_gmv_desc_type::a_desc
_XMP_array_t * a_desc
Definition: xmp_data_struct.h:391
_XMP_array_info_type::dim_acc
unsigned long long dim_acc
Definition: xmp_data_struct.h:242
_XMP_M_COUNT_TRIPLETi
#define _XMP_M_COUNT_TRIPLETi(l_, u_, s_)
Definition: xmp_gpu_func.hpp:25
_XACC_gmv_comm_type::num_sends
int num_sends
Definition: xmp_gmove_acc.c:24
_XMP_array_type::type
int type
Definition: xmp_data_struct.h:273
_XMP_normalize_array_section
void _XMP_normalize_array_section(int *lower, int *upper, int *stride)
_XMP_gmv_desc_type::a_lb
int * a_lb
Definition: xmp_data_struct.h:394