2
$\begingroup$

I need to Compile functions for use on parallel kernels. There are many such functions, so compiling in parallel is desirable. When compiling functions with CompilationTarget -> "C", the compilation fails with multiple errors related to CLangFormat.

Is there a way to compile these functions without fancy formatting, so that - presumably - the compilation would succeed?

$\endgroup$

1 Answer 1

3
$\begingroup$

It seems that SymbolicC`Utilities`ClangFormatString is not designed for parallel operation. It uses a hardcoded path that's same on all kernels. Thus, when invoked in parallel, it steps on its own toes.

This is true at least up to Mathematica 14.0.0.

A workaround is to disable fancy formatting on parallel kernels. The code is not for human consumption, so it is unnecessary anyway:

ParallelEvaluate[
  (* Parallel compilation fails if default code indentation is performed. *)
  (* SymbolicC`Utilities`ClangFormatString is not designed for parallel operation *)
  Needs["SymbolicC`"];
  SetOptions[SymbolicC`ToCCodeString, Indent -> None]
];
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.