parquet_set_table_threads Subroutine

public subroutine parquet_set_table_threads(n)

Sets the cap on how many threads a parquet_table's row-structural mutation may use to rewrite its columns concurrently -- %sort_by, %filter_rows, %top_n, and %delete_rows and %truncate, which go through the same loop.

Read per mutation, so it takes effect immediately. 0 restores automatic behaviour. The value is a cap: the mutation never uses more threads than OpenMP offers, and never more than the table has columns to rewrite, so setting this higher than OMP_NUM_THREADS changes nothing. 1 makes the mutation serial, which is also what happens automatically inside an existing parallel region, on a table with fewer than two rewritable columns, and on a table too small to be worth a thread team.

This is also the memory control. Each thread rewriting a column holds a transient second copy of it, so n threads hold n copies rather than one. Since the count is bounded by the column count, the transient copies come to at most one extra copy of the table -- a whole-column rewrite (%sort_by) can therefore double the table's peak memory for the duration of the call. A program near its memory ceiling caps the threads here, which caps the copies with them.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

thread cap, or 0 for automatic; must be >= 0.


Source Code

    subroutine parquet_set_table_threads(n)
        integer, intent(in) :: n !! thread cap, or 0 for automatic; must be >= 0.

        if (n < 0) error stop "parquet_set_table_threads: n must be >= 0 (0 means automatic)"
        cfg_table_threads = n
    end subroutine parquet_set_table_threads