Strange behavior from Compile[ ]

*To*: mathgroup at yoda.physics.unc.edu*Subject*: Strange behavior from Compile[ ]*From*: barry at math.ucla.edu (Barry Merriman)*Date*: Tue, 27 Aug 91 15:46:32 PDT

I'm trying to benchmark the speed of Mma 2.0 on Compile-ed calculations. I've come across some strange "feature" in the Mma compiler. Essentially, it compiles a Do loop of < 50,000 loops fine, but can't compile it when it goes to > 50,000 loops. Very odd, since 50,000 is not a particularly big integer, and so shouldn't bother the compiler. Here what I do: (Mma 2.0 on NeXTstation) In[30]:= (* compiled benchmark of 40,000 multiplies *) benchmark40 = Compile[ {x0,y0}, Module[{x = x0,y = y0}, Do[ y *= x, {40000} ]; y ] ] Out[30] := (* OK *) CompiledFunction[{x0, y0}, Module[{x = x0, y = y0}, Do[y *= x, {40000}]; y], -CompiledCode-] In[31]:= (* Time our 40,000 benchmark *) Timing @ benchmark40[1.0001, 1.0] Out[31]:= (* not bad---0.03 MFLOPS on a 3.0 MFLOP machine *) {1.51667 Second, 54.5872} In[32]:= (* try a 50,000 multiply becnhmark *) benchmark50 = Compile[ {x0,y0}, Module[{x = x0,y = y0}, Do[ y *= x, {50000} ]; y ] ] Out[32]:= CompiledFunction[{x0, y0}, Module[{x = x0, y = y0}, Do[y *= x, {50000}]; y], -CompiledCode-] In[33]:= (* Time the 50,000 benchmark *) Timing @ benchmark50[1.0001, 1.0] CompiledFunction::cfn: (* Trouble !!! *) Numerical error encountered at instruction 23 ; proceeding with uncompiled evaluation. Out[33]:= (* lost big on time! slowed down by factor of 60, "as usual" *) {34.1 Second, 148.376}