dtfft_config Module

Configuration module for dtFFT. It handles both runtime (environment variables) and compile-time (dtfft_config_t) configurations.


Uses

  • module~~dtfft_config~~UsesGraph module~dtfft_config dtfft_config iso_c_binding iso_c_binding module~dtfft_config->iso_c_binding iso_fortran_env iso_fortran_env module~dtfft_config->iso_fortran_env module~dtfft_errors dtfft_errors module~dtfft_config->module~dtfft_errors module~dtfft_interface_cuda_runtime dtfft_interface_cuda_runtime module~dtfft_config->module~dtfft_interface_cuda_runtime module~dtfft_parameters dtfft_parameters module~dtfft_config->module~dtfft_parameters module~dtfft_utils dtfft_utils module~dtfft_config->module~dtfft_utils mpi_f08 mpi_f08 module~dtfft_config->mpi_f08 module~dtfft_errors->iso_fortran_env module~dtfft_interface_cuda_runtime->iso_c_binding module~dtfft_interface_cuda_runtime->module~dtfft_parameters module~dtfft_interface_cuda_runtime->module~dtfft_utils module~dtfft_parameters->iso_c_binding module~dtfft_parameters->iso_fortran_env module~dtfft_parameters->mpi_f08 module~dtfft_utils->iso_c_binding module~dtfft_utils->iso_fortran_env module~dtfft_utils->module~dtfft_errors module~dtfft_utils->module~dtfft_parameters module~dtfft_utils->mpi_f08

Used by

  • module~~dtfft_config~~UsedByGraph module~dtfft_config dtfft_config module~dtfft dtfft module~dtfft->module~dtfft_config module~dtfft_plan dtfft_plan module~dtfft->module~dtfft_plan module~dtfft_abstract_backend dtfft_abstract_backend module~dtfft_abstract_backend->module~dtfft_config module~dtfft_nvrtc_kernel dtfft_nvrtc_kernel module~dtfft_abstract_backend->module~dtfft_nvrtc_kernel module~dtfft_abstract_transpose_plan dtfft_abstract_transpose_plan module~dtfft_abstract_transpose_plan->module~dtfft_config module~dtfft_abstract_transpose_plan->module~dtfft_abstract_backend module~dtfft_abstract_transpose_plan->module~dtfft_nvrtc_kernel module~dtfft_api dtfft_api module~dtfft_api->module~dtfft_config module~dtfft_api->module~dtfft_plan module~dtfft_executor_cufft_m dtfft_executor_cufft_m module~dtfft_executor_cufft_m->module~dtfft_config module~dtfft_executor_vkfft_m dtfft_executor_vkfft_m module~dtfft_executor_vkfft_m->module~dtfft_config module~dtfft_nvrtc_block_optimizer dtfft_nvrtc_block_optimizer module~dtfft_nvrtc_block_optimizer->module~dtfft_config module~dtfft_nvrtc_kernel->module~dtfft_config module~dtfft_nvrtc_kernel->module~dtfft_nvrtc_block_optimizer module~dtfft_nvrtc_kernel_cache dtfft_nvrtc_kernel_cache module~dtfft_nvrtc_kernel->module~dtfft_nvrtc_kernel_cache module~dtfft_nvrtc_kernel_generator dtfft_nvrtc_kernel_generator module~dtfft_nvrtc_kernel->module~dtfft_nvrtc_kernel_generator module~dtfft_nvrtc_kernel_cache->module~dtfft_config module~dtfft_plan->module~dtfft_config module~dtfft_plan->module~dtfft_abstract_transpose_plan module~dtfft_plan->module~dtfft_executor_cufft_m module~dtfft_plan->module~dtfft_executor_vkfft_m module~dtfft_transpose_plan_cuda dtfft_transpose_plan_cuda module~dtfft_plan->module~dtfft_transpose_plan_cuda module~dtfft_transpose_plan_host dtfft_transpose_plan_host module~dtfft_plan->module~dtfft_transpose_plan_host module~dtfft_transpose_plan_cuda->module~dtfft_config module~dtfft_transpose_plan_cuda->module~dtfft_abstract_backend module~dtfft_transpose_plan_cuda->module~dtfft_abstract_transpose_plan module~dtfft_transpose_plan_cuda->module~dtfft_nvrtc_kernel_cache module~dtfft_transpose_handle_cuda dtfft_transpose_handle_cuda module~dtfft_transpose_plan_cuda->module~dtfft_transpose_handle_cuda module~dtfft_transpose_plan_host->module~dtfft_config module~dtfft_transpose_plan_host->module~dtfft_abstract_transpose_plan module~dtfft_backend_cufftmp_m dtfft_backend_cufftmp_m module~dtfft_backend_cufftmp_m->module~dtfft_abstract_backend module~dtfft_backend_mpi dtfft_backend_mpi module~dtfft_backend_mpi->module~dtfft_abstract_backend module~dtfft_backend_nccl_m dtfft_backend_nccl_m module~dtfft_backend_nccl_m->module~dtfft_abstract_backend module~dtfft_nvrtc_kernel_generator->module~dtfft_nvrtc_block_optimizer module~dtfft_transpose_handle_cuda->module~dtfft_abstract_backend module~dtfft_transpose_handle_cuda->module~dtfft_nvrtc_kernel module~dtfft_transpose_handle_cuda->module~dtfft_backend_cufftmp_m module~dtfft_transpose_handle_cuda->module~dtfft_backend_mpi module~dtfft_transpose_handle_cuda->module~dtfft_backend_nccl_m

Variables

Type Visibility Attributes Name Initial
logical, private, save :: is_init_called = .false.

Has init_internal already been called or not

integer(kind=int32), private, save :: log_enabled_from_env

Should we log messages to stdout or not

type(dtfft_platform_t), private, save :: platform_from_env = PLATFORM_NOT_SET

Platform obtained from environ

integer(kind=int32), private, save :: z_slab_from_env

Should Z-slab be used if possible

integer(kind=int32), private, save :: n_measure_warmup_iters_from_env

Number of warmup iterations for measurements

integer(kind=int32), private, save :: n_measure_iters_from_env

Number of measurement iterations

logical, private, save :: is_log_enabled = .false.

Should we print additional information during plan creation

logical, private, save :: is_z_slab_enabled = .true.

Should we use z-slab decomposition or not

type(dtfft_platform_t), private, save :: platform = DTFFT_PLATFORM_HOST

Default platform

integer(kind=int32), private, save :: n_measure_warmup_iters = 2

Number of warmup iterations for measurements

integer(kind=int32), private, save :: n_measure_iters = 5

Number of measurement iterations

type(dtfft_backend_t), private, save :: backend_from_env

Backend obtained from environ

integer(kind=int32), private, save :: mpi_enabled_from_env

Should we use MPI backends during autotune or not

integer(kind=int32), private, save :: nccl_enabled_from_env

Should we use NCCL backends during autotune or not

integer(kind=int32), private, save :: nvshmem_enabled_from_env

Should we use NVSHMEM backends during autotune or not

integer(kind=int32), private, save :: pipelined_enabled_from_env

Should we use pipelined backends during autotune or not

integer(kind=int32), private, save :: kernel_optimization_enabled_from_env

Should we enable kernel block optimization during autotune or not

integer(kind=int32), private, save :: n_configs_to_test_from_env

Number of blocks to test during nvrtc kernel autotune

integer(kind=int32), private, save :: forced_kernel_optimization_from_env
type(dtfft_backend_t), private, parameter :: DEFAULT_GPU_BACKEND = DTFFT_BACKEND_NCCL

Default GPU backend

type(dtfft_stream_t), private, save :: main_stream

Default dtFFT CUDA stream

type(dtfft_stream_t), private, save :: custom_stream

CUDA stream set by the user

