void si_ndrange_free(struct si_ndrange_t *ndrange) { /* Set event status to complete if an event was set. */ if(ndrange->event) ndrange->event->status = SI_OPENCL_EVENT_STATUS_COMPLETE; int i; /* Clear task from command queue */ if (ndrange->command_queue && ndrange->command) { si_opencl_command_queue_complete(ndrange->command_queue, ndrange->command); si_opencl_command_free(ndrange->command); } /* Clear all states that affect lists. */ si_ndrange_clear_status(ndrange, si_ndrange_pending); si_ndrange_clear_status(ndrange, si_ndrange_running); si_ndrange_clear_status(ndrange, si_ndrange_finished); /* Extract from ND-Range list in Southern Islands emulator */ assert(DOUBLE_LINKED_LIST_MEMBER(si_emu, ndrange, ndrange)); DOUBLE_LINKED_LIST_REMOVE(si_emu, ndrange, ndrange); /* Free lists */ list_free(ndrange->uav_list); /* Free work-groups */ for (i = 0; i < ndrange->work_group_count; i++) si_work_group_free(ndrange->work_groups[i]); free(ndrange->work_groups); /* Free wavefronts */ for (i = 0; i < ndrange->wavefront_count; i++) { si_wavefront_free(ndrange->wavefronts[i]); si_work_item_free(ndrange->scalar_work_items[i]); } free(ndrange->wavefronts); free(ndrange->scalar_work_items); /* Free work-items */ for (i = 0; i < ndrange->work_item_count; i++) si_work_item_free(ndrange->work_items[i]); free(ndrange->work_items); /* Free instruction histogram */ if (ndrange->inst_histogram) free(ndrange->inst_histogram); /* Free ndrange */ free(ndrange->name); free(ndrange); }
void si_ndrange_free(struct si_ndrange_t *ndrange) { int i; /* Run free notify call-back */ if (ndrange->free_notify_func) ndrange->free_notify_func(ndrange->free_notify_data); /* Clear all states that affect lists. */ si_ndrange_clear_status(ndrange, si_ndrange_pending); si_ndrange_clear_status(ndrange, si_ndrange_running); si_ndrange_clear_status(ndrange, si_ndrange_finished); /* Extract from ND-Range list in Southern Islands emulator */ assert(DOUBLE_LINKED_LIST_MEMBER(si_emu, ndrange, ndrange)); DOUBLE_LINKED_LIST_REMOVE(si_emu, ndrange, ndrange); /* Free work-groups */ for (i = 0; i < ndrange->work_group_count; i++) si_work_group_free(ndrange->work_groups[i]); free(ndrange->work_groups); /* Free wavefronts */ for (i = 0; i < ndrange->wavefront_count; i++) { si_wavefront_free(ndrange->wavefronts[i]); si_work_item_free(ndrange->scalar_work_items[i]); } free(ndrange->wavefronts); free(ndrange->scalar_work_items); /* Free work-items */ for (i = 0; i < ndrange->work_item_count; i++) si_work_item_free(ndrange->work_items[i]); free(ndrange->work_items); /* Free instruction histogram */ if (ndrange->inst_histogram) free(ndrange->inst_histogram); /* Free instruction buffer */ if (ndrange->inst_buffer) free(ndrange->inst_buffer); /* Free ndrange */ free(ndrange->name); free(ndrange); }