avtWholeImageCompositerWithZ::avtWholeImageCompositerWithZ()
{

   if (avtWholeImageCompositerWithZ::objectCount == 0)
      InitializeMPIStuff();
   avtWholeImageCompositerWithZ::objectCount++;
}
Example #2
0
void
ParallelZComposite(const MPI_Comm &comm,
                   int npixels,
                   const float *inz, const unsigned char *inrgba,
                   float *outz, unsigned char *outrgba,
                   unsigned char bgr, unsigned char bgg, unsigned char bgb)
{
    static bool MPIStuffInitialized = false;
    if (!MPIStuffInitialized)
    {
        InitializeMPIStuff();
        MPIStuffInitialized = true;
    }

    const int chunksize = 1 << 20;
    std::vector<Pixel> inpixels(chunksize);
    std::vector<Pixel> outpixels(chunksize);

    local_bg[0] = bgr;
    local_bg[1] = bgg;
    local_bg[2] = bgb;

    //cerr << "merging "<<npixels<<" pixels, bg="<<int(bgr)<<","<<int(bgg)<<","<<int(bgb)<<"\n";
    //cerr << "inpixel[0] = "<<int(inrgba[0])<<","<<int(inrgba[1])<<","<<int(inrgba[2])<<","<<int(inrgba[3])<<"\n";
    //cerr << "inzbuff[0] = "<<inz[0]<<endl;

    int i_in = 0, i_out = 0;
    while (npixels > 0)
    {
        int chunk = npixels < chunksize ? npixels : chunksize;

        for (int i=0; i<chunk; ++i, ++i_in)
        {
            inpixels[i].z = inz[i_in];
            inpixels[i].r = inrgba[i_in*4 + 0];
            inpixels[i].g = inrgba[i_in*4 + 1];
            inpixels[i].b = inrgba[i_in*4 + 2];
            inpixels[i].a = inrgba[i_in*4 + 3];
        }

        int err = MPI_Allreduce(&inpixels[0],  &outpixels[0], chunk,
                                mpiTypePixel, mpiOpMergePixelBuffers, comm);
        if (err != MPI_SUCCESS)
        {
            int errclass;
            MPI_Error_class(err,&errclass);
            char err_buffer[4096];
            int resultlen;
            MPI_Error_string(err,err_buffer,&resultlen);
            cerr << err_buffer << endl;
        }


        for (int i=0; i<chunk; ++i, ++i_out)
        {
            outz[i_out]          = outpixels[i].z;
            outrgba[i_out*4 + 0] = outpixels[i].r;
            outrgba[i_out*4 + 1] = outpixels[i].g;
            outrgba[i_out*4 + 2] = outpixels[i].b;
            outrgba[i_out*4 + 3] = outpixels[i].a;
        }

        npixels -= chunk;
    }

}