Changeset 5efe850 in sasmodels for sasmodels/kerneldll.py


Ignore:
Timestamp:
May 20, 2016 10:53:41 AM (8 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:
c98c772, 4bfbca2
Parents:
33af590
Message:

Use tinycc if available; support float32 models in tinycc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kerneldll.py

    r821a9c6 r5efe850  
    6060from .exception import annotate_exception 
    6161 
    62 # Compiler platform details 
    63 if sys.platform == 'darwin': 
    64     #COMPILE = "gcc-mp-4.7 -shared -fPIC -std=c99 -fopenmp -O2 -Wall %s -o %s -lm -lgomp" 
    65     COMPILE = "gcc -shared -fPIC -std=c99 -O2 -Wall %(source)s -o %(output)s -lm" 
    66 elif os.name == 'nt': 
     62if os.name == 'nt': 
     63    # Windows compiler; check if TinyCC is available 
     64    try: 
     65        from tinycc import TCC 
     66    except ImportError: 
     67        TCC = None 
    6768    # call vcvarsall.bat before compiling to set path, headers, libs, etc. 
    6869    if "VCINSTALLDIR" in os.environ: 
     
    7374        # TODO: remove intermediate OBJ file created in the directory 
    7475        # TODO: maybe don't use randomized name for the c file 
     76        # TODO: maybe ask distutils to find MSVC 
    7577        CC = "cl /nologo /Ox /MD /W3 /GS- /DNDEBUG /Tp%(source)s " 
    7678        LN = "/link /DLL /INCREMENTAL:NO /MANIFEST /OUT:%(output)s" 
     
    7981        else: 
    8082            COMPILE = " ".join((CC, LN)) 
    81     elif True: 
    82         # If MSVC compiler is not available, try using mingw 
    83         # fPIC is not needed on windows 
     83    elif TCC: 
     84        # TinyCC compiler. 
     85        COMPILE = TCC + " -shared -rdynamic -Wall %(source)s -o %(output)s" 
     86    else: 
     87        # MinGW compiler. 
    8488        COMPILE = "gcc -shared -std=c99 -O2 -Wall %(source)s -o %(output)s -lm" 
    8589        if "SAS_OPENMP" in os.environ: 
    86             COMPILE = COMPILE + " -fopenmp" 
    87     else: 
    88         # If MSVC compiler is not available, try using tinycc 
    89         from tinycc import TCC 
    90         COMPILE = TCC + " -shared -rdynamic -Wall %(source)s -o %(output)s" 
     90            COMPILE += " -fopenmp" 
    9191else: 
    92     COMPILE = "cc -shared -fPIC -fopenmp -std=c99 -O2 -Wall %(source)s -o %(output)s -lm" 
     92    # Generic unix compile 
     93    # On mac users will need the X code command line tools installed 
     94    COMPILE = "cc -shared -fPIC -std=c99 -O2 -Wall %(source)s -o %(output)s -lm" 
     95 
     96    # add openmp support if not running on a mac 
     97    if sys.platform != 'darwin': 
     98        #COMPILE = "gcc-mp-4.7 -shared -fPIC -std=c99 -fopenmp -O2 -Wall %s -o %s -lm -lgomp" 
     99        COMPILE += " -fopenmp" 
    93100 
    94101# Windows-specific solution 
Note: See TracChangeset for help on using the changeset viewer.