intset_l_t *set_new_l() { intset_l_t *set; node_l_t *min, *max; if ((set = (intset_l_t *)ssalloc_aligned(CACHE_LINE_SIZE, sizeof(intset_l_t))) == NULL) { perror("malloc"); exit(1); } max = new_node_l(KEY_MAX, 0, NULL, 1); /* ssalloc_align_alloc(0); */ min = new_node_l(KEY_MIN, 0, max, 1); set->head = min; #if defined(LL_GLOBAL_LOCK) set->lock = (volatile ptlock_t*) ssalloc_aligned(CACHE_LINE_SIZE, sizeof(ptlock_t)); if (set->lock == NULL) { perror("malloc"); exit(1); } GL_INIT_LOCK(set->lock); #endif MEM_BARRIER; return set; }
static copy_on_write_t* copy_on_write_new_init(size_t num_buckets) { copy_on_write_t* cow; cow = ssalloc_aligned(CACHE_LINE_SIZE, sizeof(copy_on_write_t)); assert(cow != NULL); cow->num_buckets = num_buckets; cow->hash = cow->num_buckets - 1; #if defined(LL_GLOBAL_LOCK) cow->lock = ssalloc_aligned(CACHE_LINE_SIZE, sizeof(ptlock_t)); assert(cow->lock != NULL); GL_INIT_LOCK(cow->lock); #else cow->lock = ssalloc_aligned(CACHE_LINE_SIZE, cow->num_buckets * sizeof(ptlock_t)); assert(cow->lock != NULL); #endif cow->array = ssalloc_aligned(CACHE_LINE_SIZE, cow->num_buckets * sizeof(array_ll_t*)); assert(cow->array != NULL); int i; for (i = 0; i < cow->num_buckets; i++) { INIT_LOCK(cow->lock + i); cow->array[i] = array_ll_new_init(0); } return cow; }
queue_t* queue_new() { queue_t *set; if ((set = (queue_t*) ssalloc_aligned(CACHE_LINE_SIZE, sizeof(queue_t))) == NULL) { perror("malloc"); exit(1); } queue_node_t* node = (queue_node_t*) ssalloc_aligned(CACHE_LINE_SIZE, sizeof(queue_node_t)); node->next = NULL; set->head = node; set->tail = node; return set; }
static inline volatile array_ll_t* array_ll_new_init(size_t size) { array_ll_t* all; all = ssalloc_aligned(CACHE_LINE_SIZE, sizeof(array_ll_t) + (array_ll_fixed_size * sizeof(kv_t))); assert(all != NULL); all->size = size; all->kvs = (kv_t*) ((uintptr_t) all + sizeof(array_ll_t)); return all; }
node_t* bst_initialize() { // node_t* root = (node_t*) ssalloc(sizeof(node_t)); node_t* root = (node_t*) ssalloc_aligned(CACHE_LINE_SIZE, CACHE_LINE_SIZE); // assign minimum key to the root, actual tree will be // the right subtree of the root root->key = 0; root->left = NULL; root->right = NULL; root->op = NULL; return root; }
intset_t *set_new() { intset_t *set; if ((set = (intset_t *)ssalloc_aligned(CACHE_LINE_SIZE, sizeof(intset_t))) == NULL) { perror("malloc"); exit(1); } set->head = NULL; MEM_BARRIER; return set; }
intset_t* set_new() { intset_t *set; if ((set = (intset_t *)ssalloc_aligned(CACHE_LINE_SIZE, sizeof(intset_t))) == NULL) { perror("malloc"); exit(1); } node_t* min = new_node(INT_MIN, 1, NULL, NULL, 1); node_t* max = new_node(INT_MAX, 1, NULL, NULL, 1); set->head = new_node(INT_MAX, 0, min, max, 1); MEM_BARRIER; return set; }
intset_t* set_new() { intset_t *set; node_t *min, *max; if ((set = (intset_t*)ssalloc_aligned(CACHE_LINE_SIZE, sizeof(intset_t))) == NULL) { perror("malloc"); exit(1); } max = new_node(KEY_MAX, 0, NULL, 1); min = new_node(KEY_MIN, 0, max, 1); set->head = min; return set; }
node_t* bst_initialize(int num_proc) { node_t* root = (node_t*) ssalloc_aligned(sizeof(node_t)); // assign minimum key to the root, actual tree will be // the right subtree of the root root->key = 0; root->left = NULL; root->right = NULL; root->op = NULL; my_search_result = (bst_search_result_t**) malloc(num_proc * sizeof(bst_search_result_t*)); // should we create an op pointer and flag it with NONE? // fprintf(stderr, "root address: %p, key address %p, left node addr: %p, right node addr: %p, op addr: %p\n", (unsigned long)root, &(root->key), &(root->left), &(root->right), &(root->op) // ); // fprintf(stderr, "sizes in bytes: int = %d, bst_key_t = %d, operation_t* = %d, node_t* = %d, node_t = %d, bool_t = %d, child_cas_op_t = %d, relocate_op_t = %d, operation_t = %d, search_res_t = %d \n", sizeof(int), sizeof(bst_key_t), sizeof(operation_t*), sizeof(node_t*), sizeof(node_t), sizeof(bool_t), sizeof(child_cas_op_t), sizeof(relocate_op_t), sizeof(operation_t), sizeof(search_res_t)); return root; }
node_t* create_node(skey_t k, sval_t value, int initializing) { volatile node_t* new_node; #if GC == 1 if (unlikely(initializing)) { new_node = (volatile node_t*) ssalloc_aligned(CACHE_LINE_SIZE, sizeof(node_t)); } else { new_node = (volatile node_t*) ssmem_alloc(alloc, sizeof(node_t)); } #else new_node = (volatile node_t*) ssalloc(sizeof(node_t)); #endif if (new_node == NULL) { perror("malloc in bst create node"); exit(1); } new_node->left = NULL; new_node->right = NULL; new_node->key = k; new_node->value = value; asm volatile("" ::: "memory"); return (node_t*) new_node; }