12.34

    matrix size and thread number

    1. !INCLUDE "./code/12.34.h"

    non concurrent version

    1. !INCLUDE "./code/12.34.non.concurrent.c"

    concurrent version

    1. !INCLUDE "./code/12.34.concurrent.c"

    measure performance

    1. (cd chapter12/code; make clean && make && make measure)

    output

    1. (time ./12.34.non.concurrent)
    2. 0.90user 0.00system 0:00.90elapsed 99%CPU (0avgtext+0avgdata 3704maxresident)k
    3. 0inputs+0outputs (0major+756minor)pagefaults 0swaps
    4. // single cpu run time 0.9s
    5. (time ./12.34.concurrent)
    6. 2.20user 0.00system 0:00.64elapsed 341%CPU (0avgtext+0avgdata 3896maxresident)k
    7. 0inputs+0outputs (0major+1462minor)pagefaults 0swaps
    8. // 4 cpu, total run time 2.2s(every cpu run 0.55s, concurrent!!)

    more detialed

    thread(t) 1 2 4 8 16
    core(p) 1 2 4 4 4
    time(Tp) 0.86 0.466 0.626 0.627 0.628
    speedup(Sp) 1 1.84 1.37 1.37 1.37
    efficiency(Ep) 100% 92.2% 34.3% 34.3% 34.3%