/* Destroy a reducer map. The map must have been allocated from the worker's global context and should have been allocated from the same worker. */ void __cilkrts_destroy_reducer_map(__cilkrts_worker *w, cilkred_map *h) { CILK_ASSERT((w == 0 && h->g == 0) || w->g == h->g); verify_current_wkr(w); /* the reducer map is allowed to contain el->val == NULL here (and only here). We set el->val == NULL only when we know that the map will be destroyed immediately afterwards. */ DBG h->check(/*allow_null_val=*/true); bucket *b; size_t i; for (i = 0; i < h->nbuckets; ++i) { b = h->buckets[i]; if (b) { elem *el; for (el = b->el; el->key; ++el) { if (el->val) el->destroy(); } } } free_buckets(w, h->buckets, h->nbuckets); #if REDPAR_DEBUG >= 1 fprintf(stderr, "W=%d, destroy_red_map, freeing map h=%p, size=%zd\n", w->self, h, sizeof(*h)); #endif __cilkrts_frame_free(w, h, sizeof(*h)); }
void cilkred_map::rehash(__cilkrts_worker *w) { #if REDPAR_DEBUG >= 1 fprintf(stderr, "[W=%d, desc=rehash, this_map=%p, g=%p, w->g=%p]\n", w->self, this, g, w->g); verify_current_wkr(w); #endif CILK_ASSERT((w == 0 && g == 0) || w->g == g); size_t onbuckets = nbuckets; size_t onelem = nelem; bucket **obuckets = buckets; size_t i; bucket *b; make_buckets(w, nextsz(nbuckets)); for (i = 0; i < onbuckets; ++i) { b = obuckets[i]; if (b) { elem *oel; for (oel = b->el; oel->key; ++oel) insert_no_rehash(w, oel->key, oel->hb, oel->val); } } CILK_ASSERT(nelem == onelem); free_buckets(w, obuckets, onbuckets); }
void Octree_Delete(Octree *myOctree) { if(!myOctree) return; delete myOctree->info; free_buckets(myOctree->root); delete myOctree->root; delete myOctree; }
void solve_pbqp_heuristical_co_ld(pbqp_t *pbqp, deq_t *rpeo) { #ifndef NDEBUG assert(pbqp); assert(rpeo); assert(pbqp->solution == INF_COSTS && "PBQP already solved"); pbqp->solution = 0; #endif /* Reduce nodes degree ... */ initial_simplify_edges(pbqp); /* ... and put node into bucket representing their degree. */ fill_node_buckets(pbqp); #if KAPS_STATISTIC FILE *fh = fopen("solutions.pb", "a"); fprintf(fh, "Solution"); fclose(fh); #endif apply_heuristic_reductions_co(pbqp, rpeo); pbqp->solution = determine_solution(pbqp); #if KAPS_STATISTIC fh = fopen("solutions.pb", "a"); #if KAPS_USE_UNSIGNED fprintf(fh, ": %u RE:%u R0:%u R1:%u R2:%u RM:%u RN/BF:%u\n", pbqp->solution, pbqp->num_edges, pbqp->num_r0, pbqp->num_r1, pbqp->num_r2, pbqp->num_rm, pbqp->num_rn); #else fprintf(fh, ": %lld RE:%u R0:%u R1:%u R2:%u RM:%u RN/BF:%u\n", pbqp->solution, pbqp->num_edges, pbqp->num_r0, pbqp->num_r1, pbqp->num_r2, pbqp->num_rm, pbqp->num_rn); #endif fclose(fh); #endif /* Solve reduced nodes. */ back_propagate_ld(pbqp); free_buckets(); }
void free_buckets(octantBucket * bucket) { int i, numBuck = 8; ELink ptr1, ptr2; if(bucket->next == NULL) { ptr1 = bucket->lhead; while(ptr1 != NULL) { ptr2 = ptr1; ptr1 = ptr1->next; delete ptr2; } bucket->listBB.clear(); return; } for(i = numBuck-1; i >= 0; i--) free_buckets((bucket->next)+i); delete []bucket->next; return; }
static void __table_instance_destroy(struct table_instance *ti) { free_buckets(ti->buckets); kfree(ti); }