Hi everyone. I've got some logic running over points. That logic involves accessing neighbor points and setting some attributes. If I use GA_SplittableRange that causes race condition in this situation so my idea is to split point cloud to n-groups(~threads count), run them in parallel and then do some logic as a final step.
I came across UT_TaskGroup(). Is that one way of doing it ?
Thank you.
HDK Multithreading over point groups(one thread - one group)
555 6 0-
- maxpayne
- Member
- 53 posts
- Joined: Dec. 2010
- Offline
-
- johnmather
- Staff
- 718 posts
- Joined: Aug. 2019
- Offline
Be sure to check this page: https://www.sidefx.com/docs/hdk/_h_d_k__g_a__using.html#HDK_GA_Using_Parallel [www.sidefx.com]
For foreach-style algorithms, the simplest approach is to use GAparallelForEachPage() which provides a higher-level API that is convenient to use with lambdas.
-
- maxpayne
- Member
- 53 posts
- Joined: Dec. 2010
- Offline
-
- Umang_Raj
- Member
- 68 posts
- Joined: March 2024
- Offline
maxpayneyou don't have to build a splitted range for the function john sir showed to you, as much as i know, it is meant to run on each pages parallely, pages as i know are the way houdini stores the attribute data, they are contiguos blocks of data and have a fixed size (1024 elements, you can see it in ga_types header), and the page handle gives you direct access to the data from memory (read the attributes 101 in docs), and it will be the fastest way to read/write attribute.
Hi johnmather. Thank you for the link. I've actually seen this but I can't figure out how to build 'Range' out of point groups or it can be Array or a list of Ranges ?
Thank you
here is the test code i tried-
GU_Detail* gdp = parms.gdh().gdpNC(); GA_Range pointRange = gdp->getPointRange(); GAparallelForEachPage(pointRange, true, [&](GA_PageIterator it){ std::cerr << "page off-" << it.getFirstOffsetInPage() << std::endl; });
page off-0
page off-1024
page off-2048
page off-3072
page off-4096
page off-5120
page off-page off-61447168
(some lines overlap because it is parallel)
-
- maxpayne
- Member
- 53 posts
- Joined: Dec. 2010
- Offline
Hi Umang_Raj. Thank you for the explanation. That is more clear now. I guess that won't work in my case then. I'm now thinking that my initial question was a bit misleading.
I have point groups. pt_group_0 pt_group_1 etc. Each group has mutually exclusive points. I want to run some logic on each group of points but in parallel and so they don't overlap each other. So one thread takes care of one group(as an example).
Creating GA_Range using those groups works but it contains only one range at a time. How to run over all those ranges?
I have point groups. pt_group_0 pt_group_1 etc. Each group has mutually exclusive points. I want to run some logic on each group of points but in parallel and so they don't overlap each other. So one thread takes care of one group(as an example).
Creating GA_Range using those groups works but it contains only one range at a time. How to run over all those ranges?
Edited by maxpayne - July 10, 2026 16:17:18
-
- BabaJ
- Member
- 2184 posts
- Joined: Sept. 2015
- Offline
What I need is to split point cloud to n - point groups (specifically Point groups). pt_group_0 pt_group_1 etc.
Yes, you can do that:
vex wrangle;
if( @ptnum < x && @ptnum > y ) i@group_Specific_Group_A = 1; if( @ptnum < z && @ptnum > u ) i@group_Specific_Group_B = 1; ....; ....; // " ...@ptnum < z && @ptnum > u ..." being any type of conditional you need to define.
Edited by BabaJ - July 10, 2026 13:22:05
-
- maxpayne
- Member
- 53 posts
- Joined: Dec. 2010
- Offline
It loos like I've got something working.
class moveUp
{
...
Getting current range from the array of UT_Array<GA_Range>
looping over that range of points and doing something
...
};
groupRangesArray has several UT_Array<GA_Range> made of point groups.
UT_BlockedRange<exint> groupsRange(0, groupRangesArray.entries());
moveUp MoveUpWorker(&groupRangesArray, gdp);
UTparallelForLightItems(groupsRange, MoveUpWorker, true);
UTparallelForHeavyItems is deprecated but UTparallelForEachNumber gives me weird behavior but I didn't look into it yet.
It would be great if someone could confirm that this is the right way of doing it or it doesn't make sense.
class moveUp
{
...
Getting current range from the array of UT_Array<GA_Range>
looping over that range of points and doing something
...
};
groupRangesArray has several UT_Array<GA_Range> made of point groups.
UT_BlockedRange<exint> groupsRange(0, groupRangesArray.entries());
moveUp MoveUpWorker(&groupRangesArray, gdp);
UTparallelForLightItems(groupsRange, MoveUpWorker, true);
UTparallelForHeavyItems is deprecated but UTparallelForEachNumber gives me weird behavior but I didn't look into it yet.
It would be great if someone could confirm that this is the right way of doing it or it doesn't make sense.
Edited by maxpayne - July 14, 2026 13:22:49
-
- Quick Links


