Opened 8 years ago

Closed 7 years ago

#576 closed defect (fixed)

updated custom models not being recompiled

Reported by: pkienzle Owned by: wojciech
Priority: major Milestone: SasView 4.1.0
Component: SasView Keywords:
Cc: Work Package: SasView Bug Fixing

Description

When updating the custom model within sasview on opencl the model doesn't always get updated.

When compiling to a dll, compile fails because dll is already loaded.

Attachments (1)

hexagonal_cylinder.py (4.2 KB) - added by ajj 8 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 8 years ago by wojciech

  • Owner set to wojciech
  • Status changed from new to assigned

comment:2 Changed 8 years ago by pkienzle

Can force use of DLL rather than OpenCL using the following in the python shell:

    import sasmodels.core
    sasmodels.core.USE_OPENCL = False

comment:3 Changed 8 years ago by pkienzle

To reproduce, create a custom model using Fitting>Edit Custom Model>New, setting model to e.g.,

return a + cos(b*x)

You can then use this model on the fit page. When the model is updated, e.g., to:

return a + cos(b*x) + 100

the new model is not updated.

The same is true for C models. Update the model to:

form_volume = """return 1.0;"""
Iq = """return a + cos(b*q) + 1;"""
Iqxy = None

Test model update and reload on mac, windows wt/ opencl and windows wt/ tinycc.

comment:4 Changed 8 years ago by pkienzle

OpenCL fixed, DLL fails.

To get the DLL to work, first remove the frozen check in sasmodels.kerneldll.make_dll, then restructure the DllKernel so that it doesn't hold any references to the DLL.

Follow the instructions to reproduce above, but with sasmodels.core.HAVE_OPENCL=False.

We can do this by wrapping the ct.CDLL in a class with methods for the different kernels. Instead of calling the kernels directly, calls from DllKernel will go through this object. DllModel may be could do this if we can guarantee there is only ever one DllModel instance for a particular dll, for example, by caching DllModel within load_dll(). Then its internal dll can be released, recompiled and reloaded with any attached kernels automatically updated.

Last edited 8 years ago by butler (previous) (diff)

comment:5 Changed 8 years ago by ajj

A student I am working with (Windows / no OpenCL) noticed this problem and currently is working round it by deleting the dll to force a rebuild.

He also noticed that python models will rebuild if secondary functions are changed, but not if Iq and Iqxy are changed. Which is odd.

comment:6 Changed 8 years ago by ajj

Attached model (hexagonal_cylinder.py) is the one that was causing problems - there was different rebuild behaviour between modifying secondary functions (e.g. Reflections() ) vs modifying Iq or Iqxy.

Changed 8 years ago by ajj

comment:7 Changed 8 years ago by wojciech

I did some testing and it seems that python models behave properly (are being updated). This also applies to hexagonal_cylinder.py (at least according to my test).

However, the problem still persist if the plugin models have c code sections like:
form_volume = """return 1.0;"""
Iq = """return a + cos(b*q) + 1;"""
Iqxy = None

These models don't update but SasView doesn't crush.

So this bug seems to apply to rather limited number of cases (plugins with C code embedded and no OpenCL). I guess it shouldn't affect too many users. Shouldn't we wait with fixing it until full 4.0 is out?

comment:8 Changed 8 years ago by butler

  • Milestone changed from SasView 4.0.0 to SasView 4.1.0

As decided at the fortnightly meeting Sep 28, 2016 we feel this is good enough for release 4.0 and it would be dangerous to try to fix the rest 3 days before the final release — moving to 4.1

Version 0, edited 8 years ago by butler (next)

comment:9 Changed 7 years ago by wojciech

In 9acbd37c401f7d905e67370f7361a35762628e75/sasmodels:

Unloading lib from ctypes by triggering release function in kerneldll ref #576

comment:10 Changed 7 years ago by ajj

In 886fa25dbb18c6bb0e504b4c4231771e0f26d910/sasmodels:

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

comment:11 Changed 7 years ago by wojciech

In 5b37fd681b84af2a1adc33b956ca441b19da76fe/sasmodels:

Needed to try except clause, otherwise was failing when trying disatch model on Windows without precompiled models - ref #576

comment:12 Changed 7 years ago by wojciech

In 47f2b5d45af5a67c5de39b0539edcbfbe5acbe7c/sasview:

Skipping extra Iq evaluation by not calling draw_model function from set polydisperisty parameters routine, ref #624 and #576

comment:13 Changed 7 years ago by wojciech

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.