Esempio n. 1
0
void timers_mark_updated(void) {
  uint8_t handler_count = linked_list_count(update_handlers);
  for (uint8_t h = 0; h < handler_count; h += 1) {
    TimersUpdatedHandler handler = linked_list_get(update_handlers, h);
    handler();
  }
}
Esempio n. 2
0
/* Return a wavefront from the wavefront pool in the compute unit.
 * If a wavefront was found, it will be extracted from the wavefront pool.
 * If no valid candidate is found in the wavefront pool, the function returns NULL. */
struct gpu_wavefront_t *gpu_schedule(struct gpu_compute_unit_t *compute_unit)
{
	struct gpu_wavefront_t *wavefront;

	/* If there is no wavefront in the pool, return NULL. */
	if (!linked_list_count(compute_unit->wavefront_pool))
		return NULL;

	/* Run different scheduling algorithm depending on configured policy */
	switch (gpu_sched_policy)
	{

	case gpu_sched_round_robin:

		wavefront = gpu_schedule_round_robin(compute_unit);
		break;

	case gpu_sched_greedy:

		wavefront = gpu_schedule_greedy(compute_unit);
		break;

	default:
		panic("%s: invalid policy", __FUNCTION__);
	}

	/* Scheduled wavefront */
	return wavefront;
}
Esempio n. 3
0
void timers_highlight(Timer* timer) {
  uint8_t handler_count = linked_list_count(highlight_handlers);
  for (uint8_t h = 0; h < handler_count; h += 1) {
    TimerHighlightHandler handler = linked_list_get(highlight_handlers, h);
    handler(timer);
  }
}
Esempio n. 4
0
static DISCRETE_START(dss_input_stream)
{
	struct dss_input_context *context = (struct dss_input_context *)node->context;

	assert(DSS_INPUT_STREAM__STREAM < linked_list_count(node->info->input_list));

	context->is_stream = TRUE;
	/* Stream out number is set during start */
	context->stream_in_number = DSS_INPUT_STREAM__STREAM;
	context->gain = DSS_INPUT_STREAM__GAIN;
	context->offset = DSS_INPUT_STREAM__OFFSET;
	context->ptr = NULL;
	//context->data = 0;

	if (node->block->type == DSS_INPUT_BUFFER)
	{
		context->is_buffered = TRUE;
		context->buffer_stream = stream_create(node->info->device, 0, 1, node->info->sample_rate, (void *) node, buffer_stream_update);

		stream_set_input(node->info->discrete_stream, context->stream_in_number,
			context->buffer_stream, 0, 1.0);
	}
	else
	{
		context->is_buffered = FALSE;
		context->buffer_stream = NULL;
	}
}
Esempio n. 5
0
static void prv_init(void) {
  if (!s_handler_list) {
    s_handler_list = linked_list_create_root();
  }
  if (linked_list_count(s_handler_list) == 0) {
    battery_state_service_subscribe(prv_handle_state_change);
  }
}
Esempio n. 6
0
void bitmaps_cleanup(void) {
  while (linked_list_count(bitmaps) > 0) {
    AppBitmap* bmp = linked_list_get(bitmaps, 0);
    gbitmap_destroy(bmp->bitmap);
    free(bmp);
    linked_list_remove(bitmaps, 0);
  }
}
Esempio n. 7
0
static char* clear_multiple(void) {
  linked_list_append(root, create_object(1));
  linked_list_append(root, create_object(2));
  linked_list_append(root, create_object(3));
  linked_list_clear(root);
  mu_assert(0 == linked_list_count(root), "List is not empty after clearing multiple item list.");
  return 0;
}
Esempio n. 8
0
static char* append_count_multiple(void) {
  linked_list_append(root, create_object(1));
  linked_list_append(root, create_object(2));
  linked_list_append(root, create_object(3));
  linked_list_append(root, create_object(4));
  mu_assert(4 == linked_list_count(root), "Appending four item doesn't set size to 4.");
  return 0;
}
Esempio n. 9
0
static void prv_init(void) {
  if (!s_handler_list) {
    s_handler_list = linked_list_create_root();
  }
  if (linked_list_count(s_handler_list) == 0) {
    app_focus_service_subscribe_handlers((AppFocusHandlers) {
      .will_focus = prv_handle_will_focus,
      .did_focus = prv_handle_did_focus,
    });
Esempio n. 10
0
int return_valid_ticket(linked_list_t *invalid_tickets, int ticket_tail) {
	while (++ticket_tail) {
		if (linked_list_count(invalid_tickets, ticket_tail))
			linked_list_remove(invalid_tickets, ticket_tail);
		else
			break;
	}
	return ticket_tail;
}
Esempio n. 11
0
void evg_faults_done(void)
{
	while (linked_list_count(evg_fault_list))
	{
		linked_list_head(evg_fault_list);
		free(linked_list_get(evg_fault_list));
		linked_list_remove(evg_fault_list);
	}
	linked_list_free(evg_fault_list);
}
Esempio n. 12
0
static AppBitmap* get_app_bitmap_by_group(uint8_t group) {
  uint8_t count = linked_list_count(bitmaps);
  for (uint8_t b = 0; b < count; b += 1) {
    AppBitmap* bmp = (AppBitmap*)linked_list_get(bitmaps, b);
    if (bmp->group == group) {
      return bmp;
    }
  }
  return NULL;
}
Esempio n. 13
0
static AppBitmap* get_app_bitmap_by_res_id(uint32_t res_id) {
  uint8_t count = linked_list_count(bitmaps);
  for (uint8_t b = 0; b < count; b += 1) {
    AppBitmap* bmp = (AppBitmap*)linked_list_get(bitmaps, b);
    if (bmp->res_id == res_id) {
      return bmp;
    }
  }
  return NULL;
}
Esempio n. 14
0
static char* remove_multiple_items(void) {
  linked_list_append(root, create_object(1));
  linked_list_append(root, create_object(2));
  linked_list_append(root, create_object(3));
  linked_list_remove(root, 2);
  linked_list_remove(root, 1);
  mu_assert(1 == get_id(linked_list_get(root, 0)), "Removing multiple items failed.");
  mu_assert(1 == linked_list_count(root), "Removing multiple items failed.");
  return 0;
}
Esempio n. 15
0
void timers_clear(void) {
  if (! timers) {
    return;
  }
  while (linked_list_count(timers) > 0) {
    Timer* timer = (Timer*) linked_list_get(timers, 0);
    linked_list_remove(timers, 0);
    free(timer);
  }
}
/* Free command queue */
void evg_opencl_command_queue_free(struct evg_opencl_command_queue_t *command_queue)
{
	/* Check that command list is empty */
	if (linked_list_count(command_queue->command_list))
		fatal("%s: freed command queue is not empty", __FUNCTION__);
	
	/* Free */
	evg_opencl_repo_remove_object(evg_emu->opencl_repo, command_queue);
	linked_list_free(command_queue->command_list);
	free(command_queue);
}
Esempio n. 17
0
void si_uop_list_free(struct linked_list_t *gpu_uop_list)
{
	struct si_uop_t *uop;
	while (linked_list_count(gpu_uop_list))
	{
		linked_list_head(gpu_uop_list);
		uop = linked_list_get(gpu_uop_list);
		si_uop_free(uop);
		linked_list_remove(gpu_uop_list);
	}
}
Esempio n. 18
0
void events_app_message_unsubscribe(EventHandle handle) {
  int16_t index = linked_list_find(s_handler_list, handle);
  if (index == -1) {
    return;
  }
  free(linked_list_get(s_handler_list, index));
  linked_list_remove(s_handler_list, index);
  if (linked_list_count(s_handler_list) == 0) {
    app_message_deregister_callbacks();
  }
}
Esempio n. 19
0
void events_battery_state_service_unsubscribe(EventHandle handle) {
  int16_t index = linked_list_find(s_handler_list, handle);
  if (index == -1) {
    return;
  }
  free(linked_list_get(s_handler_list, index));
  linked_list_remove(s_handler_list, index);
  if (linked_list_count(s_handler_list) == 0) {
    battery_state_service_unsubscribe();
  }
}
Esempio n. 20
0
void X86CoreFreeEventQueue(X86Core *self)
{
	struct x86_uop_t *uop;

	while (linked_list_count(self->event_queue))
	{
		uop = X86CoreExtractFromEventQueue(self);
		x86_uop_free_if_not_queued(uop);
	}
	linked_list_free(self->event_queue);
}
Esempio n. 21
0
static bool prv_init(void) {
  if (!s_handler_list) {
    s_handler_list = linked_list_create_root();
  }
  if (linked_list_count(s_handler_list) == 0) {
    app_message_register_outbox_sent(prv_handle_outbox_sent);
    app_message_register_outbox_failed(prv_handle_outbox_failed);
    app_message_register_inbox_received(prv_handle_inbox_received);
    app_message_register_inbox_dropped(prv_handle_inbox_dropped);
  }
  return true;
}
Esempio n. 22
0
void X86ThreadFreeLSQ(X86Thread *self) {
  struct linked_list_t *lq;
  struct linked_list_t *sq;
  struct linked_list_t *preq;
  struct x86_uop_t *uop;

  /* Load queue */
  lq = self->lq;
  linked_list_head(lq);
  while (linked_list_count(lq)) {
    uop = linked_list_get(lq);
    uop->in_lq = 0;
    linked_list_remove(lq);
    x86_uop_free_if_not_queued(uop);
  }
  linked_list_free(lq);

  /* Store queue */
  sq = self->sq;
  linked_list_head(sq);
  while (linked_list_count(sq)) {
    uop = linked_list_get(sq);
    uop->in_sq = 0;
    linked_list_remove(sq);
    x86_uop_free_if_not_queued(uop);
  }
  linked_list_free(sq);

  /* Prefetch queue */
  preq = self->preq;
  linked_list_head(preq);
  while (linked_list_count(preq)) {
    uop = linked_list_get(preq);
    uop->in_preq = 0;
    linked_list_remove(preq);
    x86_uop_free_if_not_queued(uop);
  }
  linked_list_free(preq);
}
Esempio n. 23
0
/* Schedule all events waiting in the wakeup list */
void net_buffer_wakeup(struct net_buffer_t *buffer)
{
	struct net_buffer_wakeup_t *wakeup;

	while (linked_list_count(buffer->wakeup_list))
	{
		/* Get event/stack */
		linked_list_head(buffer->wakeup_list);
		wakeup = linked_list_get(buffer->wakeup_list);
		linked_list_remove(buffer->wakeup_list);

		/* Schedule event */
		esim_schedule_event(wakeup->event, wakeup->stack, 0);
		free(wakeup);
	}
}
Esempio n. 24
0
struct x86_uop_t *X86CoreExtractFromEventQueue(X86Core *self)
{
	struct linked_list_t *event_queue = self->event_queue;
	struct x86_uop_t *uop;

	if (!linked_list_count(event_queue))
		return NULL;

	linked_list_head(event_queue);
	uop = linked_list_get(event_queue);
	assert(x86_uop_exists(uop));
	assert(uop->in_event_queue);
	linked_list_remove(event_queue);
	uop->in_event_queue = 0;
	return uop;
}
Esempio n. 25
0
GBitmap* bitmaps_get_sub_bitmap(uint32_t res_id, GRect rect) {
  if (! bitmaps) {
    return NULL;
  }
  GBitmap* parent = NULL;
  uint8_t count = linked_list_count(bitmaps);
  for (uint8_t b = 0; b < count; b += 1) {
    AppBitmap* bmp = (AppBitmap*)linked_list_get(bitmaps, b);
    if (bmp->res_id == res_id) {
      if (bmp->is_sub) {
        if (grect_equal(bmp->rect, &rect)) {
          return bmp->bitmap;
        }
      }
      else {
        parent = bmp->bitmap;
      }
    }
  }
  if (! parent) {
    parent = bitmaps_get_bitmap(res_id);
    if (! parent) {
      return NULL;
    }
  }
  AppBitmap* app_bmp = malloc(sizeof(AppBitmap));
  if (app_bmp == NULL) {
    return NULL;
  }
  app_bmp->res_id = res_id;
  app_bmp->bitmap = gbitmap_create_as_sub_bitmap(parent, rect);
  if (app_bmp->bitmap == NULL) {
    return NULL;
  }
  app_bmp->rect = malloc(sizeof(GRect));
  app_bmp->rect->origin = rect.origin;
  app_bmp->rect->size = rect.size;
  app_bmp->is_sub = true;
  linked_list_append(bitmaps, app_bmp);
  return app_bmp->bitmap;
}
const char *localize_str(int hashval) { 
  hash_string s;
  s.hashval = hashval;
  int16_t index = linked_list_find_compare(s_root, &s, compare_hash_string);
  if(index > -1){
    return ((hash_string*)linked_list_get(s_root, index))->value;
  }
  else {
    char *res = prv_load(hashval);
    if(res){
      if(s_limit > 0){
        uint16_t count = linked_list_count(s_root);
        if(count > s_limit){
          hash_string *last = linked_list_get(s_root, count-1);
          prv_destroy_element(last, NULL);
          linked_list_remove(s_root, count-1);
        }
      }
      return res;
    }
  }
  return "\7"; //return blank character
}
Esempio n. 27
0
uint8_t timers_count(void) {
  return linked_list_count(timers);
}
Esempio n. 28
0
void si_scalar_unit_writeback(struct si_scalar_unit_t *scalar_unit)
{
	struct si_uop_t *uop = NULL;
	struct si_wavefront_t *wavefront;
	struct si_work_group_t *work_group;
	struct si_ndrange_t *ndrange;
	int i;
	int list_count;
	int wavefront_id;

	/* Process completed memory instructions */
	list_count = linked_list_count(scalar_unit->mem_out_buffer);
	linked_list_head(scalar_unit->mem_out_buffer);
	for (i = 0; i < list_count; i++)
	{
		uop = linked_list_get(scalar_unit->mem_out_buffer);
		assert(uop);

		if (!uop->global_mem_witness)
		{
			/* Access complete, remove the uop from the queue */
			linked_list_remove(scalar_unit->mem_out_buffer);

			si_trace("si.inst id=%lld cu=%d stg=\"su-w\"\n", uop->id_in_compute_unit, 
				scalar_unit->compute_unit->id);

			/* Make the wavefront active again */
			wavefront = uop->wavefront;
			wavefront->ready = 1;

			/* Free uop */
			if (si_tracing())
				si_gpu_uop_trash_add(uop);
			else
				si_uop_free(uop);
		}
		else
		{
			linked_list_next(scalar_unit->mem_out_buffer);
		}
	}

	/* Process completed ALU instructions */
	list_count = linked_list_count(scalar_unit->alu_out_buffer);
	linked_list_head(scalar_unit->alu_out_buffer);
	for (i = 0; i < list_count; i++)
	{
		uop = linked_list_get(scalar_unit->alu_out_buffer);
		assert(uop);

		if (uop->execute_ready <= si_gpu->cycle)
		{
			/* Access complete, remove the uop from the queue */
			linked_list_remove(scalar_unit->alu_out_buffer);

			si_trace("si.inst id=%lld cu=%d stg=\"su-w\"\n", uop->id_in_compute_unit, 
				scalar_unit->compute_unit->id);

			/* Make the wavefront active again */
			wavefront = uop->wavefront;
			work_group = wavefront->work_group;
			ndrange = work_group->ndrange;
			if (wavefront->finished)
			{
				work_group->compute_unit_finished_count++;
			}
			else if (wavefront->barrier)
			{
				if (wavefront->barrier_cleared) 
				{
					/* All wavefronts have hit barrier */

					wavefront->barrier_cleared = 0;

					SI_FOREACH_WAVEFRONT_IN_WORK_GROUP(work_group, 
						wavefront_id)
					{
						wavefront = ndrange->wavefronts[wavefront_id];
						wavefront->barrier = 0;
						wavefront->ready = 1;
					}
	
				}
				else 
				{
					/* Wavefront is waiting at barrier */
				}
			}
			else 
			{
Esempio n. 29
0
/**
 * Function to get the number of presets in the list.
 * @return number of presets in the preset list.
 */
int presets_get_count(){
	return linked_list_count(presets);
}
Esempio n. 30
0
int timers_get_count() {
  return linked_list_count(timers);
}