Skip to main content
added 191 characters in body
Source Link
Szabolcs
  • 238.9k
  • 32
  • 653
  • 1.3k

Warning: The SetSystemOptions method to detect failed compilation, described below, is not 100% reliable. Please see the comments (e.g. trC = Compile[{{a, _Integer, 2}}, Tr[a]] won't warn).


I assume you need the list of compilable functions to make sure that all of your code will be properly compiled, and it won't take any speed penalties (that why I was looking for this information before). People have shown you how to print the compiled code and check that there are no calls to MainEvaluate in it. There is an alternative and simpler way of working:

SetSystemOptions["CompileOptions" -> "CompileReportExternal" -> True] 

After setting this, Compile will warn about uncompilable things:

In[4]:= cf1 = Compile[{x}, Total[x]] During evaluation of In[4]:= Compile::extscalar: Total[x] cannot be compiled and will be evaluated externally. The result is assumed to be of type Real. >> Out[4]= CompiledFunction[{x},Total[x],-CompiledCode-] In[5]:= cf2 = Compile[{{x,_Integer,1}}, Total[x]] Out[5]= CompiledFunction[{x},Total[x],-CompiledCode-] 

This is better than just thinking about which function is compilable and which isn't because as you can see, whether something can be compiled also depends on context (Total in this example.)


For completeness, let me show that CompilePrint[cf1] gives

 R0 = A1 Result = R1 1 R1 = MainEvaluate[ Hold[Total][ R0]] 2 Return 

while CompilePrint[cf2] gives

 T(I1)0 = A1 I0 = 4 Result = I1 1 I1 = TotalAll[ T(I1)0, I0]] 2 Return 

I assume you need the list of compilable functions to make sure that all of your code will be properly compiled, and it won't take any speed penalties (that why I was looking for this information before). People have shown you how to print the compiled code and check that there are no calls to MainEvaluate in it. There is an alternative and simpler way of working:

SetSystemOptions["CompileOptions" -> "CompileReportExternal" -> True] 

After setting this, Compile will warn about uncompilable things:

In[4]:= cf1 = Compile[{x}, Total[x]] During evaluation of In[4]:= Compile::extscalar: Total[x] cannot be compiled and will be evaluated externally. The result is assumed to be of type Real. >> Out[4]= CompiledFunction[{x},Total[x],-CompiledCode-] In[5]:= cf2 = Compile[{{x,_Integer,1}}, Total[x]] Out[5]= CompiledFunction[{x},Total[x],-CompiledCode-] 

This is better than just thinking about which function is compilable and which isn't because as you can see, whether something can be compiled also depends on context (Total in this example.)


For completeness, let me show that CompilePrint[cf1] gives

 R0 = A1 Result = R1 1 R1 = MainEvaluate[ Hold[Total][ R0]] 2 Return 

while CompilePrint[cf2] gives

 T(I1)0 = A1 I0 = 4 Result = I1 1 I1 = TotalAll[ T(I1)0, I0]] 2 Return 

Warning: The SetSystemOptions method to detect failed compilation, described below, is not 100% reliable. Please see the comments (e.g. trC = Compile[{{a, _Integer, 2}}, Tr[a]] won't warn).


I assume you need the list of compilable functions to make sure that all of your code will be properly compiled, and it won't take any speed penalties (that why I was looking for this information before). People have shown you how to print the compiled code and check that there are no calls to MainEvaluate in it. There is an alternative and simpler way of working:

SetSystemOptions["CompileOptions" -> "CompileReportExternal" -> True] 

After setting this, Compile will warn about uncompilable things:

In[4]:= cf1 = Compile[{x}, Total[x]] During evaluation of In[4]:= Compile::extscalar: Total[x] cannot be compiled and will be evaluated externally. The result is assumed to be of type Real. >> Out[4]= CompiledFunction[{x},Total[x],-CompiledCode-] In[5]:= cf2 = Compile[{{x,_Integer,1}}, Total[x]] Out[5]= CompiledFunction[{x},Total[x],-CompiledCode-] 

This is better than just thinking about which function is compilable and which isn't because as you can see, whether something can be compiled also depends on context (Total in this example.)


For completeness, let me show that CompilePrint[cf1] gives

 R0 = A1 Result = R1 1 R1 = MainEvaluate[ Hold[Total][ R0]] 2 Return 

while CompilePrint[cf2] gives

 T(I1)0 = A1 I0 = 4 Result = I1 1 I1 = TotalAll[ T(I1)0, I0]] 2 Return 
