Example #1
0
File: util.c Project: LaHaine/ohpc
void copy_data (void *dst, void *src,
        int idim,
        int ndim,
        uint64_t* size_in_dset,
        uint64_t* ldims,
        const uint64_t * readsize,
        uint64_t dst_stride,
        uint64_t src_stride,
        uint64_t dst_offset,
        uint64_t src_offset,
        uint64_t ele_num,
        int      size_of_type,
        enum ADIOS_FLAG change_endiness,
        enum ADIOS_DATATYPES type
        )
{
    unsigned int i, j;
    uint64_t dst_offset_new=0;
    uint64_t src_offset_new=0;
    uint64_t src_step, dst_step;
    if (ndim-1==idim) {
        for (i=0;i<size_in_dset[idim];i++) {
            memcpy ((char *)dst + (i*dst_stride+dst_offset)*size_of_type,
                    (char *)src + (i*src_stride+src_offset)*size_of_type,
                    ele_num*size_of_type);
            if (change_endiness == adios_flag_yes) {
                change_endianness ((char *)dst + (i*dst_stride+dst_offset)*size_of_type, 
                                   ele_num*size_of_type, type);
            }
        }
        return;
    }

    for (i = 0; i<size_in_dset[idim];i++) {
        // get the different step granularity 
        // for each different reading pattern broke
        src_step = 1;
        dst_step = 1;
        for (j = idim+1; j <= ndim-1;j++) {
            src_step *= ldims[j];
            dst_step *= readsize[j];
        }
        src_offset_new =src_offset + i * src_stride * src_step;
        dst_offset_new = dst_offset + i * dst_stride * dst_step;
        copy_data ( dst, src, idim+1, ndim, size_in_dset,
                ldims,readsize,
                dst_stride, src_stride,
                dst_offset_new, src_offset_new,
                ele_num, size_of_type, change_endiness, type);
    }
}
Example #2
0
inline static uint64_t adios_patch_data_wb_to_wb(void *dst, uint64_t dst_ragged_offset, const ADIOS_SELECTION_WRITEBLOCK_STRUCT *dst_wb,
                                                 void *src, uint64_t src_ragged_offset, const ADIOS_SELECTION_WRITEBLOCK_STRUCT *src_wb,
                                                 const ADIOS_SELECTION_BOUNDINGBOX_STRUCT *vb_bounds,
                                                 enum ADIOS_DATATYPES datum_type,
                                                 enum ADIOS_FLAG swap_endianness)
{
	uint64_t copy_elem_offset, copy_nelems;
	const uint64_t vb_size_in_elements = compute_volume(vb_bounds->ndim, vb_bounds->count);

	const uint64_t dst_elem_offset = dst_wb->is_sub_pg_selection ? dst_wb->element_offset : 0;
	const uint64_t dst_nelems = dst_wb->is_sub_pg_selection ? dst_wb->nelements : vb_size_in_elements;
	const uint64_t src_elem_offset = src_wb->is_sub_pg_selection ? src_wb->element_offset : 0;
	const uint64_t src_nelems = src_wb->is_sub_pg_selection ? src_wb->nelements : vb_size_in_elements;

	// Find out how many elements overlap between the two
	// writeblock selections (due to the potential existence
	// of sub-PG writeblock selections; if both are whole-PG,
	// this overlap will be complete)
	int intersects = intersect_segments(
			dst_elem_offset, dst_nelems,
			src_elem_offset, src_nelems,
			&copy_elem_offset, &copy_nelems
	);

	// Copy any elements that are common to both selections
	// (for whole-PG writeblock selections, this will be all of them)
	if (intersects) {
		int typesize = adios_get_type_size(datum_type, NULL);
		void *copy_dst = (char*)dst + (copy_elem_offset - dst_elem_offset) * typesize;
		void *copy_src = (char*)src + (copy_elem_offset - src_elem_offset) * typesize;

		memcpy(copy_dst, copy_src, copy_nelems * typesize);
		if (swap_endianness == adios_flag_yes)
			change_endianness(copy_dst, copy_nelems * typesize, datum_type);

		return copy_nelems;
	} else {
		return 0;
	}
}
Example #3
0
 inline void change_endianness(uint64_t *dest,uint64_t *sour,int nints,int verbose=1)
 {change_endianness((double*)dest,(double*)sour,nints,verbose);}  
Example #4
0
template <class T> void change_endianness(T &a,int verbose=0){change_endianness(&a,&a,1,verbose);}
Example #5
0
 inline void change_endianness(int *dest,int *sour,int nints,int verbose=1)
 {change_endianness((float*)dest,(float*)sour,nints,verbose);}