tag:blogger.com,1999:blog-4295204633719044289.post729391915008959730..comments2023-12-13T07:32:58.016-05:00Comments on φ-node: Faster image filters in Python with Parakeet Alex Rhttp://www.blogger.com/profile/04049149415019007603noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-4295204633719044289.post-52003903008372626992018-12-25T04:39:34.708-05:002018-12-25T04:39:34.708-05:00Very Nice blog for learning new things,thanks for ...Very Nice blog for learning new things,thanks for such beautiful blog.<br />below some new idea plz check once.<br /><a href="https://www.viraltrench.com/kissanime/" rel="nofollow">KissAnime alternatives</a><br />rohithttps://www.blogger.com/profile/02074015070459346909noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-78807371878283611012013-06-26T05:07:15.650-04:002013-06-26T05:07:15.650-04:00On the first look there isn't anything dramati...On the first look there isn't anything dramatically wrong with this code.<br /><br />Additional "if(minimum)" should be handled by branch prediction machinery in the CPU.<br />Another difference is that scipy version allocates line buffers and copies data to/from them while parakeet version must be doing calculations in-place. But this shouldn't result in factor of two difference in the performance.<br /><br />Can it be the difference between optimization levels? I imagine parakeet uses instruction set of the CPU it's running on, while distro package is compiled for i686(?).Usovhttps://www.blogger.com/profile/16539322267902118002noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-12412218992009479982013-06-19T12:42:34.535-04:002013-06-19T12:42:34.535-04:00Hey Usov,
From a brief exploration of the Scipy ...Hey Usov, <br /><br />From a brief exploration of the Scipy source it seems that the call chain is: <br /><br />1) morphology.py: grey_dilation <br />2) filters.py: min_or_max_filter <br />3) nd_image.c: Py_MinOrMaxFilter1D <br />4) ni_filters.c: NI_MinOrMaxFilter1D<br /><br />That last function is where the actual work happens. Aside from some copies to buffers it seems to do essentially the same as the Numba/Parakeet code above: <br /><br /> /* iterate over all the array lines: */<br /> do {<br /> /* copy lines from array to buffer: */<br /> if (!NI_ArrayToLineBuffer(&iline_buffer, &lines, &more))<br /> goto exit;<br /> /* iterate over the lines in the buffers: */<br /> for(kk = 0; kk < lines; kk++) {<br /> /* get lines: */<br /> double *iline = NI_GET_LINE(iline_buffer, kk) + size1;<br /> double *oline = NI_GET_LINE(oline_buffer, kk);<br /> for(ll = 0; ll < length; ll++) {<br /> /* find minimum or maximum filter: */<br /> double val = iline[ll - size1];<br /> for(jj = -size1 + 1; jj <= size2; jj++) {<br /> double tmp = iline[ll + jj];<br /> if (minimum) {<br /> if (tmp < val)<br /> val = tmp;<br /> } else {<br /> if (tmp > val)<br /> val = tmp;<br /> }<br /> }<br /> oline[ll] = val;<br /> }<br /> }<br /> /* copy lines from buffer to array: */<br /> if (!NI_LineBufferToArray(&oline_buffer))<br /> goto exit;<br /> } while(more);<br />Alex Rhttps://www.blogger.com/profile/04049149415019007603noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-32896897463060094572013-06-19T08:47:39.642-04:002013-06-19T08:47:39.642-04:00My first question would be why your version beats ...My first question would be why your version beats scipy's by a factor of two.<br /><br />Is it because scipy version is more generic?Usovhttps://www.blogger.com/profile/16539322267902118002noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-5093147041254206802013-06-14T20:49:21.492-04:002013-06-14T20:49:21.492-04:00Hi Michel,
PyCUDA is great-- but it's very l...Hi Michel, <br /><br />PyCUDA is great-- but it's very low level compared with Parakeet & Numba. You still usually end up having to write CUDA code in an inline string. <br /><br />Copperhead, on the other hand, is very neat, albeit a little limited semantically (i.e. purely function, HM type inference, etc..). <br />I wrote a little bit about it in this older post: http://www.phi-node.com/2013/01/a-journey-through-parakeet.html<br /><br />Alex Rhttps://www.blogger.com/profile/04049149415019007603noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-54164254286619559272013-06-14T20:46:38.885-04:002013-06-14T20:46:38.885-04:00Hey Travis,
Thanks a lot! Sorry that I didn'...Hey Travis, <br /><br />Thanks a lot! Sorry that I didn't know about no_python when I wrote the post. I agree that the spirit is the same. <br /><br />As for type inference: Parakeet uses an abstract interpreter to infer local & return types from inputs and specializes function bodies for those inferred types. Parakeet also does shape inference in a similar fashion. Alex Rhttps://www.blogger.com/profile/04049149415019007603noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-53363003090221762492013-06-14T20:43:08.751-04:002013-06-14T20:43:08.751-04:00I'm not sure what you mean by an "array v...I'm not sure what you mean by an "array version". As for NumPyPy, check out the example code I linked to. Alex Rhttps://www.blogger.com/profile/04049149415019007603noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-17888893240962413242013-06-14T12:50:42.596-04:002013-06-14T12:50:42.596-04:00GPUs have specific hardware optimizations for neig...GPUs have specific hardware optimizations for neighborhood operations and parallel reductions. Check out PyCUDA and PyOpenCL. Also the copperhead library is pretty amazing! It compiles Python into an AST and then into a CUDA function and comes with some great real-world examples.<br /><br />https://github.com/copperhead/copperheadMichel Pelletierhttps://www.blogger.com/profile/06825732011232709429noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-71947907626791114212013-06-10T07:41:32.190-04:002013-06-10T07:41:32.190-04:00Didn't know about the "no_python" mo...Didn't know about the "no_python" mode -- thanks!Juanlu001https://www.blogger.com/profile/06915112755443159434noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-45827080544080430102013-06-07T02:32:01.950-04:002013-06-07T02:32:01.950-04:00actually, shedskin never boxes a scalar.. actually, shedskin never boxes a scalar.. srepmubhttps://www.blogger.com/profile/15831320699731673389noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-46553672534972563272013-06-06T20:08:21.799-04:002013-06-06T20:08:21.799-04:00This is very nice work and a great comparison of a...This is very nice work and a great comparison of approaches. It's nice to have other projects to compare to that are recognizing the power of using LLVM from CPython. Perhaps we can collaborate more in the future. <br /><br />One correction to make. Numba does have a "no_python" mode which seems to be exactly the spirit of Parakeet --- complain loudly if you have to resort to using Python objects in the middle. <br /><br />Does your "jit" do run-time detection of types like Numba's autojit? It would be interesting to compare type-inference approaches between Numba and Parakeet. Anonymoushttps://www.blogger.com/profile/13691214053063138876noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-35172421774047292632013-06-06T10:37:33.349-04:002013-06-06T10:37:33.349-04:00Do you have an array version lying around? I'...Do you have an array version lying around? I'd like to try it in NumPyPy.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-35650216225367797312013-06-06T06:22:33.872-04:002013-06-06T06:22:33.872-04:00This looks good, I'm interested in something l...This looks good, I'm interested in something like this that would provide image effects + work with cairo images (precalc BGRA).stuaxohttps://www.blogger.com/profile/08755227063937859112noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-59109911255908327142013-06-06T00:33:11.747-04:002013-06-06T00:33:11.747-04:00Hey phsorx,
I haven't tried shedskin, though...Hey phsorx, <br /><br />I haven't tried shedskin, though I'm curious how both shedskin and Nuitka would perform. My suspicion is they would do very badly until they start doing something intelligent to unbox scalars instead of representing them as PyObjects. I'm leaving my computer for a few days but I'll check out the static Python compilers when I get back. Alex Rhttps://www.blogger.com/profile/04049149415019007603noreply@blogger.comtag:blogger.com,1999:blog-4295204633719044289.post-35485510443002343292013-06-05T20:28:09.310-04:002013-06-05T20:28:09.310-04:00Have you tried shedskin compiler on your code?
h...Have you tried shedskin compiler on your code? <br /><br />https://code.google.com/p/shedskin/<br /><br />I would be interested in the results.phsorxhttps://www.blogger.com/profile/04486193659670730577noreply@blogger.com