added 37 characters in body
Source Link
Szabolcs
  • 238.9k
  • 32
  • 653
  • 1.3k

I assume you need the list of compilable functions to make sure that everythingall of your code will be properly compiled in your function, and it won't take any speed penalties (that why I was looking for this information before). People have shown you how to print the compiled code and check that there are no calls to MainEvaluate in it. There is an alternative and simpler way of working:

SetSystemOptions["CompileOptions" -> "CompileReportExternal" -> True] 

After setting this, Compile will warn about uncompilable things:

In[4]:= cf1 = Compile[{x}, Total[x]] During evaluation of In[4]:= Compile::extscalar: Total[x] cannot be compiled and will be evaluated externally. The result is assumed to be of type Real. >> Out[4]= CompiledFunction[{x},Total[x],-CompiledCode-] In[5]:= cf2 = Compile[{{x,_Integer,1}}, Total[x]] Out[5]= CompiledFunction[{x},Total[x],-CompiledCode-] 

This is better than just thinking about which function is compilable and which isn't because as you can see, whether something can be compiled also depends on context (Total in this example.)


For completeness, let me show that CompilePrint[cf1] gives

 R0 = A1 Result = R1 1 R1 = MainEvaluate[ Hold[Total][ R0]] 2 Return 

while CompilePrint[cf2] gives

 T(I1)0 = A1 I0 = 4 Result = I1 1 I1 = TotalAll[ T(I1)0, I0]] 2 Return 

I assume you need the list of compilable functions to make sure that everything will be compiled in your function (that why I was looking for this information before). People have shown you how to print the compiled code and check that there are no calls to MainEvaluate in it. There is an alternative and simpler way of working:

SetSystemOptions["CompileOptions" -> "CompileReportExternal" -> True] 

After setting this, Compile will warn about uncompilable things:

In[4]:= cf1 = Compile[{x}, Total[x]] During evaluation of In[4]:= Compile::extscalar: Total[x] cannot be compiled and will be evaluated externally. The result is assumed to be of type Real. >> Out[4]= CompiledFunction[{x},Total[x],-CompiledCode-] In[5]:= cf2 = Compile[{{x,_Integer,1}}, Total[x]] Out[5]= CompiledFunction[{x},Total[x],-CompiledCode-] 

This is better than just thinking about which function is compilable and which isn't because as you can see, whether something can be compiled also depends on context (Total in this example.)


For completeness, let me show that CompilePrint[cf1] gives

 R0 = A1 Result = R1 1 R1 = MainEvaluate[ Hold[Total][ R0]] 2 Return 

while CompilePrint[cf2] gives

 T(I1)0 = A1 I0 = 4 Result = I1 1 I1 = TotalAll[ T(I1)0, I0]] 2 Return 

I assume you need the list of compilable functions to make sure that all of your code will be properly compiled, and it won't take any speed penalties (that why I was looking for this information before). People have shown you how to print the compiled code and check that there are no calls to MainEvaluate in it. There is an alternative and simpler way of working:

SetSystemOptions["CompileOptions" -> "CompileReportExternal" -> True] 

After setting this, Compile will warn about uncompilable things:

In[4]:= cf1 = Compile[{x}, Total[x]] During evaluation of In[4]:= Compile::extscalar: Total[x] cannot be compiled and will be evaluated externally. The result is assumed to be of type Real. >> Out[4]= CompiledFunction[{x},Total[x],-CompiledCode-] In[5]:= cf2 = Compile[{{x,_Integer,1}}, Total[x]] Out[5]= CompiledFunction[{x},Total[x],-CompiledCode-] 

This is better than just thinking about which function is compilable and which isn't because as you can see, whether something can be compiled also depends on context (Total in this example.)


For completeness, let me show that CompilePrint[cf1] gives

 R0 = A1 Result = R1 1 R1 = MainEvaluate[ Hold[Total][ R0]] 2 Return 

