Changeset c98c772 in sasmodels


Ignore:
Timestamp:
May 20, 2016 4:23:46 PM (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:
7e16db7
Parents:
5efe850 (diff), a7a5ff3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge pull request #5 from bmaranville/master

import was causing problems… race condition?

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/generate.py

    r558d3b3 ra7a5ff3  
    785785    model_info = dict( 
    786786        id=kernel_id,  # string used to load the kernel 
    787         filename=abspath(kernel_module.__file__), 
     787        filename=abspath(kernel_module.__file__.rstrip("cd")), 
    788788        name=name, 
    789789        title=kernel_module.title, 
  • sascomp

    ra78bebc r5efe850  
    44import os 
    55import glob 
     6import logging 
     7logging.basicConfig(level=logging.INFO) 
    68 
    79def main(): 
     
    1113    sys.path.insert(0, os.path.join(root, 'bumps')) 
    1214    sys.path.insert(0, os.path.join(root, 'periodictable')) 
     15    sys.path.insert(0, os.path.join(root, 'tinycc')) 
    1316    if sasview:  # glob returns a list 
    1417        sys.path.insert(0, sasview[0]) 
  • sasmodels/kernel_template.c

    r3832f27 r5efe850  
    1212// Note: if using a C++ compiler, then define kernel as extern "C" 
    1313#ifndef USE_OPENCL 
     14// Use SAS_DOUBLE to force the use of double even for float kernels 
     15#  define SAS_DOUBLE dou ## ble 
    1416#  ifdef __cplusplus 
    1517      #include <cstdio> 
     
    3840     #if defined(__TINYC__) 
    3941         #include <math.h> 
    40          inline double trunc(double x) { return x>=0?floor(x):-floor(-x); } 
    41          inline double fmin(double x, double y) { return x>y ? y : x; } 
    42          inline double fmax(double x, double y) { return x<y ? y : x; } 
    4342         // TODO: test isnan 
    4443         inline double _isnan(double x) { return x != x; } // hope this doesn't optimize away! 
    4544         #undef isnan 
    4645         #define isnan(x) _isnan(x) 
     46         // Defeat the double->float conversion since we don't have tgmath 
     47         inline SAS_DOUBLE trunc(SAS_DOUBLE x) { return x>=0?floor(x):-floor(-x); } 
     48         inline SAS_DOUBLE fmin(SAS_DOUBLE x, SAS_DOUBLE y) { return x>y ? y : x; } 
     49         inline SAS_DOUBLE fmax(SAS_DOUBLE x, SAS_DOUBLE y) { return x<y ? y : x; } 
    4750         #define NEED_EXPM1 
    4851         #define NEED_TGAMMA 
     
    7073 
    7174#if defined(NEED_EXPM1) 
    72    static double expm1(double x) { 
     75   static SAS_DOUBLE expm1(SAS_DOUBLE x_in) { 
     76      double x = (double)x_in;  // go back to float for single precision kernels 
    7377      // Adapted from the cephes math library. 
    7478      // Copyright 1984 - 1992 by Stephen L. Moshier 
  • sasmodels/kernelcl.py

    r821a9c6 r33af590  
    6161    warnings.warn(str(exc)) 
    6262    raise RuntimeError("OpenCL not available") 
     63 
     64# CRUFT: pyopencl < 2017.1  (as of June 2016 needs quotes around include path) 
     65def _quote_path(v): 
     66    """ 
     67    Quote the path if it is not already quoted. 
     68 
     69    If v starts with '-', then assume that it is a -I option or similar 
     70    and do not quote it.  This is fragile:  -Ipath with space needs to 
     71    be quoted. 
     72    """ 
     73    return '"'+v+'"' if v and ' ' in v and not v[0] in "\"'-" else v 
     74 
     75if hasattr(cl, '_DEFAULT_INCLUDE_OPTIONS'): 
     76    cl._DEFAULT_INCLUDE_OPTIONS = [_quote_path(v) for v in cl._DEFAULT_INCLUDE_OPTIONS] 
    6377 
    6478from pyopencl import mem_flags as mf 
     
    224238            context = self.get_context(dtype) 
    225239            logging.info("building %s for OpenCL %s" 
    226                          % (key, context.devices[0].name)) 
     240                         % (key, context.devices[0].name.strip())) 
    227241            program = compile_model(context, source, np.dtype(dtype), fast) 
    228242            self.compiled[key] = program 
  • 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.