logical, private, save :: is_stream_created = .false.

Is the default stream created?

logical, private, save :: is_custom_stream = .false.

Is the custom stream provided by the user?

logical, private, save :: is_pipelined_enabled = .true.

Should we use pipelined backends or not

logical, private, save :: is_mpi_enabled = .false.

Should we use MPI backends or not

logical, private, save :: is_nccl_enabled = .true.

Should we use NCCL backends or not

logical, private, save :: is_nvshmem_enabled = .true.

Should we use NCCL backends or not

logical, private, save :: is_kernel_optimization_enabled = .true.

Should we use kernel optimization or not

integer(kind=int32), private, save :: n_configs_to_test = 5

Number of different NVRTC kernel configurations to try during autotune

logical, private, save :: is_forced_kernel_optimization = .false.

Should we use forced kernel optimization or not

type(dtfft_backend_t), private, save :: backend = DEFAULT_GPU_BACKEND

Default GPU backend

character(len=26), private, parameter :: UPPER_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

Upper case alphabet.

character(len=26), private, parameter :: LOWER_ALPHABET = 'abcdefghijklmnopqrstuvwxyz'

Lower case alphabet.


Interfaces

public interface dtfft_config_t

Interface to create a new configuration

  • private pure function config_constructor(enable_log, enable_z_slab, n_measure_warmup_iters, n_measure_iters, platform, stream, backend, enable_mpi_backends, enable_pipelined_backends, enable_nccl_backends, enable_nvshmem_backends, enable_kernel_optimization, n_configs_to_test, force_kernel_optimization) result(config)

    Creates a new configuration

    Arguments

    Type IntentOptional Attributes Name
    logical, intent(in), optional :: enable_log

    Should dtFFT use Z-slab optimization or not.

    logical, intent(in), optional :: enable_z_slab

    Should dtFFT use Z-slab optimization or not.

    integer(kind=int32), intent(in), optional :: n_measure_warmup_iters

    Number of warmup iterations for measurements

    integer(kind=int32), intent(in), optional :: n_measure_iters

    Number of measurement iterations

    type(dtfft_platform_t), intent(in), optional :: platform

    Selects platform to execute plan.

    type(dtfft_stream_t), intent(in), optional :: stream

    Main CUDA stream that will be used in dtFFT.

    type(dtfft_backend_t), intent(in), optional :: backend

    Backend that will be used by dtFFT when effort is DTFFT_ESTIMATE or DTFFT_MEASURE.

    logical, intent(in), optional :: enable_mpi_backends

    Should MPI GPU Backends be enabled when effort is DTFFT_PATIENT or not.

    logical, intent(in), optional :: enable_pipelined_backends

    Should pipelined GPU backends be enabled when effort is DTFFT_PATIENT or not.

    logical, intent(in), optional :: enable_nccl_backends

    Should NCCL Backends be enabled when effort is DTFFT_PATIENT or not.

    logical, intent(in), optional :: enable_nvshmem_backends

    Should NVSHMEM Backends be enabled when effort is DTFFT_PATIENT or not.

    logical, intent(in), optional :: enable_kernel_optimization

    Should dtFFT try to optimize NVRTC kernel block size during autotune or not.

    integer(kind=int32), intent(in), optional :: n_configs_to_test

    Number of top theoretical best performing blocks of threads to test for transposition kernels when effort is DTFFT_PATIENT.

    logical, intent(in), optional :: force_kernel_optimization

    Whether to force kernel optimization when effort is not DTFFT_PATIENT.

    Return Value type(dtfft_config_t)

    Constructed dtFFT config ready to be set by call to dtfft_set_config

public interface get_env

