[MINC-users] Problem in Parallel mode

Parya Mamayyez Siahkal parya.momayyezsiahkal at mail.mcgill.ca
Wed Oct 28 09:44:43 EDT 2009


Andrew Janke wrote:
>> The files I am using are all MINC1 files.
>> Does this help?
>>     
>
> Well it helps me but you aren't going to like the answer that MINC1
> files (as far as I am aware) don't support parallel access as they are
> netcdf3 based. Netcdf4 does do parallel access but this is because it
> is HDF5 underneath..
>
>   
>> In terms of where this error messages are being generated, it is just at
>> the beginning of the program where I am trying to initialize the volume:
>>
>> volume_io::set_volume_real_value(_cf_minc_volume,n,z,y,x,0,value);
>>     
>
> Erk! where does this C++ wrapper come from? In any case I don't like
> to be the bearer of bad news but I doubt that anything that uses
> volume_io will ever allow parallel access. (unless you do something
> internally and have a single process that reads and writes the
> resulting volume out).
>
> It is possible to do parallel access with HDF5 files so if you are
> careful with how you use the libminc2 functions if should be possible.
> Either that or just use raw HDF5 calls on the minc volume itself.
> This link should help:
>
>    http://www.physics.ohio-state.edu/~wilkins/computing/HDF/hdf5tutorial/pprog.html
>
> Good luck!
>
>
> --
> Andrew Janke
> (a.janke at gmail.com || http://a.janke.googlepages.com/)
> Canberra->Australia    +61 (402) 700 883
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www2.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>
>   
Hi Andrew,

Thanks a lot for your response.
But what exactly it means that I cannot run the code in parallel!?
I am using Intel threading building blocks. and it works for smaller
volumes. I 'll get exactly the same result if I run the program on a
single processor.

Part of the code which can be run in parallel is as follows:

void CompletionField::SetAllVoxels(float value, ImageData *input_mask)
{
    int xsize, ysize, zsize;
    xsize = this->GetXSize();
    ysize = this->GetYSize();
    zsize = this->GetZSize();

    static affinity_partitioner ap;

    InitVolume init_vol(this, value, input_mask);
    if (!_parallel)
    {
        init_vol(blocked_range3d<int>(0, xsize, 0, ysize, 0, zsize));
    }
    else if (_parallel)
    {
        if (_grnSize)
        {
            parallel_for( blocked_range3d<int>(0, xsize, int_max(1,
floor(xsize/_grnSize)), 0, ysize, int_max(1, floor(ysize/_grnSize)), 0,
zsize, int_max(1, floor(zsize/_grnSize))), init_vol);
        }
        else
        {
            parallel_for( blocked_range3d<int>(0, xsize, 0, ysize, 0,
zsize), init_vol, ap);
        }
    }
}

class InitVolume  {
    CompletionField* InCFVolume;
    ImageData* input_mask;
    float value;

public:
    void operator() (const blocked_range3d<int>& r) const
    {
        int x,y,z,n;

        for (x = r.pages().begin(); x != r.pages().end(); ++x)
        {
            for (y = r.rows().begin(); y != r.rows().end(); ++y)
            {
                for (z = r.cols().begin(); z != r.cols().end(); ++z)
                {
                    if (input_mask->GetValue(x,y,z) > FLT_EPSILON)
                   {
                       for (n = 0; n < InCFVolume->GetNSize(); n++)
                       {
                           InCFVolume->SetValue(x, y, z, n, value);
                       }
                   }
                }
            }
        }
    }

    InitVolume(CompletionField *CFVolume, float val, ImageData *mask)
    {
        input_mask = mask;
        InCFVolume = CFVolume;
        value = val;
    }
};


void CompletionField::SetValue(int x, int y, int z, int n, float value)
{
    if (this->GetDimensions()!=4)
    {
        Error("Illegal use of CompletionField volume!");
    }

    set_volume_real_value(_cf_minc_volume,n,z,y,x,0,value);
}

regards,
Parya





More information about the MINC-users mailing list