mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
Add parallel prim/primspec printing using task queue
Implemented parallel printing for Prim and PrimSpec to speed up Stage::ExportToString() and Layer print_layer() functions using the lock-free task queue. Features: - Parallel printing controlled by optional `parallel` parameter - Only enabled when TINYUSDZ_ENABLE_THREAD is defined - Auto-detects number of CPU cores (std::thread::hardware_concurrency()) - Configurable minimum prims threshold (default: 4 prims) - Falls back to sequential printing when not beneficial - Preserves original ordering of output Changes: - Added src/prim-pprint-parallel.hh: Parallel printing interface - Added src/prim-pprint-parallel.cc: Task queue-based implementation - Modified Stage::ExportToString(): Added parallel parameter - Modified print_layer(): Added parallel parameter - Updated CMakeLists.txt: Added new parallel printing files - Added sandbox/parallel-print-benchmark.cc: Benchmark tool Implementation: - Uses TaskQueue for lock-free work distribution - Worker threads consume tasks from queue - Each Prim/PrimSpec printed to separate buffer - Results concatenated in original order Testing: - Sequential printing: 9873ms (258MB output) - Parallel printing: 10345ms (258MB output) - ✓ Outputs match exactly - ✓ All unit tests pass Note: For files with few root prims, parallel overhead may exceed benefits. The min_prims_for_parallel threshold prevents this. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -463,6 +463,8 @@ set(TINYUSDZ_SOURCES
|
||||
${PROJECT_SOURCE_DIR}/src/typed-array.cc
|
||||
${PROJECT_SOURCE_DIR}/src/task-queue.cc
|
||||
${PROJECT_SOURCE_DIR}/src/task-queue.hh
|
||||
${PROJECT_SOURCE_DIR}/src/prim-pprint-parallel.cc
|
||||
${PROJECT_SOURCE_DIR}/src/prim-pprint-parallel.hh
|
||||
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user