Re: Version of dpi_pipe_c_send() that can handle messages of unlimited size

From: Per Bojsen <bojsen_at_.....>
Date: Thu Mar 30 2006 - 21:28:44 PST
Hi John,

> Basically what I do is put in a small optimization
> where if the bytes_per_element is a multiple
> of sizeof(svBitVecVal) it means that all elements
> are word aligned and you can do it slightly more
> efficiently.

The case of pipe depth >= 4 in my code was actually
more general than that.  Basically when pipe depth
is at least 4 the code would pick a number of elements
to transfer such that the total number of bytes,
i.e., nElements * bytesPerElement is a multiple of
4, i.e., svBitVecVal aligned.  Your optimization is
a special case of this.

For pipe depth < 4 I briefly considered to optimize
for the case when pipeDepth * bytesPerElement is
a multiple of 4, but decided I already had too many
special cases :-)  In any event, I found it reasonable
to assume that pipe depth is normally not so small
so there is not much benefit to optimizing for this
case.

But all of the above is moot anyway considering your
proposal to add the byte offset to the try_send()
function.  I like this a lot and it is obvious how
much it simplifies the dpi_pipe_c_send() function.

BTW, we should work on changing the names of those
dpi_pipe functions . . .

> The revised dpi_pipe_c_send() would then look something
> like this:
> 
> void dpi_pipe_c_send(
>      void *pipe_handle,         // input: pipe handle
>      int bytes_per_element,     // input: #bits/element
>      int num_elements,          // input: #elements to be written
>      const svBitVecVal *data,   // input: data
>      svBit eom )                // input: end-of-message marker flag
> {
>      int byte_offset = 0, elements_sent;
> 
>      while( num_elements ){
>          elements_sent =
>              dpi_pipe_c_try_send(
>                  pipe_handle, byte_offset,
>                  bytes_per_element, num_elements, data, eom )
>              * bytes_per_element;

Don't you have to be careful with the eom flag here?  In my
example I put some code in that ensured eom would not be set
except for the last transfer.  Oh, I guess dpi_pipe_c_try_send()
now takes care of this, right?  It knows whether to apply eom
or not based on knowing whether it transferred all of the
remaining part of the message or not.

I like your proposed modifications to dpi_pipe_c_try_send().
They make it much easier for the user of this call.

Per
Received on Thu Mar 30 21:28:49 2006

This archive was generated by hypermail 2.1.8 : Thu Mar 30 2006 - 21:28:57 PST