dtfft_utils Module

All Utilities functions are located here


Uses

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

Used by

  • module~~dtfft_utils~~UsedByGraph module~dtfft_utils dtfft_utils module~dtfft_abstract_backend dtfft_abstract_backend module~dtfft_abstract_backend->module~dtfft_utils module~dtfft_config dtfft_config module~dtfft_abstract_backend->module~dtfft_config module~dtfft_interface_cuda_runtime dtfft_interface_cuda_runtime module~dtfft_abstract_backend->module~dtfft_interface_cuda_runtime module~dtfft_interface_nccl dtfft_interface_nccl module~dtfft_abstract_backend->module~dtfft_interface_nccl module~dtfft_nvrtc_kernel dtfft_nvrtc_kernel module~dtfft_abstract_backend->module~dtfft_nvrtc_kernel module~dtfft_pencil dtfft_pencil module~dtfft_abstract_backend->module~dtfft_pencil module~dtfft_abstract_executor dtfft_abstract_executor module~dtfft_abstract_executor->module~dtfft_utils module~dtfft_interface_nvtx dtfft_interface_nvtx module~dtfft_abstract_executor->module~dtfft_interface_nvtx module~dtfft_abstract_executor->module~dtfft_pencil module~dtfft_abstract_transpose_plan dtfft_abstract_transpose_plan module~dtfft_abstract_transpose_plan->module~dtfft_utils module~dtfft_abstract_transpose_plan->module~dtfft_abstract_backend module~dtfft_abstract_transpose_plan->module~dtfft_config module~dtfft_abstract_transpose_plan->module~dtfft_interface_cuda_runtime module~dtfft_abstract_transpose_plan->module~dtfft_interface_nccl module~dtfft_interface_nvshmem dtfft_interface_nvshmem module~dtfft_abstract_transpose_plan->module~dtfft_interface_nvshmem module~dtfft_abstract_transpose_plan->module~dtfft_interface_nvtx module~dtfft_abstract_transpose_plan->module~dtfft_nvrtc_kernel module~dtfft_abstract_transpose_plan->module~dtfft_pencil module~dtfft_api dtfft_api module~dtfft_api->module~dtfft_utils module~dtfft_api->module~dtfft_config module~dtfft_api->module~dtfft_pencil module~dtfft_plan dtfft_plan module~dtfft_api->module~dtfft_plan module~dtfft_backend_cufftmp_m dtfft_backend_cufftmp_m module~dtfft_backend_cufftmp_m->module~dtfft_utils module~dtfft_backend_cufftmp_m->module~dtfft_abstract_backend module~dtfft_backend_cufftmp_m->module~dtfft_interface_cuda_runtime module~dtfft_interface_cufft dtfft_interface_cufft module~dtfft_backend_cufftmp_m->module~dtfft_interface_cufft module~dtfft_backend_cufftmp_m->module~dtfft_interface_nvshmem module~dtfft_backend_cufftmp_m->module~dtfft_pencil module~dtfft_backend_mpi dtfft_backend_mpi module~dtfft_backend_mpi->module~dtfft_utils module~dtfft_backend_mpi->module~dtfft_abstract_backend module~dtfft_backend_mpi->module~dtfft_interface_cuda_runtime module~dtfft_backend_nccl_m dtfft_backend_nccl_m module~dtfft_backend_nccl_m->module~dtfft_utils module~dtfft_backend_nccl_m->module~dtfft_abstract_backend module~dtfft_backend_nccl_m->module~dtfft_interface_cuda_runtime module~dtfft_backend_nccl_m->module~dtfft_interface_nccl module~dtfft_config->module~dtfft_utils module~dtfft_config->module~dtfft_interface_cuda_runtime module~dtfft_executor_cufft_m dtfft_executor_cufft_m module~dtfft_executor_cufft_m->module~dtfft_utils module~dtfft_executor_cufft_m->module~dtfft_abstract_executor module~dtfft_executor_cufft_m->module~dtfft_config module~dtfft_executor_cufft_m->module~dtfft_interface_cuda_runtime module~dtfft_executor_cufft_m->module~dtfft_interface_cufft module~dtfft_executor_fftw_m dtfft_executor_fftw_m module~dtfft_executor_fftw_m->module~dtfft_utils module~dtfft_executor_fftw_m->module~dtfft_abstract_executor module~dtfft_executor_fftw_m->module~dtfft_pencil module~dtfft_executor_mkl_m dtfft_executor_mkl_m module~dtfft_executor_mkl_m->module~dtfft_utils module~dtfft_executor_mkl_m->module~dtfft_abstract_executor module~dtfft_interface_mkl_m dtfft_interface_mkl_m module~dtfft_executor_mkl_m->module~dtfft_interface_mkl_m module~dtfft_interface_cuda dtfft_interface_cuda module~dtfft_interface_cuda->module~dtfft_utils module~dtfft_interface_cuda_runtime->module~dtfft_utils module~dtfft_interface_cufft->module~dtfft_utils module~dtfft_interface_mkl_m->module~dtfft_utils module~dtfft_interface_nccl->module~dtfft_utils module~dtfft_interface_nvrtc dtfft_interface_nvrtc module~dtfft_interface_nvrtc->module~dtfft_utils module~dtfft_interface_nvshmem->module~dtfft_utils module~dtfft_interface_nvtx->module~dtfft_utils module~dtfft_interface_vkfft_m dtfft_interface_vkfft_m module~dtfft_interface_vkfft_m->module~dtfft_utils module~dtfft_nvrtc_block_optimizer dtfft_nvrtc_block_optimizer module~dtfft_nvrtc_block_optimizer->module~dtfft_utils module~dtfft_nvrtc_block_optimizer->module~dtfft_config module~dtfft_nvrtc_block_optimizer->module~dtfft_interface_cuda module~dtfft_nvrtc_block_optimizer->module~dtfft_interface_cuda_runtime module~dtfft_nvrtc_kernel->module~dtfft_utils module~dtfft_nvrtc_kernel->module~dtfft_config module~dtfft_nvrtc_kernel->module~dtfft_interface_cuda module~dtfft_nvrtc_kernel->module~dtfft_interface_cuda_runtime module~dtfft_nvrtc_kernel->module~dtfft_interface_nvrtc module~dtfft_nvrtc_kernel->module~dtfft_interface_nvtx 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_utils module~dtfft_nvrtc_kernel_cache->module~dtfft_config module~dtfft_nvrtc_kernel_cache->module~dtfft_interface_cuda module~dtfft_nvrtc_kernel_cache->module~dtfft_interface_cuda_runtime module~dtfft_nvrtc_kernel_generator->module~dtfft_utils module~dtfft_nvrtc_kernel_generator->module~dtfft_interface_cuda module~dtfft_nvrtc_kernel_generator->module~dtfft_interface_cuda_runtime module~dtfft_nvrtc_kernel_generator->module~dtfft_interface_nvrtc module~dtfft_nvrtc_kernel_generator->module~dtfft_nvrtc_block_optimizer module~dtfft_pencil->module~dtfft_utils module~dtfft_pencil->module~dtfft_interface_cuda_runtime module~dtfft_plan->module~dtfft_utils module~dtfft_plan->module~dtfft_abstract_executor module~dtfft_plan->module~dtfft_abstract_transpose_plan module~dtfft_plan->module~dtfft_config module~dtfft_plan->module~dtfft_executor_cufft_m module~dtfft_plan->module~dtfft_executor_fftw_m module~dtfft_plan->module~dtfft_executor_mkl_m module~dtfft_plan->module~dtfft_interface_cuda_runtime module~dtfft_plan->module~dtfft_interface_nvshmem module~dtfft_plan->module~dtfft_interface_nvtx module~dtfft_plan->module~dtfft_pencil 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_executor_vkfft_m dtfft_executor_vkfft_m module~dtfft_plan->module~dtfft_executor_vkfft_m module~dtfft_transpose_handle_cuda dtfft_transpose_handle_cuda module~dtfft_transpose_handle_cuda->module~dtfft_utils module~dtfft_transpose_handle_cuda->module~dtfft_abstract_backend 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 module~dtfft_transpose_handle_cuda->module~dtfft_interface_cuda_runtime module~dtfft_transpose_handle_cuda->module~dtfft_interface_nvtx module~dtfft_transpose_handle_cuda->module~dtfft_nvrtc_kernel module~dtfft_transpose_handle_cuda->module~dtfft_pencil module~dtfft_transpose_plan_cuda->module~dtfft_utils 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_config module~dtfft_transpose_plan_cuda->module~dtfft_interface_cuda module~dtfft_transpose_plan_cuda->module~dtfft_interface_cuda_runtime module~dtfft_transpose_plan_cuda->module~dtfft_interface_nvrtc module~dtfft_transpose_plan_cuda->module~dtfft_interface_nvtx module~dtfft_transpose_plan_cuda->module~dtfft_nvrtc_kernel_cache module~dtfft_transpose_plan_cuda->module~dtfft_pencil module~dtfft_transpose_plan_cuda->module~dtfft_transpose_handle_cuda module~dtfft_transpose_plan_host->module~dtfft_utils module~dtfft_transpose_plan_host->module~dtfft_abstract_transpose_plan module~dtfft_transpose_plan_host->module~dtfft_config module~dtfft_transpose_plan_host->module~dtfft_interface_nvtx module~dtfft_transpose_plan_host->module~dtfft_pencil module~dtfft_transpose_handle_host dtfft_transpose_handle_host module~dtfft_transpose_plan_host->module~dtfft_transpose_handle_host module~dtfft dtfft module~dtfft->module~dtfft_config module~dtfft->module~dtfft_pencil module~dtfft->module~dtfft_plan module~dtfft_executor_vkfft_m->module~dtfft_abstract_executor module~dtfft_executor_vkfft_m->module~dtfft_config module~dtfft_executor_vkfft_m->module~dtfft_interface_vkfft_m module~dtfft_transpose_handle_host->module~dtfft_interface_nvtx module~dtfft_transpose_handle_host->module~dtfft_pencil

