Ejemplo n.º 1
0
void vi_si_compute_unit_write_checkpoint(struct vi_si_compute_unit_t *compute_unit, FILE *f)
{
	int num_work_groups;
	int num_insts;

	int count;

	char *work_group_name;
	char *inst_name;

	struct vi_si_work_group_t *work_group;
	struct vi_si_inst_t *inst;

	/* Write number of work-groups */
	num_work_groups = hash_table_count(compute_unit->work_group_table);
	count = fwrite(&num_work_groups, 1, 4, f);
	if (count != 4)
		fatal("%s: cannot write checkpoint", __FUNCTION__);

	/* Write work-groups */
	HASH_TABLE_FOR_EACH(compute_unit->work_group_table, work_group_name, work_group)
		vi_si_work_group_write_checkpoint(work_group, f);

	/* Write number of instructions */
	num_insts = hash_table_count(compute_unit->inst_table);
	count = fwrite(&num_insts, 1, 4, f);
	if (count != 4)
		fatal("%s: cannot write checkpoint", __FUNCTION__);

	/* Write instructions */
	HASH_TABLE_FOR_EACH(compute_unit->inst_table, inst_name, inst)
		vi_si_inst_write_checkpoint(inst, f);
}
Ejemplo n.º 2
0
Archivo: core.c Proyecto: ajithcj/miaow
void vi_x86_core_write_checkpoint(struct vi_x86_core_t *core, FILE *f)
{
    struct vi_x86_context_t *context;
    struct vi_x86_inst_t *inst;

    int num_contexts;
    int num_insts;
    int count;

    char *context_name;
    char *inst_name;

    /* Number of contexts */
    num_contexts = hash_table_count(core->context_table);
    count = fwrite(&num_contexts, 1, 4, f);
    if (count != 4)
        fatal("%s: cannot write checkpoint", __FUNCTION__);

    /* Contexts */
    HASH_TABLE_FOR_EACH(core->context_table, context_name, context)
    str_write_to_file(f, context_name);

    /* Number of instructions */
    num_insts = hash_table_count(core->inst_table);
    count = fwrite(&num_insts, 1, 4, f);
    if (count != 4)
        fatal("%s: cannot write checkpoint", __FUNCTION__);

    /* Instructions */
    HASH_TABLE_FOR_EACH(core->inst_table, inst_name, inst)
    vi_x86_inst_write_checkpoint(inst, f);
}
Ejemplo n.º 3
0
void vi_evg_compute_unit_read_checkpoint(struct vi_evg_compute_unit_t *compute_unit, FILE *f)
{
	char *work_group_name;
	char *inst_name;

	struct vi_evg_work_group_t *work_group;
	struct vi_evg_inst_t *inst;

	int num_work_groups;
	int num_insts;

	int count;
	int i;

	/* Empty work-group list */
	HASH_TABLE_FOR_EACH(compute_unit->work_group_table, work_group_name, work_group)
		vi_evg_work_group_free(work_group);
	hash_table_clear(compute_unit->work_group_table);

	/* Empty instruction list */
	HASH_TABLE_FOR_EACH(compute_unit->inst_table, inst_name, inst)
		vi_evg_inst_free(inst);
	hash_table_clear(compute_unit->inst_table);

	/* Read number of work-groups */
	count = fread(&num_work_groups, 1, 4, f);
	if (count != 4)
		fatal("%s: cannot read checkpoint", __FUNCTION__);

	/* Read work-groups */
	for (i = 0; i < num_work_groups; i++)
	{
		work_group = vi_evg_work_group_create(NULL, 0, 0, 0, 0, 0);
		vi_evg_work_group_read_checkpoint(work_group, f);
		if (!hash_table_insert(compute_unit->work_group_table, work_group->name, work_group))
			panic("%s: invalid work-group in checkpoint", __FUNCTION__);
	}

	/* Read number of instructions */
	count = fread(&num_insts, 1, 4, f);
	if (count != 4)
		fatal("%s: cannot read checkpoint", __FUNCTION__);

	/* Read instructions */
	for (i = 0; i < num_insts; i++)
	{
		inst = vi_evg_inst_create(NULL, 0, 0, 0, 0, 0, 0, NULL, NULL,
			NULL, NULL, NULL, NULL);
		vi_evg_inst_read_checkpoint(inst, f);
		if (!hash_table_insert(compute_unit->inst_table, inst->name, inst))
			panic("%s: invalid instruction in checkpoint", __FUNCTION__);
	}
}
Ejemplo n.º 4
0
void Llvm2siSymbolTableDestroy(Llvm2siSymbolTable *self)
{
	char *key;
	Llvm2siSymbol *symbol;

	/* Free symbol hash table */
	HASH_TABLE_FOR_EACH(self->table, key, symbol)
		delete(symbol);
	hash_table_free(self->table);
}
Ejemplo n.º 5
0
void frm_symbol_table_done(void)
{
	struct frm_symbol_t *symbol;
	char *name;

	/* Free all symbols */
	HASH_TABLE_FOR_EACH(frm_symbol_table, name, symbol)
		frm_symbol_free(symbol);
	
	/* Free symbol table */
	hash_table_free(frm_symbol_table);
}
Ejemplo n.º 6
0
void vi_si_compute_unit_free(struct vi_si_compute_unit_t *compute_unit)
{
	struct vi_si_work_group_t *work_group;
	struct vi_si_inst_t *inst;

	char *work_group_name;
	char *inst_name;

	/* Free work-groups */
	HASH_TABLE_FOR_EACH(compute_unit->work_group_table, work_group_name, work_group)
		vi_si_work_group_free(work_group);
	hash_table_free(compute_unit->work_group_table);

	/* Free instructions */
	HASH_TABLE_FOR_EACH(compute_unit->inst_table, inst_name, inst)
		vi_si_inst_free(inst);
	hash_table_free(compute_unit->inst_table);

	/* Free compute unit */
	free(compute_unit->name);
	free(compute_unit);
}
Ejemplo n.º 7
0
void Llvm2siSymbolTableDump(Object *self, FILE *f)
{
	Llvm2siSymbolTable *symbol_table;
	Llvm2siSymbol *symbol;

	char *key;

	symbol_table = asLlvm2siSymbolTable(self);
	fprintf(f, "Symbol table:\n");
	HASH_TABLE_FOR_EACH(symbol_table->table, key, symbol)
		Llvm2siSymbolDump(asObject(symbol), f);
	fprintf(f, "\n");
}
Ejemplo n.º 8
0
Archivo: core.c Proyecto: ajithcj/miaow
void vi_x86_core_read_checkpoint(struct vi_x86_core_t *core, FILE *f)
{
    struct vi_x86_inst_t *inst;

    int num_contexts;
    int num_insts;
    int count;
    int i;

    char context_name[MAX_STRING_SIZE];

    char *inst_name;

    /* Clear table of contexts.
     * Elements are VI_X86_CONTEXT_EMPTY, no need to free. */
    hash_table_clear(core->context_table);

    /* Create table of instructions */
    HASH_TABLE_FOR_EACH(core->inst_table, inst_name, inst)
    vi_x86_inst_free(inst);
    hash_table_clear(core->inst_table);

    /* Number of contexts */
    count = fread(&num_contexts, 1, 4, f);
    if (count != 4)
        fatal("%s: cannot read checkpoint", __FUNCTION__);

    /* Read contexts */
    for (i = 0; i < num_contexts; i++)
    {
        str_read_from_file(f, context_name, sizeof context_name);
        if (!hash_table_insert(core->context_table, context_name, VI_X86_CONTEXT_EMPTY))
            panic("%s: invalid context", __FUNCTION__);
    }

    /* Number of instructions */
    count = fread(&num_insts, 1, 4, f);
    if (count != 4)
        fatal("%s: cannot read checkpoint", __FUNCTION__);

    /* Read instructions */
    for (i = 0; i < num_insts; i++)
    {
        inst = vi_x86_inst_create(0, NULL, NULL, NULL, 0, 0);
        vi_x86_inst_read_checkpoint(inst, f);
        if (!hash_table_insert(core->inst_table, inst->name, inst))
            panic("%s: invalid instruction", __FUNCTION__);
    }
}
Ejemplo n.º 9
0
Archivo: core.c Proyecto: ajithcj/miaow
void vi_x86_core_free(struct vi_x86_core_t *core)
{
    struct vi_x86_inst_t *inst;

    char *inst_name;

    /* Free contexts (elements are VI_X86_CONTEXT_EMPTY). */
    hash_table_free(core->context_table);

    /* Free instructions */
    HASH_TABLE_FOR_EACH(core->inst_table, inst_name, inst)
    vi_x86_inst_free(inst);
    hash_table_free(core->inst_table);

    /* Free core */
    str_free(core->name);
    free(core);
}