I'm using Numba with several jitclasses to speed up a fairly complex biophysics model which must be solved with a computationally intensive but nicely parallelizable genetic algorithm. Before I started compiling things with Numba, I was getting a ~4x speed improvement out of Python's multiprocess module splitting the job across my four cores. The compilation from Numba is giving an even bigger speed improvement, but I can no longer parallelize it because jitclasses can't be pickled. It would be ideal if I could get both these speed benefits at the same time.
I've tried using the pathos version of multiprocessing instead of the standard multiprocess module, which is supposed to use the more flexible 'dill' for serialization, but I still get the following error thrown by the standard multiprocess library's pool.pyc:
PicklingError: Can't pickle <class 'numba.jitclass.base.MyJitclassName'>: it's not found as numba.jitclass.base.MyJitclassName
Is there any hope for using Jitclasses in any sort of parallel way in the near future? Or is there an alternative, comprehensibly-structured way to pass a complex data structure in and out of jitted functions? Or is the only parallelizable option to pass it all around in simple numpy arrays?
--------------
Two other quick questions/comments:
- I figured out that we can use jitclasses as attributes of other jitclasses by defining their types like so: my_jitclass_type = MyJitclassName.class_type.instance_type. This doesn't seem to be anywhere in the documentation, and it would be really helpful to others if it were.
- Is there any way to print() something more complex than a single number at a time from inside a jitted class or function? Diagnosing bugs in my jitted code has been a nightmare without a good way to view intermediate values.
Thanks in advance for any tips.