8#include "../offload/offload_mempool.h" 
   24  while (candidate < start) {
 
 
   35  int candidate = start, divisor = 0;
 
   36  while (divisor < candidate) {
 
   37    for (divisor = 2; divisor < candidate; divisor++) {
 
   38      if (candidate % divisor == 0) {
 
 
   73  omp_init_lock(&shard->
lock);
 
 
   81  assert(shard_a != NULL && shard_b != NULL);
 
   87    assert(shard_a->
blocks != NULL);
 
  104    assert(shard_a->
data != NULL);
 
  109    assert(shard_a->
blocks != NULL && shard_b->
blocks != NULL);
 
  119    assert(shard_a->
data != NULL && shard_b->
data != NULL);
 
 
  132  omp_destroy_lock(&shard->
lock);
 
 
  142static inline unsigned int hash(
const unsigned int row,
 
  143                                const unsigned int col) {
 
  144  return (row + col) * (row + col + 1) / 2 + row; 
 
 
  160  assert(0 <= block_idx && block_idx < shard->nblocks);
 
  162  const unsigned int h = 
hash(blk->
row, blk->
col);
 
 
  184      if (block_idx == 0) { 
 
  187      assert(0 < block_idx && block_idx <= shard->nblocks);
 
  189      if (blk->
row == row && blk->
col == col) {
 
 
  201                                         const int col, 
const int block_size) {
 
  208    assert(shard->
blocks != NULL);
 
  218  const int new_block_idx = shard->
nblocks;
 
  221  new_block->
row = row;
 
  222  new_block->
col = col;
 
 
  238    const double *data = shard->
data;
 
  243    assert(shard->
data != NULL);
 
  245      memcpy(shard->
data, data, shard->
data_size * 
sizeof(
double));
 
  255    memset(shard->
data + shard->
data_size, 0, tail * 
sizeof(
double));
 
 
  266                                            const int block_size) {
 
  268  if (existing_blk != NULL) {
 
 
  281                                             const int block_size) {
 
  283  if (existing_blk != NULL) {
 
 
#define DBM_ALLOCATION_FACTOR
#define DBM_HASHTABLE_FACTOR
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.
static int hashtable_mask(const dbm_shard_t *shard)
Internal routine for masking a slot in the hash-table.
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_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.
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...
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.
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.
static void const int const int i
void offload_mempool_host_free(const void *memory)
Internal routine for releasing memory back to the pool.
void * offload_mempool_host_malloc(const size_t size)
Internal routine for allocating host memory from the pool.
Internal struct for storing a block's metadata.
Internal struct for storing a matrix shard.