# Tips for running Mathematica on Solaris

Mathematica from Wolfram Research is a high-end maths program that runs on various operating systems. Whereas the maths programs MATLAB, Maple and Mathematica are all available for Sun's Solaris on Sun's SPARC hardware, Mathematica is the only commercial maths program currently available on Solaris x86. However, due to their popularity, both Windows and Linux versions of Mathematica appear to undergo more testing, so sometimes issues arise on Solaris which are not met on other platforms, such as Windows or Linux. This document will highlight some of these, and give solutions where I am aware of them.## The necessary -noTrueTypeFont

Some versions of Solaris will need the`-noTrueTypeFont`

option to Mathematica, as described on the Wolfram Reserach web site
## Removing cache data

If Mathematica gets in a mess, crashes or otherwise mis-behaves, the
cache data it computes may be invalid. Try the option

`-cleanstart`

## Other useful command line options

It's worth trying any sensible looking command line options listed on Wolfram's web site, in the event of problems.## Mathematica 6.0.1 crashes on Solaris (SPARC)

If you find Mathematica crashing all the time, update the XSun patch. Solaris patch 119059-31 caused Mathematica to crash on my system. You will also need`-noTrueTypeFont`

. Once Mathematica has had a problem, always use `-cleanStart`

to.
## Mathematica 5.x using excessive CPU time on Solaris 10.

On some systems, computing something as simple as 1+1=2 on Mathematica 5.1 and 5.2 can result in Mathematica using loads of CPU time. The anwser is returned quickly, but the program just pegs the CPU. The following conditions are necessary for the bug to be exhibited:- Mathematica 5.1 or 5.2. The status of Mathematica 6.0 is unknown, as is 5.0, but 4.2 is unaffected.
- Solaris 10 (01/2005), Solaris 10 update 1 (01/2006), or Solaris 10 update 2 (06/2006). Solaris 9 is unaffected, as is Solaris 10 update 3 (11/2006) or later.
- The machine needs to be reasonably slow. A 450 MHz Ultra 60 or Ultra 80 will exhibit the problem, but a 1200 MHz Blade 2000 will not. (If a faster machine was heavily loaded, it might exhibit the problem.)
- The graphical front (notebook interface) of Mathematica must be used - the text-based interface is unaffected.

The problem was introduced following a change to Solaris in
the first release of Solaris 10 in January 2006.
Sun would say this was not a
Solaris bug, but an enhancement to Solaris. But the enhancement
broke binary backward compatibility, so it was submitted as a
bug ID 6404383 on 27^{th} March 2006.
A solution was found by Casper Dik
of Sun Microsystems
following my post to comp.unix.solaris under the title Mathematica problems on Solaris. I then posted
the solution to sci.math.symbolic and comp.unix.solaris under the new title SOLVED - Excessive Mathematica CPU usage on Solaris 10.
**Solution**

The best way to solve
this is to update to Solaris 10 update 3 or later.

Another method, which is detailed on sci.math.symobic and comp.unix.solaris is quicker to implement. This involves compiling a small C file select_preload.c to create a shared library, then ensuring Mathematica loads this before the main libraries. (Here is a copy of the compiled library select_preload.so if you would rather not compile it youself). Read the thread SOLVED - Excessive Mathematica CPU usage on Solaris 10 if you want to use this method, but upgrading the operating system is probably a good idea.

## Mathematica uses excessive CPU time on multi-processor machines

**Problem**

Another bug noticed on Mathematica 5.2 only appeared in some calculations and only when there were multiple CPUs present.

**Solution**

The solution to this is to either disable the extra CPUs with

`/usr/sbin/psradm`

, or set the environment variable
`OMP_NUM_THREADS`

to 1. Clearly setting an environment variable
that only affects Mathematica and not every application on the system is better,
so it is suggested you use```
$ OMP_NUM_THREADS=1
```

$ export OMP_NUM_THREADS

$ /usr/local/bin/mathematica

or if you use the csh or tcsh,```
% set env OMP_NUM_THREADS 1
```

