示例#1
0
/* Remove all speculative uops from a given load/store queue in the
 * given thread. */
void X86ThreadRecoverLSQ(X86Thread *self) {
  struct linked_list_t *lq = self->lq;
  struct linked_list_t *sq = self->sq;
  struct x86_uop_t *uop;

  /* Recover load queue */
  linked_list_head(lq);
  while (!linked_list_is_end(lq)) {
    uop = linked_list_get(lq);
    if (uop->specmode) {
      X86ThreadRemoveFromLQ(self);
      x86_uop_free_if_not_queued(uop);
      continue;
    }
    linked_list_next(lq);
  }

  /* Recover store queue */
  linked_list_head(sq);
  while (!linked_list_is_end(sq)) {
    uop = linked_list_get(sq);
    if (uop->specmode) {
      X86ThreadRemoveFromSQ(self);
      x86_uop_free_if_not_queued(uop);
      continue;
    }
    linked_list_next(sq);
  }
}
示例#2
0
文件: sched.c 项目: abhaykadam/vm
static struct gpu_wavefront_t *gpu_schedule_round_robin(struct gpu_compute_unit_t *compute_unit)
{
	struct gpu_wavefront_t *wavefront, *temp_wavefront;
	struct linked_list_t *wavefront_pool = compute_unit->wavefront_pool;

	/* Select current position in pool as initial candidate wavefront */
	if (!linked_list_get(wavefront_pool))
		linked_list_head(wavefront_pool);
	wavefront = linked_list_get(wavefront_pool);
	temp_wavefront = wavefront;

	/* Look for a valid candidate */
	for (;;)
	{
		/* Wavefront must be running,
		 * and the corresponding slot in fetch buffer must be free. */
		assert(wavefront->id_in_compute_unit < gpu->wavefronts_per_compute_unit);
		if (DOUBLE_LINKED_LIST_MEMBER(wavefront->work_group, running, wavefront) &&
			!compute_unit->cf_engine.fetch_buffer[wavefront->id_in_compute_unit])
			break;

		/* Current candidate is not valid - go to next.
		 * If we went through the whole pool, no fetch. */
		linked_list_next_circular(wavefront_pool);
		wavefront = linked_list_get(wavefront_pool);
		if (wavefront == temp_wavefront)
			return NULL;
	}

	/* Wavefront found, remove from pool and return. */
	assert(wavefront->clause_kind == GPU_CLAUSE_CF);
	linked_list_remove(wavefront_pool);
	return wavefront;
}
示例#3
0
void x86_loader_free(struct x86_loader_t *loader)
{
	/* Check no more links */
	assert(!loader->num_links);

	/* Free ELF file  */
	if (loader->elf_file)
		elf_file_free(loader->elf_file);

	/* Free arguments */
	LINKED_LIST_FOR_EACH(loader->args)
		str_free(linked_list_get(loader->args));
	linked_list_free(loader->args);

	/* Free environment variables */
	LINKED_LIST_FOR_EACH(loader->env)
		str_free(linked_list_get(loader->env));
	linked_list_free(loader->env);

	/* Free loader */
	str_free(loader->interp);
	str_free(loader->exe);
	str_free(loader->cwd);
	str_free(loader->stdin_file);
	str_free(loader->stdout_file);
	free(loader);
}
示例#4
0
static char* append_get_multiple(void) {
  linked_list_append(root, create_object(1));
  linked_list_append(root, create_object(2));
  Object* object1 = (Object*)linked_list_get(root, 0);
  Object* object2 = (Object*)linked_list_get(root, 1);
  mu_assert(NULL != object1 && 1 == object1->id, "Cannot get first appended item.");
  mu_assert(NULL != object2 && 2 == object2->id, "Cannot get second appended item.");
  return 0;
}
示例#5
0
static char* remove_single_item(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, 1);
  mu_assert(1 == get_id(linked_list_get(root, 0)), "Removing single item failed.");
  mu_assert(3 == get_id(linked_list_get(root, 1)), "Removing single item failed.");
  mu_assert(2 == linked_list_count(root), "Removing single item failed.");
  return 0;
}
示例#6
0
static char* prepend_not_empty(void) {
  linked_list_append(root, create_object(1));
  linked_list_prepend(root, create_object(2));
  Object* object = (Object*)linked_list_get(root, 0);
  mu_assert(NULL != object && 2 == object->id, "Cannot get item prepended on list.");
  return 0;
}
示例#7
0
/**
 * Destroy BAM framework data structure.
 */
