how to use thrust with unified memory? #1046
Unanswered
ztdepztdep
asked this question in
Thrust
Replies: 0 comments 4 replies
-
|
Hello, @ztdepztdep! There's thrust universal vector that represents unified (managed) memory: #include <thrust/universal_vector.h>
__global__ void kernel(int *data) {
printf("%d\n", data[threadIdx.x]);
}
int main() {
thrust::universal_vector<int> in(4);
in[0] = 0;
in[1] = 1;
in[2] = 2;
in[3] = 3;
kernel<<<1, 4>>>(thrust::raw_pointer_cast(in.data()));
cudaDeviceSynchronize();
} |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
Thrust algorithms will also work with unified memory that's allocated manually. Just pass the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Does thrust support the unified memory?
Beta Was this translation helpful? Give feedback.
All reactions