static GtRadixsortinfo *gt_radixsort_new(bool pairs,GtUword maxlen) { GtRadixsortinfo *radixsortinfo = gt_malloc(sizeof (*radixsortinfo)); radixsortinfo->size = sizeof (*radixsortinfo); radixsortinfo->rbuf = gt_radixbuffer_new(pairs); radixsortinfo->size += gt_radixbuffer_size(radixsortinfo->rbuf); radixsortinfo->pairs = pairs; radixsortinfo->maxlen = maxlen; if (maxlen > 0) { if (pairs) { radixsortinfo->sortspace.ulongpairptr = gt_malloc(sizeof (*radixsortinfo->sortspace.ulongpairptr) * maxlen); radixsortinfo->size += sizeof (*radixsortinfo->sortspace.ulongpairptr) * maxlen; } else { radixsortinfo->sortspace.ulongptr = gt_malloc(sizeof (*radixsortinfo->sortspace.ulongptr) * maxlen); radixsortinfo->size += sizeof (*radixsortinfo->sortspace.ulongptr) * maxlen; } } GT_STACK_INIT(&radixsortinfo->stack,32UL); radixsortinfo->size += sizeof (radixsortinfo->stack); #ifdef GT_THREADS_ENABLED { const unsigned int threads = GT_THREADS_JOBS; if (threads > 1U) { unsigned int t; radixsortinfo->lentab = gt_malloc(sizeof (*radixsortinfo->lentab) * (UINT8_MAX+1)); radixsortinfo->size += sizeof (*radixsortinfo->lentab) * (UINT8_MAX+1); radixsortinfo->endindexes = gt_malloc(sizeof (*radixsortinfo->endindexes) * threads); radixsortinfo->size += sizeof (*radixsortinfo->endindexes) * threads; radixsortinfo->threadinfo = gt_malloc(sizeof (*radixsortinfo->threadinfo) * threads); radixsortinfo->size += sizeof (*radixsortinfo->threadinfo) * threads; for (t = 0; t < threads; t++) { GT_STACK_INIT(&radixsortinfo->threadinfo[t].stack,32UL); radixsortinfo->size += sizeof (radixsortinfo->threadinfo[t].stack); radixsortinfo->threadinfo[t].rbuf = gt_radixbuffer_new(pairs); radixsortinfo->size += gt_radixbuffer_size(radixsortinfo->threadinfo[t].rbuf); } } } #endif return radixsortinfo; }
void gt_pck_count_nodes_dfs(const FMindex *index, GtUword totallength, unsigned int numofchars) { GtStackNodecount stack; Nodecount root; Nodecount *current; Mbtab *tmpmbtab; GtUword *rangeOccs; GtUword resize = 128UL; /* TODO DW make this user definable, or dependable on input data */ GT_STACK_INIT(&stack, resize); rangeOccs = gt_malloc(sizeof (*rangeOccs) * GT_MULT2(numofchars)); tmpmbtab = gt_malloc(sizeof (*tmpmbtab) * numofchars); root.lower = 0UL; root.upper = totallength + 1; root.leaves = 0UL; root.branching = 1UL; root.parentOffset = 0U; root.visited = false; root.on_branch = false; GT_STACK_PUSH(&stack, root); while (!GT_STACK_ISEMPTY(&stack)) { current = &(stack.space[stack.nextfree -1]); if (current->visited) { current = &(GT_STACK_POP(&stack)); if GT_STACK_ISEMPTY(&stack) { /* TODO DW change to gt_loger_log */ gt_log_log("on root:\n "GT_WU" branching nodes\n "GT_WU" leaves\n", current->branching, current->leaves); } else { process_count_node(&stack, current); } }
static GtRadixsortinfo *gt_radixsort_new(GtRadixelemtype elemtype, GtUword maxlen) { GtRadixsortinfo *radixsortinfo = gt_malloc(sizeof *radixsortinfo); radixsortinfo->size = sizeof *radixsortinfo; radixsortinfo->rbuf = gt_radixbuffer_new(elemtype); radixsortinfo->size += gt_radixbuffer_size(radixsortinfo->rbuf); radixsortinfo->elemtype = elemtype; radixsortinfo->maxlen = maxlen; if (maxlen > 0) { if (elemtype == GtRadixelemtypeGtUwordPair) { radixsortinfo->sortspace.ulongpairptr = gt_malloc(sizeof *radixsortinfo->sortspace.ulongpairptr * maxlen); radixsortinfo->size += sizeof *radixsortinfo->sortspace.ulongpairptr * maxlen; } else { if (elemtype == GtRadixelemtypeGtUword) { radixsortinfo->sortspace.ulongptr = gt_malloc(sizeof *radixsortinfo->sortspace.ulongptr * maxlen); radixsortinfo->size += sizeof *radixsortinfo->sortspace.ulongptr * maxlen; } else { radixsortinfo->sortspace.uint64keypairptr = gt_malloc(sizeof *radixsortinfo->sortspace.uint64keypairptr * maxlen); radixsortinfo->size += sizeof *radixsortinfo->sortspace.uint64keypairptr * maxlen; } } } GT_STACK_INIT(&radixsortinfo->stack,32UL); radixsortinfo->size += sizeof radixsortinfo->stack; #ifdef GT_THREADS_ENABLED { const unsigned int threads = GT_THREADS_JOBS; if (threads > 1U) { unsigned int t; radixsortinfo->lentab = gt_malloc(sizeof *radixsortinfo->lentab * (UINT8_MAX+1)); radixsortinfo->size += sizeof *radixsortinfo->lentab * (UINT8_MAX+1); radixsortinfo->endindexes = gt_malloc(sizeof *radixsortinfo->endindexes * threads); radixsortinfo->size += sizeof *radixsortinfo->endindexes * threads; radixsortinfo->threadinfo = gt_malloc(sizeof *radixsortinfo->threadinfo * threads); radixsortinfo->size += sizeof *radixsortinfo->threadinfo * threads; for (t = 0; t < threads; t++) { GT_STACK_INIT(&radixsortinfo->threadinfo[t].stack,32UL); radixsortinfo->size += sizeof (radixsortinfo->threadinfo[t].stack); radixsortinfo->threadinfo[t].rbuf = gt_radixbuffer_new(elemtype); radixsortinfo->size += gt_radixbuffer_size(radixsortinfo->threadinfo[t].rbuf); } } } #endif return radixsortinfo; }