I'm running Mathematica on a machine wtih 48 cores and 96 threads. I want to limit the number of threads the computation can have access to. If I give LaunchKernels[1] it correctly launches a single kernel, but then the computation is distributed over many more threads (48, which I guess is some default value or the max license number). Is there a way to limit the number of threads?

Thanks, Paolo

It seems I misunderstood the kind of threading you were addressing when writing my original reply (below). For internally multithreaded functions launched from a single kernel I you can limit the cores used with this setting:

(* e.g. two cores *)

SetSystemOptions[

• @Paolo I see now. I think you need to set the "ParallelThreadNumber" and "MKLThreadNumber" in SystemOptions["ParallelOptions"] to limit that kind of multi-threading, but I don't think you can specify that per computation other than to change the setting and then change it back. I shall admit I haven't tried to do this myself as I only have four cores to work with. Jun 13 '20 at 6:39