Alexey Smolenchuk

AlexeySmolenchuk

About Me

Connect

LOCATION
London, Not Specified
ウェブサイト

Houdini Engine

Availability

Not Specified

Recent Forum Posts

How to perform multithreaded GU_Detail->load() ? 2024年1月2日20:58

OK, seems I figured this out.
Looks like sort of initialize or license check supposed to happen before multi threaded execution.
When I'm adding
    GU_Detail *temp = new GU_Detail;
    delete temp;
in the beginning of my program it works fine.

Is there a clear way to do this?

How to perform multithreaded GU_Detail->load() ? 2024年1月2日20:16

cwhite
Loading bgeo files in parallel should be safe (as long as you're using separate GU_Detail's per thread, of course)

I've just tried with simplified example:
#include <omp.h>
#include <GU/GU_Detail.h>
#include <UT/UT_Exit.h>
#include <iostream>
#include <vector>

int main()
{
    std::vector<std::string> files = {
        "Flip.bgeo.sc",
        "pighead.bgeo.sc",
        "SquidCrab.bgeo.sc"
    };

    #pragma omp parallel for
    for ( int i = 0; i < 10; i++)
    {
        GU_Detail *gdp = new GU_Detail;
        if (gdp->load( files[ i%files.size() ].c_str() ).success())
            std::cout << "Loaded "<< gdp->getNumPoints() << " points in thread " << omp_get_thread_num() << std::endl;
        else
            std::cout << ":(" << std::endl;
            
        delete gdp;
    }

    UT_Exit::exit(UT_Exit::EXIT_OK);
    return 0;
}

This in my CMakeLists.txt:
find_package(OpenMP)
find_package(Houdini REQUIRED
PATHS ${HFS}/toolkit/cmake)

add_executable(standalone src/standalone.cpp)
target_link_libraries( standalone Houdini OpenMP::OpenMP_CXX)

Results on my Windows machine and HDK from 19.5.605:
:(
:(
:(
:(
Loaded 2789 points in thread 4
Loaded 12874 points in thread 6
Loaded 12874 points in thread 9
Loaded 20109 points in thread 5
Loaded 12874 points in thread 0
Loaded 20109 points in thread 8

Can someone please check it for sanity?

How to perform multithreaded GU_Detail->load() ? 2023年12月30日20:23

I'm trying to parallelize geometry loading in standalone application.
When I'm wrapping this call in OMP or TBB loops it's randomly failing

GU_Detail *gdp = new GU_Detail;
if (gdp->load( filename.c_str() ).success() ){
...
}

Is it possible to load several bgeo multithreaded?