No speedup on multi-processor machine?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • danfan1981@yahoo.com

    #1

    No speedup on multi-processor machine?

    Hi,
    I am using Python Thread library for my parallel processing course
    project. I am doing matrix convolution on a multi-processor machine
    running Solaris. I just found out that no speed-up is obtained with
    threading. It is probably because of something called GIL in Python.
    How can I get around
    that GIL and get speed-up?
    Thanks in advance.
    Daniel

  • Fuzzyman

    #2
    Re: No speedup on multi-processor machine?

    On Apr 21, 10:53 pm, Dennis Lee Bieber <wlfr...@ix.net com.comwrote:
    On 21 Apr 2007 14:02:12 -0700, danfan1...@yaho o.com declaimed the
    following in comp.lang.pytho n:
    >
    Hi,
    I am using Python Thread library for my parallel processing course
    project. I am doing matrix convolution on a multi-processor machine
    running Solaris. I just found out that no speed-up is obtained with
    threading. It is probably because of something called GIL in Python.
    How can I get around
    that GIL and get speed-up?
    >
    Threading in Python is optimized for I/O bound processing, wherein
    the threads spend most of their lives sleeping (blocked waiting for some
    I/O to complete, or some lock/event/condition to change state). It is
    not optimized for parallel number crunching.
    >
    Options:
    >
    Don't use the common "CPython" (eg, the Python built from C-language
    source using the C-runtime library). Jython (a version that runs on the
    JVM, using Java libraries) may not be afflicted with the GIL.
    >
    IronPython is *definitely* not restricted by the GIL.

    Fuzzyman
    http://www.voidspace.org.uk/ironpython/index.shtml

    Comment

    • Caleb Hattingh

      #3
      Re: No speedup on multi-processor machine?

      On Apr 21, 11:02 pm, danfan1...@yaho o.com wrote:
      Hi,
      I am using Python Thread library for my parallel processing course
      project. I am doing matrix convolution on a multi-processor machine
      running Solaris. I just found out that no speed-up is obtained with
      threading. It is probably because of something called GIL in Python.
      How can I get around
      that GIL and get speed-up?
      Thanks in advance.
      Daniel
      Perhaps try

      Effortless parallel and distributed computing in Python. Scale from multi-core workstations to compute clusters with a clean job-based API, zero dependencies. pip install pp


      or



      Caleb

      Comment

      • John Nagle

        #4
        Re: No speedup on multi-processor machine?

        Caleb Hattingh wrote:
        On Apr 21, 11:02 pm, danfan1...@yaho o.com wrote:
        >
        >>Hi,
        >>I am using Python Thread library for my parallel processing course
        >>project. I am doing matrix convolution on a multi-processor machine
        >>running Solaris. I just found out that no speed-up is obtained with
        >>threading. It is probably because of something called GIL in Python.
        >>How can I get around
        >>that GIL and get speed-up?
        >>Thanks in advance.
        >>Daniel
        If you're actually doing the convolution in Python, you need
        optimization before you need more CPUs. There's a numerics library
        for Python called NumPy, but it doesn't have a convolution function,
        although it has an FFT, which may be useful.

        But this is just homework. Do something reasonable and turn it
        in. A high performance solution to this problem is probably more
        work than it's worth.

        John Nagle

        Comment

        • Neil Hodgson

          #5
          Re: No speedup on multi-processor machine?

          Fuzzyman:
          IronPython is *definitely* not restricted by the GIL.
          IronPython is currently mostly slower than CPython although the
          particular problem should be tested to see if IronPython helps.

          Some recent benchmarks between IronPython and CPython:


          Neil

          Comment

          • Fuzzyman

            #6
            Re: No speedup on multi-processor machine?

            On Apr 22, 1:03 am, Neil Hodgson <nyamatongwe+th un...@gmail.com >
            wrote:
            Fuzzyman:
            >
            IronPython is *definitely* not restricted by the GIL.
            >
            IronPython is currently mostly slower than CPython although the
            particular problem should be tested to see if IronPython helps.
            >
            Some recent benchmarks between IronPython and CPython:http://sparcs.kaist.ac.kr/~tinuviel/pybench/
            >
            Yep, I've seen that. :-)

            http://www.voidspace.org.uk/python/w..._21.shtml#e687

            It's not entirely slower, but mainly slower.

            OTOH, if you split a job into two threads on a twin-core machine,
            IronPython performance will increase dramatically whilst CPython will
            go down...

            Additionally, extending IronPython from C# is orders of magnitude
            easier than extending CPython from C.

            Fuzzyman
            http://www.voidspace.org.uk/ironpython/index.shtml
            Neil

            Comment

            • Grant Edwards

              #7
              Re: No speedup on multi-processor machine?

              On 2007-04-21, danfan1981@yaho o.com <danfan1981@yah oo.comwrote:
              I am using Python Thread library for my parallel processing
              course project. I am doing matrix convolution on a
              multi-processor machine running Solaris. I just found out that
              no speed-up is obtained with threading. It is probably because
              of something called GIL in Python. How can I get around that
              GIL and get speed-up?
              Not much of a parallel processing course. It appears they
              haven't taught you anything about parallel processing.




              --
              Grant Edwards grante Yow! There's a SALE on
              at STRETCH SOCKS down at the
              visi.com "7-11"!!

              Comment

              • Robert Kern

                #8
                Re: No speedup on multi-processor machine?

                John Nagle wrote:
                There's a numerics library
                for Python called NumPy, but it doesn't have a convolution function,
                although it has an FFT, which may be useful.
                In [1]: from numpy import *

                In [2]: convolve?
                Type: function
                Base Class: <type 'function'>
                Namespace: Interactive
                File:
                /Library/Frameworks/Python.framewor k/Versions/2.5/lib/python2.5/site-packages/numpy-1.0.3.dev3714-py2.5-macosx-10.3-fat.egg/numpy/core/numeric.py
                Definition: convolve(a, v, mode='full')
                Docstring:
                Returns the discrete, linear convolution of 1-D sequences a and v; mode
                can be 'valid', 'same', or 'full' to specify size of the resulting sequence.

                --
                Robert Kern

                "I have come to believe that the whole world is an enigma, a harmless enigma
                that is made terrible by our own mad attempt to interpret it as though it had
                an underlying truth."
                -- Umberto Eco

                Comment

                • danfan1981@yahoo.com

                  #9
                  Re: No speedup on multi-processor machine?

                  Thanks guys. But I think IronPython only works on Windows machine, but
                  I am using a Sun machine. I was suggested to use Jython, which can run
                  on Sun. But I need to use Numpy for matrix operations, which is only
                  available to CPython.

                  Comment

                  • Fuzzyman

                    #10
                    Re: No speedup on multi-processor machine?

                    On Apr 22, 1:03 am, Neil Hodgson <nyamatongwe+th un...@gmail.com >
                    wrote:
                    Fuzzyman:
                    >
                    IronPython is *definitely* not restricted by the GIL.
                    >
                    IronPython is currently mostly slower than CPython although the
                    particular problem should be tested to see if IronPython helps.
                    >
                    Some recent benchmarks between IronPython and CPython:http://sparcs.kaist.ac.kr/~tinuviel/pybench/
                    Not when running on the .NET platform, there is not a lot of
                    difference overall:

                    http://www.voidspace.org.uk/python/w..._21.shtml#e688

                    Fuzzyman
                    http://www.voidspace.org.uk/ironpython/index.shtml
                    >
                    Neil

                    Comment

                    • Stefan Behnel

                      #11
                      Re: No speedup on multi-processor machine?

                      danfan1981@yaho o.com schrieb:
                      Thanks guys. But I think IronPython only works on Windows machine, but
                      I am using a Sun machine.
                      Isn't there a mono port for Sun?

                      Stefan

                      Comment

                      • Cameron Laird

                        #12
                        Re: No speedup on multi-processor machine?

                        In article <EdxWh.5224$2v1 .4151@newssvr14 .news.prodigy.n et>,
                        John Nagle <nagle@animats. comwrote:
                        >Caleb Hattingh wrote:
                        >On Apr 21, 11:02 pm, danfan1...@yaho o.com wrote:
                        >>
                        >>>Hi,
                        >>>I am using Python Thread library for my parallel processing course
                        >>>project. I am doing matrix convolution on a multi-processor machine
                        >>>running Solaris. I just found out that no speed-up is obtained with
                        >>>threading. It is probably because of something called GIL in Python.
                        >>>How can I get around
                        >>>that GIL and get speed-up?
                        >>>Thanks in advance.
                        >>>Daniel
                        >
                        If you're actually doing the convolution in Python, you need
                        >optimization before you need more CPUs. There's a numerics library
                        >for Python called NumPy, but it doesn't have a convolution function,
                        >although it has an FFT, which may be useful.
                        >
                        But this is just homework. Do something reasonable and turn it
                        >in. A high performance solution to this problem is probably more
                        >work than it's worth.
                        >
                        > John Nagle
                        Along with the excellent advice given by Dennis, John, and the
                        rest, please be aware that *process*-level parallelization of
                        a problem sometimes is a benefit. As already recommended, <URL:
                        http://wiki.python.org/moin/ParallelProcessing touches on most
                        of the pertinent concepts.

                        Comment

                        • Klaas

                          #13
                          Re: No speedup on multi-processor machine?

                          On Apr 21, 5:14 pm, Fuzzyman <fuzzy...@gmail .comwrote:
                          Additionally, extending IronPython from C# is orders of magnitude
                          easier than extending CPython from C.
                          Given the existence of Pyrex, that statement is pretty difficult to
                          substantiate.

                          -Mike

                          Comment

                          • Fuzzyman

                            #14
                            Re: No speedup on multi-processor machine?

                            On Apr 23, 9:52 pm, Klaas <mike.kl...@gma il.comwrote:
                            On Apr 21, 5:14 pm, Fuzzyman <fuzzy...@gmail .comwrote:
                            >
                            Additionally, extending IronPython from C# is orders of magnitude
                            easier than extending CPython from C.
                            >
                            Given the existence of Pyrex, that statement is pretty difficult to
                            substantiate.
                            >
                            With Pyrex you still need to do memory management for non-Python
                            types. Additionally compiling C# from within IronPython is *very*easy.

                            C# is a much easier language to use than C - even with the help of
                            Pyrex. You use types defined in C# *natively* within IronPython.

                            All the best,

                            Fuzzyman
                            http://www.voidspace.org.uk/python/articles.shtml
                            -Mike

                            Comment

                            • Jorgen Grahn

                              #15
                              Re: No speedup on multi-processor machine?

                              On 23 Apr 2007 13:52:52 -0700, Klaas <mike.klaas@gma il.comwrote:
                              On Apr 21, 5:14 pm, Fuzzyman <fuzzy...@gmail .comwrote:
                              >
                              >Additionally , extending IronPython from C# is orders of magnitude
                              >easier than extending CPython from C.
                              >
                              Given the existence of Pyrex, that statement is pretty difficult to
                              substantiate.
                              IMHO, you don't even need Pyrex. When you've done it manually once,
                              you have the blueprint for your other extension modules. Most of the
                              work should be normal "fake OOP in C" programming.

                              Doing it for the first time is another matter, however.

                              /Jorgen

                              --
                              // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
                              \X/ snipabacken.dyn dns.org R'lyeh wgah'nagl fhtagn!

                              Comment

                              Working...