Task Mapping File Overview
To make thing easier I will give a short guide to help you understand how mapping works
First I suggest you run a mapping file in a web browser this will help you find any mistakes you have done in the syntax of your file your mapping file must be readable by a web browser.
The look of the mapping file is much different than what it really is. It looks scary and complex but don’t worry more than half of the lines are written there to meet the XML language syntax requirements.
First of all you have to do these things before you start reading this guide
While reading the documents please pay more attention to these concepts .
- The max field in arrays
- Difference between Task Types
- Task calling semantics
- Task variant call graph
- Difference between mappar and mapreduce
Hint: These two below pages should be read more than twice
- Task instantiation: setting the tunable for different memory and data sizes considering the optimization
- Mapping Control: pay attention on 2D parallelization mapping
After reading these stuff you should take a look at the mapping syntax in XML to get what is going on but do not panic I will describe this matrix multiplication mapping for you to make it easy.
<mapping>
<machine filename="generic_cell/config/ps3.xml"/>
<entrypoints>matrixmult_inner_entrypoint</entrypoints>
<taskmapping name="matrixmult">
<instance name="matrixmult_inner_entrypoint">
<level>1</level>
<variant>inner_reduce</variant>
<tunable name="Mblk">64</tunable>
<tunable name="Nblk">64</tunable>
<tunable name="Pblk">64</tunable>
<ctrl>
<level>0</level>
<loop name="i" lexnum="0">
<spmd>
<fullrange> 0, 6 </fullrange>
<ways> 3 </ways>
<iterblk>1</iterblk>
</spmd>
</loop>
<loop name="k" lexnum="0">
<spmd>
<ways> 2 </ways>
<iterblk>1</iterblk>
</spmd>
</loop>
<callsite name="matrixmult" lexnum="0">
<target name="matrixmult_leaf">
</target>
<combiner id='0'>matrixadd_leaf</combiner>
</callsite>
</ctrl>
</instance>
<instance name="matrixmult_leaf">
<level>0</level>
<variant>leaf</variant>
<filename>matrixmult_leaf_gcell.c</filename>
</instance>
</taskmapping>
</mapping>
How to read and write a Task
If you look at this mapping file you will notice that each mapping setting phrase like <mapping>, <level> and …. has a begin and an end that starts with <name> and finishes with </name> it means for each <level> there is a </level>. this shows the domain of your mapping and can help you separate the stuff you have there.
Note that the mapping is not done nested. Consider the case of Matrix multiplication: If you have 4 level of memory you have 4 instances of task and their mappings that are written one by one It means if you learn the mapping of one level of hierarchy you can write the mapping of N level of hierarchy by just copying and pasting the same mapping and just change the variant names and parameters and the level in which your task instance is located
It is obvious from the above example <instance name=“ “> phrases are written collateral for all inner instances tasks and the leaf task. The best thing to do is that when you write a phrase write its twin ending phrase immediately like below and then fill in the middle.
- <instance name name=“ “>
- </instance >
Here is a simple description of what you will do in mapping of an instance.
- You will select the task instance name for which you are writing the mapping
- Then write the type of the task variant (inner/leaf)
- Write in which level of memory you task is doing its job
- Set the tunables
- Then you will have Data and control parts
- data part is for setting the restriction of arrays passed to this Task
- control part is for defining
- Your first loop variable name and its definition
- The optimization settings and parameters such as :
- fullrange which shows the number of parallel loops that are run concurrently
- optimization options such as software pipelining
- The optimization settings and parameters such as :
- Your second,third and … loops variable names and their definitions
- The next level task that your task will call (callsite)
- Your first loop variable name and its definition
Hints
- Basically, each instance of a task needs a block
- Within a block, each callsite (any task that you call) needs a description of what instance it will be calling.
*In general there can be more than one callsite, and the description needs to appear for each one in lexical order.
- If you have four instances you have to do the same thing for all of those tasks. the tasks are connected to each other like a chain.
With your mapping each task mapping will say which tasks in the next level it will call and how it will run them in its for-loops.
