List Info

Thread: LAM: Derived Datatype or not?




LAM: Derived Datatype or not?
country flaguser name
Germany
2007-09-02 13:29:33
Hello,

i'm using C++ with MPI and have a template function. 

The two template candidates can be double or a structure
called Complex which holds two double values. 
Now i wanted to write a MPI_Send - call within this template
function. 
But i have problems with the datatype-argument within the
signature. 

Simply i cannot enter the T value for the datatype-argument
so can it be that i need to build a derived datatype?

Or do i really need two implementation of this function -
one for the double input and one for the complex input?

my function looks this:

struct Complex {double r; double i;};

void Class<T>::fct(Matrix<T> *m)
{
     MPI_Send(buf, len, T, requestor, send_tag, world)
}

Sure this does not work because of the T type. 
How could i implement the MPI_Send - function only once,
both for a buffer holding double values 
and for a buffer holding Complex values?

Are derived datatypes the solution? If so - a bit help would
be very fine.

Thanks a lot
____________________________________________________________
___________
Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 3
Monate
kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=022220


_______________________________________________
This list is archived at http://www.l
am-mpi.org/MailArchives/lam/

Re: LAM: Derived Datatype or not?
country flaguser name
United States
2007-09-02 21:46:53
On Sep 2, 2007, at 12:29 PM, XMATXweb.de wrote:

> i'm using C++ with MPI and have a template function.
>
> The two template candidates can be double or a
structure called  
> Complex which holds two double values.
> Now i wanted to write a MPI_Send - call within this
template function.
> But i have problems with the datatype-argument within
the signature.
>
> Simply i cannot enter the T value for the
datatype-argument so can  
> it be that i need to build a derived datatype?
>
> Or do i really need two implementation of this function
- one for  
> the double input and one for the complex input?

Since MPI type constants don't have any special meaning or
mapping to  
template type parameters, you can not just pass the type
parameter  
into the MPI_Send as the specified datatype.  The most
straight  
forward solution is to provide the necessary specializations
so that  
you can pass in the correct MPI type constant.


Hope this helps,

Brian

-- 
   Brian Barrett
   LAM/MPI Developer
   Make today a LAM/MPI day!


_______________________________________________
This list is archived at http://www.l
am-mpi.org/MailArchives/lam/

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )