1 / 6

const in the C bindings

const in the C bindings. MPI Forum meeting 1/2008. Background:

hada
Download Presentation

const in the C bindings

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. const in the C bindings MPI Forum meeting1/2008

  2. Background: The const keyword in C defines a contract between the library implementer and the library user. Using the const keyword the library contracts that it will not change its input object. This contract enables some compile-time optimization, but more important it provides clearer and const-correct interface to the library user. (more on http://en.wikipedia.org/wiki/Const_correctness) The MPI C bindings as defined by the MPI 1.1 & 2.0 standards are missing the const keyword for many of the input only parameters. • Proposal: Add the const keyword to the API’s listed below.

  3. Why not? • It is a change, and as a change to the standard requires a good reason • This change can break existing application at compile time • No runtime or link-time break

  4. myth • Compiler optimization would break correct (and incorrect code) Buf[3] MPI_Irecv(buf[2]) X = exp(buf[2]) MPI_Send(buf[1]&buf[3]) y = exp(buf[2]) • consider Buf[3] MPI_Irecv(buf[2]) X = exp(buf[2]) foo(); y = exp(buf[2])

  5. Why yes? • Better contract for the interface • Developers don’t like to cast away their const’ness • Enables better static analysis tools • Enables sending constants in the .TEXT section (read only) (without casting) • Example, MPI_Add_error_string(77, “my error”) • Will be placed in the writable .DATA section (initialized data)

  6. Work group list • Erez Haba erezh@microsoft.com • David Gingold david.gingold@sicortex.com • Quincey Koziol koziol@hdfgroup.org • George Bosilca bosilca@eecs.utk.edu • Darius Buntinas buntinas@mcs.anl.gov • Dries Kimpe Dries.Kimpe@cs.kuleuven.be • Pavan Balaji balaji@mcs.anl.gov

More Related