Variables

Type Visibility Attributes Name Initial
integer(kind=c_int), private, parameter :: RTLD_LAZY = 1_c_int

Each external function reference is bound the first time the function is called.

integer(kind=c_int), private, parameter :: RTLD_NOW = 2_c_int

All external function references are bound when the library is loaded.


Interfaces

public interface to_str

Convert various types to string

  • private function int8_to_string(n) result(str)

    Convert 8-bit integer to string

    Arguments

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

    Integer to convert

    Return Value character(len=:), allocatable

    Resulting string

  • private function int32_to_string(n) result(str)

    Convert 32-bit integer to string

    Arguments

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

    Integer to convert

    Return Value character(len=:), allocatable

    Resulting string

  • private function int64_to_string(n) result(str)

    Convert 64-bit integer to string

    Arguments

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

    Integer to convert

    Return Value character(len=:), allocatable

    Resulting string

  • private function double_to_string(n) result(str)

    Convert double to string

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: n

    Double to convert

    Return Value character(len=:), allocatable

    Resulting string

  • private function float_to_string(n) result(str)

    Convert double to string

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(in) :: n

    Double to convert

    Return Value character(len=:), allocatable

    Resulting string

interface

  • public subroutine mem_free_host(ptr) bind(C, name="free")

    Frees memory allocated with aligned_alloc

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: ptr

    Pointer to free

