Esempio n. 1
0
static void X86ContextDoCreate(X86Context *self, X86Emu *emu)
{
	int num_nodes;
	int i;
	
	/* Initialize */
	self->emu = emu;
	self->pid = emu->current_pid++;
	self->sched_policy = SCHED_RR;
	self->sched_priority = 1;  /* Lowest priority */

	/* Update state so that the context is inserted in the
	 * corresponding lists. The x86_ctx_running parameter has no
	 * effect, since it will be updated later. */
	X86ContextSetState(self, X86ContextRunning);
	DOUBLE_LINKED_LIST_INSERT_HEAD(emu, context, self);

	/* Structures */
	self->regs = x86_regs_create();
	self->backup_regs = x86_regs_create();
	self->signal_mask_table = x86_signal_mask_table_create();

	/* Thread affinity mask, used only for timing simulation. It is
	 * initialized to all 1's. */
	num_nodes = x86_cpu_num_cores * x86_cpu_num_threads;
	self->affinity = bit_map_create(num_nodes);
	for (i = 0; i < num_nodes; i++)
		bit_map_set(self->affinity, i, 1, 1);

	/* Initialize statically allocate instruction */
	new_static(&self->inst, X86Inst, emu->as);

	/* Virtual functions */
	asObject(self)->Dump = X86ContextDump;
}
Esempio n. 2
0
struct si_wavefront_t *si_wavefront_create()
{
    struct si_wavefront_t *wavefront;

    /* Initialize */
    wavefront = xcalloc(1, sizeof(struct si_wavefront_t));
    wavefront->pred = bit_map_create(si_emu_wavefront_size);
    si_wavefront_sreg_init(wavefront);

    /* Return */
    return wavefront;
}
Esempio n. 3
0
void KplWarpCreate(KplWarp *self, int id, KplThreadBlock *thread_block,
		KplGrid *grid)
{
	KplEmu *emu = grid->emu;

	/* Initialization */
	self->id = id + thread_block->id * thread_block->warp_count;
	self->id_in_thread_block = id;
	self->grid = grid;
	self->thread_block = thread_block;

	/* Allocate threads */
	if (id < thread_block->warp_count - 1)
		self->thread_count = kpl_emu_warp_size;
	else
		self->thread_count = grid->thread_block_size -
		(thread_block->warp_count - 1) * kpl_emu_warp_size;
	self->threads = (KplThread **) xcalloc(self->thread_count,
			sizeof(KplThread *));

	/* Instruction */
	self->inst = KplInstWrapCreate(emu->as);
	self->inst_size = 8;
	self->inst_buffer = grid->function->inst_bin;
	self->inst_buffer_size = grid->function->inst_bin_size;

	/* Sync stack */
	self->sync_stack_top = 0;
	self->sync_stack.entries[self->sync_stack_top].active_thread_mask =
			bit_map_create(self->thread_count);
	bit_map_set(self->sync_stack.entries[self->sync_stack_top].
			active_thread_mask, 0, self->thread_count,
			((unsigned long long)1 << self->thread_count) - 1);

	/* Reset flags */
	self->at_barrier = 0;
	self->finished_thread_count = 0;
	self->finished = 0;
}