void *malloc(size_t size) { size_t k; block_t *ptr; //fprintf(stderr, "malloc with size: %d\n", size); if (mem_pool == NULL) { mem_pool = sbrk(POOL_SIZE); if (mem_pool == (void*) -1) return NULL; freelist[N] = mem_pool; block_t *mem_first = (block_t*) mem_pool; mem_first->reserved = 0; mem_first->k = N; mem_first->succ = NULL; } k = 0; while ((1 << k) < (size + BLOCK_SIZE)) { k++; } ptr = split_blocks(k); return ptr->data; }
void add_blocks() { int l, i, j, n, in, num_split, split; double t1, t2, t3; block *bp; t3 = 0.0; t1 = timer(); if (target_active) num_split = (num_pes*target_active + 3 - global_active)/7; else num_split = (num_pes*target_active - global_active)/7; for (split = l = 0; split < num_split; l++) { zero_refine(); for (j = num_refine; j >= 0; j--) if (num_blocks[j]) { cur_max_level = j; break; } for (in = 0; split < num_split && in < sorted_index[num_refine+1]; in++) { n = sorted_list[in].n; if ((bp = &blocks[n])->number >= 0) if (bp->level == l) { bp->refine = 1; split++; } } t2 = timer(); split_blocks(); t3 += timer() - t2; } timer_target_ab += timer() - t1; timer_target_da += timer() - t1 - t3; timer_target_sb += t3; }