Obtains environment variable

  • private function get_env_base(name) result(env)

    Base function of obtaining dtFFT environment variable

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: name

    Name of environment variable without prefix

    Return Value type(string)

    Environment variable value

  • private function get_env_string(name, default, valid_values) result(env)

    Obtains string environment variable

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: name

    Name of environment variable without prefix

    character(len=*), intent(in) :: default

    Name of environment variable without prefix

    type(string), intent(in) :: valid_values(:)

    List of valid variable values

    Return Value character(len=:), allocatable

    Environment variable value

  • private function get_env_int32(name, default, valid_values, min_valid_value) result(env)

    Base Integer function of obtaining dtFFT environment variable

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: name

    Name of environment variable without prefix

    integer(kind=int32), intent(in) :: default

    Default value in case env is not set or it has wrong value

    integer(kind=int32), intent(in), optional :: valid_values(:)

    List of valid values

    integer(kind=int32), intent(in), optional :: min_valid_value

    Mininum valid value. Usually 0 or 1

    Return Value integer(kind=int32)

  • private function get_env_int8(name, default, valid_values) result(env)

    Obtains int8 environment variable

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: name

    Name of environment variable without prefix

    integer(kind=int8), intent(in) :: default

    Default value in case env is not set or it has wrong value

    integer(kind=int32), intent(in) :: valid_values(:)

    List of valid values

    Return Value integer(kind=int8)

  • private function get_env_logical(name, default) result(env)

    Obtains logical environment variable

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: name

    Name of environment variable without prefix

    logical, intent(in) :: default

    Default value in case env is not set or it has wrong value

    Return Value logical

private interface get_conf_internal

Returns value from configuration unless environment variable is set

  • private elemental function get_conf_internal_logical(from_conf, from_env)

    Returns value from configuration unless environment variable is set

    Arguments

    Type IntentOptional Attributes Name
    logical, intent(in) :: from_conf

    Value from configuration

    integer(kind=int32), intent(in) :: from_env

    Value from environment variable

    Return Value logical

  • private elemental function get_conf_internal_int32(from_conf, from_env)

    Returns value from configuration unless environment variable is set

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: from_conf

    Value from configuration

    integer(kind=int32), intent(in) :: from_env

    Value from environment variable

    Return Value integer(kind=int32)


Derived Types

type, public, bind(C) ::  dtfft_config_t

Type that can be used to set additional configuration parameters to dtFFT

Components

Type Visibility Attributes Name Initial
logical(kind=c_bool), public :: enable_log

Should dtFFT print additional information during plan creation or not.

Read more…
logical(kind=c_bool), public :: enable_z_slab

Should dtFFT use Z-slab optimization or not.

Read more…
integer(kind=c_int32_t), public :: n_measure_warmup_iters

Number of warmup iterations to execute when effort level is higher or equal to DTFFT_MEASURE

Read more…
integer(kind=c_int32_t), public :: n_measure_iters

Number of iterations to execute when effort level is higher or equal to DTFFT_MEASURE

Read more…
type(dtfft_platform_t), public :: platform

Selects platform to execute plan.

Read more…
type(dtfft_stream_t), public :: stream

Main CUDA stream that will be used in dtFFT.

Read more…
type(dtfft_backend_t), public :: backend

Backend that will be used by dtFFT when effort is DTFFT_ESTIMATE or DTFFT_MEASURE.

Read more…
logical(kind=c_bool), public :: enable_mpi_backends

Should MPI GPU Backends be enabled when effort is DTFFT_PATIENT or not.

Read more…
logical(kind=c_bool), public :: enable_pipelined_backends

Should pipelined GPU backends be enabled when effort is DTFFT_PATIENT or not.

Read more…
logical(kind=c_bool), public :: enable_nccl_backends

Should NCCL Backends be enabled when effort is DTFFT_PATIENT or not.

Read more…
logical(kind=c_bool), public :: enable_nvshmem_backends

Should NVSHMEM Backends be enabled when effort is DTFFT_PATIENT or not.

Read more…
logical(kind=c_bool), public :: enable_kernel_optimization

Should dtFFT try to optimize NVRTC kernel block size when effort is DTFFT_PATIENT or not.

Read more…
integer(kind=c_int32_t), public :: n_configs_to_test