while CompilePrint[cf2] gives

 T(I1)0 = A1 I0 = 4 Result = I1 1 I1 = TotalAll[ T(I1)0, I0]] 2 Return 
deleted 2 characters in body
Source Link
Szabolcs
  • 238.9k
  • 32
  • 653
  • 1.3k

I assume you need the list of compilable functions to make sure that everything will be compiled in your function (that why I was looking for this information before). People have shown you how to print the compiled code and check that there are no calls to MainEvaluate in it.

There There is an alternative and simpler way of working:

SetSystemOptions["CompileOptions" -> "CompileReportExternal" -> True] 

After setting this, Compile will warn about uncompilable things:

In[4]:= cf1 = Compile[{x}, Total[x]] During evaluation of In[4]:= Compile::extscalar: Total[x] cannot be compiled and will be evaluated externally. The result is assumed to be of type Real. >> Out[4]= CompiledFunction[{x},Total[x],-CompiledCode-] In[5]:= cf2 = Compile[{{x,_Integer,1}}, Total[x]] Out[5]= CompiledFunction[{x},Total[x],-CompiledCode-] 

This is better than just thinking about which function is compilable and which isn't because as you can see, whether something can be compiled also depends on context (Total in this example.)


For completeness, let me show that CompilePrint[cf1] gives

 R0 = A1 Result = R1 1 R1 = MainEvaluate[ Hold[Total][ R0]] 2 Return 

while CompilePrint[cf2] gives

 T(I1)0 = A1 I0 = 4 Result = I1 1 I1 = TotalAll[ T(I1)0, I0]] 2 Return 

I assume you need the list of compilable functions to make sure that everything will be compiled in your function (that why I was looking for this information before). People have shown you how to print the compiled code and check that there are no calls to MainEvaluate in it.

There is an alternative and simpler way of working:

SetSystemOptions["CompileOptions" -> "CompileReportExternal" -> True] 

After setting this, Compile will warn about uncompilable things:

In[4]:= cf1 = Compile[{x}, Total[x]] During evaluation of In[4]:= Compile::extscalar: Total[x] cannot be compiled and will be evaluated externally. The result is assumed to be of type Real. >> Out[4]= CompiledFunction[{x},Total[x],-CompiledCode-] In[5]:= cf2 = Compile[{{x,_Integer,1}}, Total[x]] Out[5]= CompiledFunction[{x},Total[x],-CompiledCode-] 

This is better than just thinking about which function is compilable and which isn't because as you can see, whether something can be compiled also depends on context (Total in this example.)


For completeness, let me show that CompilePrint[cf1] gives

 R0 = A1 Result = R1 1 R1 = MainEvaluate[ Hold[Total][ R0]] 2 Return 

while CompilePrint[cf2] gives

 T(I1)0 = A1 I0 = 4 Result = I1 1 I1 = TotalAll[ T(I1)0, I0]] 2 Return 

I assume you need the list of compilable functions to make sure that everything will be compiled in your function (that why I was looking for this information before). People have shown you how to print the compiled code and check that there are no calls to MainEvaluate in it. There is an alternative and simpler way of working:

SetSystemOptions["CompileOptions" -> "CompileReportExternal" -> True] 

After setting this, Compile will warn about uncompilable things:

In[4]:= cf1 = Compile[{x}, Total[x]] During evaluation of In[4]:= Compile::extscalar: Total[x] cannot be compiled and will be evaluated externally. The result is assumed to be of type Real. >> Out[4]= CompiledFunction[{x},Total[x],-CompiledCode-] In[5]:= cf2 = Compile[{{x,_Integer,1}}, Total[x]] Out[5]= CompiledFunction[{x},Total[x],-CompiledCode-] 

This is better than just thinking about which function is compilable and which isn't because as you can see, whether something can be compiled also depends on context (Total in this example.)


For completeness, let me show that CompilePrint[cf1] gives

 R0 = A1 Result = R1 1 R1 = MainEvaluate[ Hold[Total][ R0]] 2 Return 

while CompilePrint[cf2] gives

 T(I1)0 = A1 I0 = 4 Result = I1 1 I1 = TotalAll[ T(I1)0, I0]] 2 Return 
Source Link
Szabolcs
  • 238.9k
  • 32
  • 653
  • 1.3k
Loading