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?
GU_Detail *gdp = new GU_Detail; if (gdp->load( filename.c_str() ).success() ){ ... }
cwhite
Loading bgeo files in parallel should be safe (as long as you're using separate GU_Detail's per thread, of course)
#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; }
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)
:(
:(
:(
:(
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