I know it&#39;s not that important--and clearly not relevant--but BG/P will generate a compiler warning if I use an MPI_Aint cast there.  We want to avoid any ambiguity that such a cast would involve (i.e. is it sign extended?), so I use a cast that works correctly for this sort of micro-tests.  It is also correct on PPC32.  This small example shows the warnings:<div>
<br></div><div><div>$ cat -n size.c</div><div>     1  #include &lt;mpi.h&gt;</div><div>     2</div><div>     3  extern void bar(MPI_Aint a, MPI_Aint b, MPI_Aint c);</div><div>     4</div><div>     5  void foo(void* p)</div>
<div>     6  {</div><div><b>     7    MPI_Aint aint = (MPI_Aint)p;</b></div><div>     8</div><div><b>     9    MPI_Aint one = (long long int)p;</b></div><div>    10    MPI_Aint two = (int)p;</div><div>    11</div><div>    12    bar(aint, one, two);</div>
<div>    13  }</div><div><br></div><div>$ /bgsys/drivers/ppcfloor/comm/bin/mpicc -Wall -g -c size.csize.c: In function &#39;foo&#39;:</div><div>size.c:7: warning: cast from pointer to integer of different size</div><div>size.c:9: warning: cast from pointer to integer of different size</div>
<div><br></div><div><br></div>Thanks,<br><div><div>Joe Ratterman</div><div><a href="mailto:jratt@us.ibm.com">jratt@us.ibm.com</a></div></div><div><br><div class="gmail_quote">On Tue, Jun 9, 2009 at 3:50 PM, Rob Ross <span dir="ltr">&lt;<a href="mailto:rross@mcs.anl.gov" target="_blank">rross@mcs.anl.gov</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
Those type casts to (size_t) should be to (MPI_Aint).<br>
<br>
That assertion is checking that a parameter being passed to Segment_mpi_flatten is &gt; 0. The parameter is the length of the list of regions being passed in by reference to be filled in (the destination of the list of regions). So for some reason we&#39;re getting a zero (or possibly negative) value passed in as the length of the arrays.<br>


<br>
There&#39;s only one place in the struct creation where Segment_mpi_flatten() is called; it&#39;s line 666 (evil!) of dataloop_create_struct.c. This is in DLOOP_Dataloop_create_flattened_struct(), which is a function used to make a struct into an indexed type.<br>


<br>
The &quot;pairtypes&quot;, such as MPI_SHORT_INT, are special cases in MPI in that some of them have more than one &quot;element type&quot; (e.g. MPI_INT, MPI_SHORT_INT) in them. My guess is that there&#39;s an assumption in the DLOOP_Dataloop_create_flattened_struct() code path that is having trouble with the pairtype.<br>


<br>
I&#39;m surprised that we might have introduced something between 1.0.7 and 1.1; I can&#39;t recall anything in particular that has changed in this code path. Someone should check the repo logs and see if something snuck in?<br>

<font color="#888888">
<br>
Rob</font><div><div></div><div><br>
<br>
On Jun 9, 2009, at 3:13 PM, Joe Ratterman wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The specifics of this test come from an MPI excerciser that gathered (using MPIR_Gather) a variety of types, including MPI_SHORT_INT.  The way that gather is implemented, it created and then sent a struct datatype of the tmp-data from the software tree and the local-data.  I pulled out the important bits, and got this test-case.  It asserts on PPC32 Linux 1.1 and BGP 1.1rc0, but runs fine on 1.0.7.  The addresses/displacements are fake, but were originally based on the actual values used inside MPIR_Gather.  It does the type-create on the first two types just to show that it doesn&#39;t always fail.<br>


<br>
<br>
Error message:<br>
<br>
Creating  addr=[0x1,0x2]  types=[8c000003,4c00010d]  struct_displs=[1,2]  blocks=[256,256]  MPI_BOTTOM=(nil)<br>
foo:25<br>
Assertion failed in file segment_ops.c at line 994: *lengthp &gt; 0<br>
internal ABORT - process 0<br>
<br>
<br>
Code<br>
<br>
#include &lt;stdio.h&gt;<br>
#include &lt;stdlib.h&gt;<br>
#include &lt;unistd.h&gt;<br>
#include &lt;mpi.h&gt;<br>
<br>
void foo(void *sendbuf,<br>
         MPI_Datatype sendtype,<br>
         void *recvbuf,<br>
         MPI_Datatype recvtype)<br>
{<br>
  int blocks[2];<br>
  MPI_Aint struct_displs[2];<br>
  MPI_Datatype types[2], tmp_type;<br>
<br>
  blocks[0] = 256;<br>
  struct_displs[0] = (size_t)sendbuf;<br>
  types[0] = sendtype;<br>
  blocks[1] = 256;<br>
  struct_displs[1] = (size_t)recvbuf;<br>
  types[1] = MPI_BYTE;<br>
<br>
  printf(&quot;Creating  addr=[%p,%p]  types=[%x,%x]  struct_displs=[%x,%x]  blocks=[%d,%d]  MPI_BOTTOM=%p\n&quot;,<br>
         sendbuf, recvbuf, types[0], types[1], struct_displs[0], struct_displs[1], blocks[0], blocks[1], MPI_BOTTOM);<br>
  MPI_Type_create_struct(2, blocks, struct_displs, types, &amp;tmp_type);<br>
  printf(&quot;%s:%d\n&quot;, __func__, __LINE__);<br>
  MPI_Type_commit(&amp;tmp_type);<br>
  printf(&quot;%s:%d\n&quot;, __func__, __LINE__);<br>
  MPI_Type_free  (&amp;tmp_type);<br>
  puts(&quot;Done&quot;);<br>
}<br>
<br>
<br>
int main()<br>
{<br>
  MPI_Init(NULL, NULL);<br>
<br>
  foo((void*)0x1,<br>
      MPI_FLOAT_INT,<br>
      (void*)0x2,<br>
      MPI_BYTE);<br>
  sleep(1);<br>
  foo((void*)0x1,<br>
      MPI_DOUBLE_INT,<br>
      (void*)0x2,<br>
      MPI_BYTE);<br>
  sleep(1);<br>
  foo((void*)0x1,<br>
      MPI_SHORT_INT,<br>
      (void*)0x2,<br>
      MPI_BYTE);<br>
<br>
  MPI_Finalize();<br>
  return 0;<br>
}<br>
<br>
<br>
<br>
I don&#39;t know anything about how this might be fixed, but we are looking into it as well.<br>
<br>
Thanks,<br>
Joe Ratterman<br>
<a href="mailto:jratt@us.ibm.com" target="_blank">jratt@us.ibm.com</a><br>
</blockquote>
<br>
</div></div></blockquote></div><br>
</div></div>