G2A Many GEOs
SHARE
TWEET

Untitled

a guest Apr 6th, 2020 201 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cuda.h>
  2. #include <stdio.h>
  3.  
  4. #define N 10
  5.  
  6. __global__ void kernel(int *result) { return; }
  7.  
  8. int main() {
  9.   int **result;
  10.   cudaMallocManaged(&result, N * sizeof(int*));
  11.   for(int i = 0; i < N; i++) cudaMallocManaged(&result[i], sizeof(int));
  12.  
  13.   cudaDeviceSynchronize();
  14.   printf("okay\n");
  15.  
  16.   for(int i = 0; i < N; i++) {
  17.     kernel<<<1, 1>>>(result[i]);
  18.     // cudaDeviceSynchronize();  // decomment me, and evertying works
  19.   }
  20.  
  21.   cudaDeviceSynchronize();
  22.   printf("perfect\n");
  23.  
  24.   return 0;
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top