Jump to content

UT_ThreadSpecificValue help


Recommended Posts

Hi everyone. I'm trying to use UT_ThreadSpecificValue inside Threaded loop using UT_Parallel_for.

Every thread supposed to have some variable that is accumulated and after loop it's being summed up.

It all seems to work but it looks like values that are being accumulated indefinitely. What is the correct way of using it ?

I tried to set UT_ThreadSpecificValue back to 0.0 but looks like it doesn't do much.

Any help would be appreciated.

Code example:

static UT_ThreadSpecificValue<UT_Vector3D> temp

        GA_SplittableRange point_range(gdp->getPointRange());
        UTparallelFor(point_range, [&](const GA_SplittableRange& r)
        {

        setting variables...

            for (GA_Iterator it(r.begin()); !it.atEnd(); ++it)
            {

                GA_Offset ptoff = *it;

                UT_Vector3D myVector = temp.get();

                myVector+=1;

                temp.get()=myVector;

           }

            for (UT_Vector3D value : temp)
            {
                x_var+= temp.x();
                y_var+= temp.y();
                z_var+= temp.z();
            }

...

UPDATE: resetting values with temp.clear() before loop works but whenever I change any parameter on a node repeatedly , Houdini crashes.

Edited by maxpayne
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...