I made some code that I compiled. The snippet looks as follows:
compiledcode = With[{f1 = function1, f2 = function2, ...}, Hold@Compile[{...},Module[{...},...(*some code involving f1, f2*)...], CompilationTarget -> lang, RuntimeOptions -> "Speed", CompilationOptions -> {"InlineCompiledFunctions" -> True}, RuntimeAttributes ->{Listable}]/.DownValues@.../.OwnValues@...//ReleaseHold]
Here, function1
, function2
are some other compiled codes, lang
is any. I noticed that if making an alternative code, where I explicitly insert function1
, function2
inside compiledcode
each time when I need to call them instead of using externally, the code works faster (maybe 2 times or so).
Could you please tell me what can be the reason for this? Unfortunately, I was not able to find a minimal example reproducing the issue, but I think that this may be a kind of a generic issue.
function1
andfunction2
actually do (so if gets presented their code), then it can try to inline them and to perform all sorts of optimization. But that really depends onfunction1
andfunction2
actually do. So that is hard so say. $\endgroup$