Changeset 6dba2f0 in sasmodels


Ignore:
Timestamp:
Jan 27, 2018 9:00:07 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
e59f60a
Parents:
2ab1bac
Message:

py.test needs kernelcl import to succeed even if pyopencl is not available

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • conftest.py

    r2ab1bac r6dba2f0  
    2020import pytest 
    2121from _pytest.unittest import TestCaseFunction 
    22  
    23 try: 
    24     # Ask OpenCL for the default context so that we know that one exists 
    25     import pyopencl as cl 
    26     cl.create_some_context(interactive=False) 
    27     TEST_PYOPENCL = True 
    28 except ImportError: 
    29     TEST_PYOPENCL = False 
    30  
    31 def pytest_ignore_collect(path, config): 
    32     ignore = TEST_PYOPENCL and path.basename == "kernelcl.py" 
    33     return ignore 
    3422 
    3523USE_DOCSTRING_AS_DESCRIPTION = True 
  • sasmodels/core.py

    ra69d8cd r6dba2f0  
    2121from . import mixture 
    2222from . import kernelpy 
     23from . import kernelcl 
    2324from . import kerneldll 
    2425from . import custom 
    2526 
    26 if os.environ.get("SAS_OPENCL", "").lower() == "none": 
    27     HAVE_OPENCL = False 
    28 else: 
    29     try: 
    30         from . import kernelcl 
    31         HAVE_OPENCL = True 
    32     except Exception: 
    33         HAVE_OPENCL = False 
     27# Other modules look for HAVE_OPENCL in core, not in kernelcl. 
     28HAVE_OPENCL = kernelcl.HAVE_OPENCL 
    3429 
    3530CUSTOM_MODEL_PATH = os.environ.get('SAS_MODELPATH', "") 
  • sasmodels/kernelcl.py

    r2d81cfe r6dba2f0  
    5858import numpy as np  # type: ignore 
    5959 
     60import pyopencl as cl  # type: ignore 
     61from pyopencl import mem_flags as mf 
     62from pyopencl.characterize import get_fast_inaccurate_build_options 
     63 
    6064try: 
    61     #raise NotImplementedError("OpenCL not yet implemented for new kernel template") 
    62     import pyopencl as cl  # type: ignore 
    63     # Ask OpenCL for the default context so that we know that one exists 
    64     cl.create_some_context(interactive=False) 
     65    if os.environ.get("SAS_OPENCL", "").lower() == "none": 
     66        HAVE_OPENCL = False 
     67    else: 
     68        # Ask OpenCL for the default context so that we know that one exists 
     69        cl.create_some_context(interactive=False) 
     70        HAVE_OPENCL = True 
    6571except Exception as exc: 
    6672    warnings.warn("OpenCL startup failed with ***" 
    6773                  + str(exc) + "***; using C compiler instead") 
    68     raise RuntimeError("OpenCL not available") 
    69  
    70 from pyopencl import mem_flags as mf 
    71 from pyopencl.characterize import get_fast_inaccurate_build_options 
     74    HAVE_OPENCL = False 
    7275 
    7376from . import generate 
     
    102105        cl._DEFAULT_INCLUDE_OPTIONS = [quote_path(v) for v in cl._DEFAULT_INCLUDE_OPTIONS] 
    103106 
    104 fix_pyopencl_include() 
    105  
     107if HAVE_OPENCL: 
     108    fix_pyopencl_include() 
    106109 
    107110# The max loops number is limited by the amount of local memory available 
Note: See TracChangeset for help on using the changeset viewer.