[Sidefx-houdini-list] HDK: Parallel processing? multi processing?

jlait at sidefx.com jlait at sidefx.com
Wed Jul 2 11:57:43 EDT 2008

On Wed, Jul 02, 2008 at 04:30:08PM +0200, Tamis wrote:
> Hey people,
> I am a beginner programmer and i am playing around with the Houdini HDK.
> I have a question and it might sound stupid and i am probably not using
> the right terminology for what i am asking about but here i go...
> I am building my own little volume sampler to convert normal geometry
> into volumes.
> I know Houdini can already do this for me but i believe by doing this i
> can gather allot of knowledge.
> My algorithm is extremely simple so don't laugh :P
> 1. Loop threw all primitives for each voxol.
> 2. Find the closest primitive to the current voxol.
> 3. Dot product between primitive normal and normalized(voxol position -
> primitive position)
> 4. if <=0 then voxol density == 1;
> Now although there are some unresolved issues this seams to do the
> trick.
> The problem with this is is that it's a very slow process.
> So what i was wondering is: can i use the same kind of processing vex
> uses?(Parallel processing??)
> That is instead of letting 1 CPU loop threw all the voxols, divide the
> voxols between multiple CPU's and process it in parallel.
> I have no idea how to do this? Is there a generic way of doing this in C
> ++ for any application one would write? 
> Or is there some sort of way to let Houdini handle this?
> I thank you for your patience, Tamis van der Laan

    There is no nice standard way of doing this in C++.  We've built a
simple wrapper that can do a fair bit of the work for you in
UT_ThreadedAlgorithm.h, specifically the macros described as:

class Foobar
  THREADED_METHOD2(Foobar, gdp->points().entries() > 100,
                   GU_Detail *, gdp,
                   const UT_Vector3 &, delta)

  void translatePartial(GU_Detail *gdp, const UT_Vector3 &delta,
                        const UT_JobInfo &info);

Foobar::translatePartial(GU_Detail *gdp, const UT_Vector3 &delta,
                         const UT_JobInfo &info)
  int                i, n;

  for (info.divideWork(gdp->points().entries, i, n); i < n; i++)
      gdp->points()(i).getPos() += delta;

    Note, however, that it is imperative you only call threadsafe
functions from inside your Partial method.  And note that most of
Houdini's functions are *not* threadsafe.  
        - Jeff Lait

More information about the Sidefx-houdini-list mailing list