[Mpi-22] Ticket #46: Addconst Keyword to the C bindings- implementation

Erez Haba erezh at [hidden]
Fri Mar 13 11:40:22 CDT 2009



Hi Jeff,

The point of this ticket is to present a consistent const correct interface to the programmer and hide all the idiosyncrasies of the down-level interfaces.

That said, to answer your questions:

No casting is required for:
* shared memory
* sockets (TCP) when using 'send()' (single buffer passed in)

Casting is required for interfaces that did not define their io vector buffer member as const. (an interface would need to define two io vector structures, one with const buffer for send and one with non-const for receive; most of them don't).

Thus, casting is required when using the scatter/gather io vector with
* sockets (TC)
* Network Direct (IB and iWarp)

With MPICH2 implementation, casting out the const for the send buffer when using these interfaces was there all along as (most of) MPICH2 internal functions already used const to pass the send buffer. No new cast was required in this full const implementation.

Again, casting away the const to use the lower level interface does not violate any const rules as long as the semantic is preserved.

Thanks,
.Erez

-----Original Message-----
From: mpi-22-bounces_at_[hidden] [mailto:mpi-22-bounces_at_[hidden]] On Behalf Of Jeff Squyres
Sent: Friday, March 13, 2009 6:05 AM
To: MPI 2.2
Subject: Re: [Mpi-22] Ticket #46: Addconst Keyword to the C bindings- implementation

Do you end up casting away the const when invoking the Windows network  
interfaces?

On Linux, I think the following interfaces would require casting the  
const away:

- shared memory (even using Linux vmsplice())
- MX
- TCP
- OpenFabrics (both verbs and udapl)

These interfaces do not require casting away const:

- SCTP (I *think* -- I'm not an SCTP expert, but a quick look in  
sctp.h showed a "const" argument for the sctp_sendmsg() function)

I can't check these offhand:

- Portals
- Elan

On Mar 12, 2009, at 6:06 PM, Erez Haba wrote:

> I urge you, please read the ticket proposal again. It discusses the  
> merit of this proposal.
>
> As for IB; yes you'd copy small messages (which const is fine with)  
> and some implement RDMA read or write for large messages; you might  
> need to cast the const away if your IB interface does not expose  
> const SGE's.
>
> As for the compiler; no you are not violating the contact;  
> (otherwise we wouldn't have casts); as long as you guarantee that  
> you are not changing the buffer. It's a way for the programmer to  
> use old, non const correct, interfaces.
>
> .Erez
>
> -----Original Message-----
> From: mpi-22-bounces_at_[hidden] [mailto:mpi-22-bounces_at_[hidden] 
> ] On Behalf Of Underwood, Keith D
> Sent: Thursday, March 12, 2009 2:03 PM
> To: MPI 2.2
> Subject: Re: [Mpi-22] Ticket #46: Add const Keyword to the C  
> bindings- implementation
>
> I didn't think that typical MPI implementations over IB copied the  
> data for large messages (as opposed to the bounce buffers for small  
> messages).
>
> If you are going to have to cast away the const, what is the point  
> of putting it in?  In fact, if you have to cast away the const,  
> aren't you violating your contract with the compiler?  Should this  
> change be rolled out from the bottom up?  i.e. common low-level APIs  
> first and then MPI?
>
> Keith
>
> >-----Original Message-----
> >From: mpi-22-bounces_at_[hidden] [mailto:mpi-22-bounces_at_lists.mpi-
> >forum.org] On Behalf Of Erez Haba
> >Sent: Thursday, March 12, 2009 2:10 PM
> >To: MPI 2.2
> >Subject: Re: [Mpi-22] Ticket #46: Add const Keyword to the C  
> bindings-
> >implementation
> >
> >Possibly you'll have to cast.
> >There are few interfaces that take const for send buffer (like  
> sockets).
> >In other cases you copy the buffer (like with IB) which keeps the  
> const
> >property.
> >
> >Thanks,
> >.Erez
> >
> >-----Original Message-----
> >From: mpi-22-bounces_at_[hidden] [mailto:mpi-22-bounces_at_lists.mpi-
> >forum.org] On Behalf Of Underwood, Keith D
> >Sent: Thursday, March 12, 2009 12:05 PM
> >To: MPI 2.2
> >Subject: Re: [Mpi-22] Ticket #46: Add const Keyword to the C  
> bindings-
> >implementation
> >
> >It would seem like const would eventually have to be cast away for  
> most
> >lower level interfaces.  Portals, Elan, IB Verbs, and as best I can  
> tell MX
> >don't have const on their send buffers...
> >
> >Keith
> >
> >>-----Original Message-----
> >>From: mpi-22-bounces_at_[hidden] [mailto:mpi-22-bounces_at_lists.mpi-
> >>forum.org] On Behalf Of Erez Haba
> >>Sent: Thursday, March 12, 2009 12:44 PM
> >>To: MPI 2.2
> >>Subject: Re: [Mpi-22] Ticket #46: Add const Keyword to the C  
> bindings-
> >>implementation
> >>
> >>No, it's not being cast away (although it is a quick way for you to
> >>implement it).
> >>In MPICH2 implementation it trickles down to the lower functions.  
> There
> >are
> >>very few places where the const is being cast away because ticket  
> #46 does
> >>not to break backward compatibility.
> >>For example, when the user function is called (const was not added  
> to the
> >>MPI_User_function) the implementation must cast away const from  
> the send
> >>buffer before calling the user function.
> >>
> >>Thanks,
> >>.Erez
> >>
> >>-----Original Message-----
> >>From: mpi-22-bounces_at_[hidden] [mailto:mpi-22-bounces_at_lists.mpi-
> >>forum.org] On Behalf Of Jeff Squyres
> >>Sent: Thursday, March 12, 2009 11:34 AM
> >>To: MPI 2.2
> >>Subject: Re: [Mpi-22] Ticket #46: Add const Keyword to the C  
> bindings-
> >>implementation
> >>
> >>More importantly, how is const handled?  Is it just cast away inside
> >>the MPI library?
> >>
> >>
> >>On Mar 12, 2009, at 2:34 PM, Underwood, Keith D wrote:
> >>
> >>> Since the main purpose of an implementation for something like
> >>> adding const is to see how invasive the change is, would it be
> >>> possible to get a diff against the trees that these were created  
> from?
> >>>
> >>> Thanks,
> >>> Keith
> >>>
> >>> From: mpi-22-bounces_at_[hidden] [mailto:mpi-22-
> >>bounces_at_[hidden]
> >>> ] On Behalf Of Erez Haba
> >>> Sent: Thursday, March 12, 2009 12:24 PM
> >>> To: MPI 2.2
> >>> Subject: [Mpi-22] Ticket #46: Add const Keyword to the C  
> bindings -
> >>> implementation
> >>>
> >>>
> >>> Implementation for ticket #46 is now available from ANL (thanks  
> Pavan)
> >>>
> >>>
> >>> tarballs
> >>>
> >>http://www.mcs.anl.gov/research/projects/mpich2/downloads/tarballs/nightly
> >/
> >>const
> >>>
> >>>
> >>> thanks,
> >>> .Erez
> >>>
> >>> _______________________________________________
> >>> mpi-22 mailing list
> >>> mpi-22_at_[hidden]
> >>> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-22
> >>
> >>
> >>--
> >>Jeff Squyres
> >>Cisco Systems
> >>
> >>_______________________________________________
> >>mpi-22 mailing list
> >>mpi-22_at_[hidden]
> >>http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-22
> >>
> >>
> >>_______________________________________________
> >>mpi-22 mailing list
> >>mpi-22_at_[hidden]
> >>http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-22
> >
> >_______________________________________________
> >mpi-22 mailing list
> >mpi-22_at_[hidden]
> >http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-22
> >
> >
> >_______________________________________________
> >mpi-22 mailing list
> >mpi-22_at_[hidden]
> >http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-22
>
> _______________________________________________
> mpi-22 mailing list
> mpi-22_at_[hidden]
> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-22
>
>
> _______________________________________________
> mpi-22 mailing list
> mpi-22_at_[hidden]
> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-22


-- 
Jeff Squyres
Cisco Systems
_______________________________________________
mpi-22 mailing list
mpi-22_at_[hidden]
http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-22




More information about the Mpi-22 mailing list