Number of top theoretical best performing blocks of threads to test for transposition kernels when effort is DTFFT_PATIENT or force_kernel_optimization set to true.

Read more…
logical(kind=c_bool), public :: force_kernel_optimization

Whether to force kernel optimization when effort is not DTFFT_PATIENT.

Read more…

Constructor

Interface to create a new configuration

private pure function config_constructor (enable_log, enable_z_slab, n_measure_warmup_iters, n_measure_iters, platform, stream, backend, enable_mpi_backends, enable_pipelined_backends, enable_nccl_backends, enable_nvshmem_backends, enable_kernel_optimization, n_configs_to_test, force_kernel_optimization)

Creates a new configuration


Functions

public function init_internal()

Checks if MPI is initialized and loads environment variables

Arguments

None

Return Value integer(kind=int32)

public elemental function get_conf_log_enabled() result(bool)

Whether logging is enabled or not

Arguments

None

Return Value logical

Result flag

public elemental function get_conf_z_slab_enabled() result(bool)

Whether Z-slab optimization is enabled or not

Arguments

None

Return Value logical

Result flag

public elemental function get_conf_measure_warmup_iters() result(iters)

Returns the number of warmup iterations

Arguments

None

Return Value integer(kind=int32)

Result

public elemental function get_conf_measure_iters() result(iters)

Returns the number of measurement iterations

Arguments

None

Return Value integer(kind=int32)

Result

public elemental function get_conf_platform()

Returns platform set by the user or default one

Arguments

None

Return Value type(dtfft_platform_t)

public function get_conf_stream() result(stream)

Returns either the custom provided by user or creates a new one

Arguments

None

Return Value type(dtfft_stream_t)

public elemental function get_conf_backend()

Returns GPU backend set by the user or default one

Arguments

None

Return Value type(dtfft_backend_t)

public elemental function get_conf_pipelined_enabled() result(bool)

Whether pipelined backends are enabled or not

Arguments

None

Return Value logical

Result flag

public elemental function get_conf_mpi_enabled() result(bool)

Whether MPI backends are enabled or not

Arguments

None

Return Value logical

Result flag

public elemental function get_conf_nccl_enabled() result(bool)

Whether NCCL backends are enabled or not

Arguments

None

Return Value logical

Result flag

public elemental function get_conf_nvshmem_enabled() result(bool)

Whether nvshmem backends are enabled or not

Arguments

None

Return Value logical

Result flag

public elemental function get_conf_kernel_optimization_enabled() result(bool)

Whether kernel optimization is enabled or not

Arguments

None

Return Value logical

Result flag

public pure function get_conf_configs_to_test() result(n)

Returns the number of configurations to test

Arguments

None

Return Value integer(kind=int32)

Result

public elemental function get_conf_forced_kernel_optimization() result(bool)

Whether forced kernel optimization is enabled or not

Arguments

None

Return Value logical

Result flag

public function get_datatype_from_env(name) result(env)

Obtains datatype id from environment variable

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Name of environment variable without prefix

Return Value integer(kind=int8)

private pure function config_constructor(enable_log, enable_z_slab, n_measure_warmup_iters, n_measure_iters, platform, stream, backend, enable_mpi_backends, enable_pipelined_backends, enable_nccl_backends, enable_nvshmem_backends, enable_kernel_optimization, n_configs_to_test, force_kernel_optimization) result(config)

Creates a new configuration

Arguments

Type IntentOptional Attributes Name
logical, intent(in), optional :: enable_log

Should dtFFT use Z-slab optimization or not.

logical, intent(in), optional :: enable_z_slab

Should dtFFT use Z-slab optimization or not.

integer(kind=int32), intent(in), optional :: n_measure_warmup_iters

Number of warmup iterations for measurements

integer(kind=int32), intent(in), optional :: n_measure_iters

Number of measurement iterations

type(dtfft_platform_t), intent(in), optional :: platform

Selects platform to execute plan.