% /usr/local/bin/mathematica

## Mathematica 6.0.1 or 6.0.2 has some characters unreadable

**Problem**

Mathematica has been known to generate tons of error messages to stderr, like the following

```
X Error: BadMatch (invalid parameter attributes) 8
Extension: 156 (RENDER)
Minor opcode: 4 (RenderCreatePicture)
Resource id: 0x3600003
X Error: RenderBadPicture (invalid Picture parameter) 182
Extension: 156 (RENDER)
Minor opcode: 7 (RenderFreePicture)
Resource id: 0x3600004
X Error: BadMatch (invalid parameter attributes) 8
Extension: 156 (RENDER)
Minor opcode: 4 (RenderCreatePicture)
Resource id: 0x3600004
X Error: RenderBadPicture (invalid Picture parameter) 182
Extension: 156 (RENDER)
Minor opcode: 7 (RenderFreePicture)
Resource id: 0x3600005
Major opcode of failed request: 156 (RENDER)
Minor opcode of failed request: 7 (RenderFreePicture)
Picture id in failed request: 0x36002dc
```

and not display some characters such as [ and ]. This has been observed on both Solaris x86 and Linux. The characters are actually displayed, but
the problem is they are in the same colour as the background, so you can't see
them.
**Solution**

The solution is given on a Linux web site, under the title Mathematica renders fonts incorrectly in Hardy. (Hardy is the code name for some Linux release I believe). One needs to to pass the command line parameter

`-defaultvisual`

to mathematica. It might be easier to edit /usr/local/bin/mathematica and add `-defaultvisual`

to the last line.
## Mathematica crashes on Solaris x86 with an Intel CPU

**Problem**

Mathematica 6.0, 6.0.1 and 6.0.2 are all supported on Solaris 10 x86, but only on AMD CPUs, not Intel CPUs. You will get error messages similar to these

```
ld.so.1: MathKernel: fatal: libfsu.so.1: version `SUNWprivate_1.1' not
found (required by file
/usr/local/Wolfram/Mathematica/6.0/SystemFiles/Libraries/Solaris-x86-64/libsunperf.so.1)
ld.so.1: MathKernel: fatal: libfsu.so.1: open failed: No such file or
directory
Killed
```

The reason for the error is that some of the libraries supplied with
Mathematica 6.0, 6.01 and 6.0.2 need the AMD_3DNOW instruction set, which
Intel CPUs don't have. (At the time of writing, Mathemtaica 6.0.2 is the latest release, so this may or may not apply to later releases of Mathematica.)
**Solution**

The solution to this is to replace some of the libraries supplied with Mathematica by those supplied by Sun, which do not need the AMD_3DNOW instructions. I posted full instructions on the sci.math.symoblic newsgroup, under the title A hack to run Mathematica 6 on Solaris x86 with an Intel CPU The instructions there require you to install Sun Studio 12 development system to get the libraries. If you dont have Sun Stuidio 12, you can download the librares from this web site.

## Mathematica fails to determine the number of CPUs correctly on SPARC

At least some versions of Mathematica prior to 6.0.2, the scripts /usr/local/bin/mathematica and /usr/local/bin/math set a variable SystemID to Solaris-SPARC on Solaris SPARC. There is a test```
if [ "${SystemID}" = "UltraSPARC" -o "${SystemID}" = "Solaris-x86-64" ];
```

That will never evaluate to true, since the SystemID was set to Solaris-SPARC and not UltraSPARC. Instead the code should have been:

```
if [ "${SystemID}" = "Solaris-SPARC" -o "${SystemID}" = "Solaris-x86-64" ];
```

That was fixed in 6.0.2 (and possibly in 6.0.1, but I dont know.) Note also that I think the test is a bit simplistic, as it actually measures the number of CPUs in the system, not the number online, which might be different. I'm not sure how it will handle the cases of processor sets. For original post on this was in the thread Mathematica 6 bug. Fails to find number of CPUs - a cure!!.