SHARE
TWEET

Untitled

a guest May 11th, 2017 203 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cuda_runtime.h>
  2. #include <iostream>
  3.  
  4. __global__ void kernel() {
  5.   __shared__ volatile bool looped;
  6.   __shared__ volatile bool done;
  7.  
  8.   if (!threadIdx.x) {
  9.     looped = false;
  10.     done   = false;
  11.   }
  12.  
  13.   while (true) {
  14.     if ((threadIdx.x == 0) && looped)
  15.       done = true;
  16.  
  17.     if (done)
  18.       return;
  19.  
  20.     if (threadIdx.x == 0)
  21.       looped = true;
  22.   }
  23. }
  24.  
  25. int main() {
  26.   kernel<<<dim3(1), dim3(2)>>>();
  27. }
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