@contextlib.contextmanager
def captured_cuda_stdout():
 sys.stdout.flush()
 if config.ENABLE_CUDASIM:
  with captured_stdout() as stream:
   (yield PythonTextCapture(stream))
 else:
  from numba import cuda
  fd = sys.__stdout__.fileno()
  with redirect_fd(fd) as stream:
   (yield CUDATextCapture(stream))
   cuda.synchronize()

@ contextlib . contextmanager def captured_cuda_stdout ( ) : sys . stdout . flush ( ) if config . ENABLE_CUDASIM : with captured_stdout ( ) as stream : ( yield PythonTextCapture ( stream ) ) else : from numba import cuda fd = sys . __stdout__ . fileno ( ) with redirect_fd ( fd ) as stream : ( yield CUDATextCapture ( stream ) ) cuda . synchronize ( )
return a minimal stream-like object capturing the text output of either cuda or the simulator .