7
$\begingroup$

On the same Windows 11 machine with the same C compiler (Visual Studio 2022):

$Version
(* "13.3.1 for Microsoft Windows (64-bit) (July 24, 2023)" *)

c = Compile[{{x, _Real}, {n, _Integer}},
  Module[{sum, inc}, sum = 1.0; inc = 1.0;
  Do[inc = inc*x/i; sum = sum + inc, {i, n}]; sum], 
  CompilationTarget -> "C"]; 

c[1.5, 10^9] // AbsoluteTiming
(* {0.691227, 4.48169} *)

cNormal = Compile[{{x, _Real}, {n, _Integer}},
  Module[{sum, inc}, sum = 1.0; inc = 1.0; 
  Do[inc = inc*x/i; sum = sum + inc, {i, n}]; sum]]; 

cNormal[1.5, 10^9] // AbsoluteTiming
(* {14.8374, 4.48169} *)

But with the new version 14.1:

$Version
(* "14.1.0 for Microsoft Windows (64-bit) (July 16, 2024)" *)

c = Compile[{{x, _Real}, {n, _Integer}},
  Module[{sum, inc}, sum = 1.0; inc = 1.0;
  Do[inc = inc*x/i; sum = sum + inc, {i, n}]; sum], 
  CompilationTarget -> "C"]; 

c[1.5, 10^9] // AbsoluteTiming
(* {56.2374, 4.48169} *)

cNormal = Compile[{{x, _Real}, {n, _Integer}},
  Module[{sum, inc}, sum = 1.0; inc = 1.0; 
  Do[inc = inc*x/i; sum = sum + inc, {i, n}]; sum]];

cNormal[1.5, 10^9] // AbsoluteTiming
(* {25.5739, 4.48169} *)

Did anyone else notice similar behavior with the 14.1 compiler in their installation?

$\endgroup$
3
  • 1
    $\begingroup$ Same on Mac ARM. $\endgroup$
    – Michael E2
    Commented Aug 5 at 1:07
  • 4
    $\begingroup$ 14.0 is the same, I guess the default setting for the new version is RuntimeOptions -> {"CatchMachineOverflow" -> True} $\endgroup$
    – chyanog
    Commented Aug 5 at 1:55
  • $\begingroup$ @chyanog Thanks for the tip; adding RuntimeOptions -> {"CatchMachineOverflow" -> False} seems to be a workaround. I am not sure if this should be reported to Wolfram as a bug or inadequate documentation? $\endgroup$
    – ulvi
    Commented Aug 5 at 23:56

0

Your Answer

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

Browse other questions tagged or ask your own question.