Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Using all processors

    Scheduled Pinned Locked Moved PYTHON Development
    6 Posts 0 Posters 448 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 12/05/2014 at 12:03, xxxxxxxx wrote:

      With a python tag plugin, I'm calculating voxels, so a lot of polygon handing.
      Now I see that cinema is not using all processors (only 1 out of 4) on my Windows 7 machine.
      When rendering it uses all processors, but not with my python tag plugin.
       
      What to do, so that cinema will use all processors?

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 12/05/2014 at 12:58, xxxxxxxx wrote:

        It's a CPython Limitation, read up on the GIL and Multiprocessing in Python.

        -Niklas

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 13/05/2014 at 01:08, xxxxxxxx wrote:

          So, in C++ cinema uses uses all / more processors?
          -Pim

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 13/05/2014 at 01:36, xxxxxxxx wrote:

            Hi pgrooff

            I guess that´s why e.g. supervoxels was written in c++.

            http://www.remotion4d.net/redokuwiki/doku.php?id=supervoxels2013

            Funny, I also created a voxelizer in the past few days.

            cheers
            Martin

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 13/05/2014 at 06:07, xxxxxxxx wrote:

              Originally posted by xxxxxxxx

              Funny, I also created a voxelizer in the past few days.

              Yes, it is quite a challenge, but fun.
              The main challenge is to optimize, improve the algorithm step by step.
              I am doing a prototype in python and then port it to C++.

              One of the things I like to do with the voxels, is to explode volumetric objects.

              Also with "supervoxels" you have threading option / nr of cores options. 
              Very advanced and interesting. But I guess you can divide the processing in parts and assign that to different threads (processors?).

              I saw your new post sharing your voxelizer. Great thanks.
              I do not use particle, but straight forward cubes.

              -Pim

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 14/05/2014 at 01:39, xxxxxxxx wrote:

                I´ve never used threads before and I´m not sure if I understand this right.
                If I open a new thread in c4d, is it only a user thread and not a Kernel thread?
                Does that mean that I'm only working on one Kernel and I just delegate tasks to several User threads?

                And is this the right usage, cause within the function it says that I´m still using the Main thread?

                  
                import c4d  
                from c4d.threading import C4DThread  
                  
                class firstThread(c4d.threading.C4DThread) :  
                  k=0  
                  def func1(self,k) :  
                      print  c4d.threading.GeIsMainThread(),"main"  
                        
                      for i in xrange(1,8000) :  
                          x=1000000/i  
                            
                          for j in xrange(1,1000) :  
                              y=1000000/j  
                              k=x*y  
                      print c.IsRunning(),"first inside"                      
                      return k  
                    
                class secondThread(c4d.threading.C4DThread) :  
                  o=0  
                  def func2(self,o) :  
                      print  c4d.threading.GeIsMainThread(),"main"  
                      for i in xrange(1,8000) :  
                          x=1000000/i  
                            
                          for j in xrange(1,1000) :  
                              y=1000000/j  
                              o=x*y  
                                             
                      return o  
                  
                    
                c= firstThread()  
                d= secondThread()  
                  
                #Start Threads      
                c.Start()  
                k= 0  
                print c.IsRunning(),"first"  
                  
                k= c.func1(op)   
                d.Start()  
                o= 0  
                print d.IsRunning(),"second"  
                o= d.func2(op)  
                  
                c.End()  
                d.End()  
                print o+k  
                

                Martin

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post