Changeset 3764ec1 in sasmodels


Ignore:
Timestamp:
Sep 12, 2016 1:21:45 AM (5 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
733a3e1
Parents:
4cc161e
Message:

improve docs; support python 3.x

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kerneldll.py

    r14a15a3 r3764ec1  
    22DLL driver for C kernels 
    33 
    4 The global attribute *ALLOW_SINGLE_PRECISION_DLLS* should be set to *True* if 
    5 you wish to allow single precision floating point evaluation for the compiled 
    6 models, otherwise it defaults to *False*. 
    7  
    8 The compiler command line is stored in the attribute *COMPILE*, with string 
    9 substitutions for %(source)s and %(output)s indicating what to compile and 
    10 where to store it.  The actual command is system dependent. 
    11  
    12 On windows systems, you have a choice of compilers.  *MinGW* is the GNU 
    13 compiler toolchain, available in packages such as anaconda and PythonXY, 
    14 or available stand alone. This toolchain has had difficulties on some 
    15 systems, and may or may not work for you.  In order to build DLLs, *gcc* 
    16 must be on your path.  If the environment variable *SAS_OPENMP* is given 
    17 then -fopenmp is added to the compiler flags.  This requires a version 
    18 of MinGW compiled with OpenMP support. 
    19  
    20 An alternative toolchain uses the Microsoft Visual C++ compiler, available 
    21 free from microsoft: 
     4If the environment variable *SAS_OPENMP* is set, then sasmodels 
     5will attempt to compile with OpenMP flags so that the model can use all 
     6available kernels.  This may or may not be available on your compiler 
     7toolchain.  Depending on operating system and environment. 
     8 
     9Windows does not have provide a compiler with the operating system. 
     10Instead, we assume that TinyCC is installed and available.  This can 
     11be done with a simple pip command if it is not already available:: 
     12 
     13    pip install tinycc 
     14 
     15If Microsoft Visual C++ is available (because VCINSTALLDIR is 
     16defined in the environment), then that will be used instead. 
     17Microsoft Visual C++ for Python is available from Microsoft: 
    2218 
    2319    `<http://www.microsoft.com/en-us/download/details.aspx?id=44266>`_ 
    2420 
    25 Again, this requires that the compiler is available on your path.  This is 
    26 done by running vcvarsall.bat in a windows terminal.  Install locations are 
    27 system dependent, such as: 
     21If neither compiler is available, sasmodels will check for *MinGW*, 
     22the GNU compiler toolchain. This available in packages such as Anaconda 
     23and PythonXY, or available stand alone. This toolchain has had 
     24difficulties on some systems, and may or may not work for you. 
     25 
     26You can control which compiler to use by setting SAS_COMPILER in the 
     27environment: 
     28 
     29  - tinycc (Windows): use the TinyCC compiler shipped with SasView 
     30  - msvc (Windows): use the Microsoft Visual C++ compiler 
     31  - mingw (Windows): use the MinGW GNU cc compiler 
     32  - unix (Linux): use the system cc compiler. 
     33  - unix (Mac): use the clang compiler. You will need XCode installed, and 
     34    the XCode command line tools. Mac comes with OpenCL drivers, so generally 
     35    this will not be needed. 
     36 
     37Both *msvc* and *mingw* require that the compiler is available on your path. 
     38For *msvc*, this can done by running vcvarsall.bat in a windows terminal. 
     39Install locations are system dependent, such as: 
    2840 
    2941    C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat 
     
    3345    C:\Users\yourname\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat 
    3446 
    35 And again, the environment variable *SAS_OPENMP* controls whether OpenMP is 
    36 used to compile the C code.  This requires the Microsoft vcomp90.dll library, 
    37 which doesn't seem to be included with the compiler, nor does there appear 
    38 to be a public download location.  There may be one on your machine already 
    39 in a location such as: 
     47OpenMP for *msvc* requires the Microsoft vcomp90.dll library, which doesn't 
     48seem to be included with the compiler, nor does there appear to be a public 
     49download location.  There may be one on your machine already in a location 
     50such as: 
    4051 
    4152    C:\Windows\winsxs\x86_microsoft.vc90.openmp*\vcomp90.dll 
    4253 
    43 If you copy this onto your path, such as the python directory or the install 
    44 directory for this application, then OpenMP should be supported. 
     54If you copy this to somewhere on your path, such as the python directory or 
     55the install directory for this application, then OpenMP should be supported. 
     56 
     57For full control of the compiler, define a function 
     58*compile_command(source,output)* which takes the name of the source file 
     59and the name of the output file and returns a compile command that can be 
     60evaluated in the shell.  For even more control, replace the entire 
     61*compile(source,output)* function. 
     62 
     63The global attribute *ALLOW_SINGLE_PRECISION_DLLS* should be set to *False* if 
     64you wish to prevent single precision floating point evaluation for the compiled 
     65models, otherwise set it defaults to *True*. 
    4566""" 
    4667from __future__ import print_function 
     
    90111    compiler = "unix" 
    91112 
    92 ARCH = "" if sys.maxint > 2**32 else "x86"  # maxint=2**31-1 on 32 bit 
     113ARCH = "" if ct.sizeof(c_void_p) > 4 else "x86"  # 4 byte pointers on x86 
    93114if compiler == "unix": 
    94115    # Generic unix compile 
Note: See TracChangeset for help on using the changeset viewer.