|TIFF and LibTiff Mail List Archive|
LibTiff Mailing List
2015.01.05 15:05 "Re: [Tiff] Fast TIFF Reading on Windows", by Bob Friesenhahn
> Actually, this would be a perfect job for OpenMP. And you wouldn't need a thread safe list, just divide up the > strips evenly across threads.
Libtiff does not use any locking or use thread-specific contexts so I think it is definitely not safe for using code to request multiple strips from the same image at a time with the same tiff handle using multiple threads. It should be mostly safe to read multiple images at one time (different tiff handles) using multiple threads. It should be safe to open the same input TIFF file several times so that there is a different handle for each reading thread. The threads would then need to agree on which strips/tiles they would read.
It would be good for libtiff to support multiple strip/tile reads at a time using the same handle in different threads. This would require thread-specific context and some locking.
Regardless, in my own experience, libtiff strip/tile reads are quite fast and the bottleneck is normally in the using code. Using a semaphore to protect tiff handle use would allow multiple threads to use libtiff to obtain strips/tiles and threads can be dealing with data returned while one thread is getting the next strip/tile. This could result in a 2X to 4X speed-up.