MPI sending an array of 128bits integer <p>I have a struct like: </p> <pre><code>union W128_T { uint32_t u[4]; uint64_t u64[2]; }; struct SFMT_T { /** the 128-bit internal state array */ w128_t state[SFMT_N]; /** index counter to the 32-bit internal state array */ int idx; }; </code></pre> <p>It is an implementation for pseudo-random generator, mersenne twister. I want to send an SFM_T element to all workers. I have two options. </p> <ol> <li>Using MPI_Derived type: I create an MPI_Derived type for state array, using an MPI_Type for 128 bits. I searched and i found this page for MPI_Type: <a href="http://www-01.ibm.com/support/knowledgecenter/SSFK3V_1.3.0/com.ibm.cluster.pe.v1r3.pe400.doc/am106_pmd.htm?lang=en" rel="nofollow">IBM Knowledge Center-MPI Data Types</a>. There are types for 128 floating points. Can i use it for my data type.</li> <li><p>Using a char array to store state array: I plan to create a char array of size <code>[SFMT_N * 16 + 2]</code> because 128bit variable is equal to 16 chars and <code>+2</code> indicates the <code>idx</code> variable. I am not sure how to change state array into a character array. I wrote some code for this serialization: </p> <pre><code>typedef struct SFMT_T sfmt_t; char * serialize(sfmt_t* sfmt) { char buffer[SFMT_N*16+sizeof(int16_t)]; int16_t tmp_size = 0 ; int8_t offset = 0; int i=0,j; tmp_size =(4*sizeof(uint32_t)); for(i=0;i&lt;SFMT_N;i++) { memcpy(buffer+offset,&amp;sfmt-&gt;state[i].u, tmp_size); for(j=offset;j&lt;offset+tmp_size;j++) { printf("buffer %c \n",buffer[j]); } offset += tmp_size; } memcpy(buffer+offset,&amp;sfmt-&gt;idx,sizeof(uint16_t)); return buffer;} void deserialize(char* buffer, sfmt_t* sfmt) { int16_t tmp_size,start,i ; for(i=0;i&lt;SFMT_N;i++) { start = sizeof(uint32_t)*4*i; tmp_size =(4*sizeof(uint32_t)); memcpy(sfmt-&gt;state[i].u,&amp;buffer[start], tmp_size);} for(i=0;i&lt;SFMT_N;i++) { printf("%d %d %d %d \n",sfmt-&gt;state[i].u[0],sfmt-&gt;state[i].u[1],sfmt-&gt;state[i].u[2],sfmt-&gt;state[i].u[3]); } } </code></pre> <p>It doesn't give exactly what i want. What am i missing? </p></li> </ol> <p>Also, i want to know which way can be more efficient for a distributed system. </p>