23 while (candidate < start) {
34 int candidate = start, divisor = 0;
35 while (divisor < candidate) {
36 for (divisor = 2; divisor < candidate; divisor++) {
37 if (candidate % divisor == 0) {
73 omp_init_lock(&shard->
lock);
111 omp_destroy_lock(&shard->
lock);
121 static inline unsigned int hash(
const unsigned int row,
122 const unsigned int col) {
123 return (row + col) * (row + col + 1) / 2 + row;
131 assert(0 <= block_idx && block_idx < shard->nblocks);
133 const int row = blk->
row, col = blk->
col;
153 const int block_idx = shard->
hashtable[slot] - 1;
157 assert(0 <= block_idx && block_idx < shard->nblocks);
159 if (blk->
row == row && blk->
col == col) {
172 const int col,
const int block_size) {
187 const int new_block_idx = shard->
nblocks;
190 new_block->
row = row;
191 new_block->
col = col;
216 memset(&shard->
data[shard->
data_size], 0, tail *
sizeof(
double));
227 const int block_size) {
229 if (existing_blk != NULL) {
242 const int block_size) {
244 if (existing_blk != NULL) {
static const float ALLOCATION_FACTOR
static const int INITIAL_DATA_ALLOCATED
static const int INITIAL_NBLOCKS_ALLOCATED
static const float HASHTABLE_FACTOR
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.
static void hashtable_insert(dbm_shard_t *shard, const int block_idx)
Private routine for inserting a block into a shard's hashtable.
static void hashtable_init(dbm_shard_t *shard)
Internal routine for initializing a shard's hashtable.
void dbm_shard_release(dbm_shard_t *shard)
Internal routine for releasing a shard.
static int next_prime(const int start)
Internal routine for finding a prime greater equal than given number.
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.
static int next_power2(const int start)
Internal routine for finding a power of two greater than given number.
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.
void dbm_shard_allocate_promised_blocks(dbm_shard_t *shard)
Internal routine for allocating and zeroing any promised block's data.
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_functio...
void dbm_shard_init(dbm_shard_t *shard)
Internal routine for initializing a shard.
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.
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.
static void const int const int i
Internal struct for storing a block's metadata.
Internal struct for storing a matrix shard.