0
$\begingroup$

I have a Windows machine with installed Mathematica. I compile the code in C. The compiler I use is CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler from Visual Studio Express. Does anyone know whether there may be a difference between the runtime of the code depending on the compiler?

The reason I am asking is that the same code on Mac is evaluated ~3 times faster. This may be due to the difference in OS and CPU, but who knows.

The code deals with some table, computes the values of some functions using the elements of the table (multiplication, etc.), and makes other similar actions.

$\endgroup$
8
  • 1
    $\begingroup$ Such a large difference is due to hardware differences, not the compiler, and definitely not the OS. Apple's arm-based processors are very fast. $\endgroup$
    – Szabolcs
    Commented May 23, 2023 at 8:40
  • $\begingroup$ @Szabolcs : indeed, there definitely may be such a component. However, what is interesting is whether there may be some differences in Windows due to different compilers. $\endgroup$ Commented May 23, 2023 at 8:43
  • 1
    $\begingroup$ It depends quite heavily on the tasks. For example some compilers are better at vectorizing code as others. And things like this apply to many other compiler optimizations as well. But as Szabolcs said, a 3x difference only due to the compiler would be really, really unexpected. If that happened on the same hardware, then I'd would rather check whether all optimizations flags were correctly set and whether debugging mode is turned off. In different hardware I'd tend to blame it on the hardware. $\endgroup$ Commented May 23, 2023 at 10:48
  • 1
    $\begingroup$ Unfortunately, the WolframMark is not really representative. It was developped for much older CPUs and I think it is not suited for differentiating between recent processor (e.g., because many of the tests are so "tiny" that one has a substantial portion of overhead in the measrued runtimes). $\endgroup$ Commented May 23, 2023 at 10:54
  • 1
    $\begingroup$ Moreover, it could be that the Windows machine seems to perform better in these benchmarks because Mathematica on Windows uses the Intel MKL which is heavily optimized for Intel machine. On the mac side, parts of this are covered by Apple's Accelerate framework, but not all of them. And I am not sure to which extent Mathematica on a mac makes use of Accelerate. So the M1 might not shine as bright as it could in these benchmarks. $\endgroup$ Commented May 23, 2023 at 10:59

0

Your Answer

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