[1875f4e] | 1 | .. _models-complitation: |
---|
| 2 | |
---|
| 3 | ****************** |
---|
| 4 | Models Compliation |
---|
| 5 | ****************** |
---|
| 6 | SasView model evaluations can run on your graphics card (GPU) or they can run |
---|
| 7 | on the processor (CPU). |
---|
| 8 | |
---|
| 9 | To run on the GPU, your computer must have OpenCL drivers installed. |
---|
| 10 | |
---|
| 11 | ... give details on how to identify graphics cards, how to tell if OpenCL |
---|
| 12 | is already installed and where to get drivers if it is not ... |
---|
| 13 | |
---|
| 14 | Note that Intel provides an OpenCL drivers for Intel processors. |
---|
| 15 | This can sometimes make use of special vector instructions across multiple |
---|
| 16 | processors, so it is worth installing if the GPU does not support double |
---|
| 17 | precision. |
---|
| 18 | You can install this driver alongside the GPU driver for NVIDIA or AMD. |
---|
| 19 | |
---|
| 20 | Where the model is evaluated is a little bit complicated. |
---|
| 21 | If the model has the line *single=False* then it requires double precision. |
---|
| 22 | If the GPU is single precision only, then it will try running via OpenCL |
---|
| 23 | on the CPU. If the OpenCL driver is not available for the CPU then |
---|
| 24 | it will run as a normal program on the CPU. |
---|
| 25 | For models with a large number of parameters or with a lot of code, |
---|
| 26 | the GPU may be too small to run the program effectively. |
---|
| 27 | In this case, you should try simplifying the model, maybe breaking it |
---|
| 28 | into several different models so that you don't need if statements in your code. |
---|
| 29 | If it is still too big, you can set *opencl=False* in the model file and |
---|
| 30 | the model will only run as a normal program on the CPU. |
---|
| 31 | This will not usually be necessary. |
---|
| 32 | |
---|
| 33 | If you have multiple GPU devices you can tell SasView which device to use. |
---|
| 34 | By default, SasView looks for one GPU and one CPU device |
---|
| 35 | from available OpenCL platforms. |
---|
| 36 | |
---|
| 37 | It prefers AMD or NVIDIA drivers for GPU, and prefers Intel or |
---|
| 38 | Apple drivers for CPU. |
---|
| 39 | Both GPU and CPU are included on the assumption that CPU is always available |
---|
| 40 | and supports double precision. |
---|
| 41 | |
---|
| 42 | The device order is important: GPU is checked before CPU on the assumption that |
---|
| 43 | it will be faster. By examining ~/sasview.log you can see which device SasView |
---|
| 44 | chose to run the model. |
---|
| 45 | If you don't want to use OpenCL, you can set *SAS_OPENCL=None* |
---|
| 46 | in the environment, and it will only use normal programs. |
---|
| 47 | If you want to use one of the other devices, you can run the following |
---|
| 48 | from the python console in SasView:: |
---|
| 49 | |
---|
| 50 | import pyopencl as cl |
---|
| 51 | cl.create_some_context() |
---|
| 52 | |
---|
| 53 | This will provide a menu of different OpenCL drivers available. |
---|
| 54 | When one is selected, it will say "set PYOPENCL_CTX=..." |
---|
| 55 | Use that value as the value of *SAS_OPENCL*. |
---|
| 56 | |
---|
| 57 | For models run as normal programs, you may need to specify a compiler. |
---|
| 58 | This is done using the SAS_COMPILER environment variable. |
---|
| 59 | Set it to *tinycc* for the tinycc compiler, *msvc* for the |
---|
| 60 | Microsoft Visual C compiler, or *mingw* for the MinGW compiler. |
---|
| 61 | TinyCC is provided with SasView so that is the default. |
---|
| 62 | If you want one of the other compilers, be sure to have it available |
---|
| 63 | on the path so SasView can find it. |
---|