void
bfwork_destroy(bam_fwork_t *fwork)
{
	int i;
	bam_region_t *region;
	linked_list_t *list;
	size_t list_l;

	assert(fwork);
	assert(fwork->regions_list);

	//Handle to list
	list = fwork->regions_list;

	//Regions exists?
	if(fwork->regions_list)
	{
		//for(i = 0; i < wanderer->regions_l; i++)
		list_l = linked_list_size(list);
		for(i = 0; i < list_l; i++)
		{
			//Get region
			region = linked_list_get(i, list);
			breg_destroy(region, 1);
			free(region);
		}
		linked_list_free(list, NULL);
	}

	//Destroy lock
	omp_destroy_lock(&fwork->regions_lock);
	omp_destroy_lock(&fwork->output_file_lock);
	omp_destroy_lock(&fwork->reference_lock);
}
示例#8
0
文件: timers.c 项目: Kfernand2/pebble
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();
  }
}
示例#9
0
static int X86ThreadIssueSQ(X86Thread *self, int quantum) {
  X86Cpu *cpu = self->cpu;
  X86Core *core = self->core;

  struct x86_uop_t *store;
  struct linked_list_t *sq = self->sq;
  struct mod_client_info_t *client_info;

  /* Process SQ */
  linked_list_head(sq);
  while (!linked_list_is_end(sq) && quantum) {
    /* Get store */
    store = linked_list_get(sq);
    assert(store->uinst->opcode == x86_uinst_store);

    /* Only committed stores issue */
    if (store->in_rob) break;

    /* Check that memory system entry is ready */
    if (!mod_can_access(self->data_mod, store->phy_addr)) break;

    /* Remove store from store queue */
    X86ThreadRemoveFromSQ(self);

    /* create and fill the mod_client_info_t object */
    client_info = mod_client_info_create(self->data_mod);
    client_info->prefetcher_eip = store->eip;

    /* Issue store */
    mod_access(self->data_mod, mod_access_store, store->phy_addr, NULL,
               core->event_queue, store, client_info);

    /* The cache system will place the store at the head of the
     * event queue when it is ready. For now, mark "in_event_queue" to
     * prevent the uop from being freed. */
    store->in_event_queue = 1;
    store->issued = 1;
    store->issue_when = asTiming(cpu)->cycle;

    /* Statistics */
    core->num_issued_uinst_array[store->uinst->opcode]++;
    core->lsq_reads++;
    core->reg_file_int_reads += store->ph_int_idep_count;
    core->reg_file_fp_reads += store->ph_fp_idep_count;
    self->num_issued_uinst_array[store->uinst->opcode]++;
    self->lsq_reads++;
    self->reg_file_int_reads += store->ph_int_idep_count;
    self->reg_file_fp_reads += store->ph_fp_idep_count;
    cpu->num_issued_uinst_array[store->uinst->opcode]++;
    if (store->trace_cache) self->trace_cache->num_issued_uinst++;

    /* One more instruction, update quantum. */
    quantum--;

    /* MMU statistics */
    if (*mmu_report_file_name)
      mmu_access_page(store->phy_addr, mmu_access_write);
  }
  return quantum;
}
示例#10
0
void timer_process(void)
{
    PCB *each_pcb;
    int size, i, on;
    MSG_BUF *each_msg, *received_msg;
    while(1)
    {
        received_msg = receive_message(&size);
				on = atomic_on();
        if(received_msg->mtype == MSG_TIMER_NOTIFICATION)
        {
            for (i = 0; i < gp_pending_message_queue.size; i++)
            {
                each_msg = list_entry(linked_list_get(&gp_pending_message_queue, i), MSG_BUF, m_lnode);
                each_msg->delay--;
                if (each_msg->delay <= 0)
                {
                    each_pcb = get_pcb_by_pid(each_msg->m_recv_pid);
                    linked_list_remove(&gp_pending_message_queue, i);
                    add_to_message_queue(each_pcb, each_msg);
                    i--;
                    if (each_pcb->m_state == BLK && each_pcb->m_blk_reason == BLK_REASON_WAITING_FOR_MSG)
                    {
                        k_unblock_process(each_pcb->m_pid);
                    }
                }
            }
        }
			atomic_off(on);
    }
}
示例#11
0
文件: timers.c 项目: Kfernand2/pebble
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);
  }
}
示例#12
0
static void evg_tex_engine_fetch(struct evg_compute_unit_t *compute_unit) {
  struct linked_list_t *pending_queue = compute_unit->tex_engine.pending_queue;
  struct linked_list_t *finished_queue =
      compute_unit->tex_engine.finished_queue;

  struct evg_wavefront_t *wavefront;
  struct evg_uop_t *cf_uop, *uop;
  struct evg_work_item_uop_t *work_item_uop;
  struct evg_inst_t *inst;
  int inst_num;

  struct evg_work_item_t *work_item;
  int work_item_id;

  char str[MAX_LONG_STRING_SIZE];
  char str_trimmed[MAX_LONG_STRING_SIZE];

  /* Get wavefront to fetch from */
  linked_list_head(pending_queue);
  cf_uop = linked_list_get(pending_queue);
  if (!cf_uop) return;
  wavefront = cf_uop->wavefront;
  assert(wavefront->clause_kind == EVG_CLAUSE_TEX);

  /* If fetch queue is full, cannot fetch until space is made */
  if (compute_unit->tex_engine.fetch_queue_length >=
      evg_gpu_tex_engine_fetch_queue_size)
    return;

  /* Emulate instruction and create uop */
  inst_num = (wavefront->clause_buf - wavefront->clause_buf_start) / 16;
  evg_wavefront_execute(wavefront);
  inst = &wavefront->tex_inst;
  uop = evg_uop_create();
  uop->wavefront = wavefront;
  uop->work_group = wavefront->work_group;
  uop->cf_uop = cf_uop;
  uop->compute_unit = compute_unit;
  uop->id_in_compute_unit = compute_unit->gpu_uop_id_counter++;
  uop->last = wavefront->clause_kind != EVG_CLAUSE_TEX;
  uop->global_mem_read = wavefront->global_mem_read;
  uop->global_mem_write = wavefront->global_mem_write;
  uop->vliw_slots = 1;

  /* If TEX clause finished, extract CF uop from 'pending_queue' and
   * insert it into 'finished_queue'. */
  if (uop->last) {
    linked_list_remove(pending_queue);
    linked_list_add(finished_queue, cf_uop);
  }

  /* If instruction is a global memory read (should be), record addresses */
  if (uop->global_mem_read) {
    assert((inst->info->flags & EVG_INST_FLAG_MEM_READ));
    EVG_FOREACH_WORK_ITEM_IN_WAVEFRONT(wavefront, work_item_id) {
      work_item = evg_gpu->ndrange->work_items[work_item_id];
      work_item_uop = &uop->work_item_uop[work_item->id_in_wavefront];
      work_item_uop->global_mem_access_addr = work_item->global_mem_access_addr;
      work_item_uop->global_mem_access_size = work_item->global_mem_access_size;
    }
示例#13
0
static char* insert_invalid_index(void) {
  linked_list_append(root, create_object(1));
  linked_list_append(root, create_object(2));
  linked_list_insert(root, create_object(3), 4);
  Object* object = (Object*)linked_list_get(root, 2);
  mu_assert(NULL != object && 3 == object->id, "Cannot insert item at an invalid index.");
  return 0;
}
示例#14
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);
  }
}
示例#15
0
文件: stg-issue.c 项目: abhaykadam/vm
static int issue_sq(int core, int thread, int quant)
{
	struct uop_t *store;
	struct linked_list_t *sq = THREAD.sq;

	/* Process SQ */
	linked_list_head(sq);
	while (!linked_list_is_end(sq) && quant)
	{
		/* Get store */
		store = linked_list_get(sq);
		assert(store->uinst->opcode == x86_uinst_store);

		/* Only committed stores issue */
		if (store->in_rob)
			break;

		/* Check that memory system entry is ready */
		if (!mod_can_access(THREAD.data_mod, store->phy_addr))
			break;

		/* Remove store from store queue */
		sq_remove(core, thread);

		/* Issue store */
		mod_access(THREAD.data_mod, mod_entry_cpu, mod_access_write,
			store->phy_addr, NULL, CORE.eventq, store);

		/* The cache system will place the store at the head of the
		 * event queue when it is ready. For now, mark "in_eventq" to
		 * prevent the uop from being freed. */
		store->in_eventq = 1;
		store->issued = 1;
		store->issue_when = cpu->cycle;
	
		/* Instruction issued */
		CORE.issued[store->uinst->opcode]++;
		CORE.lsq_reads++;
		CORE.rf_int_reads += store->ph_int_idep_count;
		CORE.rf_fp_reads += store->ph_fp_idep_count;
		THREAD.issued[store->uinst->opcode]++;
		THREAD.lsq_reads++;
		THREAD.rf_int_reads += store->ph_int_idep_count;
		THREAD.rf_fp_reads += store->ph_fp_idep_count;
		cpu->issued[store->uinst->opcode]++;
		quant--;
		
		/* MMU statistics */
		if (*mmu_report_file_name)
			mmu_access_page(store->phy_addr, mmu_access_write);

		/* Debug */
		esim_debug("uop action=\"update\", core=%d, seq=%llu,"
			" stg_issue=1, in_lsq=0, issued=1\n",
			store->core, (long long unsigned) store->di_seq);
	}
	return quant;
}
示例#16
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;
}
示例#17
0
文件: pebble.c 项目: Kfernand2/pebble
int32_t persist_read_int(const uint32_t key) {
  Persist* persist = (Persist*) linked_list_get(persistence, linked_list_find_compare(persistence, fake_persist(key), persist_compare));
  if (! persist) {
    return -1;
  }
  if (NUMBER != persist->type) {
    return -1;
  }
  return persist->number;
}
示例#18
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);
}
示例#19
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;
}
示例#20
0
static void action_paste_files_draw_top(ui_view* view, void* data, float x1, float y1, float x2, float y2) {
    paste_files_data* pasteData = (paste_files_data*) data;

    u32 curr = pasteData->pasteInfo.processed;
    if(curr < pasteData->pasteInfo.total) {
        ui_draw_file_info(view, ((list_item*) linked_list_get(&pasteData->contents, curr))->data, x1, y1, x2, y2);
    } else if(pasteData->target != NULL) {
        ui_draw_file_info(view, pasteData->target, x1, y1, x2, y2);
    }
}
示例#21
0
文件: timers.c 项目: Kfernand2/pebble
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);
  }
}
示例#22
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();
  }
}
示例#23
0
文件: pebble.c 项目: Kfernand2/pebble
int persist_read_data(const uint32_t key, void *buffer, const size_t buffer_size) {
  Persist* persist = (Persist*) linked_list_get(persistence, linked_list_find_compare(persistence, fake_persist(key), persist_compare));
  if (! persist) {
    return -1;
  }
  if (DATA != persist->type) {
    return -1;
  }
  memcpy(buffer, persist->data, buffer_size);
  return buffer_size;
}
示例#24
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);
	}
}
示例#25
0
文件: pebble.c 项目: Kfernand2/pebble
int persist_read_string(const uint32_t key, char *buffer, const size_t buffer_size) {
  Persist* persist = (Persist*) linked_list_get(persistence, linked_list_find_compare(persistence, fake_persist(key), persist_compare));
  if (! persist) {
    return -1;
  }
  if (STRING != persist->type) {
    return -1;
  }
  strncpy(buffer, persist->str, buffer_size);
  return buffer_size;
}
示例#26
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();
  }
}
示例#27
0
// This function tries to find the key/value pair identified by "key"
// (by delegating to linked_list_get) and returns either:
// - HT_VALUE_FOUND if the key was found in the hash table ht, in which case
//   it also assigns the associated value to "result" before returning
// - HT_VALUE_NOT_FOUND if the "key" parameter can not be found in 
//   the hash table "ht", in which case NULL is assigned to "value" 
ht_status_code
get(hashtable *ht, char *key, char **result)
{
  unsigned int hashed_value = hash(key, ht->size); 
  ll_status_code sc = linked_list_get(ht->table[hashed_value], key, result);
  switch(sc){
    case LL_VALUE_FOUND:
      return HT_VALUE_FOUND; 
    case LL_VALUE_NOT_FOUND:
      return HT_VALUE_NOT_FOUND;
  }
} 
示例#28
0
static int x86_cpu_issue_sq(int core, int thread, int quant)
{
	struct x86_uop_t *store;
	struct linked_list_t *sq = X86_THREAD.sq;

	/* Process SQ */
	linked_list_head(sq);
	while (!linked_list_is_end(sq) && quant)
	{
		/* Get store */
		store = linked_list_get(sq);
		assert(store->uinst->opcode == x86_uinst_store);

		/* Only committed stores issue */
		if (store->in_rob)
			break;

		/* Check that memory system entry is ready */
		if (!mod_can_access(X86_THREAD.data_mod, store->phy_addr))
			break;

		/* Remove store from store queue */
		x86_sq_remove(core, thread);

		/* Issue store */
		mod_access(X86_THREAD.data_mod, mod_access_store,
			store->phy_addr, NULL, X86_CORE.event_queue, store);

		/* The cache system will place the store at the head of the
		 * event queue when it is ready. For now, mark "in_event_queue" to
		 * prevent the uop from being freed. */
		store->in_event_queue = 1;
		store->issued = 1;
		store->issue_when = x86_cpu->cycle;
	
		/* Instruction issued */
		X86_CORE.issued[store->uinst->opcode]++;
		X86_CORE.lsq_reads++;
		X86_CORE.reg_file_int_reads += store->ph_int_idep_count;
		X86_CORE.reg_file_fp_reads += store->ph_fp_idep_count;
		X86_THREAD.issued[store->uinst->opcode]++;
		X86_THREAD.lsq_reads++;
		X86_THREAD.reg_file_int_reads += store->ph_int_idep_count;
		X86_THREAD.reg_file_fp_reads += store->ph_fp_idep_count;
		x86_cpu->issued[store->uinst->opcode]++;
		quant--;
		
		/* MMU statistics */
		if (*mmu_report_file_name)
			mmu_access_page(store->phy_addr, mmu_access_write);
	}
	return quant;
}
void test_lookup()
{
	// get 
	linked_list* ll = linked_list_new();
	int i;
	for (i = 0; i < 100; i++)
	{
		linked_list_insert(ll, i * 2);
	}
	assert_equals(linked_list_get(ll, 0), 0);
	assert_equals(linked_list_get(ll, 99), 99 * 2);
	assert_equals(linked_list_get(ll, 50), 50 * 2);
	// contains 
	assert_true(linked_list_contains(ll, 10));
	assert_false(linked_list_contains(ll, 1));
	// peek 
	//assert_equals(linked_list_first(ll), 0);
	// last 
	//assert_equals(linked_list_last(ll), 99 * 2);
	// index of 
}
示例#30
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);
}