interface

  • public function Comm_f2c(fcomm) bind(C, name="Comm_f2c")

    Converts Fortran communicator to C

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), value :: fcomm

    Fortran communicator

    Return Value type(c_ptr)

interface

  • public function is_device_ptr(ptr) result(bool) bind(C)

    Checks if pointer can be accessed from device

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: ptr

    Device pointer

    Return Value logical(kind=c_bool)

    Result

public interface string

Creates string object

  • private function string_constructor(str)

    Creates string object

    Arguments

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

    String

    Return Value type(string)

private interface is_null_ptr

Checks if pointer is NULL

  • private interface is_null_ptr()

    Checks if pointer is NULL

    Arguments

    None
  • private elemental function is_null_funptr(ptr)

    Checks if pointer is NULL

    Arguments

    Type IntentOptional Attributes Name
    type(c_funptr), intent(in) :: ptr

    Pointer to check

    Return Value logical

interface

  • private function dlopen(filename, mode) bind(C)

    Load and link a dynamic library

    Arguments

    Type IntentOptional Attributes Name
    character(len=c_char) :: filename(*)

    Name of the library

    integer(kind=c_int), value :: mode

    Options to dlopen

    Return Value type(c_ptr)

    Handle to the library

interface

  • private function dlsym(handle, name) bind(C)

    Get address of a symbol from a dynamic library

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: handle

    Handle to the library

    character(len=c_char) :: name(*)

    Name of the symbol

    Return Value type(c_funptr)

    Address of the symbol

interface

  • private function dlclose(handle) bind(C)

    Close a dynamic library

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: handle

    Handle to the library

    Return Value integer(kind=c_int)

    Result of the operation

interface

  • private function dlerror() bind(C)

    Get diagnostic information

    Arguments

    None

    Return Value type(c_ptr)

    Error message

interface

  • private function aligned_alloc(alignment, alloc_size) result(ptr) bind(C)

    Allocates memory using C11 Standard alloc_align with 16 bytes alignment

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_size_t), value :: alignment

    Alignment in bytes (16 bytes by default)

    integer(kind=c_size_t), value :: alloc_size

    Number of bytes to allocate

    Return Value type(c_ptr)

    Pointer to allocate


