Ejemplo n.º 1
0
// Creates a writeblock selection that only retrieves elements [start_elem, start_elem + num_elems)
// within a variable. An element is a single value of whatever the varaible's datatype is (i.e.,
// 1 element = 1 double if the variable type is double, 1 byte if the variable type is byte, etc.)
ADIOS_SELECTION * adios_selection_writeblock_bounded(int index, uint64_t start_elem, uint64_t num_elems, int is_timestep_relative) {
	ADIOS_SELECTION *sel = common_read_selection_writeblock(index);
	sel->u.block.is_absolute_index = !is_timestep_relative;
	sel->u.block.is_sub_pg_selection = 1;
	sel->u.block.element_offset = start_elem;
	sel->u.block.nelements = num_elems;
	return sel;
}
Ejemplo n.º 2
0
static int generate_read_request_for_pg(
		const ADIOS_VARINFO *raw_varinfo, const ADIOS_TRANSINFO *transinfo,
		const ADIOS_SELECTION *sel,
		int timestep, int timestep_blockidx, int blockidx,
		adios_transform_read_request *readreq)
{
    const ADIOS_SELECTION *pg_bounds_sel;
    ADIOS_SELECTION *pg_intersection_sel;
    ADIOS_SELECTION *pg_writeblock_sel;

    const ADIOS_VARBLOCK *raw_vb = &raw_varinfo->blockinfo[blockidx];
    const ADIOS_VARBLOCK *orig_vb = &transinfo->orig_blockinfo[blockidx];

    pg_bounds_sel = create_pg_bounds_from_varblock(transinfo->orig_ndim, orig_vb);
    pg_writeblock_sel = common_read_selection_writeblock(blockidx);
    pg_writeblock_sel->u.block.is_absolute_index = 1;

    // Find the intersection, if any
    if (is_global_selection(sel)) {
    	pg_intersection_sel = adios_selection_intersect_global(pg_bounds_sel, sel);
    } else if (sel->type == ADIOS_SELECTION_WRITEBLOCK) {
    	pg_intersection_sel = adios_selection_intersect_local(pg_writeblock_sel, sel, timestep, raw_varinfo, transinfo);
    } else {
    	abort(); // Should never be called with other types of selections
    }

    // If there is an intersection, generate a corresponding PG read request
    if (pg_intersection_sel) {
        // Make a PG read request group, and fill it with some subrequests, and link it into the read reqgroup
        adios_transform_pg_read_request *new_pg_readreq;
        new_pg_readreq = adios_transform_pg_read_request_new(timestep, timestep_blockidx, blockidx,
                                                              transinfo->orig_ndim, raw_varinfo->ndim,
                                                              orig_vb, raw_vb,
                                                              pg_intersection_sel, pg_bounds_sel,
                                                              transinfo->transform_metadatas[blockidx].content,
                                                              (uint16_t)transinfo->transform_metadatas[blockidx].length);

        adios_transform_generate_read_subrequests(readreq, new_pg_readreq);
        adios_transform_pg_read_request_append(readreq, new_pg_readreq);

        // Don't free pg_bounds_sel or pg_intersection_sel, since they are now
        // held by the adios_transform_pg_read_request struct
        return 1;
    } else {
        // Cleanup
        common_read_selection_delete((ADIOS_SELECTION *)pg_bounds_sel); // OK to delete, because this function only frees the outer struct, not the arrays within
        return 0;
    }
}
Ejemplo n.º 3
0
//
// One-on-one global intersection functions
//
ADIOS_SELECTION * adios_selection_intersect_wb_wb(const ADIOS_SELECTION_WRITEBLOCK_STRUCT *wb1,
                                                  const ADIOS_SELECTION_WRITEBLOCK_STRUCT *wb2,
                                                  int timestep,
                                                  const ADIOS_VARINFO *raw_varinfo, const ADIOS_TRANSINFO *transinfo)
{
	int is_abs_idx;
	int wbindex;
	if (wb1->is_absolute_index == wb2->is_absolute_index) {
		const int index1 = wb1->index;
		const int index2 = wb2->index;
		if (index1 != index2)
			return NULL;

		wbindex = index1;
		is_abs_idx = wb1->is_absolute_index;
	} else {
		const int index1 = wb1->is_absolute_index ? wb1->index : adios_get_absolute_writeblock_index(raw_varinfo, wb1->index, timestep);
		const int index2 = wb2->is_absolute_index ? wb2->index : adios_get_absolute_writeblock_index(raw_varinfo, wb2->index, timestep);
		if (index1 != index2)
			return NULL;

		wbindex = index1;
		is_abs_idx = 1;
	}

	if (!wb1->is_sub_pg_selection && !wb2->is_sub_pg_selection) {
		// If neither selection is a sub-PG selection, the result is easy, and we can return immediately
		ADIOS_SELECTION *inter_sel = common_read_selection_writeblock(wbindex);
		inter_sel->u.block.is_absolute_index = is_abs_idx;
		return inter_sel;
	} else if (wb1->is_sub_pg_selection && wb2->is_sub_pg_selection) {
		// Else, if both selections are sub-PG selections, take the overlapping portion (if any)
		uint64_t inter_elem_offset, inter_nelems;

		int intersects = intersect_segments(
				wb1->element_offset, wb1->nelements,
				wb2->element_offset, wb2->nelements,
				&inter_elem_offset, &inter_nelems
		);

		if (intersects) {
			ADIOS_SELECTION *inter_sel = common_read_selection_writeblock(wbindex);
			inter_sel->u.block.is_absolute_index = is_abs_idx;
			inter_sel->u.block.is_sub_pg_selection = 1;
			inter_sel->u.block.element_offset = inter_elem_offset;
			inter_sel->u.block.nelements = inter_nelems;
			return inter_sel;
		} else {
			return NULL;
		}
	} else if (wb1->is_sub_pg_selection) {
		// Else, if only the first selection is sub-PG, so just use its range
		ADIOS_SELECTION *newwb = common_read_selection_writeblock(wb1->index);
		newwb->u.block = *wb1;
		return newwb;
	} else if (wb2->is_sub_pg_selection) {
		// Else, only the second selection is sub-PG, so just use its range
		ADIOS_SELECTION *newwb = common_read_selection_writeblock(wb2->index);
		newwb->u.block = *wb2;
		return newwb;
	} else {
		abort(); // Should not be possible'
		return NULL;
	}
}
Ejemplo n.º 4
0
ADIOS_SELECTION * adios_selection_writeblock (int index)
{
    return common_read_selection_writeblock (index);
}