Ejemplo n.º 1
0
adios_datablock * adios_transform_alacrity_pg_reqgroup_completed(adios_transform_read_request *reqgroup,
                                                                 adios_transform_pg_read_request *completed_pg_reqgroup)
{
    //uint64_t raw_size = (uint64_t)completed_pg_reqgroup->raw_var_length;
    void* raw_buff = completed_pg_reqgroup->subreqs->data;

    uint64_t orig_size = adios_get_type_size(reqgroup->transinfo->orig_type, "");
    int d = 0;
    for(d = 0; d < reqgroup->transinfo->orig_ndim; d++)
        orig_size *= (uint64_t)(completed_pg_reqgroup->orig_varblock->count[d]);

    void* orig_buff = malloc(orig_size);

    ALPartitionData output_partition;
    uint64_t numElements = 0;

    // Decompress into output_partition from compressed_buf
    memstream_t ms = memstreamInitReturn (raw_buff);

    // Deserialize the ALPartitionData from memstream
    ALDeserializePartitionData (&output_partition, &ms);

    // Decode ALPartitionData into decompresed buffer
    int rtn = ALDecode (&output_partition, orig_buff, &numElements);
    if (ALErrorNone != rtn)
        return NULL;

    ALPartitionDataDestroy(&output_partition);

    return adios_datablock_new(reqgroup->transinfo->orig_type,
                               completed_pg_reqgroup->timestep,
                               completed_pg_reqgroup->pg_bounds_sel,
                               orig_buff);
}
Ejemplo n.º 2
0
// Encodes the data from infile into the ALFileStore outfile, closing both afterward
int decodeCommandDecode(ALStore *infile, FILE *outfile) {
    ALPartitionData partdata;   // Output buffer
    void *outbuf;
    uint64_t outbufCount;
    uint64_t totalElemsWritten = 0;
    ALError err;
    size_t writelen;

    while (!ALStoreEOF(infile)) {
        err = ALStoreReadPartition(infile, &partdata);
        if (err != ALErrorNone) {
            fprintf(stderr, "Error reading the next partition from the input files\n");
            return 1;
        }

        outbuf = malloc(ALGetDecodeLength(&partdata));
        if (!outbuf) {
            fprintf(stderr, "Error allocating %llu btyes of temporary memory for decoding\n", ALGetDecodeLength(&partdata));
            return 1;
        }

        err = ALDecode(&partdata, outbuf, &outbufCount);
        if (err != ALErrorNone) {
            fprintf(stderr, "Error decoding partition from input files\n");
            return 1;
        }

        writelen = fwrite(outbuf, partdata.metadata.elementSize, outbufCount, outfile);
        if (writelen != outbufCount) {
            fprintf(stderr, "Error writing decoded elements to file (wrote %llu, expected to write %llu)\n",
                    (uint64_t)writelen, (uint64_t)partdata.metadata.elementSize);
            return 1;
        }

        totalElemsWritten += outbufCount;

        free(outbuf);
        ALPartitionDataDestroy(&partdata);
    }

    // Cleanup
    fclose(outfile);

    printf("Decoding complete, wrote out %llu elements\n", totalElemsWritten);

    dbprintf("Closing ALACRITY input files...\n");
    if (ALStoreClose(infile) != ALErrorNone) {
        fprintf(stderr, "Error closing ALACRITY input file, aborting (output should still be correct)\n");
        return 1;
    }

    return 0;
}