type(dtfft_stream_t), intent(in), optional :: stream

Main CUDA stream that will be used in dtFFT.

type(dtfft_backend_t), intent(in), optional :: backend

Backend that will be used by dtFFT when effort is DTFFT_ESTIMATE or DTFFT_MEASURE.

logical, intent(in), optional :: enable_mpi_backends

Should MPI GPU Backends be enabled when effort is DTFFT_PATIENT or not.

logical, intent(in), optional :: enable_pipelined_backends

Should pipelined GPU backends be enabled when effort is DTFFT_PATIENT or not.

logical, intent(in), optional :: enable_nccl_backends

Should NCCL Backends be enabled when effort is DTFFT_PATIENT or not.

logical, intent(in), optional :: enable_nvshmem_backends

Should NVSHMEM Backends be enabled when effort is DTFFT_PATIENT or not.

logical, intent(in), optional :: enable_kernel_optimization

Should dtFFT try to optimize NVRTC kernel block size during autotune or not.

integer(kind=int32), intent(in), optional :: n_configs_to_test

Number of top theoretical best performing blocks of threads to test for transposition kernels when effort is DTFFT_PATIENT.

logical, intent(in), optional :: force_kernel_optimization

Whether to force kernel optimization when effort is not DTFFT_PATIENT.

Return Value type(dtfft_config_t)

Constructed dtFFT config ready to be set by call to dtfft_set_config

private elemental function get_conf_internal_logical(from_conf, from_env)

Returns value from configuration unless environment variable is set

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: from_conf

Value from configuration

integer(kind=int32), intent(in) :: from_env

Value from environment variable

Return Value logical

private elemental function get_conf_internal_int32(from_conf, from_env)

Returns value from configuration unless environment variable is set

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: from_conf

Value from configuration

integer(kind=int32), intent(in) :: from_env

Value from environment variable

Return Value integer(kind=int32)

private function get_env_base(name) result(env)

Base function of obtaining dtFFT environment variable

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Name of environment variable without prefix

Return Value type(string)

Environment variable value

private function get_env_string(name, default, valid_values) result(env)

Obtains string environment variable

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Name of environment variable without prefix

character(len=*), intent(in) :: default

Name of environment variable without prefix

type(string), intent(in) :: valid_values(:)

List of valid variable values

Return Value character(len=:), allocatable

Environment variable value

private function get_env_int32(name, default, valid_values, min_valid_value) result(env)

Base Integer function of obtaining dtFFT environment variable

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Name of environment variable without prefix

integer(kind=int32), intent(in) :: default

Default value in case env is not set or it has wrong value

integer(kind=int32), intent(in), optional :: valid_values(:)

List of valid values

integer(kind=int32), intent(in), optional :: min_valid_value

Mininum valid value. Usually 0 or 1

Return Value integer(kind=int32)

private function get_env_int8(name, default, valid_values) result(env)

Obtains int8 environment variable

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Name of environment variable without prefix

integer(kind=int8), intent(in) :: default

Default value in case env is not set or it has wrong value

integer(kind=int32), intent(in) :: valid_values(:)

List of valid values

Return Value integer(kind=int8)

private function get_env_logical(name, default) result(env)

Obtains logical environment variable

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Name of environment variable without prefix

logical, intent(in) :: default

Default value in case env is not set or it has wrong value

Return Value logical


Subroutines

public pure subroutine dtfft_create_config(config) bind(C, name="dtfft_create_config_c")

Creates a new configuration and sets default values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(dtfft_config_t), intent(out) :: config

Configuration to create

public subroutine dtfft_set_config(config, error_code)

Sets configuration parameters

Arguments

Type IntentOptional Attributes Name
type(dtfft_config_t), intent(in) :: config

Configuration to set

integer(kind=int32), intent(out), optional :: error_code

Error code

public subroutine destroy_stream()

Destroy the default stream if it was created

Arguments

None

private subroutine init_environment()

Arguments

None