[Chennaipy] Mutli- threading in cython

aishwarya selvaraj aishwaryaselvaraj1708 at gmail.com
Fri Jun 1 07:02:31 EDT 2018


Hi,
I tried the changes. No was not able to solve my issue. I'm attaching the
file. Kindly take a look at it.

ᐧ

On Mon, May 28, 2018 at 10:21 PM, Aravindhan K <aravindhank1994 at gmail.com>
wrote:

> Hi,
>
> See the comments starts with NOTE in the attached file.
> Hope that may guide you find the issue.
>
> Regards,
> Araindhan K
>
> On Mon, May 28, 2018 at 11:35 AM, aishwarya selvaraj <
> aishwaryaselvaraj1708 at gmail.com> wrote:
>
>> Hi,
>> Yes, I was able to make use of  PyArray_NewFromDescr in my code. Storing
>> into a 3D array has now become a lot faster. Thank you!But the CCD
>> images stored using this method looks quite different from the ones
>> acquired earlier.
>> In the older method at the end of for loop, there is incrementing using  _puc_image
>> += aoiStride, I'm not very sure on how to do it with new method. Could
>> you please take a look at it?
>>>>
>> On Mon, May 28, 2018 at 11:17 AM, aishwarya selvaraj <
>> aishwaryaselvaraj1708 at gmail.com> wrote:
>>
>>> Hi,
>>> Yes, I was able to make use of  PyArray_NewFromDescr in my code.
>>> Storing into a 3D array has now become a lot faster. Thank you!But the
>>> CCD images stored using this method looks quite different from the ones
>>> acquired earlier.
>>> In the older method at the end of for loop there is incrementing using  _puc_image
>>> += aoiStride, I'm not very sure on how to do it with new method. Could
>>> you please take a look at it? I'm not very sure what am I missing here.
>>>>>>
>>>>
>>>>> dims[0] = self.aoiWidth
>>>>
>>>> dims[1] = self.aoiHeight
>>>>
>>>>                         #method 1
>>>>
>>>> data[i,:,:] = PyArray_NewFromDescr(<PyTypeObject *> np.ndarray,
>>>>> np.dtype('<B'), 2,dims, NULL,pBuf, np.NPY_C_CONTIGUOUS, None)
>>>>
>>>> #-----------------------------------------------------------
>>>>> ------------------------------------------------
>>>>
>>>> #method 2:
>>>>
>>>> #if (i==0) or (i == 1) or (i ==2) or (i==3) or (i==4):
>>>>
>>>> #_puc_image = pBuf
>>>>
>>>> #pus_image = <unsigned short*>pBuf
>>>>
>>>> #for j in range(self.aoiWidth/self.hbin):
>>>>
>>>> #pus_image = <unsigned short*>(_puc_image)
>>>>
>>>> #for k in range(self.aoiHeight/self.vbin):
>>>>
>>>> #data[l][j][k]  = pus_image[0]
>>>>
>>>> #pus_image += 1
>>>>
>>>> #_puc_image += aoiStride
>>>>
>>>> #l = l+1
>>>>
>>>> the image displayed using method 1 is very different from method 1.
>>>
>>>>>>
>>> On Thu, May 24, 2018 at 9:34 AM, aishwarya selvaraj <
>>> aishwaryaselvaraj1708 at gmail.com> wrote:
>>>
>>>> Hi, Yes I was able to make use of  PyArray_NewFromDescr in my code.
>>>> Storing into a 3D array has now become a lot faster.Thank you!
>>>> But the CCD images stored using this method looks quite different from
>>>> the ones acquired earlier. I'm yet to find the root of the problem for the
>>>> same. Could you please take a look at it? I'm not very sure what am I
>>>> missing here.
>>>>>>>>
>>>> On Wed, May 23, 2018 at 7:43 AM, Aravindhan K <
>>>> aravindhank1994 at gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>> Please use this example code. https://pastebin.com/nh9rvqfm.
>>>>> I have used this link as a reference.
>>>>> https://groups.google.com/forum/#!topic/cython-users/fFBiCCwblD0
>>>>>
>>>>>
>>>>> Regards,
>>>>> Aravindhan K
>>>>>
>>>>> On Tue, May 22, 2018 at 11:58 AM, aishwarya selvaraj <
>>>>> aishwaryaselvaraj1708 at gmail.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>> Thank you for the suggestion. I was trying out an example code using
>>>>>> PyArray_NewFromDescr*.* PFA of the code.I compiled the file using
>>>>>> :python setup.py build_ext --inplace.
>>>>>> When compiled I get the following error :
>>>>>> fatal error : numpy/arrayobject.h :No such file or directory.
>>>>>> I would be realy gratefull if you could do the edit in the file I
>>>>>> sent in my first mail.
>>>>>>
>>>>>>>>>>>>
>>>>>> On Mon, May 21, 2018 at 9:19 PM, Aravindhan K <
>>>>>> aravindhank1994 at gmail.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> You could try using PyArray_NewFromDescr NumPy C-API function for
>>>>>>> creating nd-array
>>>>>>> in function capturing frames.
>>>>>>> than doing nested loops to do copy byte by byte. (This could be the
>>>>>>> bottleneck)
>>>>>>> https://docs.scipy.org/doc/numpy-1.14.0/reference/c-api.arra
>>>>>>> y.html#from-scratch
>>>>>>>
>>>>>>>
>>>>>>> Regards,
>>>>>>> Aravindhan K
>>>>>>>
>>>>>>> On Mon, May 21, 2018 at 5:12 PM, aishwarya selvaraj <
>>>>>>> aishwaryaselvaraj1708 at gmail.com> wrote:
>>>>>>>
>>>>>>>> Dear all,
>>>>>>>> I was programming for Andor CCD using SDK libraries in python using
>>>>>>>> cython.
>>>>>>>> I have a piece of code within my .pyx script which does the
>>>>>>>> function of storing the data into a 3D array. While acquiring n frames,
>>>>>>>> each of them is stored in a 3D array named data, which later I would be
>>>>>>>> displaying. But this creates a bottleneck in my code.
>>>>>>>> Hence I need to introduce threading, such that for each frame to be
>>>>>>>> stored there are individual threads for the same and the frames could be
>>>>>>>> displayed simultaneously without creating a performance lag.
>>>>>>>> Since I have never worked on multithreading, could anyone please
>>>>>>>> help me.
>>>>>>>> PFA of the code. (LiveAcquisition code)
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Regards,
>>>>>>>> Aishwarya Selvaraj
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Chennaipy mailing list
>>>>>>>> Chennaipy at python.org
>>>>>>>> https://mail.python.org/mailman/listinfo/chennaipy
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Chennaipy mailing list
>>>>>>> Chennaipy at python.org
>>>>>>> https://mail.python.org/mailman/listinfo/chennaipy
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Regards,
>>>>>> Aishwarya Selvaraj
>>>>>>
>>>>>> _______________________________________________
>>>>>> Chennaipy mailing list
>>>>>> Chennaipy at python.org
>>>>>> https://mail.python.org/mailman/listinfo/chennaipy
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Chennaipy mailing list
>>>>> Chennaipy at python.org
>>>>> https://mail.python.org/mailman/listinfo/chennaipy
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Regards,
>>>> Aishwarya Selvaraj
>>>>
>>>
>>>
>>>
>>> --
>>> Regards,
>>> Aishwarya Selvaraj
>>>
>>
>>
>>
>> --
>> Regards,
>> Aishwarya Selvaraj
>>
>> _______________________________________________
>> Chennaipy mailing list
>> Chennaipy at python.org
>> https://mail.python.org/mailman/listinfo/chennaipy
>>
>>
>
> _______________________________________________
> Chennaipy mailing list
> Chennaipy at python.org
> https://mail.python.org/mailman/listinfo/chennaipy
>
>


-- 
Regards,
Aishwarya Selvaraj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chennaipy/attachments/20180601/64270be6/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: atcore_py .pyx
Type: application/octet-stream
Size: 3185 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/chennaipy/attachments/20180601/64270be6/attachment-0001.obj>


More information about the Chennaipy mailing list