Derived Types

type, public ::  string

Class used to create array of strings

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: raw

String

Constructor

Creates string object

private function string_constructor (str)

Creates string object

Type-Bound Procedures

procedure, public, pass(self) :: destroy => destroy_string

Functions

public function dynamic_load(name, symbol_names, handle, symbols) result(error_code)

Dynamically loads library and its symbols

Arguments

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

Name of library to load

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

Names of functions to load

type(c_ptr), intent(out) :: handle

Loaded handle

type(c_funptr), intent(out) :: symbols(:)

Function pointers

Return Value integer(kind=int32)

Error code

public elemental function get_inverse_kind(r2r_kind) result(result_kind)

Get the inverse R2R kind of transform for the given R2R kind

Arguments

Type IntentOptional Attributes Name
type(dtfft_r2r_kind_t), intent(in) :: r2r_kind

R2R kind

Return Value type(dtfft_r2r_kind_t)

public elemental function is_null_ptr(ptr)

Checks if pointer is NULL

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: ptr

Pointer to check

Return Value logical

public elemental function is_same_ptr(ptr1, ptr2)

Checks if two pointer are the same

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: ptr1

First pointer

type(c_ptr), intent(in) :: ptr2

Second pointer

Return Value logical

public function count_unique(x) result(n)

Count the number of unique elements in the array

Arguments

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

Array of integers

Return Value integer(kind=int32)

public function mem_alloc_host(alloc_size) result(ptr)

Allocates memory using C11 Standard alloc_align with 16 bytes alignment

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: alloc_size

Number of bytes to allocate

Return Value type(c_ptr)

Pointer to allocate

private function string_constructor(str)

Creates string object

Arguments

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

String

Return Value type(string)

private function load_library(name) result(lib_handle)

Dynamically loads library

Arguments

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

Name of library to load

Return Value type(c_ptr)

Loaded handle

private function load_symbol(handle, name) result(symbol_handle)

Dynamically loads symbol from library

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: handle

Loaded handle

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

Name of function to load

Return Value type(c_funptr)

Function pointer

private function int8_to_string(n) result(str)

Convert 8-bit integer to string

Arguments

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

Integer to convert

Return Value character(len=:), allocatable

Resulting string

private function int32_to_string(n) result(str)

Convert 32-bit integer to string

Arguments

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

Integer to convert

Return Value character(len=:), allocatable

Resulting string

private function int64_to_string(n) result(str)

Convert 64-bit integer to string

Arguments

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

Integer to convert

Return Value character(len=:), allocatable

Resulting string

private function double_to_string(n) result(str)

Convert double to string

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: n

Double to convert

Return Value character(len=:), allocatable

Resulting string

private function float_to_string(n) result(str)

Convert double to string

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in) :: n

Double to convert

Return Value character(len=:), allocatable

Resulting string

private elemental function is_null_funptr(ptr)

Checks if pointer is NULL

Arguments

Type IntentOptional Attributes Name
type(c_funptr), intent(in) :: ptr

Pointer to check

Return Value logical


Subroutines

public subroutine destroy_strings(strings)

Destroys array of string objects

Arguments

Type IntentOptional Attributes Name
type(string), intent(inout), allocatable :: strings(:)

Array of strings

public subroutine string_f2c(fstring, cstring, string_size)

Convert Fortran string to C string

Arguments

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

Fortran string

character(kind=c_char, len=1), intent(inout) :: cstring(*)

C string

integer(kind=int64), intent(out), optional :: string_size

Size of the C string

public subroutine string_c2f(cstring, fstring)

Convert C string to Fortran string

Arguments

Type IntentOptional Attributes Name
type(c_ptr) :: cstring

C string

character(len=:), allocatable :: fstring

Fortran string

public subroutine astring_f2c(fstring, cstring, string_size)

Convert Fortran string to C allocatable string

Arguments

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

Fortran string

character(kind=c_char, len=1), intent(out), allocatable :: cstring(:)

C string

integer(kind=int64), intent(out), optional :: string_size

Size of the C string

public subroutine write_message(unit, message, prefix)

Write message to the specified unit

Arguments

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

Unit number

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

Message to write

character(len=*), intent(in), optional :: prefix

Prefix to the message

private subroutine destroy_string(self)

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: self

private subroutine dl_error(message)

Writes error message to the error unit

Arguments

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

Message to write

private subroutine unload_library(handle)

Unloads library

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: handle

Loaded handle