Sending data to a map

Use a Get method to return (send) data to the engine through stream objects. There are a number of different ways to accomplish this task. The method chosen depends on the manner in which the resource returns data to the adapter.

  • A memory buffer is returned from the resource that can be passed to the engine.
    In this scenario, only a single call to mpiStreamWrite is required:
    mpiStreamWrite (hStream, pData, nSizeOfData);
    This will create a page, copy the data to the page and append the page to the stream.
  • The adapter allocates a single buffer that is then populated by the resource.
    If the adapter is receiving data into a buffer that it has allocated, the buffer should be allocated through the stream interface as shown in the following example:
     /* Create a page */      
    mpiStreamNewPage (hStream, &hPage, nSizeOfBuffer);
    
    /* Get the address of the buffer */
    mpiStreamPageGetInfo (hPage, &pData, &nSizeOfBuffer);
    
    /* Get the data into the buffer */
    MyGetData (pData, &ActualDataSize);
    
    /* Add the page to the stream */ 
    mpiStreamWritePageEx (hStream, hPage, nActualDataSize); 
    This will create a page and append the page to the stream. This is the preferable way to handle this kind of resource because it requires no memory copies or reallocations.
  • The adapter gets data in pieces from the resource.

    This is identical to the above scenario except that it is allocated repeatedly. Each call to mpiStreamWritePage appends a page to the stream.