MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Compiling in Mathematica 8

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115020] Re: Compiling in Mathematica 8
  • From: DmitryG <einschlag at gmail.com>
  • Date: Tue, 28 Dec 2010 06:52:14 -0500 (EST)
  • References: <if1o60$p7u$1@smc.vnet.net>

On 24 Dez., 04:12, DmitryG <einsch... at gmail.com> wrote:
> I was pleasantly surprised by new features of Mathematica 8,
> especially by the possibility to compile pieces of code that solve the
> speed issue that remained painful in previous versions of Mathematica.
> Now one can write efficient Monte Carlo or fractal routines in
> Mathematica. Compilation can be done into Mathematica's native code
> with speed increase by a factor of 50-100 or into a C code with a much
> larger speed gain, if a C compiler is installed on your computer.
>
> I have two practical questions.
>
> 1. What C compiler can be recommended for me as non-C-programmer to
> install under Windows XP SP2? In the past I was using Microsoft C
> compiler that, as my friends said, was much faster than the others.
> Now, the current version of Microsoft C compiler requires SP3 to be
> installed that I don't want.  Also what kind of C compiler would do, C
> or C++?
>
> 2. What about compiling of Mathematica's own routines such as NDSolve?
> I believe constructions such as Compile[{arguments}, NDSolve[...]]
> won't work. I have read in the help that NDSolve etc. decide
> automatically if compilation has to be done. There are also options
> such as Compile->True, and I have read that one can add //
> Developer`PackedArrayQ at the end and if the output is True, the
> command is compiled. I have tried this with NDSolve with both Compile->Tr=
ue and Compile->False inside and in all cases the output was False.
>
> So I suspect NDSolve is never compiled. This is a pity because I am
> using NDSolve a lot and it works much slower than similar routines
> written in C or Fortran.
>
> I would greatly appreciate advice from Wolfam stuff and members of
> this group.
>
> Happy holidays for all,
>
> Dmitry

I have made speed measurements on NDSolve and found that NDSolve with
the option Compile->False works by a factor about 3 slower than
NDSolve with Compile->True or without this option at all. The effect
of compilation is thus detectable but it is much smaller than the
effect of compilation of user codes such as Do loops that speeds up
the calculation by a factor about 50, if the default compilation into
Mathematica's own code is used.

Why compilation of NDSolve is so inefficient? Can NDSolve be compiled
into C?

Dmitry


  • Prev by Date: Re: newbie list question
  • Next by Date: Re: Mathematica daily WTF
  • Previous by thread: Compiling in Mathematica 8
  • Next by thread: Re: Compiling in Mathematica 8