Exemplo n.º 1
0
/*
 * Takes a datablock containing data potentially applicable to the given read
 * request group, identifies that data (if any), and returns it as an
 * ADIOS_VARCHUNK. Additionally, free the datablock.
 */
static ADIOS_VARCHUNK * apply_datablock_to_chunk_and_free(adios_datablock *datablock, adios_transform_read_request *reqgroup)
{
    assert(datablock); assert(reqgroup);
    assert(reqgroup->orig_sel);

    if (reqgroup->orig_sel->type != ADIOS_SELECTION_BOUNDINGBOX &&
    	reqgroup->orig_sel->type != ADIOS_SELECTION_POINTS &&
    	reqgroup->orig_sel->type != ADIOS_SELECTION_WRITEBLOCK)
    {
    	adios_error(err_operation_not_supported,
                    "Only read selections of bounding box, points, or writeblock selection types "
                    "are currently allowed (received selection type %d) "
    			    "(NOTE: this should have been caught earlier in the code)\n",
                    reqgroup->orig_sel->type);
    }

    if (datablock->bounds->type != ADIOS_SELECTION_BOUNDINGBOX &&
    	datablock->bounds->type != ADIOS_SELECTION_POINTS &&
    	datablock->bounds->type != ADIOS_SELECTION_WRITEBLOCK)
    {
        adios_error(err_operation_not_supported,
                    "Only results of bounding box, points, or writeblock selection types "
                    "are currently accepted from transform plugins (received selection type %d)\n",
                    datablock->bounds->type);
        abort();
    }

    // Special check due to limitations of ADIOS_VARCHUNK return:
    // If the output is a writeblock selection, AND the input is not, AND
    // the variable is a local array, AND we are required to return a chunk
    // at a time, we must warn the user about potentially unexpected output.
    // Because our results would necessarily be a global-selection-based chunk
    // (subvolume, etc.), which has no information about what PG it came from,
    // if the user submitted multiple writeblock selections over a local array
    // variable at once, there would be no way to determine which writeblock
    // a varchunk with a bounding box selection corresponds to.
    //
    // Potential solutions are: submit only one writeblock per schedule/check/perform
    // cycle, use blocking reads, use a global array file, or use a different data
    // transform.
    if (reqgroup->orig_sel->type == ADIOS_SELECTION_WRITEBLOCK &&
    	datablock->bounds->type != ADIOS_SELECTION_WRITEBLOCK &&
    	!reqgroup->transinfo->orig_global &&
    	adios_transform_read_request_get_mode(reqgroup) == PARTIAL_RESULT_MODE)
    {
    	static int warning_printed = 0;
    	if (!warning_printed) {
    		const char *transform_name = adios_transform_plugin_primary_xml_alias(reqgroup->transinfo->transform_type);
    		if (!transform_name) transform_name = "<name unknown>";
    		log_warn("Results for a chunked read using a writeblock selection over a %s-transformed "
    				"variable will return correct results, but in the form of ADIOS_VARCHUNKs with "
    				"non-writeblock selections, so it may be difficult to determine which VARCHUNK "
    				"goes with which writeblock selection if multiple have been submitted at once. "
    				"To avoid this warning, either use blocking reads, use a global array file, or "
    				"select a use data transform. This warning will only be printed once per run.",
    				transform_name);
    		warning_printed = 1;
    	}
    	return NULL;
    }

    ADIOS_SELECTION *chunk_sel = NULL;
    void *chunk_data = NULL;
    uint64_t used_count =
    	apply_datablock_to_buffer_and_free(
			reqgroup->raw_varinfo, reqgroup->transinfo,
			datablock,
			&chunk_data, reqgroup->orig_sel, &chunk_sel, // chunk_data == NULL -> allocate fitted buffer, chunk_sel == NULL -> return intersection selection
			reqgroup->swap_endianness);

    if (used_count) {
    	assert(chunk_data && chunk_sel);

        // Bind the output buffer to the chunk struct
    	ADIOS_VARCHUNK *chunk = (ADIOS_VARCHUNK *)malloc(sizeof(ADIOS_VARCHUNK));
        *chunk = (ADIOS_VARCHUNK) {
        	.varid = reqgroup->raw_varinfo->varid,
        	.data = chunk_data,
        	.type = datablock->elem_type,
        	.sel = chunk_sel,
        	.from_steps = datablock->timestep,
        	.nsteps = 1,
        };

        return chunk;
    } else {
    	return NULL;
    }
}
Exemplo n.º 2
0
void print_var_header (struct adios_var_header_struct_v1 * var_header)
{
    int i = 0;

    printf ("\t\tVar Name (ID): %s (%d)\n", var_header->name, var_header->id);
    printf ("\t\tVar Path: %s\n", var_header->path);
    printf ("\t\tDatatype: %s\n", adios_type_to_string_int (var_header->type));
    printf ("\t\tIs Dimension: %c\n"
           ,(var_header->is_dim == adios_flag_yes ? 'Y' : 'N')
           );
    if (var_header->dims)
    {
        struct adios_dimension_struct_v1 * d = var_header->dims;
        printf ("\t\tDimensions:\n");
        while (d)
        {
            printf ("\t\t\tDim %d l:g:o: ", i++);
            if (d->dimension.var_id == 0)
            {
                if (d->dimension.is_time_index == adios_flag_yes)
                {
                    printf ("TIME");
                }
                else
                {
                    printf ("R(%" PRIu64 ")", d->dimension.rank);
                }
            }
            else
            {
                printf ("V(%u)", d->dimension.var_id);
            }

            if (   d->global_dimension.var_id != 0
                || d->global_dimension.rank != 0
               )
            {
                if (d->global_dimension.var_id == 0)
                {
                    if (d->global_dimension.is_time_index == adios_flag_yes)
                    {
                        printf (":TIME");
                    }
                    else
                    {
                        printf (":R(%" PRIu64 ")", d->global_dimension.rank);
                    }
                }
                else
                {
                    printf (":V(%u)", d->global_dimension.var_id);
                }
                if (d->local_offset.var_id == 0)
                {
                    if (d->local_offset.is_time_index == adios_flag_yes)
                    {
                        printf (":TIME");
                    }
                    else
                    {
                        printf (":R(%" PRIu64 ")\n", d->local_offset.rank);
		    }
                }
                else
                {
                    printf (":V(%u)\n", d->local_offset.var_id);
                }
            }
            printf ("\n");

            d = d->next;
	}
    }
    printf ("\t\tCharacteristics:\n");
    printf ("\t\t\tOffset(%" PRIu64 ")", var_header->characteristics.offset);

    /* NCSU - Print min, max */

	if (var_header->type == adios_complex || var_header->type == adios_double_complex)
	{
		uint8_t type;

		if (var_header->type == adios_complex)
			type = adios_double;
		else
			type = adios_long_double;

        if (var_header->characteristics.stats && var_header->characteristics.stats[0][adios_statistic_min].data)
        {
            printf ("\tMin(%s)", bp_value_to_string (type
                                       ,var_header->characteristics.stats[0][adios_statistic_min].data
                                       )
                   );
        }
        if (var_header->characteristics.stats && var_header->characteristics.stats[0][adios_statistic_max].data)
        {
            printf ("\tMax(%s)", bp_value_to_string (type
                                       ,var_header->characteristics.stats[0][adios_statistic_max].data
                                       )
                   );
        }

	}
	else
	{
    	if (var_header->characteristics.stats && var_header->characteristics.stats[0][adios_statistic_min].data)
    	{
    	    printf ("\tMin(%s)", bp_value_to_string (var_header->type
    	                               ,var_header->characteristics.stats[0][adios_statistic_min].data
    	                               )
    	           );
    	}
    	if (var_header->characteristics.stats && var_header->characteristics.stats[0][adios_statistic_max].data)
    	{
    	    printf ("\tMax(%s)", bp_value_to_string (var_header->type
    	                               ,var_header->characteristics.stats[0][adios_statistic_max].data
    	                               )
    	           );
    	}
	}
	
    

    if (var_header->characteristics.value)
    {
        printf ("\t\t\tValue(%s)", bp_value_to_string (var_header->type
                                          ,var_header->characteristics.value
                                          )
               );
    }
    if (var_header->characteristics.dims.count != 0)
    {
        printf ("\t\t\tDims (l:g:o): (");
        print_characteristic_dims(&var_header->characteristics.dims);
        printf(")");
        }

    // NCSU ALACRITY-ADIOS - Adding printing of transform type
    printf ("\t\t\tTransform-type(%hhu = %s)",
            var_header->characteristics.transform.transform_type,
            adios_transform_plugin_primary_xml_alias(var_header->characteristics.transform.transform_type));
    if (var_header->characteristics.transform.transform_type != adios_transform_none) {
        printf ("\t\t\tPre-transform-datatype(%s)", adios_type_to_string_int(var_header->characteristics.transform.pre_transform_type));
        printf ("\t\t\tPre-transform-dims(l:g:o = ");
        print_characteristic_dims(&var_header->characteristics.transform.pre_transform_dimensions);
        printf (")");
        printf ("\t\t\tTransform-metadata-length(%hu)", var_header->characteristics.transform.transform_metadata_len);
    }

    printf ("\n");
}