How many threads one parquet_string_column bulk operation would use here, right now.
Public for the same reason pf_sort_threads is (feature_risks.md Risk-40): this is the
ONE place the cap and the OpenMP environment are combined, so a caller asking "what will this
do?" and the operation itself can never give different answers. A second reader is how the
two would come to disagree.
Three rules, in this order:
pf_sort_threads and parallel_prefetch_ok do. T threads
each asking for T more is slower than not threading at all, and nesting is the caller's
business. Note omp_get_max_threads() reads an ICV rather than the current team size, so
inside an 8-thread region it answers 8 and a missing check means 8x8.parquet_set_string_threads is HONOURED, bounded by what OpenMP
offers and by the CPU affinity this process actually has. A caller who names a number has
said what they want -- but a number the affinity mask cannot run is not something they can
have, and opening it would time-share the mask's processors rather than use more of them.
That last bound is parquet_clamp_to_affinity (src/parquet_settings_base.f90), shared with
sorting, table prefetching and the bulk random draws, and it warns once per process when it
bites.STRING_MAX_AUTO_THREADS, not taken as omp_get_max_threads(). See that constant for the
measurement; in short, a very large machine's full thread count is past the point where
this work stops scaling and is measurably worse than a fraction of it.The second rule differs from pf_sort_threads, deliberately, where a setting can only
ever lower the automatic answer. Sorting has no measured ceiling of its own, so there is
nothing for an explicit request to reach past; here there is, and refusing to honour it would
leave a caller on a 192-core machine unable to ask for the 128 threads that machine's own
measurement prefers.
integer function parquet_string_threads() result(n) integer :: cap, avail n = 1 avail = 1 #ifdef _OPENMP if (omp_in_parallel()) return avail = omp_get_max_threads() #endif cap = parquet_get_string_threads() if (cap > 0) then n = min(cap, avail) else n = min(string_max_auto(), avail) end if if (n < 1) n = 1 n = parquet_clamp_to_affinity(n, "string operations") end function parquet_string_threads