|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2018 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifndef DTPOOLS_INTERNAL_H_INCLUDED
|
|
Packit Service |
c5cf8c |
#define DTPOOLS_INTERNAL_H_INCLUDED
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <string.h>
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include "dtpools.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define ERR_STRING_MAX_LEN (512)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef DEBUG_DTPOOLS
|
|
Packit Service |
c5cf8c |
#define FPRINTF(fd,...) \
|
|
Packit Service |
c5cf8c |
do { \
|
|
Packit Service |
c5cf8c |
fprintf(fd,__VA_ARGS__);\
|
|
Packit Service |
c5cf8c |
fflush(fd); \
|
|
Packit Service |
c5cf8c |
} while (0)
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#define FPRINTF(...)
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define DTPI_OBJ_ALLOC_OR_FAIL(obj, size) \
|
|
Packit Service |
c5cf8c |
do { \
|
|
Packit Service |
c5cf8c |
obj = malloc(size); \
|
|
Packit Service |
c5cf8c |
if (!obj) { \
|
|
Packit Service |
c5cf8c |
err = DTP_ERR_OTHER; \
|
|
Packit Service |
c5cf8c |
fprintf(stdout, "Out of memory in %s\n", __FUNCTION__); \
|
|
Packit Service |
c5cf8c |
fflush(stdout); \
|
|
Packit Service |
c5cf8c |
goto fn_fail; \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
memset(obj, 0, size); \
|
|
Packit Service |
c5cf8c |
} while (0)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* Simple derived datatype layouts:
|
|
Packit Service |
c5cf8c |
* - block length = 1
|
|
Packit Service |
c5cf8c |
* - stride = 2
|
|
Packit Service |
c5cf8c |
* - count = N
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
enum {
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_SIMPLE__BASIC,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_SIMPLE__CONTIG,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_SIMPLE__VECTOR,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_SIMPLE__INDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_SIMPLE__BLOCK_INDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_SIMPLE__HVECTOR,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_SIMPLE__HINDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_SIMPLE__BLOCK_HINDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_SIMPLE__NUM
|
|
Packit Service |
c5cf8c |
};
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* Complex derived datatype layouts:
|
|
Packit Service |
c5cf8c |
* - block length = implementation defined
|
|
Packit Service |
c5cf8c |
* - stride = implementation defined
|
|
Packit Service |
c5cf8c |
* - count = implementation defined
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
enum {
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK__VECTOR = DTPI_OBJ_LAYOUT_SIMPLE__NUM,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK__INDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK__BLOCK_INDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK__HVECTOR,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK__HINDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK__BLOCK_HINDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK__SUBARRAY_C,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK__SUBARRAY_F,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT__VECTOR,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT__INDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT__BLOCK_INDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT__HVECTOR,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT__HINDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT__BLOCK_HINDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT__SUBARRAY_C,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT__SUBARRAY_F,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK_STRD__VECTOR,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK_STRD__INDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK_STRD__BLOCK_INDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK_STRD__HVECTOR,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK_STRD__HINDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK_STRD__BLOCK_HINDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK_STRD__SUBARRAY_C,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_BLK_STRD__SUBARRAY_F,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT_STRD__VECTOR,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT_STRD__INDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT_STRD__BLOCK_INDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT_STRD__HVECTOR,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT_STRD__HINDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT_STRD__BLOCK_HINDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT_STRD__SUBARRAY_C,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE_CNT_STRD__SUBARRAY_F,
|
|
Packit Service |
c5cf8c |
/* TODO: add LOWER BOUND use case */
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_LARGE__NUM
|
|
Packit Service |
c5cf8c |
};
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* Only one layouts for struct datatype.
|
|
Packit Service |
c5cf8c |
* TODO: extend struct with multiple
|
|
Packit Service |
c5cf8c |
* additional layouts ... ?
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
enum {
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT_SIMPLE__STRUCT,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_LAYOUT__STRUCT_NUM
|
|
Packit Service |
c5cf8c |
};
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
typedef enum {
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_TYPE__BASIC,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_TYPE__CONTIG,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_TYPE__VECTOR,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_TYPE__HVECTOR,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_TYPE__BLOCK_INDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_TYPE__BLOCK_HINDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_TYPE__INDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_TYPE__HINDEXED,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_TYPE__SUBARRAY_C,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_TYPE__SUBARRAY_F,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_TYPE__STRUCT,
|
|
Packit Service |
c5cf8c |
DTPI_OBJ_TYPE__NUM
|
|
Packit Service |
c5cf8c |
} DTPI_obj_type_e;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* Internal object information
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
typedef struct {
|
|
Packit Service |
c5cf8c |
DTPI_obj_type_e obj_type;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Aint type_basic_size; /* e.g., sizeof(int) */
|
|
Packit Service |
c5cf8c |
MPI_Aint type_extent; /* total extent of type in bytes */
|
|
Packit Service |
c5cf8c |
MPI_Aint type_lb; /* lower bound in bytes */
|
|
Packit Service |
c5cf8c |
MPI_Aint type_ub; /* upper bound in bytes */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
union {
|
|
Packit Service |
c5cf8c |
struct {
|
|
Packit Service |
c5cf8c |
int stride;
|
|
Packit Service |
c5cf8c |
int blklen;
|
|
Packit Service |
c5cf8c |
} contig;
|
|
Packit Service |
c5cf8c |
struct {
|
|
Packit Service |
c5cf8c |
int stride; /* stride in basic types */
|
|
Packit Service |
c5cf8c |
int blklen; /* # of blocks in stride */
|
|
Packit Service |
c5cf8c |
} vector;
|
|
Packit Service |
c5cf8c |
struct {
|
|
Packit Service |
c5cf8c |
MPI_Aint stride;
|
|
Packit Service |
c5cf8c |
int blklen;
|
|
Packit Service |
c5cf8c |
} hvector;
|
|
Packit Service |
c5cf8c |
struct {
|
|
Packit Service |
c5cf8c |
int stride;
|
|
Packit Service |
c5cf8c |
int blklen;
|
|
Packit Service |
c5cf8c |
} indexed;
|
|
Packit Service |
c5cf8c |
struct {
|
|
Packit Service |
c5cf8c |
MPI_Aint stride;
|
|
Packit Service |
c5cf8c |
int blklen;
|
|
Packit Service |
c5cf8c |
} hindexed;
|
|
Packit Service |
c5cf8c |
struct {
|
|
Packit Service |
c5cf8c |
int stride;
|
|
Packit Service |
c5cf8c |
int blklen;
|
|
Packit Service |
c5cf8c |
} block_indexed;
|
|
Packit Service |
c5cf8c |
struct {
|
|
Packit Service |
c5cf8c |
MPI_Aint stride;
|
|
Packit Service |
c5cf8c |
int blklen;
|
|
Packit Service |
c5cf8c |
} block_hindexed;
|
|
Packit Service |
c5cf8c |
struct {
|
|
Packit Service |
c5cf8c |
int order;
|
|
Packit Service |
c5cf8c |
int arr_sizes[2];
|
|
Packit Service |
c5cf8c |
int arr_subsizes[2];
|
|
Packit Service |
c5cf8c |
int arr_starts[2];
|
|
Packit Service |
c5cf8c |
} subarray;
|
|
Packit Service |
c5cf8c |
struct {
|
|
Packit Service |
c5cf8c |
MPI_Aint *displs; /* displacement addresses in buf */
|
|
Packit Service |
c5cf8c |
} structure;
|
|
Packit Service |
c5cf8c |
} u;
|
|
Packit Service |
c5cf8c |
} DTPI_t;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* Internal parameter structure used to pass
|
|
Packit Service |
c5cf8c |
* data around. Two types of parameters:
|
|
Packit Service |
c5cf8c |
* - User defined object information
|
|
Packit Service |
c5cf8c |
* - Implementation (core) defined object information
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* NOTE: for pools created with `DTP_pool_create_struct`
|
|
Packit Service |
c5cf8c |
* user defined count is disregarded and reset
|
|
Packit Service |
c5cf8c |
* internally to `DTP_basic_type_count`.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
struct DTPI_Par {
|
|
Packit Service |
c5cf8c |
struct {
|
|
Packit Service |
c5cf8c |
int val_start; /* start value to fill buf with */
|
|
Packit Service |
c5cf8c |
int val_stride; /* increment between values */
|
|
Packit Service |
c5cf8c |
int val_count; /* number of elements to init in buf */
|
|
Packit Service |
c5cf8c |
int obj_idx; /* index of object in pool */
|
|
Packit Service |
c5cf8c |
} user;
|
|
Packit Service |
c5cf8c |
struct {
|
|
Packit Service |
c5cf8c |
MPI_Aint type_count; /* # of elements */
|
|
Packit Service |
c5cf8c |
MPI_Aint type_blklen; /* length of a block in # of basic types */
|
|
Packit Service |
c5cf8c |
MPI_Aint type_stride; /* # of basic types between start of each block */
|
|
Packit Service |
c5cf8c |
MPI_Aint type_totlen; /* tot # of basic types in datatype */
|
|
Packit Service |
c5cf8c |
MPI_Aint type_displ; /* displ of first elem in buffer in bytes */
|
|
Packit Service |
c5cf8c |
} core;
|
|
Packit Service |
c5cf8c |
};
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
typedef int (*DTPI_Creator) (struct DTPI_Par * par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int DTPI_Struct_create(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Basic_create(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Contig_create(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Vector_create(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Hvector_create(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Indexed_create(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Hindexed_create(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Block_indexed_create(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Block_hindexed_create(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Subarray_c_create(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Subarray_f_create(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int DTPI_Struct_check_buf(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Basic_check_buf(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Contig_check_buf(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Vector_check_buf(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Hvector_check_buf(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Indexed_check_buf(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Hindexed_check_buf(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Block_indexed_check_buf(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Block_hindexed_check_buf(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Subarray_c_check_buf(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
int DTPI_Subarray_f_check_buf(struct DTPI_Par *par, DTP_t dtp);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
void DTPI_Print_error(int errcode);
|
|
Packit Service |
c5cf8c |
void DTPI_Init_creators(DTPI_Creator * creators);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#endif /* DTPOOLS_INTERNAL_H_INCLUDED */
|