Note that there are some explanatory texts on larger screens.

plurals
  1. POpack bytes array with strange alignment requirements
    primarykey
    data
    text
    <p>Suppose you have 32 threads and 32 pieces of data for each thread to operate on independently, e.g.</p> <pre><code>struct data { unsigned short int N; char *features; //array length N uint *values; //array length N }; data alldata[32]; </code></pre> <p>Suppose that the shared memory for these threads is "partitioned" into 32 "banks", where each bank is 4 bytes wide. <strong>Each thread can read from its corresponding "bank" in parallel, but if threads try to access the same bank simlutaneously, the read operation serializes.</strong></p> <pre><code>bank | 0 | 1 | 2 | ..... bytes | 0 1 2 3 | 4 5 6 7 | 8 9 10 11 | .... bytes | 128 129 130 131 | 132 133 134 135 | 136 137 138 139 | ... ............... ............... threads | 0 | 1 | 2 | ..... </code></pre> <p>(This bizarre situation is called GPU computing).</p> <p>Thus, for maximum parallelization: (in terms of the picture above) the member variables of alldata[0] must only be written to the bytes in the first column. The member of variables of alldata[1] to the second column, etc. Equivalently,</p> <p>In other words, I must write the contents of <code>alldata[32]</code> into one dynamic array, where the member variables of <code>alldata[j]</code> are written in 4-byte intervals once every <code>32*4</code> bytes. Then, when I copy this dynamic array into the shared memory for the threads, it will be properly aligned for the banks.</p> <p><strong>Question:</strong> Does anybody know of any kind of package that will write variables to a byte array with proper spacing, as discussed above (once every <code>32*4</code> bytes) ?</p> <p>This is a desperation question...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload