Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| formation:astrosim2017para4dummies [2017/06/30 04:52] – equemene | formation:astrosim2017para4dummies [2017/07/07 07:25] (Version actuelle) – [5 W/2H : Why ? What ? Where ? When ? Who ? How much ? How ?] equemene | ||
|---|---|---|---|
| Ligne 13: | Ligne 13: | ||
| * **Where ?** On workstations, | * **Where ?** On workstations, | ||
| * **Who ?** For people who want to open the hood | * **Who ?** For people who want to open the hood | ||
| - | * **How ?** Applying some simples | + | * **How ?** Applying some simple |
| ===== Session Goal ===== | ===== Session Goal ===== | ||
| Ligne 134: | Ligne 134: | ||
| </ | </ | ||
| - | === Question | + | === Exercice |
| * How much lines of informations ? | * How much lines of informations ? | ||
| - | === Question | + | === Exercice |
| * What new informations appear on the output ? | * What new informations appear on the output ? | ||
| Ligne 150: | Ligne 150: | ||
| {{ : | {{ : | ||
| - | === Question | + | === Exercice |
| * Locate and identify the elements provided with '' | * Locate and identify the elements provided with '' | ||
| Ligne 178: | Ligne 178: | ||
| </ | </ | ||
| - | === Question | + | === Exercice |
| * How many devices do you get ? | * How many devices do you get ? | ||
| Ligne 190: | Ligne 190: | ||
| As when your drive a car, it's useful to get informations about running system during process. The commands '' | As when your drive a car, it's useful to get informations about running system during process. The commands '' | ||
| - | === Question | + | === Exercice |
| * What do you see first ? | * What do you see first ? | ||
| Ligne 283: | Ligne 283: | ||
| </ | </ | ||
| - | === Question | + | === Exercice |
| Ligne 343: | Ligne 343: | ||
| </ | </ | ||
| - | === Question | + | === Exercice |
| * Launch previous command to 10000, 1000, 100 launchs with respectly sizes of 10, 100, 1000 | * Launch previous command to 10000, 1000, 100 launchs with respectly sizes of 10, 100, 1000 | ||
| Ligne 350: | Ligne 350: | ||
| This will be very useful to extract and provides statistics of times. | This will be very useful to extract and provides statistics of times. | ||
| - | ===== First steps in parallelism | + | ===== An illustrative example: Pi Dart Dash ===== |
| - | ==== An illustrative example: Pi Dart Dash ==== | + | ==== Principle, inputs & outputs |
| - | + | ||
| - | === Principle, inputs & outputs === | + | |
| The most common example of Monte Carlo program: estimate Pi number by the ratio between the number of points located in the quarter of a circle where random points are uniformly distributed. It needs: | The most common example of Monte Carlo program: estimate Pi number by the ratio between the number of points located in the quarter of a circle where random points are uniformly distributed. It needs: | ||
| Ligne 365: | Ligne 363: | ||
| * Output: an integer as number of points inside the quarter of circle | * Output: an integer as number of points inside the quarter of circle | ||
| * Output (bis): an estimation of Pi number (very inefficient method but the result is well known, so easy checked). | * Output (bis): an estimation of Pi number (very inefficient method but the result is well known, so easy checked). | ||
| + | * Output (ter): the total amount of iterations (just to remind) | ||
| The following implementation is as '' | The following implementation is as '' | ||
| Ligne 406: | Ligne 405: | ||
| A program name '' | A program name '' | ||
| - | == Question | + | === Exercice |
| - | * | + | * What is the typical precision of the result ? |
| - | == Question | + | === Exercice |
| + | |||
| + | * Grep the '' | ||
| + | * Improve the test to estimate the ITOPS //on the fly//: apply to different amount of iterations and several time | ||
| + | |||
| + | One Solution:< | ||
| + | echo $(/ | ||
| + | </ | ||
| + | |||
| + | For 100000 iterations, 10 times: | ||
| + | < | ||
| + | 31250.00000000000000000000 | ||
| + | 31645.56962025316455696202 | ||
| + | 28248.58757062146892655367 | ||
| + | 30864.19753086419753086419 | ||
| + | 31847.13375796178343949044 | ||
| + | 32362.45954692556634304207 | ||
| + | 32467.53246753246753246753 | ||
| + | 31545.74132492113564668769 | ||
| + | 32573.28990228013029315960 | ||
| + | 32362.45954692556634304207 | ||
| + | </ | ||
| + | |||
| + | Example of code for previous results:< | ||
| + | for i in $(seq 10 ) ; do echo $(/ | ||
| + | |||
| + | From 1000 to 1000000, 1 time: | ||
| + | < | ||
| + | 1000 20000.00000000000000000000 | ||
| + | 10000 26315.78947368421052631578 | ||
| + | 100000 32154.34083601286173633440 | ||
| + | 1000000 31685.67807351077313054499 | ||
| + | </ | ||
| - | === Split the execution in equal parts === | + | Example of code for previous results:< |
| + | for POWER in $(seq 3 1 6); do ITERATIONS=$((10**$POWER)) ; echo -ne $ITERATIONS' | ||
| + | ==== Split the execution in equal parts ==== | ||
| The following command line divides the job to do (10000000 iterations) into '' | The following command line divides the job to do (10000000 iterations) into '' | ||
| Ligne 436: | Ligne 469: | ||
| On the previous launch, User time represents 99.6% of Elapsed time. Internal system operations only 0.4%. | On the previous launch, User time represents 99.6% of Elapsed time. Internal system operations only 0.4%. | ||
| + | |||
| + | === Exercice #10 : identification of the cost of splitting process === | ||
| + | |||
| + | * Explore the values of '' | ||
| + | * Estimate the ratio between '' | ||
| + | * Estimate the ratio between '' | ||
| + | * What could you conclude ? | ||
| Replace the '' | Replace the '' | ||
| Ligne 550: | Ligne 590: | ||
| In this example, we see that the User time represents 98.52% of the Elapsed time. The total Elapsed time is greater up to 10% to unsplitted one. So, splitting has a cost. The system time represents 0.4% of Elapsed time. | In this example, we see that the User time represents 98.52% of the Elapsed time. The total Elapsed time is greater up to 10% to unsplitted one. So, splitting has a cost. The system time represents 0.4% of Elapsed time. | ||
| - | Replace | + | === Exercice #11 : identification of the cost of splitting process === |
| + | |||
| + | * Explore the values of '' | ||
| + | * Estimate the ratio between '' | ||
| + | * Estimate the ratio between '' | ||
| + | * What could you conclude ? | ||
| + | |||
| + | === Exercice #12 : merging results & improve metrology === | ||
| + | |||
| + | * Append | ||
| + | * Set timers inside command lines to estimate the total Elapsed time | ||
| + | |||
| + | Solution: the timer used are based on '' | ||
| < | < | ||
| ITERATIONS=1000000 | ITERATIONS=1000000 | ||
| + | START=$(date ' | ||
| PR=$(lscpu | grep ' | PR=$(lscpu | grep ' | ||
| EACHJOB=$([ $(($ITERATIONS % $PR)) == 0 ] && echo $(($ITERATIONS/ | EACHJOB=$([ $(($ITERATIONS % $PR)) == 0 ] && echo $(($ITERATIONS/ | ||
| seq $PR | / | seq $PR | / | ||
| + | STOP=$(date ' | ||
| + | echo Total Elapsed time: $(echo $STOP-$START | bc -l) | ||
| </ | </ | ||
| + | |||
| + | ==== After splitting, finally the parallelization ==== | ||
| In this illustrative case, each job is independant to others. They can be distributed to all the computing resources available. '' | In this illustrative case, each job is independant to others. They can be distributed to all the computing resources available. '' | ||
| Ligne 674: | Ligne 731: | ||
| In conclusion, splitting a huge job into small jobs has a Operating System cost. But distribute the jobs using system can very efficient to reduce Elapsed time. | In conclusion, splitting a huge job into small jobs has a Operating System cost. But distribute the jobs using system can very efficient to reduce Elapsed time. | ||
| - | We can improve statistics by launching 10x the previous program. We storage the different | + | === Exercice #13 : launch with '' |
| + | * Examine the '' | ||
| + | * Examine the '' | ||
| + | * Examine the '' | ||
| + | |||
| + | === Exercice #14 : append the program to improve statistics === | ||
| + | |||
| + | * Add iterator to redo the program 10 times | ||
| + | * Store the '' | ||
| + | * Parse the output file and extract statistics on 3 times estimators. | ||
| + | * Estimate the speedup between '' | ||
| + | * Multiply by 10 the number of iterations and estimate the speedup | ||
| + | |||
| + | Solution: | ||
| < | < | ||
| ITERATIONS=1000000 | ITERATIONS=1000000 | ||
| Ligne 688: | Ligne 758: | ||
| </ | </ | ||
| + | Example of output file: | ||
| < | < | ||
| TIME User time (seconds): 59.81 | TIME User time (seconds): 59.81 | ||
| Ligne 721: | Ligne 792: | ||
| </ | </ | ||
| + | Examples of statistics on estimators: | ||
| With //magic// '' | With //magic// '' | ||
| - | * for //Elapsed time// : '' | + | * for //Elapsed time// : '' |
| - | * for //System time// : '' | + | * for //System time// : '' |
| - | * for //User time// : '' | + | * for //User time// : '' |
| The previous results show that the variability, | The previous results show that the variability, | ||
| Ligne 740: | Ligne 812: | ||
| </ | </ | ||
| - | On the first half of cores: 0 to 15< | + | ==== Select |
| - | ITERATIONS=10000000 ; PR=$(($(lscpu | grep '^CPU(s):' | + | |
| + | It' | ||
| + | hwloc-bind -p pu: | ||
| </ | </ | ||
| - | On the second half of cores: 16 to 31< | + | If you want to select only one atomic core, the last one, for example:< |
| - | ITERATIONS=10000000 ; PR=$(($(lscpu | grep ' | + | hwloc-bind -p pu:7-7 ./MyParallelApplication |
| </ | </ | ||
| - | Why to much user time | + | If you want to select several non adjacent cores, the first and the last ones, for example:< |
| + | hwloc-bind -p pu:0-0 pu:7-7 ./ | ||
| + | </ | ||
| + | |||
| + | <note important> | ||
| + | |||
| + | === Exercice #15 : launch the previous program on a slice of machine === | ||
| + | |||
| + | * Identify and launch the program on only the first core | ||
| + | * Identify and launch the program on the first half of cores | ||
| + | * Identify and launch the program on the second half of cores | ||
| + | * Identify and launch on two first cores | ||
| + | * Identify and launch on first on the first half and first on the second half of cores | ||
| + | * Why is there a so great difference between elapsed time | ||
| + | |||
| + | Watch inside terminal with '' | ||
| + | |||
| + | Solutions for a 32 cores workstation: | ||
| + | * On the first core: 0 < | ||
| + | ITERATIONS=10000000 ; PR=$(($(lscpu | grep ' | ||
| + | </ | ||
| + | * On the first half of cores: 0 to 15< | ||
| + | ITERATIONS=10000000 ; PR=$(($(lscpu | grep ' | ||
| + | </ | ||
| + | * On the second half of cores: 16 to 31< | ||
| + | ITERATIONS=10000000 ; PR=$(($(lscpu | grep ' | ||
| + | </ | ||
| + | * On the first of first half and first of second half of cores: 0 and 8< | ||
| + | ITERATIONS=10000000 ; PR=$(($(lscpu | grep ' | ||
| + | </ | ||
| + | * On the first of first half and first of second half of cores: 0 and 8< | ||
| + | ITERATIONS=10000000 ; PR=$(($(lscpu | grep ' | ||
| + | </ | ||
| - | HT Effect | + | === Exercice #17 : from exploration to laws estimation === |
| - | Scalability exploration | + | * explore with previous program |
| + | * store the results in a file | ||
| + | Solution: | ||
| < | < | ||
| ITERATIONS=1000000 ; | ITERATIONS=1000000 ; | ||
| Ligne 841: | Ligne 949: | ||
| </ | </ | ||
| - | Examples of codes | + | === Question #18 : plot & fit with Amdahl and Mylq laws === |
| + | |||
| + | * plot the curve with your favorite plotter the different values, focus on median one ! | ||
| + | * fit with an Amdahl law where '' | ||
| + | * fit with a Mylq law where '' | ||
| + | * what law match the best | ||
| + | |||
| + | Examples of gnuplot bunch of commands to do the job. Adapt to your file and '' | ||
| + | < | ||
| + | Ta(x)=T1*(1-Pa+Pa/ | ||
| + | fit [x=1:16] Ta(x) ' | ||
| + | Tm(x)=Sm+Cm*x+Pm/ | ||
| + | fit [x=1:16] Tm(x) ' | ||
| + | set xlabel ' | ||
| + | set xrange [1:64] | ||
| + | set ylabel " | ||
| + | set title "PiMC : parallel execution with Bash for distributed iterations" | ||
| + | plot ' | ||
| + | Tm(1)/Tm(x) title "Mylq Law" with lines,\ | ||
| + | Ta(1)/Ta(x) title " | ||
| + | </ | ||
| - | xGEMM | + | {{ : |
| - | NBody.py | + | ==== Other sample codes (used for courses) ==== |
| - | PiXPU.py | + | |
| - | Choose your prefered parallel code | + | In folder ''/ |
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| - | Improvment of statistics | + | === Exercice #19 : select parallelized program and explore salability === |
| - | Scalability law | + | * launch one of the upper code with '' |
| + | * draw the scalability curve | ||
| + | * estimates the parameters with Amdahl Law and Mylq Law | ||
| - | Amdahl Law | + | ==== Your prefered software ==== |
| - | Mylq Law | + | === Exercice #20 : select parallelized program and explore salability === |
| + | * launch your MPI code with '' | ||
| + | * draw the scalability curve | ||
| + | * estimates the parameters with Amdahl Law and Mylq Law | ||
| + | --- // | ||