Changeset 886fa25 in sasmodels


Ignore:
Timestamp:
Oct 6, 2016 2:24:32 PM (3 years ago)
Author:
ajj
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
5b37fd6
Parents:
4a2e1e5
git-author:
Wojciech Potrzebowski <Wojciech.Potrzebowski@…> (10/06/16 14:24:32)
git-committer:
Andrew Jackson <andrew.jackson@…> (10/06/16 14:24:32)
Message:

Ticket576 - updated custom models not being recompiled (#10)

  • OpenCL drivers installation has been added
  • Moved compilation.rst to gpu_computations.rst (more propreiate name)
  • Check-ups for 576
  • Unloading lib from ctypes by triggering release function in kerneldll ref #576
  • Import clean-ups in kerneldll
Files:
1 added
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • doc/ref/gpu_computations.rst

    r1875f4e r886fa25  
    11.. _models-complitation: 
    22 
    3 ****************** 
    4 Models Compliation 
    5 ****************** 
     3**************** 
     4GPU Computations 
     5**************** 
    66SasView model evaluations can run on your graphics card (GPU) or they can run 
    77on the processor (CPU). 
    88 
    99To 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. 
     10For information about OpenCL installation see the 
     11:ref:`opencl-installation` documentation 
    1912 
    2013Where the model is evaluated is a little bit complicated. 
  • doc/ref/index.rst

    r4a2e1e5 r886fa25  
    99   intro.rst 
    1010   refs.rst 
    11    compilation.rst 
     11   gpu_computations.rst 
    1212   magnetism/magnetism.rst 
    1313   sesans/sans_to_sesans.rst 
  • sasmodels/kerneldll.py

    r3764ec1 r886fa25  
    7373import tempfile 
    7474import ctypes as ct  # type: ignore 
    75 from ctypes import c_void_p, c_int32, c_longdouble, c_double, c_float  # type: ignore 
     75import _ctypes as _ct 
    7676import logging 
    7777 
     
    111111    compiler = "unix" 
    112112 
    113 ARCH = "" if ct.sizeof(c_void_p) > 4 else "x86"  # 4 byte pointers on x86 
     113ARCH = "" if ct.sizeof(ct.c_void_p) > 4 else "x86"  # 4 byte pointers on x86 
    114114if compiler == "unix": 
    115115    # Generic unix compile 
     
    241241    if not os.path.exists(dll): 
    242242        need_recompile = True 
    243     elif getattr(sys, 'frozen', None) is not None: 
    244         # TODO: don't suppress time stamp 
    245         # Currently suppressing recompile when running in a frozen environment 
    246         need_recompile = False 
    247243    else: 
    248244        dll_time = os.path.getmtime(dll) 
     
    301297    def _load_dll(self): 
    302298        # type: () -> None 
    303         #print("dll", self.dllpath) 
    304299        try: 
    305300            self._dll = ct.CDLL(self.dllpath) 
     
    308303            raise 
    309304 
    310         float_type = (c_float if self.dtype == generate.F32 
    311                       else c_double if self.dtype == generate.F64 
    312                       else c_longdouble) 
     305        float_type = (ct.c_float if self.dtype == generate.F32 
     306                      else ct.c_double if self.dtype == generate.F64 
     307                      else ct.c_longdouble) 
    313308 
    314309        # int, int, int, int*, double*, double*, double*, double*, double 
    315         argtypes = [c_int32]*3 + [c_void_p]*4 + [float_type] 
     310        argtypes = [ct.c_int32]*3 + [ct.c_void_p]*4 + [float_type] 
    316311        names = [generate.kernel_name(self.info, variant) 
    317312                 for variant in ("Iq", "Iqxy", "Imagnetic")] 
     
    344339        Release any resources associated with the model. 
    345340        """ 
     341        dll_handle = self._dll._handle 
    346342        if os.name == 'nt': 
    347             #dll = ct.cdll.LoadLibrary(self.dllpath) 
    348             dll = ct.CDLL(self.dllpath) 
    349             dll_handle = dll._handle 
    350             #dll_handle = ct.c_void_p(dll._handle) 
    351             del dll, self._dll 
    352             self._dll = None 
    353343            ct.windll.kernel32.FreeLibrary(dll_handle) 
    354344        else: 
    355             pass 
    356  
     345            _ct.dlclose(dll_handle) 
     346        del self._dll 
     347        self._dll = None 
    357348 
    358349class DllKernel(Kernel): 
     
    411402        #print("returned",self.q_input.q, self.result) 
    412403        pd_norm = self.result[self.q_input.nq] 
    413         scale = values[0]/(pd_norm if pd_norm!=0.0 else 1.0) 
     404        scale = values[0]/(pd_norm if pd_norm != 0.0 else 1.0) 
    414405        background = values[1] 
    415406        #print("scale",scale,background) 
  • sasmodels/sasview_model.py

    r9c1a59c r886fa25  
    575575                            magnetic=is_magnetic) 
    576576        calculator.release() 
     577        self._model.release() 
    577578        return result 
    578579 
Note: See TracChangeset for help on using the changeset viewer.