void _tst_map_destroy(_tst_map_node *root, void (*per_value_cleanup)(void *data)) { if (root == NULL) return; /* TODO: This whole function. */ struct destroy_queue *top = calloc(1, sizeof(struct destroy_queue)); dq_push(&top, root); while (top->next != NULL) { _tst_map_node *cur_node = (_tst_map_node *)dq_pop(&top); if (cur_node->lokid != NULL) dq_push(&top, (void *)cur_node->lokid); if (cur_node->eqkid != NULL) dq_push(&top, (void *)cur_node->eqkid); if (cur_node->hikid != NULL) dq_push(&top, (void *)cur_node->hikid); if (per_value_cleanup != NULL && cur_node->value != NULL) per_value_cleanup(cur_node->value); free(cur_node->value); free(cur_node); } free(top); }
//if mrq is being serviced by dram, gets popped after CL latency fulfilled void* dram_pop( dram_t *dm ) { dram_req_t *mrq; void *data; unsigned dq_latency; data = NULL; mrq = (dram_req_t*)dq_pop(dm->rwq); if (mrq) { // data = mrq->data; #ifdef DRAM_VIEWCMD printf("\tDQ: BK%d Row:%03x Col:%03x", mrq->bk, mrq->row, mrq->col + mrq->dqbytes); #endif mrq->dqbytes += dm->BL * dm->busW * gpu_n_mem_per_ctrlr; /*16 bytes*/ if (mrq->dqbytes >= mrq->nbytes) { if (gpgpu_memlatency_stat) { dq_latency = gpu_sim_cycle + gpu_tot_sim_cycle - mrq->timestamp; dq_lat_table[LOGB2(dq_latency)]++; if (dq_latency > max_dq_latency) max_dq_latency = dq_latency; } data = mrq->data; free(mrq); } } #ifdef DRAM_VIEWCMD printf("\n"); #endif return data; }
void print_pop(deque *d) { if (!setjmp(buf)) { printf("poped: %d\n", dq_pop(d)); } else { printf("error when calling dq_pop: stack is empty!\n"); } }
void scheduler_fifo(dram_t* dm) { if (dm->mrqq->head) { dram_req_t *head_mrqq; unsigned int bkn; head_mrqq = (dram_req_t *)dm->mrqq->head->data; bkn = head_mrqq->bk; if (!dm->bk[bkn]->mrq) { dm->bk[bkn]->mrq = (dram_req_t*) dq_pop(dm->mrqq); } } }