def nonthreadsafe(fn):
 @wraps(fn)
 def core(*args, **kwargs):
  with _cuda_compiler_lock:
   return fn(*args, **kwargs)
 return core

def nonthreadsafe ( fn ) : @ wraps ( fn ) def core ( * args , ** kwargs ) : with _cuda_compiler_lock : return fn ( * args , ** kwargs ) return core
wraps a function to prevent multiple threads from executing it in parallel due to llvm is not threadsafe .