(git:58e3e09)
|
#include <assert.h>
#include <omp.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "dbm_hyperparams.h"
#include "dbm_shard.h"
Go to the source code of this file.
Functions | |
static int | next_power2 (const int start) |
Internal routine for finding a power of two greater than given number. More... | |
static int | next_prime (const int start) |
Internal routine for finding a prime greater equal than given number. More... | |
static void | hashtable_init (dbm_shard_t *shard) |
Internal routine for initializing a shard's hashtable. More... | |
void | dbm_shard_init (dbm_shard_t *shard) |
Internal routine for initializing a shard. More... | |
void | dbm_shard_copy (dbm_shard_t *shard_a, const dbm_shard_t *shard_b) |
Internal routine for copying content of shard_b into shard_a. More... | |
void | dbm_shard_release (dbm_shard_t *shard) |
Internal routine for releasing a shard. More... | |
static unsigned int | hash (const unsigned int row, const unsigned int col) |
Private hash function based on Cantor pairing function. https://en.wikipedia.org/wiki/Pairing_function#Cantor_pairing_function Szudzik's elegant pairing proved to be too asymmetric wrt. row / col. Using unsigned int to return a positive number even after overflow. More... | |
static void | hashtable_insert (dbm_shard_t *shard, const int block_idx) |
Private routine for inserting a block into a shard's hashtable. More... | |
dbm_block_t * | dbm_shard_lookup (const dbm_shard_t *shard, const int row, const int col) |
Internal routine for looking up a block from a shard. More... | |
dbm_block_t * | dbm_shard_promise_new_block (dbm_shard_t *shard, const int row, const int col, const int block_size) |
Internal routine for allocating the metadata of a new block. More... | |
void | dbm_shard_allocate_promised_blocks (dbm_shard_t *shard) |
Internal routine for allocating and zeroing any promised block's data. More... | |
dbm_block_t * | dbm_shard_get_or_promise_block (dbm_shard_t *shard, const int row, const int col, const int block_size) |
Internal routine for getting block or promising a new one. More... | |
dbm_block_t * | dbm_shard_get_or_allocate_block (dbm_shard_t *shard, const int row, const int col, const int block_size) |
Internal routine for getting block or allocating a new one. More... | |
|
static |
Internal routine for finding a power of two greater than given number.
Definition at line 21 of file dbm_shard.c.
|
static |
Internal routine for finding a prime greater equal than given number.
Definition at line 33 of file dbm_shard.c.
|
static |
Internal routine for initializing a shard's hashtable.
Definition at line 50 of file dbm_shard.c.
void dbm_shard_init | ( | dbm_shard_t * | shard | ) |
Internal routine for initializing a shard.
Definition at line 63 of file dbm_shard.c.
void dbm_shard_copy | ( | dbm_shard_t * | shard_a, |
const dbm_shard_t * | shard_b | ||
) |
Internal routine for copying content of shard_b into shard_a.
Definition at line 80 of file dbm_shard.c.
void dbm_shard_release | ( | dbm_shard_t * | shard | ) |
Internal routine for releasing a shard.
Definition at line 107 of file dbm_shard.c.
|
inlinestatic |
Private hash function based on Cantor pairing function. https://en.wikipedia.org/wiki/Pairing_function#Cantor_pairing_function Szudzik's elegant pairing proved to be too asymmetric wrt. row / col. Using unsigned int to return a positive number even after overflow.
Definition at line 121 of file dbm_shard.c.
|
static |
Private routine for inserting a block into a shard's hashtable.
Definition at line 130 of file dbm_shard.c.
dbm_block_t* dbm_shard_lookup | ( | const dbm_shard_t * | shard, |
const int | row, | ||
const int | col | ||
) |
Internal routine for looking up a block from a shard.
Definition at line 149 of file dbm_shard.c.
dbm_block_t* dbm_shard_promise_new_block | ( | dbm_shard_t * | shard, |
const int | row, | ||
const int | col, | ||
const int | block_size | ||
) |
Internal routine for allocating the metadata of a new block.
Definition at line 171 of file dbm_shard.c.
void dbm_shard_allocate_promised_blocks | ( | dbm_shard_t * | shard | ) |
Internal routine for allocating and zeroing any promised block's data.
Definition at line 203 of file dbm_shard.c.
dbm_block_t* dbm_shard_get_or_promise_block | ( | dbm_shard_t * | shard, |
const int | row, | ||
const int | col, | ||
const int | block_size | ||
) |
Internal routine for getting block or promising a new one.
Definition at line 225 of file dbm_shard.c.
dbm_block_t* dbm_shard_get_or_allocate_block | ( | dbm_shard_t * | shard, |
const int | row, | ||
const int | col, | ||
const int | block_size | ||
) |
Internal routine for getting block or allocating a new one.
Definition at line 240 of file dbm_shard.c.