index_rhash_t Derived Type

type, public :: index_rhash_t


Components

Type Visibility Attributes Name Initial
type(shared_rhash_t), private :: shared_ht

Type-Bound Procedures

procedure, public :: hash_function

  • private function hash_function(this, index) result(hval)

    Get the hash value for an arbitrary input value

    Arguments

    Type IntentOptional Attributes Name
    class(index_rhash_t), intent(in) :: this
    integer(kind=int64), intent(in) :: index

    input value to get the hash value for

    Return Value integer(kind=int64)

procedure, public :: alloc

  • private subroutine alloc(this, n_elem, htsize)

    Allocate the internal (shared) memory

    Arguments

    Type IntentOptional Attributes Name
    class(index_rhash_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: n_elem

    number of distinct values to store

    integer(kind=int64), intent(in) :: htsize

    range of the hash function

procedure, public :: dealloc

  • private subroutine dealloc(this)

    Deallocate all arrays associated with this hash table object

    Arguments

    Type IntentOptional Attributes Name
    class(index_rhash_t), intent(inout) :: this

procedure, public :: count_index

  • private subroutine count_index(this, index)

    Log the occurence of this index in the set of indices to be stored Does not add it, only updates the offsets

    Arguments

    Type IntentOptional Attributes Name
    class(index_rhash_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: index

    index value to be logged

procedure, public :: add_index

  • private subroutine add_index(this, index, pos)

    Add an input value to the stored values, assuming we already know the offsets

    Arguments

    Type IntentOptional Attributes Name
    class(index_rhash_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: index

    value to be stored

    integer(kind=int64), intent(out) :: pos

    on return, the position where this value was stored

procedure, public :: finalize_setup

  • private subroutine finalize_setup(this)

    Dealloates temporary arrays used for initialisation

    Arguments

    Type IntentOptional Attributes Name
    class(index_rhash_t) :: this

procedure, public :: setup_offsets

  • private subroutine setup_offsets(this)

    For performance reasons, we cannot directly calculate the offsets, but instead first count the number of conflicts per hash value. Then, we sum these up cumulatively Directly counting the offsets is horrifically slow

    Arguments

    Type IntentOptional Attributes Name
    class(index_rhash_t), intent(inout) :: this

procedure, public :: lookup

  • private subroutine lookup(this, index, pos, t_found)

    Look up a value in this hash table. Returns whether the value is stored and if yes, where

    Arguments

    Type IntentOptional Attributes Name
    class(index_rhash_t), intent(in) :: this
    integer(kind=int64), intent(in) :: index

    value to be looked up

    integer(kind=int64), intent(out) :: pos

    on return, the position of index if found, else 0

    logical, intent(out) :: t_found

    on return, true if and only if index was found

procedure, public :: known_conflicts

  • private function known_conflicts(this) result(t_kc)

    During initialisation, we can only start writing values once the offsets are known. This requires knowledge about the number of conflicts per hash value. This function tells us whether the conflicts have already been counted.

    Arguments

    Type IntentOptional Attributes Name
    class(index_rhash_t), intent(in) :: this

    Return Value logical

procedure, public :: sync

  • private subroutine sync(this)

    For a MPI-3 shared memory array, synchronization is required after/before each read/write epoch

    Arguments

    Type IntentOptional Attributes Name
    class(index_rhash_t), intent(inout) :: this

Source Code

    type :: index_rhash_t
        private

        type(shared_rhash_t) :: shared_ht

    contains
        ! The hash function used for storing indices
        procedure :: hash_function
        ! Allocate the memory
        procedure :: alloc
        procedure :: dealloc
        ! Fill up the indices - since this is memory critical, we allow direct write to them
        procedure :: count_index
        procedure :: add_index
        ! Set up the table. It is read-only, so this is the only way to set it up
        procedure :: finalize_setup
        ! After counting the indices, we have to get the offsets (doing so on the fly is
        ! horiffically slow)
        procedure :: setup_offsets

        ! Look up an index. Returns the position in the contiguous array
        procedure :: lookup

        ! Tell if the conflicts have been counted
        procedure :: known_conflicts

        ! Synchronize the table between tasks
        procedure :: sync
    end type index_rhash_t