Skip to content

MicroCreator_Chapter_7_Internals_Section_4_Code_Generation

Alexandre Laurent edited this page May 29, 2015 · 2 revisions

Index Navigation

This section is part of Chapter 7 in the MicroCreator Manual.

The previous section is Section 3: Plugin System.

There is no next section.

Introduction

Code generation is the purpose of MicroCreator, whether in assembly form or C code depending on the request of the user. The following section provides an insight on how the tool generates code and what options are provided. The tool also creates programs supporting OpenMP, the parallel paradigm.

Assembly Generation

The default behavior of MicroCreator generates assembly code. The way the code is generated simply follows the order in which kernels are found. A kernel is a one-entry, one-exit group of instructions, which defines, in compiler terminology, a basic block. In order to generate a kernel, the system first determines whether branch information was provided. If so, the branch label is generated first, followed by the instructions, finishing with the jump instruction. The branch label is exactly the label the user wishes to use in the generated assembly code. Instructions are created by concatenating the operation name and followed by the various operands.

C-code Generation

The C-code version of the tool generates exactly the same instructions as the assembly version, however they are integrated into GNU asm instructions. C-code microbenchmark creation allows users to automatically integrate the generated microbenchmark programs into their own C-language wrappers or applications.

OpenMP Generation

The OpenMP generation is similar to the C-code generation but contains more work for MicroCreator. Instead of only generating GNU asm instructions, MicroCreator also generates small C-code prologue and epilogue sections.

For the prologue, MicroCreator creates a few associations between the registers used in the input kernels and the C-code variables used in the C generated code. For example:

	//Registers declaration
	register ELT x0 asm ("%xmm0");
	register ELT x1 asm ("%xmm1");

The loop itself is also automatically generated by MicroLauncher:

	#pragma omp parallel for 
	for (i = 0; i < 20; i += (8 * 4))

Finally, the return of the function is generated and provides the number of iterations. In the case of one induction variable it is easy:

	return ((20 - 0) / (8 * 4));

Conclusion

MicroCreator supports three types of code generation. The assembly creation is generally coupled with the use of MicroLauncher. The C-code is used when integrating the programs into existing applications. Finally, the OpenMP variation is used to test OpenMP constructs and the impact of code variations.

Index Navigation

This section is part of Chapter 7 in the MicroCreator Manual.

The previous section is Section 3: Plugin System.

There is no next section.

Clone this wiki locally