From 9b9cd452affa2b0f632435b975ab8851589a8ba4 Mon Sep 17 00:00:00 2001 From: Mauro Werder Date: Wed, 27 Nov 2019 15:26:53 +0100 Subject: [PATCH] Make the at-threads a no-op if nthreads()==0 --- base/threadingconstructs.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/threadingconstructs.jl b/base/threadingconstructs.jl index 1d88c882a0688..baf8ab394e142 100644 --- a/base/threadingconstructs.jl +++ b/base/threadingconstructs.jl @@ -19,6 +19,8 @@ on `threadid()`. nthreads() = Int(unsafe_load(cglobal(:jl_n_threads, Cint))) function _threadsfor(iter,lbody) + nthreads()==1 && return esc(Expr(:for, iter, lbody)) # do nothing if there are not threads + lidx = iter.args[1] # index range = iter.args[2] quote