Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As mentioned in the comments, the original error described in the title is not thrust related, but due to use of <code>struct data</code>, when <code>data</code> is already typedef'ed.</p> <p>In response to the additional question posed in the comments, I merely was trying to state that I had not fully thought about the ramifications of using <code>thrust::device_vector&lt;&gt;</code> inside a struct. When I said maybe consider using <code>thrust::device_ptr&lt;&gt;</code> instead, I had in mind something like this, which seems to work for me:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;thrust/host_vector.h&gt; #include &lt;thrust/device_vector.h&gt; #include &lt;thrust/device_ptr.h&gt; #include &lt;thrust/sequence.h&gt; #include &lt;thrust/transform.h&gt; #include &lt;thrust/functional.h&gt; #define N 10 typedef struct { thrust::device_ptr&lt;float&gt; dp1; thrust::device_ptr&lt;float&gt; dp2; int i; } data; int main(){ thrust::negate&lt;int&gt; op; data *mydata = (data *)malloc(sizeof(data)); thrust::host_vector&lt;float&gt; h1(N); thrust::sequence(h1.begin(), h1.end()); thrust::device_vector&lt;float&gt; d1=h1; mydata-&gt;dp1=d1.data(); mydata-&gt;dp1[0]=mydata-&gt;dp1[N-1]; thrust::transform(mydata-&gt;dp1, mydata-&gt;dp1 + N, mydata-&gt;dp1, op); // in-place transformation thrust::copy(d1.begin(), d1.end(), h1.begin()); for (int i=0; i&lt;N; i++) printf("h1[%d] = %f\n", i, h1[i]); return 0; } </code></pre> <p>Having said that, the original method of using <code>device_vector</code> inside a struct may work, I just don't know and have not explored it.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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